Class SAMLMetadataSignature
Permits XML signature generation and verification for SAML metadata.
Inherited Members
Namespace: ComponentSpace.SAML2.Metadata
Assembly: ComponentSpace.Saml2.dll
Syntax
public static class SAMLMetadataSignature
Fields
DefaultInclusiveNamespacesPrefixList
The default inclusive namespace prefix list.
Declaration
public const string DefaultInclusiveNamespacesPrefixList = "#default md saml ds xs xsi"
Field Value
| Type | Description |
|---|---|
| string |
Methods
Generate(XmlElement, AsymmetricAlgorithm)
Generates an XML signature and adds it to the metadata.
Declaration
public static void Generate(XmlElement xmlElement, AsymmetricAlgorithm signingKey)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The metadata to sign. |
| AsymmetricAlgorithm | signingKey | The signing key. |
Remarks
An XML signature with the constraints specified in the SAML specification is generated and added to the metadata. The signature is created using the supplied signing key.
The generated signature is added to the supplied XML element.
Exceptions
| Type | Condition |
|---|---|
| SAMLSignatureException | Thrown when the signature generation fails. |
Generate(XmlElement, AsymmetricAlgorithm, X509Certificate2)
Generates an XML signature and adds it to the metadata.
Declaration
public static void Generate(XmlElement xmlElement, AsymmetricAlgorithm signingKey, X509Certificate2 x509Certificate)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The metadata to sign. |
| AsymmetricAlgorithm | signingKey | The signing key. |
| X509Certificate2 | x509Certificate | The X.509 certificate to include in the key info. |
Remarks
An XML signature with the constraints specified in the SAML specification is generated and added to the metadata. The signature is created using the supplied signing key. Key info, using the supplied X.509 certificate, is included in the signature.
The generated signature is added to the supplied XML element.
Exceptions
| Type | Condition |
|---|---|
| SAMLSignatureException | Thrown when the signature generation fails. |
Generate(XmlElement, AsymmetricAlgorithm, X509Certificate2, string, string, string)
Generates an XML signature and adds it to the metadata.
Declaration
public static void Generate(XmlElement xmlElement, AsymmetricAlgorithm signingKey, X509Certificate2 x509Certificate, string inclusiveNamespacesPrefixList, string digestMethod, string signatureMethod)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The metadata to sign. |
| AsymmetricAlgorithm | signingKey | The signing key. |
| X509Certificate2 | x509Certificate | The X.509 certificate to include in the key info. |
| string | inclusiveNamespacesPrefixList | The inclusive namespace prefix list or |
| string | digestMethod | The digest method or |
| string | signatureMethod | The signature method or |
Remarks
An XML signature with the constraints specified in the SAML specification is generated and added to the metadata. The signature is created using the supplied signing key. Key info, using the supplied X.509 certificate, is included in the signature.
The generated signature is added to the supplied XML element.
Exceptions
| Type | Condition |
|---|---|
| SAMLSignatureException | Thrown when the signature generation fails. |
Generate(XmlElement, AsymmetricAlgorithm, X509Certificate2Collection)
Generates an XML signature and adds it to the metadata.
Declaration
public static void Generate(XmlElement xmlElement, AsymmetricAlgorithm signingKey, X509Certificate2Collection x509Certificates)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The metadata to sign. |
| AsymmetricAlgorithm | signingKey | The signing key. |
| X509Certificate2Collection | x509Certificates | The list of X.509 certificate to include in the key info. |
Remarks
An XML signature with the constraints specified in the SAML specification is generated and added to the metadata. The signature is created using the supplied signing key. Key info, using the supplied X.509 certificates, is included in the signature.
The generated signature is added to the supplied XML element.
Exceptions
| Type | Condition |
|---|---|
| SAMLSignatureException | Thrown when the signature generation fails. |
Generate(XmlElement, AsymmetricAlgorithm, X509Certificate2Collection, string, string, string)
Generates an XML signature and adds it to the metadata.
Declaration
public static void Generate(XmlElement xmlElement, AsymmetricAlgorithm signingKey, X509Certificate2Collection x509Certificates, string inclusiveNamespacesPrefixList, string digestMethod, string signatureMethod)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The metadata to sign. |
| AsymmetricAlgorithm | signingKey | The signing key. |
| X509Certificate2Collection | x509Certificates | The list of X.509 certificate to include in the key info. |
| string | inclusiveNamespacesPrefixList | The inclusive namespace prefix list or |
| string | digestMethod | The digest method or |
| string | signatureMethod | The signature method or |
Remarks
An XML signature with the constraints specified in the SAML specification is generated and added to the metadata. The signature is created using the supplied signing key. Key info, using the supplied X.509 certificates, is included in the signature.
The generated signature is added to the supplied XML element.
Exceptions
| Type | Condition |
|---|---|
| SAMLSignatureException | Thrown when the signature generation fails. |
Generate(XmlElement, AsymmetricAlgorithm, KeyInfo)
Generates an XML signature and adds it to the metadata.
Declaration
public static void Generate(XmlElement xmlElement, AsymmetricAlgorithm signingKey, KeyInfo keyInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The metadata to sign. |
| AsymmetricAlgorithm | signingKey | The signing key. |
| KeyInfo | keyInfo | The key info to include in the signature. |
Remarks
An XML signature with the constraints specified in the SAML specification is generated and added to the metadata. The signature is created using the supplied signing key. The key info will be included in the signature.
The generated signature is added to the supplied XML element.
Exceptions
| Type | Condition |
|---|---|
| SAMLSignatureException | Thrown when the signature generation fails. |
Generate(XmlElement, AsymmetricAlgorithm, KeyInfo, string, string, string)
Generates an XML signature and adds it to the metadata.
Declaration
public static void Generate(XmlElement xmlElement, AsymmetricAlgorithm signingKey, KeyInfo keyInfo, string inclusiveNamespacesPrefixList, string digestMethod, string signatureMethod)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The metadata to sign. |
| AsymmetricAlgorithm | signingKey | The signing key. |
| KeyInfo | keyInfo | The key info to include in the signature. |
| string | inclusiveNamespacesPrefixList | The inclusive namespace prefix list or |
| string | digestMethod | The digest method or |
| string | signatureMethod | The signature method or |
Remarks
An XML signature with the constraints specified in the SAML specification is generated and added to the metadata. The signature is created using the supplied signing key. The key info will be included in the signature.
The generated signature is added to the supplied XML element.
Exceptions
| Type | Condition |
|---|---|
| SAMLSignatureException | Thrown when the signature generation fails. |
Generate(XmlElement, AsymmetricAlgorithm, KeyInfoX509Data)
Generates an XML signature and adds it to the metadata.
Declaration
public static void Generate(XmlElement xmlElement, AsymmetricAlgorithm signingKey, KeyInfoX509Data keyInfoX509Data)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The metadata to sign. |
| AsymmetricAlgorithm | signingKey | The signing key. |
| KeyInfoX509Data | keyInfoX509Data | The X.509 data to include in the signature. |
Remarks
An XML signature with the constraints specified in the SAML specification is generated and added to the metadata. The signature is created using the supplied signing key. Key info, using the supplied X.509 data, is included in the signature.
The generated signature is added to the supplied XML element.
Exceptions
| Type | Condition |
|---|---|
| SAMLSignatureException | Thrown when the signature generation fails. |
Generate(XmlElement, AsymmetricAlgorithm, KeyInfoX509Data, string, string, string)
Generates an XML signature and adds it to the metadata.
Declaration
public static void Generate(XmlElement xmlElement, AsymmetricAlgorithm signingKey, KeyInfoX509Data keyInfoX509Data, string inclusiveNamespacesPrefixList, string digestMethod, string signatureMethod)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The metadata to sign. |
| AsymmetricAlgorithm | signingKey | The signing key. |
| KeyInfoX509Data | keyInfoX509Data | The X.509 data to include in the signature. |
| string | inclusiveNamespacesPrefixList | The inclusive namespace prefix list or |
| string | digestMethod | The digest method or |
| string | signatureMethod | The signature method or |
Remarks
An XML signature with the constraints specified in the SAML specification is generated and added to the metadata. The signature is created using the supplied signing key. Key info, using the supplied X.509 data, is included in the signature.
The generated signature is added to the supplied XML element.
Exceptions
| Type | Condition |
|---|---|
| SAMLSignatureException | Thrown when the signature generation fails. |
Generate(XmlElement, AsymmetricAlgorithm, string, string, string)
Generates an XML signature and adds it to the metadata.
Declaration
public static void Generate(XmlElement xmlElement, AsymmetricAlgorithm signingKey, string inclusiveNamespacesPrefixList, string digestMethod, string signatureMethod)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The metadata to sign. |
| AsymmetricAlgorithm | signingKey | The signing key. |
| string | inclusiveNamespacesPrefixList | The inclusive namespace prefix list or |
| string | digestMethod | The digest method or |
| string | signatureMethod | The signature method or |
Remarks
An XML signature with the constraints specified in the SAML specification is generated and added to the metadata. The signature is created using the supplied signing key.
The generated signature is added to the supplied XML element.
Exceptions
| Type | Condition |
|---|---|
| SAMLSignatureException | Thrown when the signature generation fails. |
GetCertificate(XmlElement)
Gets the X.509 certificate embedded in the XML signature or null if none.
Declaration
public static X509Certificate2 GetCertificate(XmlElement xmlElement)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The metadata containing the signature with X.509 certificate. |
Returns
| Type | Description |
|---|---|
| X509Certificate2 | The X.509 certificate embedded in the XML signature or |
Exceptions
| Type | Condition |
|---|---|
| SAMLSignatureException | Thrown when the X.509 certificate retrieval fails. |
See Also
GetKeyInfo(XmlElement)
Gets the key info embedded in the XML signature or null if none.
Declaration
public static KeyInfo GetKeyInfo(XmlElement xmlElement)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The metadata containing the signature with key info. |
Returns
| Type | Description |
|---|---|
| KeyInfo | The key info embedded in the XML signature or |
Exceptions
| Type | Condition |
|---|---|
| SAMLSignatureException | Thrown when the key info retrieval fails. |
See Also
IsSigned(XmlElement)
Indicates whether the metadata contains an XML signature.
Declaration
public static bool IsSigned(XmlElement xmlElement)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The metadata. |
Returns
| Type | Description |
|---|---|
| bool |
|
RemoveSignature(XmlElement)
Removes the XML signature, if any, from the metadata.
Declaration
public static void RemoveSignature(XmlElement xmlElement)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The metadata. |
Verify(XmlElement)
Verifies the XML signature.
Declaration
public static bool Verify(XmlElement xmlElement)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The metadata containing the signature to verify. |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
The key info included with the signature is used to perform the verification.
Exceptions
| Type | Condition |
|---|---|
| SAMLSignatureException | Thrown when the signature verification fails. |
Verify(XmlElement, AsymmetricAlgorithm)
Verifies the XML signature.
Declaration
public static bool Verify(XmlElement xmlElement, AsymmetricAlgorithm signingKey)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The metadata containing the signature to verify. |
| AsymmetricAlgorithm | signingKey | The public key used to perform the verification or |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
The supplied public key is used to perform the verification.
Exceptions
| Type | Condition |
|---|---|
| SAMLSignatureException | Thrown when the signature verification fails. |
Verify(XmlElement, X509Certificate2)
Verifies the XML signature.
Declaration
public static bool Verify(XmlElement xmlElement, X509Certificate2 x509Certificate)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The metadata containing the signature to verify. |
| X509Certificate2 | x509Certificate | The X.509 certificate used to perform the verification. |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
The supplied X.509 certificate is used to perform the verification.
Exceptions
| Type | Condition |
|---|---|
| SAMLSignatureException | Thrown when the signature verification fails. |
Verify(XmlElement, KeyInfo)
Verifies the XML signature.
Declaration
public static bool Verify(XmlElement xmlElement, KeyInfo keyInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The metadata containing the signature to verify. |
| KeyInfo | keyInfo | The key info used to perform the verification or |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
The supplied key info is used to perform the verification.
Exceptions
| Type | Condition |
|---|---|
| SAMLSignatureException | Thrown when the signature verification fails. |
Verify(XmlElement, KeyInfoX509Data)
Verifies the XML signature.
Declaration
public static bool Verify(XmlElement xmlElement, KeyInfoX509Data keyInfoX509Data)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | xmlElement | The metadata containing the signature to verify. |
| KeyInfoX509Data | keyInfoX509Data | The X.509 data used to perform the verification or |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
The supplied X.509 data is used to perform the verification.
Exceptions
| Type | Condition |
|---|---|
| SAMLSignatureException | Thrown when the signature verification fails. |