Skip to content

Commit e449679

Browse files
committed
Add mdstore method to extract mdui uiinfo elements
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent b1986e2 commit e449679

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/saml2/mdstore.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@
3737
from saml2.sigver import security_context
3838
from saml2.extension.mdattr import NAMESPACE as NS_MDATTR
3939
from saml2.extension.mdattr import EntityAttributes
40+
from saml2.extension.mdui import NAMESPACE as NS_MDUI
41+
from saml2.extension.mdui import UIInfo
42+
from saml2.extension.mdui import DisplayName
43+
from saml2.extension.mdui import Description
44+
from saml2.extension.mdui import InformationURL
45+
from saml2.extension.mdui import PrivacyStatementURL
46+
from saml2.extension.mdui import Logo
4047

4148

4249
logger = logging.getLogger(__name__)
@@ -45,6 +52,7 @@
4552
"mdattr_entityattributes": "{ns}&{tag}".format(
4653
ns=NS_MDATTR, tag=EntityAttributes.c_tag
4754
),
55+
"mdui_uiinfo": "{ns}&{tag}".format(ns=NS_MDUI, tag=UIInfo.c_tag),
4856
}
4957

5058
ENTITY_CATEGORY = "http://macedir.org/entity-category"
@@ -1255,6 +1263,33 @@ def entity_attributes(self, entity_id):
12551263
"attribute_value"]]
12561264
return res
12571265

1266+
def _mdui_uiinfo(self, entity_id):
1267+
descriptor_names = (
1268+
item
1269+
for item in self[entity_id].keys()
1270+
if item.endswith("_descriptor")
1271+
)
1272+
descriptors = (
1273+
descriptor
1274+
for descriptor_name in descriptor_names
1275+
for descriptor in self[entity_id].get(descriptor_name, [])
1276+
)
1277+
extensions = (
1278+
extension
1279+
for descriptor in descriptors
1280+
for extension in descriptor.get("extensions", {}).get("extension_elements", [])
1281+
)
1282+
uiinfos = (
1283+
extension
1284+
for extension in extensions
1285+
if extension.get("__class__") == classnames["mdui_uiinfo"]
1286+
)
1287+
return uiinfos
1288+
1289+
def mdui_uiinfo(self, entity_id):
1290+
uiinfos = list(self._mdui_uiinfo(entity_id))
1291+
return uiinfos
1292+
12581293
def bindings(self, entity_id, typ, service):
12591294
for _md in self.metadata.values():
12601295
if entity_id in _md.items():

0 commit comments

Comments
 (0)