Author: | Roland Hedberg |
---|---|
Version: | 1.2 |
Contains base classes representing SAML elements.
These codes were originally written by Jeffrey Scudder for representing Saml elements. Takashi Matsuo had added some codes, and changed some. Roland Hedberg rewrote the whole thing from bottom up so barely anything but the original structures remained.
Module objective: provide data classes for SAML constructs. These classes hide the XML-ness of SAML and provide a set of native Python classes to interact with.
Conversions to and from XML should only be necessary when the SAML classes “touch the wire” and are sent over HTTP. For this reason this module provides methods and functions to convert SAML classes to and from strings.
Exception class thrown by this module.
XML which is not part of the SAML specification, these are called extension elements. If a classes parser encounters an unexpected XML construct, it is translated into an ExtensionElement instance. ExtensionElement is designed to fully capture the information in the XML. Child nodes in an XML extension are turned into ExtensionElements as well.
Converts this object into an etree element and adds it as a child node in an etree element.
Adds self to the ElementTree. This method is required to avoid verbose XML which constantly redefines the namespace.
Parameters: | element_tree – ElementTree._Element The element to which this object’s XML will be added. |
---|
Searches child nodes for objects with the desired tag/namespace.
Returns a list of extension elements within this object whose tag and/or namespace match those passed in. To find all children in a particular namespace, specify the namespace but not the tag name. If you specify only the tag, the result list may contain extension elements in multiple namespaces.
Parameters: |
|
---|---|
Returns: | A list of elements whose tag and/or namespace match the parameters values |
expects a special set of keys
Serialize the object into a XML string
A foundation class on which SAML classes are built. It handles the parsing of attributes and children which are common to all SAML classes. By default, the SamlBase class translates all XML child nodes into ExtensionElements.
Note: Only for use with classes that have a c_tag and c_namespace class member. It is in SamlBase so that it can be inherited but it should not be called on instances of SamlBase.
Parameters: | node – The node to which this instance should be a child |
---|
Return the cardinality of a child element
Parameters: | child – The name of the child element |
---|---|
Returns: | The cardinality as a 2-tuple (min, max). The max value is either a number or the string “unbounded”. The min value is always a number. |
Return the class a child element should be an instance of
Parameters: | child – The name of the child element |
---|---|
Returns: | The class |
Returns all children that has values
Returns: | Possibly empty list of children. |
---|
Return all the keys that represent possible attributes and children.
Returns: | list of keys |
---|
Return the keys of attributes or children that has values
Returns: | list of keys |
---|
Sets attributes, children, extension elements and extension attributes of this element instance depending on what is in the given dictionary. If there are already values on properties those will be overwritten. If the keys in the dictionary does not correspond to known attributes/children/.. they are ignored.
Parameters: |
|
---|---|
Returns: | The instance |
Sets the text property of this instance.
Parameters: |
|
---|---|
Returns: | The instance |
Converts the Saml object to a string containing XML.
Parameters: | nspair – A dictionary of prefixes and uris to use when constructing the text representation. |
---|---|
Returns: | String representation of the object |
Instantiates the class and populates members according to the tree.
Note: Only use this function with classes that have c_namespace and c_tag class members.
Parameters: |
|
---|---|
Returns: | An instance of the target class - or None if the tag and namespace of the XML tree’s root node did not match the desired namespace and tag. |
Creates an instance of the target class from a string.
Parameters: |
|
---|---|
Returns: | An instance of the target class with members assigned according to the contents of the XML - or None if the root XML tag and namespace did not match those of the target class. |
Convert an element into a extension element
Parameters: | element – The element instance |
---|---|
Returns: | An extension element instance |
Convert an extension element to a normal element. In order to do this you need to have an idea of what type of element it is. Or rather which module it belongs to.
Parameters: |
|
---|---|
Returns: | An element instance or None |
Create a list of elements each one matching one of the given extension elements. This is of course dependent on the access to schemas that describe the extension elements.
Parameters: |
|
---|---|
Returns: | A list of elements, representing the set of extension elements that was possible to match against a Class in the given schemas. The elements returned are the native representation of the elements according to the schemas. |
Constructs a class instance containing the specified information
Parameters: |
|
---|---|
Returns: | The instance |
Creates a class instance with a specified value, the specified class instance may be a value on a property in a defined class instance.
Parameters: |
|
---|---|
Returns: | Value class instance |