@@ -667,6 +667,19 @@ def do_pdp_descriptor(conf, cert=None, enc_cert=None):
667667 return pdp
668668
669669
670+ def _add_attr_to_entity_attributes (extensions , attribute ):
671+ try :
672+ entity_attributes = next (filter (
673+ lambda el : el .tag == mdattr .EntityAttributes .c_tag ,
674+ extensions .extension_elements
675+ ))
676+ except StopIteration :
677+ entity_attributes = mdattr .EntityAttributes (attribute = attribute )
678+ extensions .add_extension_element (entity_attributes )
679+ else :
680+ entity_attributes .children .append (attribute )
681+
682+
670683def entity_descriptor (confd ):
671684 mycert = None
672685 enc_cert = None
@@ -698,19 +711,18 @@ def entity_descriptor(confd):
698711 ava = [AttributeValue (text = c ) for c in confd .assurance_certification ]
699712 attr = Attribute (
700713 attribute_value = ava ,
701- name = "urn:oasis:names:tc:SAML:attribute:assurance-certification"
714+ name = "urn:oasis:names:tc:SAML:attribute:assurance-certification" ,
702715 )
703- item = mdattr .EntityAttributes (attribute = attr )
704- entd .extensions .add_extension_element (item )
716+ _add_attr_to_entity_attributes (entd .extensions , attr )
705717
706718 if confd .entity_category :
707719 if not entd .extensions :
708720 entd .extensions = md .Extensions ()
709721 ava = [AttributeValue (text = c ) for c in confd .entity_category ]
710- attr = Attribute (attribute_value = ava ,
711- name = "http://macedir.org/entity-category" )
712- item = mdattr . EntityAttributes ( attribute = attr )
713- entd .extensions . add_extension_element ( item )
722+ attr = Attribute (
723+ attribute_value = ava , name = "http://macedir.org/entity-category"
724+ )
725+ _add_attr_to_entity_attributes ( entd .extensions , attr )
714726
715727 for item in algorithm_support_in_metadata (confd .xmlsec_binary ):
716728 if not entd .extensions :
0 commit comments