def from_internal(self, attribute_profile, internal_dict):
        """
        Converts the internal data to "type"

        :type attribute_profile: str
        :type internal_dict: dict[str, str]
        :rtype: dict[str, str]

        :param attribute_profile: To which external type to convert (ex: oidc, saml, ...)
        :param internal_dict: attributes to map
        :return: attribute values and names in the specified "profile"
        """
        external_dict = {}
        for internal_attribute_name in internal_dict:
            try:
                attribute_mapping = self.from_internal_attributes[internal_attribute_name]
            except KeyError:
                logger.debug("no attribute mapping found for the internal attribute '%s'", internal_attribute_name)
                continue

            if attribute_profile not in attribute_mapping:
                # skip this internal attribute if we have no mapping in the specified profile
                logger.debug("no mapping found for '%s' in attribute profile '%s'" %
                             (internal_attribute_name,
                             attribute_profile))
                continue

            external_attribute_names = self.from_internal_attributes[internal_attribute_name][attribute_profile]
            # select the first attribute name
            external_attribute_name = external_attribute_names[0]
            logger.debug("frontend attribute %s mapped from %s" % (external_attribute_name,
                                                                   internal_attribute_name))

            if self.separator in external_attribute_name:
                nested_attribute_names = external_attribute_name.split(self.separator)
                nested_dict = self._create_nested_attribute_value(nested_attribute_names[1:],
                                                                  internal_dict[internal_attribute_name])
                external_dict[nested_attribute_names[0]] = nested_dict
            else:
                external_dict[external_attribute_name] = internal_dict[internal_attribute_name]

        return external_dict
def from_internal ( self , attribute_profile , internal_dict ) : external_dict = { } for internal_attribute_name in internal_dict : try : attribute_mapping = self . from_internal_attributes [ internal_attribute_name ] except KeyError : logger . debug ( "no attribute mapping found for the internal attribute '%s'" , internal_attribute_name ) continue if attribute_profile not in attribute_mapping : logger . debug ( "no mapping found for '%s' in attribute profile '%s'" % ( internal_attribute_name , attribute_profile ) ) continue external_attribute_names = self . from_internal_attributes [ internal_attribute_name ] [ attribute_profile ] external_attribute_name = external_attribute_names [ 0 ] logger . debug ( "frontend attribute %s mapped from %s" % ( external_attribute_name , internal_attribute_name ) ) if self . separator in external_attribute_name : nested_attribute_names = external_attribute_name . split ( self . separator ) nested_dict = self . _create_nested_attribute_value ( nested_attribute_names [ 1 : ] , internal_dict [ internal_attribute_name ] ) external_dict [ nested_attribute_names [ 0 ] ] = nested_dict else : external_dict [ external_attribute_name ] = internal_dict [ internal_attribute_name ] return external_dict
Converts the internal data to "type"

        :type attribute_profile: str
        :type internal_dict: dict[str, str]
        :rtype: dict[str, str]

        :param attribute_profile: To which external type to convert (ex: oidc, saml, ...)
        :param internal_dict: attributes to map
        :return: attribute values and names in the specified "profile"