public class SignerInfo extends Object
| Constructor and Description |
|---|
SignerInfo()
Creates an empty SignerInfo structure.
|
SignerInfo(com.itextpdf.commons.bouncycastle.asn1.IASN1Encodable signerInfoStructure,
Collection<X509Certificate> certificates)
Creates a SignerInfo structure from an ASN1 structure.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addSignedAttribute(CmsAttribute attribute)
Adds a new attribute to the signed attributes.
|
void |
addSignerCertificateToSignedAttributes(X509Certificate cert,
String digestAlgorithmOid)
Adds the signer certificate to the signed attributes as a SigningCertificateV2 structure.
|
void |
addUnSignedAttribute(CmsAttribute attribute)
Optional.
|
com.itextpdf.commons.bouncycastle.asn1.IDERSequence |
getAsDerSequence()
Serializes the SignerInfo structure and makes the signed attributes readonly.
|
int |
getCmsVersion()
Value 0 when no signerIdentifier is available.
|
AlgorithmIdentifier |
getDigestAlgorithm()
Returns the algorithmId to create the digest of the data to sign.
|
long |
getEstimatedSize()
Calculates an estimate size for the SignerInfo structure.
|
Collection<CmsAttribute> |
getSignedAttributes()
Optional.
|
X509Certificate |
getSigningCertificate()
Gets the certificate that is used to sign.
|
Collection<CmsAttribute> |
getUnSignedAttributes()
Retrieves the optional unsigned attributes.
|
byte[] |
serializeSignedAttributes()
Retrieves the encoded signed attributes of the signer info.
|
void |
setCrlResponses(Collection<byte[]> crlResponses)
Adds a set of CRL responses as signed attributes.
|
void |
setDigestAlgorithm(AlgorithmIdentifier algorithmId)
Sets the algorithmId to create the digest of the data to sign.
|
void |
setMessageDigest(byte[] digest)
Adds or replaces the message digest signed attribute.
|
void |
setOcspResponses(Collection<byte[]> ocspResponses)
Adds a set of OCSP responses as signed attributes.
|
void |
setSerializedSignedAttributes(byte[] serializedSignedAttributes)
Sets the signed attributes from a serialized version.
|
void |
setSignature(byte[] signatureData)
Sets the actual signature.
|
void |
setSignatureAlgorithm(AlgorithmIdentifier algorithm)
Optional.
|
void |
setSigningCertificate(X509Certificate certificate)
Sets the certificate that is used to sign.
|
void |
setSigningCertificateAndAddToSignedAttributes(X509Certificate certificate,
String digestAlgorithmOid)
Sets the certificate that is used to sign a document and adds it to the signed attributes.
|
public SignerInfo()
public SignerInfo(com.itextpdf.commons.bouncycastle.asn1.IASN1Encodable signerInfoStructure,
Collection<X509Certificate> certificates)
throws IOException
signerInfoStructure - the ASN1 structure containing signerInfocertificates - the certificates of the CMS, it should contain the signing certificateIOException - if issues occur during ASN1 objects creation.public AlgorithmIdentifier getDigestAlgorithm()
public void setDigestAlgorithm(AlgorithmIdentifier algorithmId)
algorithmId - the OID of the algorithmpublic void setMessageDigest(byte[] digest)
digest - ASN.1 type MessageDigestpublic void setSigningCertificate(X509Certificate certificate) throws CertificateEncodingException
certificate - the certificate that is used to signCertificateEncodingException - if an encoding error occurs.public X509Certificate getSigningCertificate()
public void setSigningCertificateAndAddToSignedAttributes(X509Certificate certificate, String digestAlgorithmOid) throws CertificateEncodingException, NoSuchAlgorithmException, NoSuchProviderException
certificate - the certificate that is used to signdigestAlgorithmOid - the oid of the digest algorithm to be added to the signed attributesCertificateEncodingException - if an encoding error occurs.NoSuchAlgorithmException - when the algorithm is unknown.NoSuchProviderException - when provider is unknown.public void setOcspResponses(Collection<byte[]> ocspResponses)
ocspResponses - a set of binary representations of OCSP responses.public void setCrlResponses(Collection<byte[]> crlResponses)
crlResponses - a set of binary representations of CRL responses.public void addSignerCertificateToSignedAttributes(X509Certificate cert, String digestAlgorithmOid) throws NoSuchAlgorithmException, NoSuchProviderException, CertificateEncodingException
cert - the certificate to adddigestAlgorithmOid - the digest algorithm oid that will be usedNoSuchAlgorithmException - when the algorithm is unknown.NoSuchProviderException - when the security provider is not known.CertificateEncodingException - when there was a problem parsing th certificate.public void setSignature(byte[] signatureData)
signatureData - a byte array containing the signaturepublic void setSignatureAlgorithm(AlgorithmIdentifier algorithm)
algorithm - The OID and parameters of the algorithm that will be used to create the signature.public int getCmsVersion()
public Collection<CmsAttribute> getSignedAttributes()
Attributes that should be part of the signed content optional, but it MUST be present if the content type of the EncapsulatedContentInfo value being signed is not id-data. In that case it must at least contain the following two attributes:
A content-type attribute having as its value the content type of the EncapsulatedContentInfo value being signed. Section 11.1 defines the content-type attribute. However, the content-type attribute MUST NOT be used as part of a countersignature unsigned attribute as defined in Section 11.4.
A message-digest attribute, having as its value the message digest of the content. Section 11.2 defines the message-digest attribute.
public void addSignedAttribute(CmsAttribute attribute)
serializeSignedAttributes().attribute - the attribute to addpublic Collection<CmsAttribute> getUnSignedAttributes()
public void addUnSignedAttribute(CmsAttribute attribute)
Adds attribute that should not or can not be part of the signed content.
attribute - the attribute to addpublic byte[] serializeSignedAttributes()
throws IOException
IOException - if issues occur during ASN1 objects creation.public final void setSerializedSignedAttributes(byte[] serializedSignedAttributes)
serializedSignedAttributes - the encoded signed attributes.public long getEstimatedSize()
throws IOException,
CertificateEncodingException
IOException - if issues occur during ASN1 objects creation.CertificateEncodingException - if issues occur during processing of certificates.public com.itextpdf.commons.bouncycastle.asn1.IDERSequence getAsDerSequence()
throws CertificateEncodingException
CertificateEncodingException - if issues occur during processing of certificates.Copyright © 1998–2024 Apryse Group NV. All rights reserved.