Package com.itextpdf.signatures
Class PdfSignature
Represents the signature dictionary.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates new PdfSignature.PdfSignature(PdfDictionary sigDictionary) Creates newPdfSignatureinstance from the providedPdfDictionary.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.Gets the /Reason value.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.Sigfor a signature dictionary orPdfName.DocTimeStampfor a timestamp signature dictionary.protected booleanDefines if the object behind this wrapper must be an indirect object in the resultant document.Add new key-value pair to the signature dictionary.voidsetByteRange(int[] range) Sets the /ByteRange.voidsetCert(byte[] cert) Sets the /Cert value of this signature.voidsetContact(String contactInfo) Sets the /ContactInfo value.voidsetContents(byte[] contents) Sets the /Contents value to the specified byte[].voidSets the /M value.voidsetLocation(String location) Sets the /Location value.voidSets the /Name of the person signing the document.voidSets the /Reason value.voidsetSignatureCreator(String signatureCreator) Sets the signature creator name in thePdfSignatureBuildPropertiesdictionary.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
Creates newPdfSignatureinstance from the providedPdfDictionary.- Parameters:
-
sigDictionary-PdfDictionaryto create newPdfSignatureinstance from
-
-
Method Details
-
getSubFilter
A name that describes the encoding of the signature value and key information in the signature dictionary.- Returns:
-
a
PdfNamewhich usually has a value eitherPdfName.Adbe_pkcs7_detachedorPdfName.ETSI_CAdES_DETACHED.
-
getType
The type of PDF object that the wrapped dictionary describes; if present, shall bePdfName.Sigfor a signature dictionary orPdfName.DocTimeStampfor a timestamp signature dictionary. Shall be not null if it's value isPdfName.DocTimeStamp. The default value is:PdfName.Sig.- Returns:
-
a
PdfNamethat 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:
-
PdfStringwhich 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
Gets the /Reason value.- Returns:
- reason for signing
-
setSignatureCreator
Sets the signature creator name in thePdfSignatureBuildPropertiesdictionary.- Parameters:
-
signatureCreator- name of the signature creator
-
setContact
Sets the /ContactInfo value.- Parameters:
-
contactInfo- information to contact the person who signed this document
-
put
Add new key-value pair to the signature dictionary.- Parameters:
-
key-PdfNameto be added as a key -
value-PdfObjectto be added as a value - Returns:
-
the same
PdfSignatureinstance
-
isWrappedObjectMustBeIndirect
protected boolean isWrappedObjectMustBeIndirect()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:
-
isWrappedObjectMustBeIndirectin classPdfObjectWrapper<PdfDictionary> - Returns:
- true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
-