def parse_legacy_provider(provider_type, composite_key, value): """ Parses legacy provider data from a config entry :param provider_prefix: A short provider prefix (such as 'SMSProvider', 'PushProvider' - all without the leading 'linotp.') """ # XXX LEGACY: providers had no names and composite attribute # names (such as EmailProviderConfig - note: without a dot) # the name in this case is set to 'imported_default' attr_updates = {} # ------------------------------------------------------------------------ - long_prefix = Provider_types[provider_type]['prefix'] provider_prefix = long_prefix[len('linotp.'):-1] # ------------------------------------------------------------------------ - # due to ambiguity of the second part in the config dot notation # we must check if the second part is the provider type if not composite_key.startswith('linotp.%s' % provider_prefix): raise ConfigNotRecognized(composite_key) # ------------------------------------------------------------------------ - parts = composite_key.split('.') if len(parts) != 2: raise ConfigNotRecognized(composite_key) object_id = 'imported_default' composite_attr_name = parts[1] # ------------------------------------------------------------------------ - prefix_len = len(provider_prefix) attr_name = composite_attr_name[prefix_len:] if not attr_name: attr_name = 'class' attr_updates[attr_name] = value # ---------------------------------------------------------------------- -- return object_id, attr_updates
def parse_provider(provider_type, composite_key, value): """ Parses provider data from a config entry :param provider_prefix: A short provider prefix (such as 'SMSProvider', 'PushProvider' - all without the leading 'linotp.') """ attr_updates = {} # ------------------------------------------------------------------------ - long_prefix = Provider_types[provider_type]['prefix'] provider_prefix = long_prefix[len('linotp.'):-1] # ------------------------------------------------------------------------ - # due to ambiguity of the second part in the config dot notation # we must check if the second part is the provider type if not composite_key.startswith('linotp.%s.' % provider_prefix): raise ConfigNotRecognized(composite_key) # ------------------------------------------------------------------------ - parts = composite_key.split('.') if len(parts) == 3: object_id = parts[2] attr_updates['class'] = value elif len(parts) == 4: object_id = parts[2] attr_name = parts[3] attr_updates[attr_name] = value else: raise ConfigNotRecognized(composite_key) # ------------------------------------------------------------------------ - return object_id, attr_updates
def parse_realm(composite_key, value): """ Parses realm data from a config entry """ if not composite_key.startswith('linotp.useridresolver.group.'): raise ConfigNotRecognized(composite_key) object_id = composite_key[len('linotp.useridresolver.group.'):] return object_id, {'resolvers': value}
def parse_default_realm(composite_key, value): """ Sets the attribute pair {default: True} to the default realm in the tree. """ if composite_key != 'linotp.DefaultRealm': raise ConfigNotRecognized(composite_key) return value, {'default': True}
def parse_resolver(composite_key, value): """Parses resolver data from a config entry""" attr_updates = {} # due to ambiguity of the second part in the config dot notation # we must check if the second part is a primary class identifier # of a resolver. cls_identifiers = get_resolver_types() # ldapresolver, passwdresolver, etc for cls_identifier in cls_identifiers: if composite_key.startswith("linotp.%s." % cls_identifier): break else: raise ConfigNotRecognized(composite_key) attr_updates["cls_identifier"] = cls_identifier # ------------------------------------------------------------------------ - parts = composite_key.split(".", 3) if len(parts) < 3: raise ConfigNotRecognized( composite_key, "This legacy resolver description is not supported anymore.", ) # ------------------------------------------------------------------------ - attr_name = parts[2] attr_updates[attr_name] = value object_id = parts[3] # the resolver name # ------------------------------------------------------------------------ - return object_id, attr_updates
def parse_default_provider(provider_type, composite_key, value): """ Sets the attribute pair {default: True} to the default provider in the tree. :param provider_type: A string identifier (such as 'sms', 'email', etc) """ # ---------------------------------------------------------------------- -- default_key = Default_Provider_Key[provider_type] if composite_key != default_key: raise ConfigNotRecognized(composite_key) # ---------------------------------------------------------------------- -- return value, {'default': True}