diff options
author | Roland Hedberg <roland@catalogix.se> | 2017-10-11 15:34:33 +0200 |
---|---|---|
committer | Roland Hedberg <roland@catalogix.se> | 2017-10-11 15:34:33 +0200 |
commit | 3360ee2734ea2fd32d131a2d908e38aa2919f076 (patch) | |
tree | 2ed0adc156465d36afb5d2b155c82d3d37a31b97 /src | |
parent | 4705e417c6ce8aaf33e700c887eb3b854bbd91b8 (diff) | |
download | pysaml2-3360ee2734ea2fd32d131a2d908e38aa2919f076.tar.gz |
Function that can tell you if an attribute is optional or not for a specified class.
Diffstat (limited to 'src')
-rw-r--r-- | src/saml2/__init__.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/saml2/__init__.py b/src/saml2/__init__.py index b246caa6..a80dbb3f 100644 --- a/src/saml2/__init__.py +++ b/src/saml2/__init__.py @@ -600,8 +600,8 @@ class SamlBase(ExtensionContainer): self.assertion.advice.encrypted_assertion: if tmp_encrypted_assertion.encrypted_data is None: prefix_map = self.get_prefix_map([ - tmp_encrypted_assertion._to_element_tree().find( - assertion_tag)]) + tmp_encrypted_assertion._to_element_tree().find( + assertion_tag)]) tree = self._to_element_tree() encs = tree.find(assertion_tag).find(advice_tag).findall( tmp_encrypted_assertion._to_element_tree().tag) @@ -1018,3 +1018,19 @@ def extension_elements_as_dict(extension_elements, onts): except KeyError: res[elem.c_tag] = [elem] return res + + +REQUIRED = 2 + + +def is_required_attribute(cls, attr): + """ + Check if the attribute is a required attribute for a specific SamlBase + class. + + :param cls: The class + :param attr: An attribute, note it must be the name of the attribute + that appears in the XSD in which the class is defined. + :return: True if required + """ + return cls.c_attributes[attr][REQUIRED] |