@@ -667,6 +667,19 @@ def do_pdp_descriptor(conf, cert=None, enc_cert=None):
667
667
return pdp
668
668
669
669
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
+
670
683
def entity_descriptor (confd ):
671
684
mycert = None
672
685
enc_cert = None
@@ -698,19 +711,18 @@ def entity_descriptor(confd):
698
711
ava = [AttributeValue (text = c ) for c in confd .assurance_certification ]
699
712
attr = Attribute (
700
713
attribute_value = ava ,
701
- name = "urn:oasis:names:tc:SAML:attribute:assurance-certification"
714
+ name = "urn:oasis:names:tc:SAML:attribute:assurance-certification" ,
702
715
)
703
- item = mdattr .EntityAttributes (attribute = attr )
704
- entd .extensions .add_extension_element (item )
716
+ _add_attr_to_entity_attributes (entd .extensions , attr )
705
717
706
718
if confd .entity_category :
707
719
if not entd .extensions :
708
720
entd .extensions = md .Extensions ()
709
721
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 )
714
726
715
727
for item in algorithm_support_in_metadata (confd .xmlsec_binary ):
716
728
if not entd .extensions :
0 commit comments