@@ -447,39 +447,41 @@ def to_(self, attrvals):
447
447
448
448
return attributes
449
449
450
- def to_eptid_value (self , value ):
450
+ def to_eptid_value (self , values ):
451
451
"""
452
- Special handling for the attribute with name
453
- urn:oid:1.3.6.1.4.1.5923.1.1.1.10, usually known by the friendly
454
- name eduPersonTargetedID. Create the AttributeValue instance(s)
455
- for the attribute.
452
+ Create AttributeValue instances of NameID from the given values.
456
453
457
- value is either a string or a dictionary with keys 'value',
458
- 'NameQualifier', and 'SPNameQualifier'.
454
+ Special handling for the "eptid" attribute
455
+ Name=urn:oid:1.3.6.1.4.1.5923.1.1.1.10
456
+ FriendlyName=eduPersonTargetedID
459
457
460
- Returns a list of AttributeValue instances.
461
- """
462
- attribute_values = []
463
-
464
- for v in value :
465
- if isinstance (v , dict ):
466
- element_attributes = {
467
- 'Format' : NAMEID_FORMAT_PERSISTENT ,
468
- 'NameQualifier' : v ['NameQualifier' ],
469
- 'SPNameQualifier' : v ['SPNameQualifier' ]
470
- }
471
- text = v ['value' ]
472
- else :
473
- element_attributes = {'Format' : NAMEID_FORMAT_PERSISTENT }
474
- text = v
475
-
476
- element = ExtensionElement ("NameID" , NAMESPACE , element_attributes ,
477
- text = text )
458
+ values is a list of items of type str or dict. When an item is a
459
+ dictionary it has the keys: "NameQualifier", "SPNameQualifier", and
460
+ "text".
478
461
479
- attrval = saml .AttributeValue (extension_elements = [element ])
480
-
481
- attribute_values .append (attrval )
462
+ Returns a list of AttributeValue instances of NameID elements.
463
+ """
482
464
465
+ def _create_nameid_ext_el (value ):
466
+ text = value ["text" ] if isinstance (value , dict ) else value
467
+ attributes = (
468
+ {
469
+ "Format" : NAMEID_FORMAT_PERSISTENT ,
470
+ "NameQualifier" : value ["NameQualifier" ],
471
+ "SPNameQualifier" : value ["SPNameQualifier" ],
472
+ }
473
+ if isinstance (value , dict )
474
+ else {"Format" : NAMEID_FORMAT_PERSISTENT }
475
+ )
476
+ element = ExtensionElement (
477
+ "NameID" , NAMESPACE , attributes = attributes , text = text
478
+ )
479
+ return element
480
+
481
+ attribute_values = [
482
+ saml .AttributeValue (extension_elements = [_create_nameid_ext_el (v )])
483
+ for v in values
484
+ ]
483
485
return attribute_values
484
486
485
487
0 commit comments