Class SamlAssertion
Represents the Assertion element.
Inheritance
Inherited Members
Namespace: ComponentSpace.Saml2.Assertions
Assembly: ComponentSpace.Saml2.dll
Syntax
public class SamlAssertion
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.
Declaration
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.
Declaration
public SamlAssertion(XmlElement xmlElement)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlElement | xmlElement | The assertion XML. |
Exceptions
Type | Condition |
---|---|
SamlSerializationException | Thrown when the XML deserialization fails. |
Properties
Advice
Gets or sets the advice.
Declaration
public Advice Advice { get; set; }
Property Value
Type | Description |
---|---|
Advice | The advice. |
Conditions
Gets or sets the conditions.
Declaration
public Conditions Conditions { get; set; }
Property Value
Type | Description |
---|---|
Conditions | The conditions. |
ID
Gets or sets the ID.
Declaration
public string ID { get; set; }
Property Value
Type | Description |
---|---|
System.String | The ID. |
IssueInstant
Gets or sets the issue instant.
Declaration
public DateTime? IssueInstant { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.DateTime> | The issue instant as coordinated universal time (UTC). |
Issuer
Gets or sets the issuer.
Declaration
public Issuer Issuer { get; set; }
Property Value
Type | Description |
---|---|
Issuer | The issuer. |
Statements
Gets or sets the statements.
Declaration
public IList<IStatement> Statements { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IList<IStatement> | The statements. |
See Also
Subject
Gets or sets the subject.
Declaration
public Subject Subject { get; set; }
Property Value
Type | Description |
---|---|
Subject | The subject. |
Version
Gets or sets the version.
Declaration
public string Version { get; set; }
Property Value
Type | Description |
---|---|
System.String | The version. The default is 2.0. |
Methods
GetAttributes()
Returns all unencrypted attributes.
Declaration
public IList<SamlAttribute> GetAttributes()
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<SamlAttribute> | The unencrypted attributes. |
GetAttributes(String)
Returns all unencrypted attributes with the specified name.
Declaration
public IList<SamlAttribute> GetAttributes(string attributeName)
Parameters
Type | Name | Description |
---|---|---|
System.String | attributeName | The attribute name. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<SamlAttribute> | The matching unencrypted attributes. |
GetAttributesByFriendlyName(String)
Returns all unencrypted attributes with the specified friendly name.
Declaration
public IList<SamlAttribute> GetAttributesByFriendlyName(string friendlyName)
Parameters
Type | Name | Description |
---|---|---|
System.String | friendlyName | The attribute friendly name. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<SamlAttribute> | The matching unencrypted attributes. |
GetAttributeStatements()
Returns all attribute statements.
Declaration
public IList<AttributeStatement> GetAttributeStatements()
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<AttributeStatement> | The attribute statements. |
See Also
GetAttributeValue(String)
Returns the value of the unencrypted attribute with the specified name.
Declaration
public string GetAttributeValue(string attributeName)
Parameters
Type | Name | Description |
---|---|---|
System.String | attributeName | The attribute name. |
Returns
Type | Description |
---|---|
System.String | The attribute value or |
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.
Declaration
public string GetAttributeValueByFriendlyName(string friendlyName)
Parameters
Type | Name | Description |
---|---|---|
System.String | friendlyName | The attribute friendly name. |
Returns
Type | Description |
---|---|
System.String | The attribute value or |
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.
GetAuthenticationStatements()
Returns all authentication statements.
Declaration
public IList<AuthnStatement> GetAuthenticationStatements()
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<AuthnStatement> | The authentication statements. |
See Also
GetAuthorizationDecisionStatements()
Returns all authorization decision statements.
Declaration
public IList<AuthzDecisionStatement> GetAuthorizationDecisionStatements()
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<AuthzDecisionStatement> | The authorization decision statements. |
See Also
GetNameID()
Gets the name identifier from the subject.
Declaration
public string GetNameID()
Returns
Type | Description |
---|---|
System.String | The name identifier from the subject or |
See Also
IsValid(XmlElement)
Indicates whether the XML is an assertion.
Declaration
public static bool IsValid(XmlElement xmlElement)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlElement | xmlElement | The XML to test. |
Returns
Type | Description |
---|---|
System.Boolean |
|
SetAttributeValue(String, String)
Sets the attribute value by adding an attribute statement containing an attribute with the specified name and value.
Declaration
public void SetAttributeValue(string name, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The attribute name. |
System.String | value | 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.
Declaration
public void SetAttributeValue(string name, string nameFormat, string friendlyName, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The attribute name. |
System.String | nameFormat | The name format or |
System.String | friendlyName | The friendly name or |
System.String | value | The attribute value. |
ToString()
Converts the SAML assertion to a string.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | The SAML assertion as a string. |
Overrides
ToXml()
Serializes the SAML assertion to XML.
Declaration
public XmlElement ToXml()
Returns
Type | Description |
---|---|
System.Xml.XmlElement | The SAML assertion as XML. |
Exceptions
Type | Condition |
---|---|
SamlSerializationException | Thrown when the XML serialization fails. |
ToXml(XmlDocument)
Serializes the SAML assertion 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 assertion as XML. |
Exceptions
Type | Condition |
---|---|
SamlSerializationException | Thrown when the XML serialization fails. |