Table of Contents

Class SamlAssertion

Namespace
ComponentSpace.Saml2.Assertions
Assembly
ComponentSpace.Saml2.dll

Represents the Assertion element.

public class SamlAssertion
Inheritance
SamlAssertion
Inherited Members

Remarks

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

Constructors

SamlAssertion()

Initializes a new instance of the SamlAssertion class.

public SamlAssertion()

Remarks

The SAML assertion is initialized with a version number of 2.0, a random identifier, and the issue instant of now.

SamlAssertion(XmlElement)

Initializes a new instance of the SamlAssertion class from XML.

public SamlAssertion(XmlElement xmlElement)

Parameters

xmlElement XmlElement

The assertion XML.

Exceptions

SamlSerializationException

Thrown when the XML deserialization fails.

Properties

Advice

Gets or sets the advice.

public Advice Advice { get; set; }

Property Value

Advice

The advice.

Conditions

Gets or sets the conditions.

public Conditions Conditions { get; set; }

Property Value

Conditions

The conditions.

ID

Gets or sets the ID.

public string ID { get; set; }

Property Value

string

The ID.

IssueInstant

Gets or sets the issue instant.

public DateTime? IssueInstant { get; set; }

Property Value

DateTime?

The issue instant as coordinated universal time (UTC).

Issuer

Gets or sets the issuer.

public Issuer Issuer { get; set; }

Property Value

Issuer

The issuer.

Statements

Gets or sets the statements.

public IList<IStatement> Statements { get; set; }

Property Value

IList<IStatement>

The statements.

See Also

Subject

Gets or sets the subject.

public Subject Subject { get; set; }

Property Value

Subject

The subject.

Version

Gets or sets the version.

public string Version { get; set; }

Property Value

string

The version. The default is 2.0.

Methods

GetAttributeStatements()

Returns all attribute statements.

public IList<AttributeStatement> GetAttributeStatements()

Returns

IList<AttributeStatement>

The attribute statements.

See Also

GetAttributeValue(string)

Returns the value of the unencrypted attribute with the specified name.

public string GetAttributeValue(string attributeName)

Parameters

attributeName string

The attribute name.

Returns

string

The attribute value or null if none.

Remarks

It's assumed that only one attribute exists with the specified name, that the attribute only has one value, and the value is a string. If this isn't the case then use one of the other attribute related methods.

GetAttributeValueByFriendlyName(string)

Returns the value of the unencrypted attribute with the specified friendly name.

public string GetAttributeValueByFriendlyName(string friendlyName)

Parameters

friendlyName string

The attribute friendly name.

Returns

string

The attribute value or null if none.

Remarks

It's assumed that only one attribute exists with the specified friendly name, that the attribute only has one value, and the value is a string. If this isn't the case then use one of the other attribute related methods.

GetAttributes()

Returns all unencrypted attributes.

public IList<SamlAttribute> GetAttributes()

Returns

IList<SamlAttribute>

The unencrypted attributes.

GetAttributes(string)

Returns all unencrypted attributes with the specified name.

public IList<SamlAttribute> GetAttributes(string attributeName)

Parameters

attributeName string

The attribute name.

Returns

IList<SamlAttribute>

The matching unencrypted attributes.

GetAttributesByFriendlyName(string)

Returns all unencrypted attributes with the specified friendly name.

public IList<SamlAttribute> GetAttributesByFriendlyName(string friendlyName)

Parameters

friendlyName string

The attribute friendly name.

Returns

IList<SamlAttribute>

The matching unencrypted attributes.

GetAuthenticationStatements()

Returns all authentication statements.

public IList<AuthnStatement> GetAuthenticationStatements()

Returns

IList<AuthnStatement>

The authentication statements.

See Also

GetAuthorizationDecisionStatements()

Returns all authorization decision statements.

public IList<AuthzDecisionStatement> GetAuthorizationDecisionStatements()

Returns

IList<AuthzDecisionStatement>

The authorization decision statements.

See Also

GetNameID()

Gets the name identifier from the subject.

public string GetNameID()

Returns

string

The name identifier from the subject or null if none.

See Also

IsValid(XmlElement)

Indicates whether the XML is an assertion.

public static bool IsValid(XmlElement xmlElement)

Parameters

xmlElement XmlElement

The XML to test.

Returns

bool

true if the XML is an assertion; otherwise false.

SetAttributeValue(string, string)

Sets the attribute value by adding an attribute statement containing an attribute with the specified name and value.

public void SetAttributeValue(string name, string value)

Parameters

name string

The attribute name.

value string

The attribute value.

SetAttributeValue(string, string, string, string)

Sets the attribute value by adding an attribute statement containing an attribute with the specified name and value.

public void SetAttributeValue(string name, string nameFormat, string friendlyName, string value)

Parameters

name string

The attribute name.

nameFormat string

The name format or null if none.

friendlyName string

The friendly name or null if none.

value string

The attribute value.

ToString()

Converts the SAML assertion to a string.

public override string ToString()

Returns

string

The SAML assertion as a string.

ToXml()

Serializes the SAML assertion to XML.

public XmlElement ToXml()

Returns

XmlElement

The SAML assertion as XML.

Exceptions

SamlSerializationException

Thrown when the XML serialization fails.

ToXml(XmlDocument)

Serializes the SAML assertion to XML.

public XmlElement ToXml(XmlDocument xmlDocument)

Parameters

xmlDocument XmlDocument

The owning XML document.

Returns

XmlElement

The SAML assertion as XML.

Exceptions

SamlSerializationException

Thrown when the XML serialization fails.