Pular para o conteúdo principal

XmlSigner

Namespace: Lacuna.Pki.Xml
Assembly: Lacuna.Pki
Class

public abstract class XmlSigner

Hierarquia: objectXmlSigner

Construtores

XmlSigner()

public XmlSigner()

Campos

namespaceMan

protected NamespaceManager namespaceMan

Retorno

NamespaceManager


xmlDocument

protected XmlDocument xmlDocument

Retorno

XmlDocument


Propriedades

ValidationResults

public ValidationResults ValidationResults { get; }

Retorno

ValidationResults


Warnings

public List<string> Warnings { get; }

Retorno

List<string>


Métodos

AddReferences(SignedXml, DigestAlgorithm, XmlPolicySpec)

protected abstract void AddReferences(SignedXml signedXml, DigestAlgorithm digestAlgorithm, XmlPolicySpec policy)

Parâmetros

NomeTipoDescrição
signedXmlSignedXml
digestAlgorithmDigestAlgorithm
policyXmlPolicySpec

ComputeSignature()

Computes the XML signature

public void ComputeSignature()

FulfillTransformations(Reference)

protected void FulfillTransformations(Reference reference)

Parâmetros

NomeTipoDescrição
referenceReference

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

public byte[] GenerateToSignHash(out SignatureAlgorithm signatureAlgorithm, out byte[] transferData)

Parâmetros

NomeTipoDescrição
signatureAlgorithmSignatureAlgorithmThe signature algorithm to be used in the user signature
transferDatabyte[]The data to be persisted until the next step

Retorno

byte[] — The hash to be signed by the user


GetSignatureElement()

Returns the computed XML signature element only

public XmlElement GetSignatureElement()

Retorno

XmlElement


GetSignedXml()

Returns the XML document containing the computed signature element

public byte[] GetSignedXml()

Retorno

byte[] — XML document bytes


GetToSignEntityTransferData()

protected abstract byte[] GetToSignEntityTransferData()

Retorno

byte[]


InsertSignatureElement()

Inserts the computed signature element in the XML document

public virtual void InsertSignatureElement()

InsertSignatureElement(XmlElement, string, XmlInsertionOptions)

protected virtual void InsertSignatureElement(XmlElement signatureElement, string xpath, XmlInsertionOptions insertionOption)

Parâmetros

NomeTipoDescrição
signatureElementXmlElement
xpathstring
insertionOptionXmlInsertionOptions

SetCertificateValidationConfigurator(Action<CertificateValidationOptions>)

Sets an action for configuring the signer certificate validation

public void SetCertificateValidationConfigurator(Action<CertificateValidationOptions> configureCertificateValidation)

Parâmetros

NomeTipoDescrição
configureCertificateValidationAction<CertificateValidationOptions>

SetClassicEnvelopedTransformation(bool)

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.

public void SetClassicEnvelopedTransformation(bool useClassicEnveloped)

Parâmetros

NomeTipoDescrição
useClassicEnvelopedbool

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

public void SetCommitmentType(CommitmentType commitmentType)

Parâmetros

NomeTipoDescrição
commitmentTypeCommitmentType

SetDataObjectFormat(string)

Sets a custom text describing the signing operation. If set, it will be inlcuded as a DataObjectFormat signed data property

public void SetDataObjectFormat(string description)

Parâmetros

NomeTipoDescrição
descriptionstring

SetPolicy(IXmlPolicyMapper)

Sets the XML signature policy mapper

public void SetPolicy(IXmlPolicyMapper policyMapper)

Parâmetros

NomeTipoDescrição
policyMapperIXmlPolicyMapper

SetPolicy(XmlPolicySpec)

Sets the XML signature policy

public void SetPolicy(XmlPolicySpec policy)

Parâmetros

NomeTipoDescrição
policyXmlPolicySpec

SetPrecomputedSignature(byte[], byte[])

Sets the precomputed signture and persisted data in an asynchronous signature

public void SetPrecomputedSignature(byte[] signature, byte[] transferData)

Parâmetros

NomeTipoDescrição
signaturebyte[]The user signature of the hash given by the method GenerateToSignHash
transferDatabyte[]The data given by the method GenerateToSignHash

SetSignatureElementId(string)

Sets the computed signature element ID

public void SetSignatureElementId(string id)

Parâmetros

NomeTipoDescrição
idstring

SetSignatureElementLocation(string, NamespaceManager, XmlInsertionOptions)

Sets the location of the computed signature element to be inserted in the XML document

public void SetSignatureElementLocation(string xpath, NamespaceManager namespaceMan, XmlInsertionOptions insertionOption)

Parâmetros

NomeTipoDescrição
xpathstringThe xpath to select the target element which the insertion will be related to. If null, XML root element will be selected.
namespaceManNamespaceManagerThe namespaces and prefixes of the XML used in the xpath
insertionOptionXmlInsertionOptionsThe insertion option that will be applied over the target element define by xpath

SetSigningCertificate(PKCertificate)

Sets the signing certificate. Used in an asynchronous signature

public void SetSigningCertificate(PKCertificate signingCertificate)

Parâmetros

NomeTipoDescrição
signingCertificatePKCertificate

SetSigningCertificate(PKCertificateWithKey)

Sets the signing certificate with private key. Used in a synchronous signature

public void SetSigningCertificate(PKCertificateWithKey signingCertificate)

Parâmetros

NomeTipoDescrição
signingCertificatePKCertificateWithKey

SetTimestampRequester(ITimestampRequester)

Sets a timestamp requester. Must be set if the policy specification requires any type of timestamp

public void SetTimestampRequester(ITimestampRequester timestampRequester)

Parâmetros

NomeTipoDescrição
timestampRequesterITimestampRequester

SetToSignEntityTransferData(byte[])

protected abstract void SetToSignEntityTransferData(byte[] transferData)

Parâmetros

NomeTipoDescrição
transferDatabyte[]

SetXml(byte[])

Sets the XML document bytes

public void SetXml(byte[] xmlDocumentBytes)

Parâmetros

NomeTipoDescrição
xmlDocumentBytesbyte[]XML document bytes

SetXml(XmlDocument)

Sets the XML document

public void SetXml(XmlDocument xmlDoc)

Parâmetros

NomeTipoDescrição
xmlDocXmlDocumentXML document

VerifyParameters(bool)

protected virtual void VerifyParameters(bool computeSignature)

Parâmetros

NomeTipoDescrição
computeSignaturebool

VerifySignerParameters(bool)

Verifies if the Xml signer necessary parameters are set. If not, throws Exception.

public void VerifySignerParameters(bool computingSignature = false)

Parâmetros

NomeTipoDescrição
computingSignatureboolWhether or not you will call the ComputeSignature() method to complete the siganture process in this step.

Membros herdados

ToString(), Equals(object), Equals(object, object), ReferenceEquals(object, object), GetHashCode(), GetType(), MemberwiseClone()