@@ -432,12 +432,7 @@ def to_(self, attrvals):
432
432
if name :
433
433
if name == "urn:oid:1.3.6.1.4.1.5923.1.1.1.10" :
434
434
# special case for eduPersonTargetedID
435
- attr_value = []
436
- for v in value :
437
- extension_element = ExtensionElement ("NameID" , NAMESPACE ,
438
- attributes = {'Format' : NAMEID_FORMAT_PERSISTENT }, text = v )
439
- attrval = saml .AttributeValue (extension_elements = [extension_element ])
440
- attr_value .append (attrval )
435
+ attr_value = self .to_eptid_value (value )
441
436
else :
442
437
attr_value = do_ava (value )
443
438
attributes .append (factory (saml .Attribute ,
@@ -452,6 +447,43 @@ def to_(self, attrvals):
452
447
453
448
return attributes
454
449
450
+ def to_eptid_value (self , values ):
451
+ """
452
+ Create AttributeValue instances of NameID from the given values.
453
+
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
457
+
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".
461
+
462
+ Returns a list of AttributeValue instances of NameID elements.
463
+ """
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
+ ]
485
+ return attribute_values
486
+
455
487
456
488
class AttributeConverterNOOP (AttributeConverter ):
457
489
""" Does a NOOP conversion, that is no conversion is made """
0 commit comments