@@ -56,6 +56,8 @@ class ToOld(Exception):
56
56
57
57
58
58
ENTITYATTRIBUTES = "urn:oasis:names:tc:SAML:metadata:attribute&EntityAttributes"
59
+ ENTITY_CATEGORY = "http://macedir.org/entity-category"
60
+ ENTITY_CATEGORY_SUPPORT = "http://macedir.org/entity-category-support"
59
61
60
62
# ---------------------------------------------------
61
63
@@ -598,30 +600,30 @@ def single_sign_on_service(self, entity_id, binding=None, typ="idpsso"):
598
600
if binding is None :
599
601
binding = BINDING_HTTP_REDIRECT
600
602
return self .service (entity_id , "idpsso_descriptor" ,
601
- "single_sign_on_service" , binding )
603
+ "single_sign_on_service" , binding )
602
604
603
605
def name_id_mapping_service (self , entity_id , binding = None , typ = "idpsso" ):
604
606
# IDP
605
607
if binding is None :
606
608
binding = BINDING_HTTP_REDIRECT
607
609
return self .service (entity_id , "idpsso_descriptor" ,
608
- "name_id_mapping_service" , binding )
610
+ "name_id_mapping_service" , binding )
609
611
610
612
def authn_query_service (self , entity_id , binding = None ,
611
613
typ = "authn_authority" ):
612
614
# AuthnAuthority
613
615
if binding is None :
614
616
binding = BINDING_SOAP
615
617
return self .service (entity_id , "authn_authority_descriptor" ,
616
- "authn_query_service" , binding )
618
+ "authn_query_service" , binding )
617
619
618
620
def attribute_service (self , entity_id , binding = None ,
619
621
typ = "attribute_authority" ):
620
622
# AttributeAuthority
621
623
if binding is None :
622
624
binding = BINDING_HTTP_REDIRECT
623
625
return self .service (entity_id , "attribute_authority_descriptor" ,
624
- "attribute_service" , binding )
626
+ "attribute_service" , binding )
625
627
626
628
def authz_service (self , entity_id , binding = None , typ = "pdp" ):
627
629
# PDP
@@ -774,13 +776,35 @@ def vo_members(self, entity_id):
774
776
775
777
def entity_categories (self , entity_id ):
776
778
ent = self .__getitem__ (entity_id )
777
- ext = ent ["extensions" ]
778
779
res = []
779
- for elem in ext ["extension_elements" ]:
780
- if elem ["__class__" ] == ENTITYATTRIBUTES :
781
- for attr in elem ["attribute" ]:
782
- if attr ["name" ] == "http://macedir.org/entity-category" :
783
- res .extend ([v ["text" ] for v in attr ["attribute_value" ]])
780
+ try :
781
+ ext = ent ["extensions" ]
782
+ except KeyError :
783
+ pass
784
+ else :
785
+ for elem in ext ["extension_elements" ]:
786
+ if elem ["__class__" ] == ENTITYATTRIBUTES :
787
+ for attr in elem ["attribute" ]:
788
+ if attr ["name" ] == ENTITY_CATEGORY :
789
+ res .extend ([v ["text" ] for v in
790
+ attr ["attribute_value" ]])
791
+
792
+ return res
793
+
794
+ def supported_entity_categories (self , entity_id ):
795
+ ent = self .__getitem__ (entity_id )
796
+ res = []
797
+ try :
798
+ ext = ent ["extensions" ]
799
+ except KeyError :
800
+ pass
801
+ else :
802
+ for elem in ext ["extension_elements" ]:
803
+ if elem ["__class__" ] == ENTITYATTRIBUTES :
804
+ for attr in elem ["attribute" ]:
805
+ if attr ["name" ] == ENTITY_CATEGORY_SUPPORT :
806
+ res .extend ([v ["text" ] for v in
807
+ attr ["attribute_value" ]])
784
808
785
809
return res
786
810
0 commit comments