Class SAMLAssertion
Represents the Assertion element.
Implements
Inherited Members
Namespace: ComponentSpace.SAML2.Assertions
Assembly: ComponentSpace.Saml2.dll
Syntax
[Serializable]
public class SAMLAssertion : ISerializable
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(SerializationInfo, StreamingContext)
Initializes a new instance of the SAMLAssertion class.
Declaration
protected SAMLAssertion(SerializationInfo info, StreamingContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| SerializationInfo | info | The serialization information. |
| StreamingContext | context | The streaming context. |
Remarks
This constructor supports serialization.
SAMLAssertion(string)
Initializes a new instance of the SAMLAssertion class from an XML string.
Declaration
public SAMLAssertion(string xmlString)
Parameters
| Type | Name | Description |
|---|---|---|
| string | xmlString | The assertion XML string. |
Exceptions
| Type | Condition |
|---|---|
| SAMLSerializationException | Thrown when the XML deserialization fails. |
SAMLAssertion(XmlElement)
Initializes a new instance of the SAMLAssertion class from XML.
Declaration
public SAMLAssertion(XmlElement xmlElement)
Parameters
| Type | Name | Description |
|---|---|---|
| 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 |
|---|---|
| string | The ID. |
IssueInstant
Gets or sets the issue instant.
Declaration
public DateTime IssueInstant { get; set; }
Property Value
| Type | Description |
|---|---|
| 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. |
Signature
Gets or sets the digital signature.
Declaration
public XmlElement Signature { get; set; }
Property Value
| Type | Description |
|---|---|
| XmlElement | The digital signature. |
Remarks
To generate or verify signatures, use SAMLAssertionSignature.
See Also
Statements
Gets or sets the statements.
Declaration
public IList<IStatement> Statements { get; set; }
Property Value
| Type | Description |
|---|---|
| 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 |
|---|---|
| string | The version. The default is 2.0. |
Methods
Find(XmlElement)
Returns the list of SAML assertion XML elements contained within the supplied XML.
Declaration
public static IList<XmlElement> Find(XmlElement xmlElement)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The XML in which to search for SAML assertions XML elements. |
Returns
| Type | Description |
|---|---|
| IList<XmlElement> | The list of SAML assertion |
GetAttributeStatements()
Returns all attribute statements.
Declaration
public IList<AttributeStatement> GetAttributeStatements()
Returns
| Type | Description |
|---|---|
| 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 |
|---|---|---|
| string | attributeName | The attribute name. |
Returns
| Type | Description |
|---|---|
| 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.
See Also
GetAttributeValueByFriendlyName(string)
Returns the value of the unencrypted attribute with the specified friendly name.
Declaration
public string GetAttributeValueByFriendlyName(string friendlyName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | friendlyName | The attribute friendly name. |
Returns
| Type | Description |
|---|---|
| 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.
See Also
GetAttributes(string)
Returns all unencrypted attributes with the specified name.
Declaration
public IList<SAMLAttribute> GetAttributes(string attributeName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | attributeName | The attribute name. |
Returns
| Type | Description |
|---|---|
| IList<SAMLAttribute> | The matching unencrypted attributes. |
See Also
GetAttributesByFriendlyName(string)
Returns all unencrypted attributes with the specified friendly name.
Declaration
public IList<SAMLAttribute> GetAttributesByFriendlyName(string friendlyName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | friendlyName | The attribute friendly name. |
Returns
| Type | Description |
|---|---|
| IList<SAMLAttribute> | The matching unencrypted attributes. |
See Also
GetAuthenticationStatements()
Returns all authentication statements.
Declaration
public IList<AuthnStatement> GetAuthenticationStatements()
Returns
| Type | Description |
|---|---|
| IList<AuthnStatement> | The authentication statements. |
See Also
GetAuthorizationDecisionStatements()
Returns all authorization decision statements.
Declaration
public IList<AuthzDecisionStatement> GetAuthorizationDecisionStatements()
Returns
| Type | Description |
|---|---|
| IList<AuthzDecisionStatement> | The authorization decision statements. |
See Also
GetNameID()
Gets the name identifier from the subject.
Declaration
public string GetNameID()
Returns
| Type | Description |
|---|---|
| string | The name identifier from the subject or |
See Also
GetObjectData(SerializationInfo, StreamingContext)
Serialize the SAML assertion.
Declaration
[SecurityCritical]
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| SerializationInfo | info | The serialization information. |
| StreamingContext | context | The streaming context. |
IsValid(XmlElement)
Indicates whether the XML is an assertion.
Declaration
public static bool IsValid(XmlElement xmlElement)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The XML to test. |
Returns
| Type | Description |
|---|---|
| bool |
|
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 attributeValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The attribute name. |
| string | attributeValue | The attribute value. |
See Also
SetAttributeValue(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 attributeType, string attributeValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The attribute name. |
| string | attributeType | The attribute type. |
| string | attributeValue | The attribute value. |
See Also
SetAttributeValues(string[], string[])
Sets the attribute values by adding an attribute statement containing attributes with the specified names and values.
Declaration
public void SetAttributeValues(string[] names, string[] attributeValues)
Parameters
| Type | Name | Description |
|---|---|---|
| string[] | names | The attribute names. |
| string[] | attributeValues | The attribute values. |
See Also
SetAttributeValues(string[], string[], string[])
Sets the attribute values by adding an attribute statement containing attributes with the specified names and values.
Declaration
public void SetAttributeValues(string[] names, string[] attributeTypes, string[] attributeValues)
Parameters
| Type | Name | Description |
|---|---|---|
| string[] | names | The attribute names. |
| string[] | attributeTypes | The attribute types. |
| string[] | attributeValues | The attribute values. |
See Also
ToString()
Converts the SAML assertion to a string.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | The SAML assertion as a string. |
Overrides
ToXml()
Serializes the SAML assertion to XML.
Declaration
public XmlElement ToXml()
Returns
| Type | Description |
|---|---|
| XmlElement | The SAML assertion as XML. |
Remarks
An XML document is created.
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 |
|---|---|---|
| XmlDocument | xmlDocument | The owning XML document. |
Returns
| Type | Description |
|---|---|
| XmlElement | The SAML assertion as XML. |
Exceptions
| Type | Condition |
|---|---|
| SAMLSerializationException | Thrown when the XML serialization fails. |