Show / Hide Table of Contents

Class SAMLResponse

Represents a SAML response.

Inheritance
System.Object
StatusResponseType
SAMLResponse
Inherited Members
StatusResponseType.GetIssuer(XmlElement)
StatusResponseType.GetIssuerName(XmlElement)
StatusResponseType.ID
StatusResponseType.InResponseTo
StatusResponseType.Version
StatusResponseType.IssueInstant
StatusResponseType.Destination
StatusResponseType.Consent
StatusResponseType.Issuer
StatusResponseType.Signature
StatusResponseType.Extensions
StatusResponseType.Status
StatusResponseType.IsSuccess()
StatusResponseType.ToXml(XmlElement)
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: ComponentSpace.SAML2.Protocols
Assembly: ComponentSpace.Saml2.dll
Syntax
public class SAMLResponse : StatusResponseType
Remarks

Refer to the Assertions and Protocol for the OASIS Security Assertion Markup Language (SAML) V2.0 specification for further details.

Constructors

SAMLResponse()

Initializes a new instance of the SAMLResponse class.

Declaration
public SAMLResponse()

SAMLResponse(XmlElement)

Initializes a new instance of the SAMLResponse class from XML.

Declaration
public SAMLResponse(XmlElement xmlElement)
Parameters
Type Name Description
System.Xml.XmlElement xmlElement

The SAML response XML.

Exceptions
Type Condition
SAMLSerializationException

Thrown when the XML deserialization fails.

Properties

Assertions

Gets or sets the assertions.

This includes all unsigned, signed and encrypted assertions.

The list may contain unencrypted and unsigned SAML assertions as SAMLAssertion objects, signed SAML assertions as XmlElement objects, and encrypted SAML assertions as EncryptedAssertion objects.

To get just the unencrypted, unsigned assertions use GetUnsignedAssertions. To get just the signed assertions use GetSignedAssertions. To get just the encrypted assertions use GetEncryptedAssertions.

Declaration
public IList Assertions { get; set; }
Property Value
Type Description
System.Collections.IList

The assertions.

See Also
SAMLAssertion
EncryptedAssertion
GetUnsignedAssertion()
GetUnsignedAssertions()
GetSignedAssertion(X509Certificate2)
GetSignedAssertions()
GetEncryptedAssertions()

Methods

GetEncryptedAssertion()

Returns the encrypted SAML assertion.

It's assumed the SAML response contains a single encrypted SAML assertion.

To get the unencrypted, unsigned assertion use GetUnsignedAssertion. To get the signed assertion use GetSignedAssertion.

Declaration
public EncryptedAssertion GetEncryptedAssertion()
Returns
Type Description
EncryptedAssertion

The encrypted assertion or null if none.

See Also
Assertions
GetUnsignedAssertion()
GetSignedAssertion(X509Certificate2)
GetSignedAssertions()
GetEncryptedAssertions()
EncryptedAssertion

GetEncryptedAssertions()

Returns all encrypted assertions.

To get the unencrypted, unsigned assertions use GetUnsignedAssertions. To get the signed assertions use GetSignedAssertions.

Declaration
public IList<EncryptedAssertion> GetEncryptedAssertions()
Returns
Type Description
System.Collections.Generic.IList<EncryptedAssertion>

The encrypted assertions.

See Also
Assertions
GetUnsignedAssertion()
GetUnsignedAssertions()
GetSignedAssertion(X509Certificate2)
GetSignedAssertions()
GetEncryptedAssertion()
EncryptedAssertion

GetSignedAssertion(X509Certificate2)

Returns the SAML assertion.

It's assumed the SAML response contains a single signed SAML assertion.

To get the unencrypted, unsigned assertion use GetUnsignedAssertion. To get the encrypted assertion use GetEncryptedAssertion.

Declaration
public SAMLAssertion GetSignedAssertion(X509Certificate2 x509Certificate)
Parameters
Type Name Description
System.Security.Cryptography.X509Certificates.X509Certificate2 x509Certificate

The X.509 certificate used to verify the XML signature.

Returns
Type Description
SAMLAssertion

The SAML assertion or null if none.

Exceptions
Type Condition
SAMLSignatureException

Thrown when the signature verification fails.

See Also
Assertions
GetUnsignedAssertion()
GetSignedAssertions()
GetEncryptedAssertion()
GetEncryptedAssertions()
SAMLAssertion

GetSignedAssertions()

Returns all signed assertions.

To get the unencrypted, unsigned assertions use GetUnsignedAssertions. To get the encrypted assertions use GetEncryptedAssertions.

Declaration
public IList<XmlElement> GetSignedAssertions()
Returns
Type Description
System.Collections.Generic.IList<System.Xml.XmlElement>

The signed assertions.

See Also
Assertions
GetUnsignedAssertion()
GetUnsignedAssertions()
GetSignedAssertion(X509Certificate2)
GetEncryptedAssertion()
GetEncryptedAssertions()

GetUnsignedAssertion()

Returns the SAML assertion.

It's assumed the SAML response contains a single unencrypted, unsigned SAML assertion.

To get the signed assertion use GetSignedAssertion. To get the encrypted assertion use GetEncryptedAssertion.

Declaration
public SAMLAssertion GetUnsignedAssertion()
Returns
Type Description
SAMLAssertion

The SAML assertion or null if none.

See Also
Assertions
GetSignedAssertion(X509Certificate2)
GetSignedAssertions()
GetEncryptedAssertion()
GetEncryptedAssertions()
SAMLAssertion

GetUnsignedAssertions()

Returns all unencrypted, unsigned assertions.

To get the signed assertions use GetSignedAssertions. To get the encrypted assertions use GetEncryptedAssertions.

Declaration
public IList<SAMLAssertion> GetUnsignedAssertions()
Returns
Type Description
System.Collections.Generic.IList<SAMLAssertion>

The assertions.

See Also
Assertions
GetUnsignedAssertion()
GetSignedAssertion(X509Certificate2)
GetSignedAssertions()
GetEncryptedAssertion()
GetEncryptedAssertions()
SAMLAssertion

IsValid(XmlElement)

Indicates whether the XML is a SAML response.

Declaration
public static bool IsValid(XmlElement xmlElement)
Parameters
Type Name Description
System.Xml.XmlElement xmlElement

The XML to test.

Returns
Type Description
System.Boolean

true if the XML is a SAML response; otherwise false.

ToString()

Converts the SAML response to a string.

Declaration
public override string ToString()
Returns
Type Description
System.String

The SAML response as a string.

Overrides
System.Object.ToString()

ToXml()

Serializes the SAML response to XML.

Declaration
public XmlElement ToXml()
Returns
Type Description
System.Xml.XmlElement

The SAML response as XML.

Remarks

An XML document is created.

Exceptions
Type Condition
SAMLSerializationException

Thrown when the XML serialization fails.

ToXml(XmlDocument)

Serializes the SAML response to XML.

Declaration
public XmlElement ToXml(XmlDocument xmlDocument)
Parameters
Type Name Description
System.Xml.XmlDocument xmlDocument

The owning XML document.

Returns
Type Description
System.Xml.XmlElement

The SAML response as XML.

Exceptions
Type Condition
SAMLSerializationException

Thrown when the XML serialization fails.

In This Article
Back to top Copyright © ComponentSpace Pty Ltd 2004-2022. All rights reserved.