Skip to content

Commit de746ba

Browse files
committed
more values for the match attribute of Entities elements in SP trust info
1 parent 3e4e24e commit de746ba

File tree

2 files changed

+55
-5
lines changed

2 files changed

+55
-5
lines changed

src/pyff/samlmd.py

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,17 @@ def entity_extended_display_i18n(entity, default_lang=None):
706706
return name_dict, desc_dict
707707

708708

709+
def entity_attribute(entity, attribute):
710+
values = None
711+
els = entity.findall(
712+
'.//{%s}EntityAttributes/{%s}Attribute[@Name="%s"]/{%s}AttributeValue'
713+
% (NS['mdattr'], NS['saml'], attribute, NS['saml'])
714+
)
715+
if len(els) > 0:
716+
values = [el.text for el in els]
717+
return values
718+
719+
709720
def entity_categories(entity):
710721
cats = None
711722
cats_els = entity.findall(
@@ -717,6 +728,28 @@ def entity_categories(entity):
717728
return cats
718729

719730

731+
def assurance_cetification(entity):
732+
certs = None
733+
certs_els = entity.findall(
734+
'.//{%s}EntityAttributes/{%s}Attribute[@Name="urn:oasis:names:tc:SAML:attribute:assurance-certification"]/{%s}AttributeValue'
735+
% (NS['mdattr'], NS['saml'], NS['saml'])
736+
)
737+
if len(certs_els) > 0:
738+
certs = [el.text for el in certs_els]
739+
return certs
740+
741+
742+
def entity_category_support(entity):
743+
cats = None
744+
cats_els = entity.findall(
745+
'.//{%s}EntityAttributes/{%s}Attribute[@Name="http://macedir.org/entity-category-support"]/{%s}AttributeValue'
746+
% (NS['mdattr'], NS['saml'], NS['saml'])
747+
)
748+
if len(cats_els) > 0:
749+
cats = [el.text for el in cats_els]
750+
return cats
751+
752+
720753
def registration_authority(entity):
721754
regauth_el = entity.find(".//{%s}RegistrationInfo" % NS['mdrpi'])
722755
if regauth_el is not None:
@@ -812,7 +845,9 @@ def discojson(e, sources=None, langs=None, fallback_to_favicon=False, icon_store
812845
entity_id = e.get('entityID')
813846
title_langs, descr_langs = entity_extended_display_i18n(e)
814847
reg_auth = registration_authority(e)
815-
cats = entity_categories(e)
848+
categories = entity_attribute(e, "http://macedir.org/entity-category")
849+
certifications = entity_attribute(e, "urn:oasis:names:tc:SAML:attribute:assurance-certification")
850+
cat_support = entity_attribute(e, "http://macedir.org/entity-category-support")
816851

817852
d = dict(
818853
title=title,
@@ -826,8 +861,14 @@ def discojson(e, sources=None, langs=None, fallback_to_favicon=False, icon_store
826861
if reg_auth is not None:
827862
d['registrationAuthority'] = reg_auth
828863

829-
if cats is not None:
830-
d['entity_categories'] = cats
864+
if categories is not None:
865+
d['entity_categories'] = categories
866+
867+
if certifications is not None:
868+
d['assurance_certifications'] = certifications
869+
870+
if cat_support is not None:
871+
d['entity_category_support'] = cat_support
831872

832873
if sources is not None:
833874
d['md_sources'] = sources

src/pyff/schema/saml-metadata-trustinfo-v1.0.xsd

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,19 @@
7272
<complexType name="TrustedEntitiesType">
7373
<simpleContent>
7474
<extension base="anyURI">
75-
<attribute name="match" type="string" default="registrationAuthority"/>
75+
<attribute name="match" type="ti:matchType" default="registrationAuthority"/>
7676
<attribute name="include" type="boolean" default="true"/>
7777
</extension>
7878
</simpleContent>
79-
</complexType>
79+
</complexType>
80+
<simpleType name="matchType">
81+
<restriction base="string">
82+
<enumeration value="registrationAuthority"/>
83+
<enumeration value="entity_categories"/>
84+
<enumeration value="assurance_certifications"/>
85+
<enumeration value="entity_category_support"/>
86+
<enumeration value="md_sources"/>
87+
</restriction>
88+
</simpleType>
8089

8190
</schema>

0 commit comments

Comments
 (0)