Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class Duende.​IdentityServer.​Saml.​Xml.​XmlTraverser

Assembly: Duende.IdentityServer

Inheritance: object → XmlTraverser

Traverser to navigate an Xml document. This is essentially a replacement for the XmlNodeReader with the difference that this keeps access to the underlying XmlDocument available. When handling data that contains XmlSignatures it is necessary to be able to read parts of the documents and look up references to the signed elements. That is not possible with a simple forward-only XmlReader. The EnvelopedSignatureReader of the Microsoft.IdentityModel.Xml library is just too complex and error prone in my opinion, I prefer using the SignedXml implementation for signature handling.

Properties

Errors encountered so far during the traversal.
public TrustLevel
TrustLevel
Trust level of the currently read data. Is set/updated when a signature is read/validated.
CurrentNode
The current node being processed.

Methods

public void
ThrowOnErrors​()
Throws exception if the error collection is non-empty.
public XmlTraverser
GetChildren​()
Creates an XML traverser for the child elements of the current node, keeping the same error list as the current traverser.
Returns XmlTraverser
public bool
ReadAndValidateOptionalSignature​(System.​Collections.​Generic.​IEnumerable?<​SigningKey> trustedSigningKeys = null, System.​Collections.​Generic.​IEnumerable?<​string> allowedAlgorithms = null)
If the current node is a signature node, read and validate it and
Returns True if there was a signature node.
trustedSigningKeys Signing keys trusted when validating the signature. If null, nothing is done.
allowedAlgorithms Allowed hash algorithms.
public bool
MoveNext​(bool expectEnd = false)
Moves to the next child node in the current collection, if one is available.
Returns true if the move was successful
expectEnd Is it correct if this MoveNext call hits the end of the child list? If not an error is recorded if we do not find any more nodes.
public void
IgnoreChildren​()
Ignore any children of this element. This suppresses the error that there are unprocessed child nodes.
public void
Skip​()
Skip over the rest of the elements on this level. This suppresses any errors if the parent calls MoveNext
public bool
EnsureNamespace​(string namespaceUri)
Ensures that the node has the specific namespace.
Returns True if ok
namespaceUri Expected Namespace uri.
public bool
EnsureName​(string localName, string namespaceUri)
Ensure that the current node has a specific localName and namespace.
Returns True if both are ok
localName Expected local name
namespaceUri Expected Namespace uri
public string
GetTextContents​()
Ensures that the contents of the current node is only text and returns the text.
public string
GetAbsoluteUriContents​()
Ensures that the contents of the current node is an absolute URI and returns the URI.
Returns URI as string
public bool
HasName​(string localName, string namespaceUri)
Checks if the current node has the qualified name.
Returns True if expected
localName Expected local name
namespaceUri Expected namespace
public string
GetAttribute​(string localName)
Get attribute value with specified <paramref name="localName" /> and where there is no namespace qualifier on the attribute.
Returns Attribute value, null if none.
localName Local name of attribute
public string
GetAttribute​(string localName, string namespaceUri)
Get attribute value with specified <paramref name="localName" /> and namespace Uri.
Returns Attribute value, null if none.
localName Local name of attribute
namespaceUri Namespace Uri of attribute
public string
GetRequiredAttribute​(string localName)
Get required attribute value with specified <paramref name="localName" /> and where there is no namespace qualifier on the attribute.
Returns Attribute value
localName Local name of attribute
public string
GetRequiredAbsoluteUriAttribute​(string localName)
Gets a required string attribute and validates that the value is an absolute URI. Note that even if the validation fails, the value is still returned to make it possible for consumers to supress the errors.
public string
GetAbsoluteUriAttribute​(string localName)
Gets a string attribute and validates that the value is an absolute URI. Note that even if the validation fails, the value is still returned to make it possible for consumers to supress the errors.
GetTimeSpanAttribute​(string localName)
Gets an attribute as timespan. On parse errors the Error is reported to the errors collection.
Returns Parsed Timespan or null if parse fails
localName Local name of attribute
GetDateTimeAttribute​(string localName)
Gets an optional attribute as DateTime. On parse errors the Error is reported to the errors collection.
Returns Parsed DateTime or null if parse fails
localName Local name of attribute
GetRequiredDateTimeAttribute​(string localName)
Gets a required attribute as DateTime. On missing attribute or parse errors the Error is reported to the errors collection.
Returns Parsed DateTime or null if parse fails
localName Local name of attribute
public bool?
GetBoolAttribute​(string localName)
Gets an optional bool attribute. On parse errors the Error is reported to the errors collection.
Returns Parsed bool or null if parse fails.
localName Local name of attribute
public bool?
GetBoolAttribute​(string localName, string namespaceUri)
Gets an optional bool attribute with a namespace. On parse errors the Error is reported to the errors collection.
Returns Parsed bool or null if parse fails.
localName Local name of attribute
namespaceUri Namespace Uri of attribute
public TEnum?
GetEnumAttribute​(string localName, bool ignoreCase)
Gets an optional enum attribute. On parse errors the Error is reported to the errors collection.
Returns Parsed enum or null if parse fails
localName Local name of attribute
ignoreCase Ignore case when parsing?
public int
GetRequiredIntAttribute​(string localName)
Get a required int attribute. On missing attribute or parse errors the error is reported to the errors collection.
Returns Parsed int or null if parse fails
localName Local name of the attribute
public int?
GetIntAttribute​(string localName)
Get an optional int attribute. On parse errors the error is reported to the errors collection
Returns Int, if available
localName the local name of the attribute
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object