Skip to content

Commit 796cac3

Browse files
committed
add entity categories info to discojson
1 parent 1b79163 commit 796cac3

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/pyff/samlmd.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,14 @@ def entity_extended_display_i18n(entity, default_lang=None):
698698
return name_dict, desc_dict
699699

700700

701+
def entity_categories(entity):
702+
cats = None
703+
cats_els = entity.findall('.//{%s}EntityAttributes/{%s}Attribute[@Name="http://macedir.org/entity-category"]/{%s}AttributeValue' % (NS['mdattr'], NS['saml'], NS['saml']))
704+
if len(cats_els) > 0:
705+
cats = [el.text for el in cats_els]
706+
return cats
707+
708+
701709
def registration_authority(entity):
702710
regauth_el = entity.find(".//{%s}RegistrationInfo" % NS['mdrpi'])
703711
if regauth_el is not None:
@@ -792,7 +800,8 @@ def discojson(e, langs=None, fallback_to_favicon=False, icon_store=None):
792800
title, descr = entity_extended_display(e)
793801
entity_id = e.get('entityID')
794802
title_langs, descr_langs = entity_extended_display_i18n(e)
795-
registrationAuthority = registration_authority(e)
803+
reg_auth = registration_authority(e)
804+
cats = entity_categories(e)
796805

797806
d = dict(
798807
title=title,
@@ -802,9 +811,13 @@ def discojson(e, langs=None, fallback_to_favicon=False, icon_store=None):
802811
auth='saml',
803812
entity_id=entity_id,
804813
entityID=entity_id,
814+
805815
)
806-
if registrationAuthority is not None:
807-
d['registrationAuthority'] = registrationAuthority
816+
if reg_auth is not None:
817+
d['registration_authority'] = reg_auth
818+
819+
if cats is not None:
820+
d['entity_categories'] = cats
808821

809822
eattr = entity_attribute_dict(e)
810823
if 'idp' in eattr[ATTRS['role']]:

0 commit comments

Comments
 (0)