Class SAMLAssertion
Represents the Assertion element.
Inheritance
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 |
---|---|---|
System.Runtime.Serialization.SerializationInfo | info | The serialization information. |
System.Runtime.Serialization.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 |
---|---|---|
System.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 |
---|---|---|
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.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 |
---|---|
System.Xml.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 |
---|---|
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
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 |
---|---|---|
System.Xml.XmlElement | xmlElement | The XML in which to search for SAML assertions XML elements. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<System.Xml.XmlElement> | The list of SAML assertion |
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. |
See Also
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. |
See Also
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.
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 |
---|---|---|
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.
See Also
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
GetObjectData(SerializationInfo, StreamingContext)
Serialize the SAML assertion.
Declaration
[SecurityCritical]
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Runtime.Serialization.SerializationInfo | info | The serialization information. |
System.Runtime.Serialization.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 |
---|---|---|
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 attributeValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The attribute name. |
System.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 |
---|---|---|
System.String | name | The attribute name. |
System.String | attributeType | The attribute type. |
System.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 |
---|---|---|
System.String[] | names | The attribute names. |
System.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 |
---|---|---|
System.String[] | names | The attribute names. |
System.String[] | attributeTypes | The attribute types. |
System.String[] | attributeValues | The attribute values. |
See Also
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. |
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 |
---|---|---|
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. |