Class EncryptedAttribute
Represents an encrypted attribute.
Inherited Members
Namespace: ComponentSpace.SAML2.Assertions
Assembly: ComponentSpace.Saml2.dll
Syntax
public class EncryptedAttribute : EncryptedElementType
Remarks
Refer to the Assertions and Protocol for the OASIS Security Assertion Markup Language (SAML) V2.0 specification for further details.
Constructors
EncryptedAttribute()
Initializes a new instance of the EncryptedAttribute class.
Declaration
public EncryptedAttribute()
EncryptedAttribute(SAMLAttribute, AsymmetricAlgorithm, EncryptionMethod, EncryptionMethod, KeyInfo)
Initializes a new instance of the EncryptedAttribute class from a SAML attribute.
Declaration
public EncryptedAttribute(SAMLAttribute samlAttribute, AsymmetricAlgorithm keyEncryptingKey, EncryptionMethod keyEncryptionMethod, EncryptionMethod dataEncryptionMethod, KeyInfo keyInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| SAMLAttribute | samlAttribute | The SAML attribute. |
| AsymmetricAlgorithm | keyEncryptingKey | The asymmetric key encrypting key. |
| EncryptionMethod | keyEncryptionMethod | The method for encrypting the symmetric key. |
| EncryptionMethod | dataEncryptionMethod | The method for encrypting the data. |
| KeyInfo | keyInfo | The key info to include with the encrypted data. |
Remarks
A random symmetric session key is generated from the public asymmetric key. The symmetric key is used to encrypt the data.
The specified key encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.
The specified data encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#aes256-cbc.
Exceptions
| Type | Condition |
|---|---|
| SAMLSerializationException | Thrown when the XML deserialization fails. |
| SAMLEncryptionException | Thrown when the encryption fails. |
See Also
EncryptedAttribute(SAMLAttribute, AsymmetricAlgorithm, EncryptionMethod, EncryptionMethod, string, string, KeyInfo)
Initializes a new instance of the EncryptedAttribute class from a SAML attribute.
Declaration
public EncryptedAttribute(SAMLAttribute samlAttribute, AsymmetricAlgorithm keyEncryptingKey, EncryptionMethod keyEncryptionMethod, EncryptionMethod dataEncryptionMethod, string digestMethod, string maskGenerationFunction, KeyInfo keyInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| SAMLAttribute | samlAttribute | The SAML attribute. |
| AsymmetricAlgorithm | keyEncryptingKey | The asymmetric key encrypting key. |
| EncryptionMethod | keyEncryptionMethod | The method for encrypting the symmetric key. |
| EncryptionMethod | dataEncryptionMethod | The method for encrypting the data. |
| string | digestMethod | The key encryption digest method or |
| string | maskGenerationFunction | The key encryption mask generation function or |
| KeyInfo | keyInfo | The key info to include with the encrypted data. |
Remarks
A random symmetric session key is generated from the public asymmetric key. The symmetric key is used to encrypt the data.
The specified key encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.
The specified data encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#aes256-cbc.
Exceptions
| Type | Condition |
|---|---|
| SAMLSerializationException | Thrown when the XML deserialization fails. |
| SAMLEncryptionException | Thrown when the encryption fails. |
See Also
EncryptedAttribute(SAMLAttribute, AsymmetricAlgorithm, EncryptionMethod, KeyInfo)
Initializes a new instance of the EncryptedAttribute class from a SAML attribute.
Declaration
public EncryptedAttribute(SAMLAttribute samlAttribute, AsymmetricAlgorithm keyEncryptingKey, EncryptionMethod dataEncryptionMethod, KeyInfo keyInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| SAMLAttribute | samlAttribute | The SAML attribute. |
| AsymmetricAlgorithm | keyEncryptingKey | The asymmetric key encrypting key. |
| EncryptionMethod | dataEncryptionMethod | The method for encrypting the data. |
| KeyInfo | keyInfo | The key info to include with the encrypted data. |
Remarks
A random symmetric session key is generated from the public asymmetric key. The symmetric key is used to encrypt the data.
The encryption method for the encrypted symmetric key is http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.
The specified data encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#aes256-cbc.
Exceptions
| Type | Condition |
|---|---|
| SAMLSerializationException | Thrown when the XML deserialization fails. |
| SAMLEncryptionException | Thrown when the encryption fails. |
See Also
EncryptedAttribute(SAMLAttribute, X509Certificate2, EncryptionMethod)
Initializes a new instance of the EncryptedAttribute class from a SAML attribute.
Declaration
public EncryptedAttribute(SAMLAttribute samlAttribute, X509Certificate2 x509Certificate, EncryptionMethod dataEncryptionMethod)
Parameters
| Type | Name | Description |
|---|---|---|
| SAMLAttribute | samlAttribute | The SAML attribute. |
| X509Certificate2 | x509Certificate | The X.509 certificate used when encrypting the data. |
| EncryptionMethod | dataEncryptionMethod | The method for encrypting the data. |
Remarks
A random symmetric session key is generated from the public key contained within the X.509 certificate. The symmetric key is used to encrypt the data.
The encryption method for the encrypted symmetric key is http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.
The specified data encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#aes256-cbc.
Exceptions
| Type | Condition |
|---|---|
| SAMLSerializationException | Thrown when the XML deserialization fails. |
| SAMLEncryptionException | Thrown when the encryption fails. |
See Also
EncryptedAttribute(SAMLAttribute, X509Certificate2, EncryptionMethod, EncryptionMethod)
Initializes a new instance of the EncryptedAttribute class from a SAML attribute.
Declaration
public EncryptedAttribute(SAMLAttribute samlAttribute, X509Certificate2 x509Certificate, EncryptionMethod keyEncryptionMethod, EncryptionMethod dataEncryptionMethod)
Parameters
| Type | Name | Description |
|---|---|---|
| SAMLAttribute | samlAttribute | The SAML attribute. |
| X509Certificate2 | x509Certificate | The X.509 certificate used when encrypting the data. |
| EncryptionMethod | keyEncryptionMethod | The method for encrypting the symmetric key. |
| EncryptionMethod | dataEncryptionMethod | The method for encrypting the data. |
Remarks
A random symmetric session key is generated from the public key contained within the X.509 certificate. The symmetric key is used to encrypt the data.
The specified key encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.
The specified data encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#aes256-cbc.
Exceptions
| Type | Condition |
|---|---|
| SAMLSerializationException | Thrown when the XML deserialization fails. |
| SAMLEncryptionException | Thrown when the encryption fails. |
See Also
EncryptedAttribute(SAMLAttribute, X509Certificate2, EncryptionMethod, EncryptionMethod, string, string)
Initializes a new instance of the EncryptedAttribute class from a SAML attribute.
Declaration
public EncryptedAttribute(SAMLAttribute samlAttribute, X509Certificate2 x509Certificate, EncryptionMethod keyEncryptionMethod, EncryptionMethod dataEncryptionMethod, string digestMethod, string maskGenerationFunction)
Parameters
| Type | Name | Description |
|---|---|---|
| SAMLAttribute | samlAttribute | The SAML attribute. |
| X509Certificate2 | x509Certificate | The X.509 certificate used when encrypting the data. |
| EncryptionMethod | keyEncryptionMethod | The method for encrypting the symmetric key. |
| EncryptionMethod | dataEncryptionMethod | The method for encrypting the data. |
| string | digestMethod | The key encryption digest method or |
| string | maskGenerationFunction | The key encryption mask generation function or |
Remarks
A random symmetric session key is generated from the public key contained within the X.509 certificate. The symmetric key is used to encrypt the data.
The specified key encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.
The specified data encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#aes256-cbc.
Exceptions
| Type | Condition |
|---|---|
| SAMLSerializationException | Thrown when the XML deserialization fails. |
| SAMLEncryptionException | Thrown when the encryption fails. |
See Also
EncryptedAttribute(XmlElement)
Initializes a new instance of the EncryptedAttribute class from XML.
Declaration
public EncryptedAttribute(XmlElement xmlElement)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The encrypted attribute XML. |
Exceptions
| Type | Condition |
|---|---|
| SAMLSerializationException | Thrown when the XML deserialization fails. |
EncryptedAttribute(XmlElement, XmlNodeList)
Initializes a new instance of the EncryptedAttribute class.
Declaration
public EncryptedAttribute(XmlElement encryptedData, XmlNodeList encryptedKeys)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | encryptedData | The encrypted data. |
| XmlNodeList | encryptedKeys | The encrypted keys. |
Methods
Decrypt(AsymmetricAlgorithm, EncryptionMethod)
Decrypts an encrypted attribute.
Declaration
public SAMLAttribute Decrypt(AsymmetricAlgorithm keyDecryptingKey, EncryptionMethod dataEncryptionMethod)
Parameters
| Type | Name | Description |
|---|---|---|
| AsymmetricAlgorithm | keyDecryptingKey | The asymmetric key decrypting key. |
| EncryptionMethod | dataEncryptionMethod | The method for decrypting the data or |
Returns
| Type | Description |
|---|---|
| SAMLAttribute | The SAML attribute. |
Remarks
The asymmetric key is used to decrypt the symmetric key contained within the encrypted data. The symmetric key is used to decrypt the data.
The encryption method for the encrypted symmetric key is expected to be http://www.w3.org/2001/04/xmlenc#rsa-1_5 or http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.
The encryption method for the data is specified in the encrypted data or may be explicitly specified.
Exceptions
| Type | Condition |
|---|---|
| SAMLSerializationException | Thrown when the XML deserialization fails. |
| SAMLEncryptionException | Thrown when the decryption fails. |
See Also
Decrypt(AsymmetricAlgorithm, EncryptionMethod, EncryptionMethod)
Decrypts an encrypted attribute.
Declaration
public SAMLAttribute Decrypt(AsymmetricAlgorithm keyDecryptingKey, EncryptionMethod keyEncryptionMethod, EncryptionMethod dataEncryptionMethod)
Parameters
| Type | Name | Description |
|---|---|---|
| AsymmetricAlgorithm | keyDecryptingKey | The asymmetric key decrypting key. |
| EncryptionMethod | keyEncryptionMethod | The method for decrypting the symmetric key or |
| EncryptionMethod | dataEncryptionMethod | The method for decrypting the data or |
Returns
| Type | Description |
|---|---|
| SAMLAttribute | The SAML attribute. |
Remarks
The asymmetric key is used to decrypt the symmetric key contained within the encrypted data. The symmetric key is used to decrypt the data.
The encryption method for the encrypted symmetric key is expected to be http://www.w3.org/2001/04/xmlenc#rsa-1_5 or http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.
The encryption method for the key is specified in the encrypted data or may be explicitly specified.
The encryption method for the data is specified in the encrypted data or may be explicitly specified.
Exceptions
| Type | Condition |
|---|---|
| SAMLSerializationException | Thrown when the XML deserialization fails. |
| SAMLEncryptionException | Thrown when the decryption fails. |
See Also
Decrypt(X509Certificate2, EncryptionMethod)
Decrypts an encrypted attribute.
Declaration
public SAMLAttribute Decrypt(X509Certificate2 x509Certificate, EncryptionMethod dataEncryptionMethod)
Parameters
| Type | Name | Description |
|---|---|---|
| X509Certificate2 | x509Certificate | The X.509 certificate containing a private key. |
| EncryptionMethod | dataEncryptionMethod | The method for decrypting the data or |
Returns
| Type | Description |
|---|---|
| SAMLAttribute | The SAML attribute. |
Remarks
The X.509 certificate's private key is used to decrypt the symmetric key contained within the encrypted data. The symmetric key is used to decrypt the data.
The encryption method for the encrypted symmetric key is expected to be http://www.w3.org/2001/04/xmlenc#rsa-1_5 or http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.
The encryption method for the data is specified in the encrypted data or may be explicitly specified.
Exceptions
| Type | Condition |
|---|---|
| SAMLSerializationException | Thrown when the XML deserialization fails. |
| SAMLEncryptionException | Thrown when the decryption fails. |
See Also
Decrypt(X509Certificate2, EncryptionMethod, EncryptionMethod)
Decrypts an encrypted attribute.
Declaration
public SAMLAttribute Decrypt(X509Certificate2 x509Certificate, EncryptionMethod keyEncryptionMethod, EncryptionMethod dataEncryptionMethod)
Parameters
| Type | Name | Description |
|---|---|---|
| X509Certificate2 | x509Certificate | The X.509 certificate containing a private key. |
| EncryptionMethod | keyEncryptionMethod | The method for decrypting the symmetric key or |
| EncryptionMethod | dataEncryptionMethod | The method for decrypting the data or |
Returns
| Type | Description |
|---|---|
| SAMLAttribute | The SAML attribute. |
Remarks
The X.509 certificate's private key is used to decrypt the symmetric key contained within the encrypted data. The symmetric key is used to decrypt the data.
The encryption method for the encrypted symmetric key is expected to be http://www.w3.org/2001/04/xmlenc#rsa-1_5 or http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.
The encryption method for the key is specified in the encrypted data or may be explicitly specified.
The encryption method for the data is specified in the encrypted data or may be explicitly specified.
Exceptions
| Type | Condition |
|---|---|
| SAMLSerializationException | Thrown when the XML deserialization fails. |
| SAMLEncryptionException | Thrown when the decryption fails. |
See Also
IsValid(XmlElement)
Indicates whether the XML is an encrypted attribute.
Declaration
public static bool IsValid(XmlElement xmlElement)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The XML to test. |
Returns
| Type | Description |
|---|---|
| bool |
|
ToXml(XmlDocument)
Serializes the encrypted attribute to XML.
Declaration
public XmlElement ToXml(XmlDocument xmlDocument)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlDocument | xmlDocument | The owning XML document. |
Returns
| Type | Description |
|---|---|
| XmlElement | The encrypted attribute as XML. |
Exceptions
| Type | Condition |
|---|---|
| SAMLSerializationException | Thrown when the XML serialization fails. |