Table of Contents

Class SamlMessageReader

Namespace
Fdyay.IdentityServer.Saml.Messages
Assembly
Fdyay.IdentityServer.Saml.dll

Parses SAML protocol messages from XML, with entity/DTD processing disabled (XXE-safe).

public static class SamlMessageReader
Inheritance
SamlMessageReader
Inherited Members

Methods

FindAssertionElement(XmlDocument)

Returns the single saml:Assertion element, or null if absent or ambiguous.

public static XmlElement? FindAssertionElement(XmlDocument doc)

Parameters

doc XmlDocument

Returns

XmlElement

LoadDocument(string)

Loads untrusted SAML XML with a hardened reader (no DTD, no external entity resolution).

public static XmlDocument LoadDocument(string xml)

Parameters

xml string

Returns

XmlDocument

LoadDocument(string, long)

The same, refusing a document longer than maxCharacters; zero means no limit.

public static XmlDocument LoadDocument(string xml, long maxCharacters)

Parameters

xml string
maxCharacters long

Returns

XmlDocument

ReadAuthnRequest(XmlDocument)

Parses a samlp:AuthnRequest into a model. Signature validation is performed separately.

public static SamlAuthnRequest ReadAuthnRequest(XmlDocument doc)

Parameters

doc XmlDocument

Returns

SamlAuthnRequest

Exceptions

SamlFormatException

The document is not a readable AuthnRequest.

ReadAuthnRequest(XmlDocument, Action<ReadErrorInspectorContext<SamlAuthnRequest>>?)

Parses a samlp:AuthnRequest, collecting what is wrong with it and handing that to errorInspector when anything is. Duende's ReadAuthnRequestAsync, measured.

public static SamlAuthnRequest ReadAuthnRequest(XmlDocument doc, Action<ReadErrorInspectorContext<SamlAuthnRequest>>? errorInspector)

Parameters

doc XmlDocument

The request as received.

errorInspector Action<ReadErrorInspectorContext<SamlAuthnRequest>>

AuthnRequestErrorInspector: asked only when there is an error, and the read fails on any it leaves standing. Null refuses at the first, as this reader did before it collected them.

Returns

SamlAuthnRequest

Exceptions

SamlFormatException

An error was left standing; the message is the first one's.

ReadLogoutRequest(XmlDocument)

Parses a samlp:LogoutRequest. Signature validation is performed separately.

public static SamlLogoutRequest ReadLogoutRequest(XmlDocument doc)

Parameters

doc XmlDocument

Returns

SamlLogoutRequest

Exceptions

SamlFormatException

The document is not a readable LogoutRequest.

ReadLogoutRequest(XmlDocument, Action<ReadErrorInspectorContext<SamlLogoutRequest>>?)

Parses a samlp:LogoutRequest, handing what is wrong with it to errorInspector when anything is. Duende's ReadLogoutRequestAsync, as ReadAuthnRequest(XmlDocument, Action<ReadErrorInspectorContext<SamlAuthnRequest>>?).

public static SamlLogoutRequest ReadLogoutRequest(XmlDocument doc, Action<ReadErrorInspectorContext<SamlLogoutRequest>>? errorInspector)

Parameters

doc XmlDocument
errorInspector Action<ReadErrorInspectorContext<SamlLogoutRequest>>

Returns

SamlLogoutRequest

Exceptions

SamlFormatException

An error was left standing; the message is the first one's.

ReadLogoutResponse(XmlDocument)

Parses a samlp:LogoutResponse. Signature validation is performed separately.

public static SamlLogoutResponse ReadLogoutResponse(XmlDocument doc)

Parameters

doc XmlDocument

Returns

SamlLogoutResponse

Exceptions

SamlFormatException

The document is not a readable LogoutResponse.

ReadLogoutResponse(XmlDocument, Action<ReadErrorInspectorContext<SamlLogoutResponse>>?)

Parses a samlp:LogoutResponse, handing what is wrong with it to errorInspector when anything is. Duende's ReadLogoutResponseAsync, as ReadAuthnRequest(XmlDocument, Action<ReadErrorInspectorContext<SamlAuthnRequest>>?).

public static SamlLogoutResponse ReadLogoutResponse(XmlDocument doc, Action<ReadErrorInspectorContext<SamlLogoutResponse>>? errorInspector)

Parameters

doc XmlDocument
errorInspector Action<ReadErrorInspectorContext<SamlLogoutResponse>>

Returns

SamlLogoutResponse

Remarks

A response whose status could not be read, let through, reads as no success.

Exceptions

SamlFormatException

An error was left standing; the message is the first one's.

ReadResponse(XmlDocument)

Parses a samlp:Response into a model. Signature validation is performed separately.

public static SamlResponse ReadResponse(XmlDocument doc)

Parameters

doc XmlDocument

Returns

SamlResponse