def _find_service(self, service_name): fse = FeideService(self.db) try: fse.find_by_name(service_name) except Errors.NotFoundError: raise CerebrumError('No such Feide service') return fse
def person_authn_levels(self): """ Returns a authentication level mapping for update_person_authn. Initializes self.person_authn_levels with a dict that maps person entity_id to a set of service authentication levels: person_id: set([ (feide_service_id, authentication_level), ... ]), ... """ if not hasattr(self, '_person_authn_levels'): supported = ldapconf('PERSON', 'norEduPersonAuthnMethod_selector', {}) if not supported: self._person_authn_levels = {} return self._person_authn_levels timer = make_timer(self.logger, 'Fetching authentication levels...') fse = FeideService(self.db) self._person_authn_levels = fse.get_person_to_authn_level_map() timer("...authentication levels done.") return self._person_authn_levels
def feide_service_add(self, operator, feide_id, service_name): """ Add a Feide service """ if not self.ba.is_superuser(operator.get_entity_id()): raise PermissionDenied('Only superusers may add Feide services') if not feide_id.isdigit(): raise CerebrumError('Feide ID can only contain digits.') fse = FeideService(self.db) service_name = service_name.strip() name_error = fse.illegal_name(service_name) if name_error: raise CerebrumError(name_error) for service in fse.search(): if int(feide_id) == int(service['feide_id']): raise CerebrumError( 'A Feide service with that ID already exists') if service_name == service['name']: raise CerebrumError( 'A Feide service with that name already exists') fse.populate(feide_id, service_name) fse.write_db() return "Added Feide service '{}'".format(service_name)
def feide_service_list(self, operator): """ List Feide services. """ if not self.ba.is_superuser(operator.get_entity_id()): raise PermissionDenied('Only superusers may list Feide services') fse = FeideService(self.db) return map(dict, fse.search())