Skip to content

Commit 3360ee2

Browse files
committed
Function that can tell you if an attribute is optional or not for a specified class.
1 parent 4705e41 commit 3360ee2

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/saml2/__init__.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,8 @@ def get_xml_string_with_self_contained_assertion_within_advice_encrypted_asserti
600600
self.assertion.advice.encrypted_assertion:
601601
if tmp_encrypted_assertion.encrypted_data is None:
602602
prefix_map = self.get_prefix_map([
603-
tmp_encrypted_assertion._to_element_tree().find(
604-
assertion_tag)])
603+
tmp_encrypted_assertion._to_element_tree().find(
604+
assertion_tag)])
605605
tree = self._to_element_tree()
606606
encs = tree.find(assertion_tag).find(advice_tag).findall(
607607
tmp_encrypted_assertion._to_element_tree().tag)
@@ -1018,3 +1018,19 @@ def extension_elements_as_dict(extension_elements, onts):
10181018
except KeyError:
10191019
res[elem.c_tag] = [elem]
10201020
return res
1021+
1022+
1023+
REQUIRED = 2
1024+
1025+
1026+
def is_required_attribute(cls, attr):
1027+
"""
1028+
Check if the attribute is a required attribute for a specific SamlBase
1029+
class.
1030+
1031+
:param cls: The class
1032+
:param attr: An attribute, note it must be the name of the attribute
1033+
that appears in the XSD in which the class is defined.
1034+
:return: True if required
1035+
"""
1036+
return cls.c_attributes[attr][REQUIRED]

0 commit comments

Comments
 (0)