Package com.itextpdf.signatures
Class PdfSignature
Represents the signature dictionary.
- Author:
- Paulo Soares
-
Constructor Summary
ConstructorDescriptionCreates new PdfSignature.PdfSignature
(PdfDictionary sigDictionary) PdfSignature
(PdfName filter, PdfName subFilter) Creates new PdfSignature. -
Method Summary
Modifier and TypeMethodDescriptionGets the /ByteRange.getCert()
Gets the /Cert entry value of this signature.Gets the /Cert entry value of this signature.Gets the /Contents entry value.getDate()
Gets the /M value.Gets the /Location entry value.getName()
gets the /Name of the person signing the document.A name that describes the encoding of the signature value and key information in the signature dictionary.getType()
The type of PDF object that the wrapped dictionary describes; if present, shall bePdfName.Sig
for a signature dictionary orPdfName.DocTimeStamp
for a timestamp signature dictionary.protected boolean
Defines if the object behind this wrapper must be an indirect object in the resultant document.void
setByteRange
(int[] range) Sets the /ByteRange.void
setCert
(byte[] cert) Sets the /Cert value of this signature.void
setContact
(String contactInfo) Sets the /ContactInfo value.void
setContents
(byte[] contents) Sets the /Contents value to the specified byte[].void
Sets the /M value.void
setLocation
(String location) Sets the /Location value.void
Sets the /Name of the person signing the document.void
Sets the /Reason value.void
setSignatureCreator
(String signatureCreator) Sets the signature creator name in thePdfSignatureBuildProperties
dictionary.Methods inherited from class com.itextpdf.kernel.pdf.PdfObjectWrapper
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, flush, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
-
Constructor Details
-
PdfSignature
public PdfSignature()Creates new PdfSignature. -
PdfSignature
Creates new PdfSignature.- Parameters:
-
filter
- PdfName of the signature handler to use when validating this signature -
subFilter
- PdfName that describes the encoding of the signature
-
PdfSignature
-
-
Method Details
-
getSubFilter
A name that describes the encoding of the signature value and key information in the signature dictionary.- Returns:
-
a
PdfName
which usually has a value eitherPdfName.Adbe_pkcs7_detached
orPdfName.ETSI_CAdES_DETACHED
.
-
getType
The type of PDF object that the wrapped dictionary describes; if present, shall bePdfName.Sig
for a signature dictionary orPdfName.DocTimeStamp
for a timestamp signature dictionary. Shall be not null if it's value isPdfName.DocTimeStamp
. The default value is:PdfName.Sig
.- Returns:
-
a
PdfName
that identifies type of the wrapped dictionary, returns null if it is not explicitly specified.
-
setByteRange
public void setByteRange(int[] range) Sets the /ByteRange.- Parameters:
-
range
- an array of pairs of integers that specifies the byte range used in the digest calculation. A pair consists of the starting byte offset and the length
-
getByteRange
Gets the /ByteRange.- Returns:
- an array of pairs of integers that specifies the byte range used in the digest calculation. A pair consists of the starting byte offset and the length.
-
setContents
public void setContents(byte[] contents) Sets the /Contents value to the specified byte[].- Parameters:
-
contents
- a byte[] representing the digest
-
getContents
Gets the /Contents entry value. See ISO 32000-1 12.8.1, Table 252 – Entries in a signature dictionary.- Returns:
- the signature content
-
setCert
public void setCert(byte[] cert) Sets the /Cert value of this signature.- Parameters:
-
cert
- the byte[] representing the certificate chain
-
getCert
Gets the /Cert entry value of this signature. See ISO 32000-1 12.8.1, Table 252 – Entries in a signature dictionary.- Returns:
- the signature cert
-
getCertObject
Gets the /Cert entry value of this signature. /Cert entry required when SubFilter is adbe.x509.rsa_sha1. May be array or byte string.- Returns:
- the signature cert value
-
setName
Sets the /Name of the person signing the document.- Parameters:
-
name
- name of the person signing the document
-
getName
gets the /Name of the person signing the document.- Returns:
- name of the person signing the document.
-
setDate
Sets the /M value. Should only be used if the time of signing is not available in the signature.- Parameters:
-
date
- time of signing
-
getDate
Gets the /M value. Should only be used if the time of signing is not available in the signature.- Returns:
-
PdfString
which denotes time of signing.
-
setLocation
Sets the /Location value.- Parameters:
-
location
- physical location of signing
-
getLocation
Gets the /Location entry value.- Returns:
- physical location of signing.
-
setReason
Sets the /Reason value.- Parameters:
-
reason
- reason for signing
-
getReason
-
setSignatureCreator
Sets the signature creator name in thePdfSignatureBuildProperties
dictionary.- Parameters:
-
signatureCreator
- name of the signature creator
-
setContact
Sets the /ContactInfo value.- Parameters:
-
contactInfo
- information to contact the person who signed this document
-
put
-
isWrappedObjectMustBeIndirect
protected boolean isWrappedObjectMustBeIndirect()Description copied from class:PdfObjectWrapper
Defines if the object behind this wrapper must be an indirect object in the resultant document.
If this method returns true it doesn't necessarily mean that object must be in the indirect state at any moment, but rather defines that when the object will be written to the document it will be transformed into indirect object if it's not indirect yet.
Return value of this method shouldn't depend on any logic, it should return always true or false.- Specified by:
-
isWrappedObjectMustBeIndirect
in classPdfObjectWrapper<PdfDictionary>
- Returns:
- true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
-