public abstract class Signature extends Object
An abstract class which represents signature object in the pdf document. Signatures are fields with values of signature objects, the last contain data which is used to verify the document validity.
Constructor and Description |
---|
Signature()
Initializes new instance of the
Signature class. |
Signature(InputStream pfx,
String password)
Initializes new instance of the
Signature class. |
Signature(String pfx,
String password)
Initializes new instance of the
Signature class. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Destructor which closes temporary streams (if necessary).
|
String |
getAuthority()
The name of the person or authority signing the document.
|
int[] |
getByteRange()
Get array of pairs of integers (starting byte offset, length in bytes) that shall describe
the exact byte range for the digest calculation.
|
String |
getContactInfo()
Get information provided by the signer to enable a recipient to contact the signer to verify
the signature, e.g.
|
SignatureCustomAppearance |
getCustomAppearance()
Gets/sets the custom appearance.
|
CustomSign |
getCustomSign()
The delegate for custom hash and sign the document (Beta).
|
SignHash |
getCustomSignHash()
The delegate for custom sign the document hash (Beta).
|
Date |
getDate()
Gets the time of signing.
|
int |
getDefaultSignatureLength()
Gets or sets the default length for the signature data in bytes.
|
com.aspose.ms.System.IO.Stream |
getImageInternal()
Gets image stream.
|
String |
getLocation()
Gets the CPU host name or physical location of the signing.
|
OcspSettings |
getOcspSettings()
Gets/sets ocsp settings.
|
String |
getReason()
Gets the reason for the signing, such as (I agreed!, Pip B.).
|
com.aspose.pdf.engine.security.SignatureAlgorithmInfo |
getSignatureAlgorithmInfo()
Retrieves information about the signature algorithm used in the signature.
|
List<com.aspose.pdf.engine.security.impl.signatures.SignatureReference> |
getSignatureReferences()
get Signature References
|
TimestampSettings |
getTimestampSettings()
Gets timestamp settings.
|
boolean |
getUseLtv()
Gets/sets ltv validation flag.
|
boolean |
isAvoidEstimatingSignatureLength()
Gets and sets an option means whether to avoid estimating the length of a signature.
|
boolean |
isShowProperties()
Force to show/hide signature properties.
|
void |
setAuthority(String value)
Sets the name of the person or authority signing the document.
|
void |
setAvoidEstimatingSignatureLength(boolean value)
Gets and sets an option means whether to avoid estimating the length of a signature.
|
void |
setContactInfo(String value)
Set information provided by the signer to enable a recipient to contact the signer to verify
the signature, e.g.
|
void |
setCustomAppearance(SignatureCustomAppearance value)
Gets/sets the custom appearance.
|
void |
setCustomSign(CustomSign value)
The delegate for custom hash and sign the document (Beta).
|
void |
setCustomSignHash(SignHash value)
The delegate for custom sign the document hash (Beta).
|
void |
setDate(Date value)
Set the time of signing.
|
void |
setDefaultSignatureLength(int value)
Gets or sets the default length for the signature data in bytes.
|
void |
setImage(InputStream _signatureAppearanceStream)
Sets image stream.
|
void |
setImageInternal(com.aspose.ms.System.IO.Stream value) |
void |
setLocation(String value)
Sets the CPU host name or physical location of the signing.
|
void |
setOcspSettings(OcspSettings value)
Gets/sets ocsp settings.
|
void |
setReason(String value)
Sets the reason for the signing, such as (I agreed!, Pip B.).
|
void |
setShowProperties(boolean value)
Force to show/hide signature properties.
|
void |
setTimestampSettings(TimestampSettings value)
Sets timestamp settings.
|
void |
setUseLtv(boolean value)
Gets/sets ltv validation flag.
|
boolean |
verify()
Verify the document regarding this signature and return true if document is valid or
otherwise false.
|
boolean |
verify(com.aspose.pdf.engine.certificatevalidation.ValidationOptions options,
com.aspose.pdf.engine.certificatevalidation.ValidationResult[] validationResult)
Verify the document regarding this signature and return true if document is valid
or otherwise false.
|
boolean |
verify(com.aspose.ms.System.Security.Cryptography.X509Certificates.X509Certificate2 publicKeyCertificate,
com.aspose.pdf.engine.certificatevalidation.ValidationOptions options,
com.aspose.pdf.engine.certificatevalidation.ValidationResult[] validationResult)
Verify the document regarding this signature and return true if document is valid
or otherwise false.
|
public Signature()
Initializes new instance of the Signature
class.
public Signature(String pfx, String password)
Initializes new instance of the Signature
class.
pfx
- Pfx file which contains certificate for signing.password
- Password to get access to the private key in the certificate.public Signature(InputStream pfx, String password)
Initializes new instance of the Signature
class.
pfx
- Stream with certificate data organized as pfx.password
- Password to get access to the private key in the certificate.public final SignatureCustomAppearance getCustomAppearance()
Gets/sets the custom appearance.
public final void setCustomAppearance(SignatureCustomAppearance value)
Gets/sets the custom appearance.
value
- SignatureCustomAppearance instancepublic final String getAuthority()
The name of the person or authority signing the document.
public void setAuthority(String value)
Sets the name of the person or authority signing the document.
value
- String valuepublic Date getDate()
Gets the time of signing.
public void setDate(Date value)
Set the time of signing.
value
- Date objectpublic String getLocation()
Gets the CPU host name or physical location of the signing.
public void setLocation(String value)
Sets the CPU host name or physical location of the signing.
value
- String valuepublic String getReason()
Gets the reason for the signing, such as (I agreed!, Pip B.).
public void setReason(String value)
Sets the reason for the signing, such as (I agreed!, Pip B.).
value
- String valuepublic String getContactInfo()
Get information provided by the signer to enable a recipient to contact the signer to verify the signature, e.g. a phone number.
public void setContactInfo(String value)
Set information provided by the signer to enable a recipient to contact the signer to verify the signature, e.g. a phone number.
value
- String valuepublic int[] getByteRange()
Get array of pairs of integers (starting byte offset, length in bytes) that shall describe the exact byte range for the digest calculation.
public TimestampSettings getTimestampSettings()
public void setTimestampSettings(TimestampSettings value)
value
- TimestampSettingspublic OcspSettings getOcspSettings()
Gets/sets ocsp settings.
public void setOcspSettings(OcspSettings value)
Gets/sets ocsp settings.
value
- OcspSettings instancepublic final boolean getUseLtv()
Gets/sets ltv validation flag.
public final void setUseLtv(boolean value)
Gets/sets ltv validation flag.
value
- boolean valuepublic com.aspose.ms.System.IO.Stream getImageInternal()
Gets image stream.
For internal only usagepublic void setImage(InputStream _signatureAppearanceStream)
Sets image stream.
_signatureAppearanceStream
- Steam objectpublic void setImageInternal(com.aspose.ms.System.IO.Stream value)
public List<com.aspose.pdf.engine.security.impl.signatures.SignatureReference> getSignatureReferences()
java.util.List<SignatureReference> object
public final boolean isAvoidEstimatingSignatureLength()
Gets and sets an option means whether to avoid estimating the length of a signature.
Avoids to estimate signature length before a signing document.
Used for signing via CustomSignHash
(#getCustomSignHash
/#setCustomSignHash(SignHash)
) an via ExternalSignature
.
If CustomSignHash
(#getCustomSignHash
/#setCustomSignHash(SignHash)
)
returns a signature longer than DefaultSignatureLength
(#getDefaultSignatureLength
/#setDefaultSignatureLength(int)
),
then SignatureLengthMismatchException
will be thrown.
The default value is false
.
public final void setAvoidEstimatingSignatureLength(boolean value)
Gets and sets an option means whether to avoid estimating the length of a signature.
Avoids to estimate signature length before a signing document.
Used for signing via CustomSignHash
(#getCustomSignHash
/#setCustomSignHash(SignHash)
)
an via ExternalSignature
.
If CustomSignHash
(#getCustomSignHash
/#setCustomSignHash(SignHash)
)
returns a signature longer than DefaultSignatureLength
(#getDefaultSignatureLength
/#setDefaultSignatureLength(int)
),
then SignatureLengthMismatchException
will be thrown.
The default value is false
.
value
- boolean valuepublic final int getDefaultSignatureLength()
Gets or sets the default length for the signature data in bytes.
This is an estimation of the length of the signature in bytes.
Used for signing via CustomSignHash
(#getCustomSignHash
/#setCustomSignHash(SignHash)
)
if the AvoidEstimatingSignatureLength
(#getAvoidEstimatingSignatureLength
/#setAvoidEstimatingSignatureLength(boolean)
) parameter is set.
The default value is 3000.
public final void setDefaultSignatureLength(int value)
Gets or sets the default length for the signature data in bytes.
This is an estimation of the length of the signature in bytes. Used for signing viaCustomSignHash
(#getCustomSignHash
/#setCustomSignHash(SignHash)
)
if the AvoidEstimatingSignatureLength
(#getAvoidEstimatingSignatureLength
/#setAvoidEstimatingSignatureLength(boolean)
) parameter is set.
The default value is 3000.value
- int valuepublic final SignHash getCustomSignHash()
The delegate for custom sign the document hash (Beta).
The algorithm with which you sign the hash in the delegate must match the type of the certificate's private key.
public final void setCustomSignHash(SignHash value)
The delegate for custom sign the document hash (Beta).
The algorithm with which you sign the hash in the delegate must match the type of the certificate's private key.
value
- SignHash instancepublic final CustomSign getCustomSign()
The delegate for custom hash and sign the document (Beta).
The algorithm with which you hash and sign the document in the delegate must match the type of the certificate's private key.
public final void setCustomSign(CustomSign value)
The delegate for custom hash and sign the document (Beta).
The algorithm with which you hash and sign the document in the delegate must match the type of the certificate's private key.
value
- CustomSign instancepublic final com.aspose.pdf.engine.security.SignatureAlgorithmInfo getSignatureAlgorithmInfo()
Retrieves information about the signature algorithm used in the signature.
public boolean verify()
Verify the document regarding this signature and return true if document is valid or otherwise false.
public final boolean verify(com.aspose.pdf.engine.certificatevalidation.ValidationOptions options, com.aspose.pdf.engine.certificatevalidation.ValidationResult[] validationResult)
Verify the document regarding this signature and return true if document is valid or otherwise false.
options
- The verification options.validationResult
- The certificate validation result.public final boolean verify(com.aspose.ms.System.Security.Cryptography.X509Certificates.X509Certificate2 publicKeyCertificate, com.aspose.pdf.engine.certificatevalidation.ValidationOptions options, com.aspose.pdf.engine.certificatevalidation.ValidationResult[] validationResult)
Verify the document regarding this signature and return true if document is valid or otherwise false. Verification is performed using the external public key certificate.
publicKeyCertificate
- The public key certificate for verification.options
- The verification options.validationResult
- The certificate validation result.public boolean isShowProperties()
Force to show/hide signature properties. In case ShowProperties is true signature field has predefined format of appearance (strings to represent): ------------------------------------------- Digitally signed by {certificate subject} Date: {signature.Date} Reason: {signature.Reason} Location: {signature.Location} ------------------------------------------- where {X} is placeholder for X value. Also signature can have image, in this case listed strings are placed over image. ShowProperties is true by default.
public void setShowProperties(boolean value)
Force to show/hide signature properties. In case ShowProperties is true signature field has predefined format of appearance (strings to represent): ------------------------------------------- Digitally signed by {certificate subject} Date: {signature.Date} Reason: {signature.Reason} Location: {signature.Location} ------------------------------------------- where {X} is placeholder for X value. Also signature can have image, in this case listed strings are placed over image. ShowProperties is true by default.
value
- boolean valuepublic void close()
Destructor which closes temporary streams (if necessary).
Copyright © 2025 Aspose. All Rights Reserved.