def to_(self, attrvals): """ Create a list of Attribute instances. :param attrvals: A dictionary of attributes and values :return: A list of Attribute instances See: https://github.com/IdentityPython/pysaml2/blob/master/src/saml2/attribute_converter.py#L486 """ attributes = [] for key, value in attrvals.items(): name = self._to.get(key.lower()) if name: typ = self._special_cases.get(name, '') attr_value = do_ava(value, typ) attributes.append( factory(Attribute, name=name, name_format=self.name_format, attribute_value=attr_value)) else: attributes.append( factory(Attribute, name=key, attribute_value=do_ava(value))) return attributes
def to_(self, attrvals): """ Create a list of Attribute instances. :param attrvals: A dictionary of attributes and values :return: A list of Attribute instances """ attributes = [] for key, value in attrvals.items(): name = self._to.get(key.lower()) if name: if name == "urn:oid:1.3.6.1.4.1.5923.1.1.1.10": # special case for eduPersonTargetedID attr_value = [] for v in value: extension_element = ExtensionElement("NameID", NAMESPACE, attributes={'Format': NAMEID_FORMAT_PERSISTENT}, text=v) attrval = saml.AttributeValue(extension_elements=[extension_element]) attr_value.append(attrval) else: attr_value = do_ava(value) attributes.append(factory(saml.Attribute, name=name, name_format=self.name_format, friendly_name=key, attribute_value=attr_value)) else: attributes.append(factory(saml.Attribute, name=key, attribute_value=do_ava(value))) return attributes
def to_(self, attrvals): """ Create a list of Attribute instances. :param attrvals: A dictionary of attributes and values :return: A list of Attribute instances """ attributes = [] for key, value in attrvals.items(): name = self._to.get(key.lower()) if name: if name == "urn:oid:1.3.6.1.4.1.5923.1.1.1.10": # special case for eduPersonTargetedID attr_value = self.to_eptid_value(value) else: attr_value = do_ava(value) attributes.append( factory(saml.Attribute, name=name, name_format=self.name_format, friendly_name=key, attribute_value=attr_value)) else: attributes.append( factory(saml.Attribute, name=key, attribute_value=do_ava(value))) return attributes
def to_(self, attrvals): """ Create a list of Attribute instances. :param attrvals: A dictionary of attributes and values :return: A list of Attribute instances """ attributes = [] for key, value in attrvals.items(): try: attributes.append(factory(saml.Attribute, name=self._to[key], name_format=self.name_format, friendly_name=key, attribute_value=do_ava(value))) except KeyError: attributes.append(factory(saml.Attribute, name=key, attribute_value=do_ava(value))) return attributes
def to_(self, attrvals): """ Create a list of Attribute instances. :param attrvals: A dictionary of attributes and values :return: A list of Attribute instances """ attributes = [] for key, value in attrvals.items(): key = key.lower() try: attributes.append(factory(saml.Attribute, name=self._to[key], name_format=self.name_format, friendly_name=key, attribute_value=do_ava(value))) except KeyError: attributes.append(factory(saml.Attribute, name=key, attribute_value=do_ava(value))) return attributes
def to_(self, attrvals): """ Create a list of Attribute instances. :param attrvals: A dictionary of attributes and values :return: A list of Attribute instances """ attributes = [] for key, value in attrvals.items(): name = self._to.get(key.lower()) if name: typ = self._special_cases.get(name, '') attr_value = do_ava(value, typ) attributes.append( factory(Attribute, name=name, name_format=self.name_format, attribute_value=attr_value)) else: attributes.append( factory(Attribute, name=key, attribute_value=do_ava(value))) return attributes
def to_(self, attrvals): """ Create a list of Attribute instances. :param attrvals: A dictionary of attributes and values :return: A list of Attribute instances """ attributes = [] for key, value in attrvals.items(): name = self._to.get(key.lower()) if name: if name == "urn:oid:1.3.6.1.4.1.5923.1.1.1.10": # special case for eduPersonTargetedID attr_value = [] for v in value: extension_element = ExtensionElement( "NameID", NAMESPACE, attributes={'Format': NAMEID_FORMAT_PERSISTENT}, text=v) attrval = saml.AttributeValue( extension_elements=[extension_element]) attr_value.append(attrval) else: attr_value = do_ava(value) attributes.append( factory(saml.Attribute, name=name, name_format=self.name_format, friendly_name=key, attribute_value=attr_value)) else: attributes.append( factory(saml.Attribute, name=key, attribute_value=do_ava(value))) return attributes
def to_(self, attrvals): """ Create a list of Attribute instances. :param attrvals: A dictionary of attributes and values :return: A list of Attribute instances """ attributes = [] for key, value in attrvals.items(): key = key.lower() attributes.append(factory(saml.Attribute, name=key, name_format=self.name_format, attribute_value=do_ava(value))) return attributes
def to_(self, attrvals): """ Create a list of Attribute instances. :param attrvals: A dictionary of attributes and values :return: A list of Attribute instances """ attributes = [] for key, value in list(attrvals.items()): key = key.lower() attributes.append( factory(saml.Attribute, name=key, name_format=self.name_format, attribute_value=do_ava(value))) return attributes