CadesSigner
Namespace: Lacuna.Pki.Cades
Assembly: Lacuna.Pki
Class
Class for creating CAdES signatures
public class CadesSigner : IDisposable
Hierarquia: object → CadesSigner
Construtores
CadesSigner()
public CadesSigner()
Propriedades
ValidationResults
public ValidationResults ValidationResults { get; }
Retorno
Warnings
public List<string> Warnings { get; }
Retorno
Métodos
AddAttributeCertificate(AttributeCertificate)
Adds attribute certificates in the signed attributes
public void AddAttributeCertificate(AttributeCertificate attributeCertificate)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
attributeCertificate | AttributeCertificate | Certificate attribute |
AddAttributeCertificate(IEnumerable<AttributeCertificate>)
Adds attribute certificates in the signed attributes
public void AddAttributeCertificate(IEnumerable<AttributeCertificate> attributeCertificate)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
attributeCertificate | IEnumerable<AttributeCertificate> | Certificate attribute |
ComputeSignature()
Computes the CAdES signature elements. Call after all parameters set
public void ComputeSignature()
Dispose()
Disposes streams used
public void Dispose()
GenerateToSignBytes(out SignatureAlgorithm)
Generates the bytes to be signed
public byte[] GenerateToSignBytes(out SignatureAlgorithm signatureAlg)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
signatureAlg | SignatureAlgorithm | Signature algorithm to be used |
Retorno
byte[] — To sign bytes
GetSignature()
Gets the completed signature content
public byte[] GetSignature()
Retorno
GetSignatureFinisher()
Gets the signature finisher. Used in a three-step signature
public CadesSignatureFinisher GetSignatureFinisher()
Retorno
CadesSignatureFinisher — Signature finisher. An element that will handle the timestamps and revocation elements of the signature
SetCertificateValidationConfigurator(Action<CertificateValidationOptions>)
Sets an action for configuring the signer certificate validation
public void SetCertificateValidationConfigurator(Action<CertificateValidationOptions> configureCertificateValidation)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
configureCertificateValidation | Action<CertificateValidationOptions> |
SetCommitmentType(CommitmentType)
Sets the signer commitment type signed attribute
public void SetCommitmentType(CommitmentType commitmentType)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
commitmentType | CommitmentType |
SetContentType(CmsContentType)
Sets the encapsulated content type of the SignedData. Note: only use this if you are not signing a Data type
public void SetContentType(CmsContentType contentType)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
contentType | CmsContentType |
SetCrlStore(IReferencedCrlStore)
Sets a trusted CRL store indexed by CRL digest values.
public void SetCrlStore(IReferencedCrlStore crlStore)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
crlStore | IReferencedCrlStore | CRL store |
SetDataDigestToSign(DigestAlgorithm, byte[])
Sets the message digest that is going to be signed. Using this method instead of SetDataToSign will mandatorily result in a detached signature, without encapsulated content.
public void SetDataDigestToSign(DigestAlgorithm digestAlgorithm, byte[] digestValue)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
digestAlgorithm | DigestAlgorithm | |
digestValue | byte[] |
SetDataToSign(byte[])
Sets the data content that is going to be signed
public void SetDataToSign(byte[] data)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
data | byte[] | The data content bytes to be signed |
SetDataToSign(Stream)
Sets the data that is going to be signed
public void SetDataToSign(Stream stream)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
stream | Stream |
SetEncapsulatedContent(bool)
Wheter or not to include the encapsulated content in the signature. If not set, default value is true
public void SetEncapsulatedContent(bool includeEncapsulatedContent)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
includeEncapsulatedContent | bool |
SetFinishSignature(bool)
Sets if the signature will be closed after the signing process ends. Default is true. Set false if it is a three-step signature
public void SetFinishSignature(bool finishSignature)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
finishSignature | bool |
SetPolicy(CadesPolicySpec)
Sets the signature policy specification
public void SetPolicy(CadesPolicySpec policy)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
policy | CadesPolicySpec | Policy specification |
SetPolicy(ICadesPolicyMapper)
Sets a policy specification mapper
public void SetPolicy(ICadesPolicyMapper policyMapper)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
policyMapper | ICadesPolicyMapper | Policy mapper |
SetPrecomputedSignature(byte[], byte[])
Sets the signed bytes from the client. Used in a two-step signature
public void SetPrecomputedSignature(byte[] signature, byte[] toSignBytes)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
signature | byte[] | Signed bytes |
toSignBytes | byte[] | To sign bytes used in the signing process |
SetPrecomputedSignature(byte[])
Sets the signed bytes from the client. Used in a two-step signature
public void SetPrecomputedSignature(byte[] signature)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
signature | byte[] | Signed bytes |
SetSignatureToCoSign(byte[])
Sets the signature to create a co-signature
public bool SetSignatureToCoSign(byte[] signature)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
signature | byte[] | Signature content bytes |
Retorno
SetSignatureToCoSign(Stream)
Sets the signature to create a co-signature
public bool SetSignatureToCoSign(Stream stream)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
stream | Stream | Signature stream |
Retorno
SetSigningCertificate(PKCertificate)
Sets the signing certificate. Used in a two-step signature
public void SetSigningCertificate(PKCertificate certificate)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
certificate | PKCertificate | Certificate |
SetSigningCertificate(PKCertificateWithKey)
Sets the signing certificate with private key. Used in a one-step signature
public void SetSigningCertificate(PKCertificateWithKey certWithKey)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
certWithKey | PKCertificateWithKey | Certificate with private key |
SetSigningDescription(string)
Sets a custom text describing the signing operation. If set, it will be inlcuded as a signingDescription signed attribute
public void SetSigningDescription(string description)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
description | string |
SetTimestampRequester(ITimestampRequester)
Sets a timestamp requester. Must be set if the policy specification requires any type of timestamp attribute
public void SetTimestampRequester(ITimestampRequester tsRequester)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
tsRequester | ITimestampRequester | Timestamp requester |
VerifyParameters(bool)
Verifies if CadesSigner necessary parameters are set. If not, throws Exception.
public void VerifyParameters(bool computingSignature = false)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
computingSignature | bool | Whether or not you will call the ComputeSignature() method to complete the siganture process in this step. |
WriteSignature(Stream)
Writes the completed signature content to a stream
public void WriteSignature(Stream stream)
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
stream | Stream | Stream |
Membros herdados
ToString(), Equals(object), Equals(object, object), ReferenceEquals(object, object), GetHashCode(), GetType(), MemberwiseClone()