Class XmlSigner
Inherited Members
Namespace: Lacuna.Pki.Xml
Assembly: Lacuna.Pki.dll
Syntax
public abstract class XmlSigner
Constructors
XmlSigner()
Declaration
public XmlSigner()
Fields
namespaceMan
Declaration
protected NamespaceManager namespaceMan
Field Value
| Type | Description |
|---|---|
| NamespaceManager |
xmlDocument
Declaration
protected XmlDocument xmlDocument
Field Value
| Type | Description |
|---|---|
| XmlDocument |
Properties
ValidationResults
Declaration
public ValidationResults ValidationResults { get; }
Property Value
| Type | Description |
|---|---|
| ValidationResults |
Warnings
Declaration
public List<string> Warnings { get; }
Property Value
| Type | Description |
|---|---|
| List<String> |
Methods
AddReferences(SignedXml, DigestAlgorithm, XmlPolicySpec)
Declaration
protected abstract void AddReferences(SignedXml signedXml, DigestAlgorithm digestAlgorithm, XmlPolicySpec policy)
Parameters
| Type | Name | Description |
|---|---|---|
| SignedXml | signedXml | |
| DigestAlgorithm | digestAlgorithm | |
| XmlPolicySpec | policy |
ComputeSignature()
Computes the XML signature
Declaration
public void ComputeSignature()
FulfillTransformations(Reference)
Declaration
protected void FulfillTransformations(Reference reference)
Parameters
| Type | Name | Description |
|---|---|---|
| Reference | reference |
GenerateToSignHash(out SignatureAlgorithm, out Byte[])
Generates the hash to be signed by the user in an asynchronous signature. In the next step, in possesion of the signed hash and the persisted transferData, you must call the SetPrecomputedSignature method
Declaration
public byte[] GenerateToSignHash(out SignatureAlgorithm signatureAlgorithm, out byte[] transferData)
Parameters
| Type | Name | Description |
|---|---|---|
| SignatureAlgorithm | signatureAlgorithm | The signature algorithm to be used in the user signature |
| Byte[] | transferData | The data to be persisted until the next step |
Returns
| Type | Description |
|---|---|
| Byte[] | The hash to be signed by the user |
GetSignatureElement()
Returns the computed XML signature element only
Declaration
public XmlElement GetSignatureElement()
Returns
| Type | Description |
|---|---|
| XmlElement |
GetSignedXml()
Returns the XML document containing the computed signature element
Declaration
public byte[] GetSignedXml()
Returns
| Type | Description |
|---|---|
| Byte[] | XML document bytes |
GetToSignEntityTransferData()
Declaration
protected abstract byte[] GetToSignEntityTransferData()
Returns
| Type | Description |
|---|---|
| Byte[] |
InsertSignatureElement()
Inserts the computed signature element in the XML document
Declaration
public virtual void InsertSignatureElement()
InsertSignatureElement(XmlElement, String, XmlInsertionOptions)
Declaration
protected virtual void InsertSignatureElement(XmlElement signatureElement, string xpath, XmlInsertionOptions insertionOption)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlElement | signatureElement | |
| String | xpath | |
| XmlInsertionOptions | insertionOption |
SetCertificateValidationConfigurator(Action<CertificateValidationOptions>)
Sets an action for configuring the signer certificate validation
Declaration
public void SetCertificateValidationConfigurator(Action<CertificateValidationOptions> configureCertificateValidation)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<CertificateValidationOptions> | configureCertificateValidation |
SetClassicEnvelopedTransformation(Boolean)
Sets whether or not to use classic enveloped transformation on enveloped signatures. By default XML Signers adds an XPath transformation along with enveloped transformation, which allows multiple new signatures to the XML. Case true, the default XPath transformation is not included, therefore, adding new signatures to the XML is not allowed and will break previous signatures validation.
Declaration
public void SetClassicEnvelopedTransformation(bool useClassicEnveloped)
Parameters
| Type | Name | Description |
|---|---|---|
| Boolean | useClassicEnveloped |
SetCommitmentType(CommitmentType)
Sets the signer commitment type signed attribute for all signed data. If executing a remote signature, the commitment type must be passed again in the compute signature step
Declaration
public void SetCommitmentType(CommitmentType commitmentType)
Parameters
| Type | Name | Description |
|---|---|---|
| CommitmentType | commitmentType |
SetDataObjectFormat(String)
Sets a custom text describing the signing operation. If set, it will be inlcuded as a DataObjectFormat signed data property
Declaration
public void SetDataObjectFormat(string description)
Parameters
| Type | Name | Description |
|---|---|---|
| String | description |
SetPolicy(IXmlPolicyMapper)
Sets the XML signature policy mapper
Declaration
public void SetPolicy(IXmlPolicyMapper policyMapper)
Parameters
| Type | Name | Description |
|---|---|---|
| IXmlPolicyMapper | policyMapper |
SetPolicy(XmlPolicySpec)
Sets the XML signature policy
Declaration
public void SetPolicy(XmlPolicySpec policy)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlPolicySpec | policy |
SetPrecomputedSignature(Byte[], Byte[])
Sets the precomputed signture and persisted data in an asynchronous signature
Declaration
public void SetPrecomputedSignature(byte[] signature, byte[] transferData)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | signature | The user signature of the hash given by the method GenerateToSignHash |
| Byte[] | transferData | The data given by the method GenerateToSignHash |
SetSignatureElementId(String)
Sets the computed signature element ID
Declaration
public void SetSignatureElementId(string id)
Parameters
| Type | Name | Description |
|---|---|---|
| String | id |
SetSignatureElementLocation(String, NamespaceManager, XmlInsertionOptions)
Sets the location of the computed signature element to be inserted in the XML document
Declaration
public void SetSignatureElementLocation(string xpath, NamespaceManager namespaceMan, XmlInsertionOptions insertionOption)
Parameters
| Type | Name | Description |
|---|---|---|
| String | xpath | The xpath to select the target element which the insertion will be related to. If null, XML root element will be selected. |
| NamespaceManager | namespaceMan | The namespaces and prefixes of the XML used in the xpath |
| XmlInsertionOptions | insertionOption | The insertion option that will be applied over the target element define by xpath |
SetSigningCertificate(PKCertificate)
Sets the signing certificate. Used in an asynchronous signature
Declaration
public void SetSigningCertificate(PKCertificate signingCertificate)
Parameters
| Type | Name | Description |
|---|---|---|
| PKCertificate | signingCertificate |
SetSigningCertificate(PKCertificateWithKey)
Sets the signing certificate with private key. Used in a synchronous signature
Declaration
public void SetSigningCertificate(PKCertificateWithKey signingCertificate)
Parameters
| Type | Name | Description |
|---|---|---|
| PKCertificateWithKey | signingCertificate |
SetTimestampRequester(ITimestampRequester)
Sets a timestamp requester. Must be set if the policy specification requires any type of timestamp
Declaration
public void SetTimestampRequester(ITimestampRequester timestampRequester)
Parameters
| Type | Name | Description |
|---|---|---|
| ITimestampRequester | timestampRequester |
SetToSignEntityTransferData(Byte[])
Declaration
protected abstract void SetToSignEntityTransferData(byte[] transferData)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | transferData |
SetXml(Byte[])
Sets the XML document bytes
Declaration
public void SetXml(byte[] xmlDocumentBytes)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | xmlDocumentBytes | XML document bytes |
SetXml(XmlDocument)
Sets the XML document
Declaration
public void SetXml(XmlDocument xmlDoc)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlDocument | xmlDoc | XML document |
VerifyParameters(Boolean)
Declaration
protected virtual void VerifyParameters(bool computeSignature)
Parameters
| Type | Name | Description |
|---|---|---|
| Boolean | computeSignature |
VerifySignerParameters(Boolean)
Verifies if the Xml signer necessary parameters are set. If not, throws Exception.
Declaration
public void VerifySignerParameters(bool computingSignature = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Boolean | computingSignature | Whether or not you will call the ComputeSignature() method to complete the siganture process in this step. |