def __init__(self, attributes_file): self.attributes_file = attributes_file self.backends = Set([]) self.self_attributes = {} self.backend_attributes = {} self.displayed_attributes = {} self.key = None try: stream = open(attributes_file, 'r') except: raise MissingAttributesFile(attributes_file) try: self.attributes = loadNoDump(stream) except DumplicatedKey as e: raise DumplicateAttributesKey(e.key) for attrid in self.attributes: self._mandatory_check(attrid) attr = self.attributes[attrid] if not attr['type'] in types: raise WrongAttributeType( attr['type'], attrid, attributes_file ) if attr['type'] == 'password': if attrid + '1' in self.attributes or \ attrid + '2' in self.attributes: raise PasswordAttributesCollision(attrid) if 'self' in attr and attr['self']: self.self_attributes[attrid] = attr if 'key' in attr and attr['key']: if self.key is not None: raise DumplicateUserKey(attrid, self.key) self.key = attrid for b in attr['backends']: self.backends.add(b) if b not in self.backend_attributes: self.backend_attributes[b] = {} self.backend_attributes[b][attr['backends'][b]] = attrid if 'search_displayed' in attr and attr['search_displayed']: self.displayed_attributes[attrid] = attr if self.key is None: raise MissingUserKey()
def __init__(self, attributes_file): self.attributes_file = attributes_file self.backends = set([]) self.self_attributes = {} self.backend_attributes = {} self.displayed_attributes = {} self.key = None try: stream = open(attributes_file, 'r') except Exception as e: raise MissingAttributesFile(attributes_file) try: self.attributes = loadNoDump(stream) except DumplicatedKey as e: raise DumplicateAttributesKey(e.key) for attrid in self.attributes: self._mandatory_check(attrid) attr = self.attributes[attrid] if not attr['type'] in types: raise WrongAttributeType( attr['type'], attrid, attributes_file ) if attr['type'] == 'password': if attrid + '1' in self.attributes or \ attrid + '2' in self.attributes: raise PasswordAttributesCollision(attrid) if 'self' in attr and attr['self']: self.self_attributes[attrid] = attr if 'key' in attr and attr['key']: if self.key is not None: raise DumplicateUserKey(attrid, self.key) self.key = attrid for b in attr['backends']: self.backends.add(b) if b not in self.backend_attributes: self.backend_attributes[b] = {} self.backend_attributes[b][attr['backends'][b]] = attrid if 'search_displayed' in attr and attr['search_displayed']: self.displayed_attributes[attrid] = attr if self.key is None: raise MissingUserKey()
def __init__(self, role_file): self.role_file = role_file self.backends = Set([]) try: stream = open(role_file, 'r') except: raise MissingRolesFile(role_file) try: self.roles_raw = loadNoDump(stream) except DumplicatedKey as e: raise DumplicateRoleKey(e.key) stream.close() self.graph = {} self.roles = {} self.flatten = {} self.group2roles = {} self.admin_roles = [] self._nest()
def __init__(self, role_file): self.role_file = role_file self.backends = Set([]) try: stream = open(role_file, 'r') except: raise MissingRolesFile(role_file) try: self.roles_raw = loadNoDump(stream) except DumplicatedKey as e: raise DumplicateRoleKey(e.key) stream.close() self.graph = {} self.roles = {} self.flatten = {} self.group2roles = {} self.admin_roles = [] self._nest()