public class SignatureUtil extends Object
| Constructor and Description |
|---|
SignatureUtil(PdfDocument document)
Creates a SignatureUtil instance.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
doesSignatureFieldExist(String name)
Checks whether a name exists as a signature field or not.
|
InputStream |
extractRevision(String field)
Extracts a revision from the document.
|
List<String> |
getBlankSignatureNames()
Gets the field names that have blank signatures.
|
int |
getRevision(String field)
Get signed document revision number, which corresponds to the provided signature name.
|
PdfSignature |
getSignature(String name)
Get
PdfSignature dictionary based on the provided name. |
PdfDictionary |
getSignatureDictionary(String name)
Gets the signature dictionary, the one keyed by /V.
|
PdfDictionary |
getSignatureFormFieldDictionary(String name) |
List<String> |
getSignatureNames()
Gets the field names that have signatures and are signed.
|
int |
getTotalRevisions()
Get the amount of signed document revisions.
|
String |
getTranslatedFieldName(String name)
Get field name, translated using XFA, if any present in the document.
|
PdfPKCS7 |
readSignatureData(String signatureFieldName)
Prepares an
PdfPKCS7 instance for the given signature. |
PdfPKCS7 |
readSignatureData(String signatureFieldName,
String securityProvider)
Prepares an
PdfPKCS7 instance for the given signature. |
boolean |
signatureCoversWholeDocument(String name)
Checks if the signature covers the entire document (except for signature's Contents) or just a part of it.
|
public SignatureUtil(PdfDocument document)
document - PdfDocument to be inspectedpublic PdfPKCS7 readSignatureData(String signatureFieldName)
PdfPKCS7 instance for the given signature.
This method handles signature parsing and might throw an exception if
signature is malformed.
The returned PdfPKCS7 can be used to fetch additional info about the signature
and also to perform integrity check of data signed by the given signature field.
In order to validate the signature it is required to check if it covers the entire file,
otherwise one cannot be sure that signature in question indeed signs the data
that constitutes current PdfDocument with all its contents.
In order to check that given signature covers the current PdfDocument please
use signatureCoversWholeDocument(String) method.
signatureFieldName - the signature field namePdfPKCS7 instance which can be used to fetch additional info about the signature
and also to perform integrity check of data signed by the given signature field.public PdfPKCS7 readSignatureData(String signatureFieldName, String securityProvider)
PdfPKCS7 instance for the given signature.
This method handles signature parsing and might throw an exception if
signature is malformed.
The returned PdfPKCS7 can be used to fetch additional info about the signature
and also to perform integrity check of data signed by the given signature field.
Prepared PdfPKCS7 instance calculates digest based on signature's /ByteRange entry.
In order to check that /ByteRange is properly defined and given signature indeed covers the current PDF document
revision please use signatureCoversWholeDocument(String) method.
signatureFieldName - the signature field namesecurityProvider - the security provider or null for the default providerPdfPKCS7 instance which can be used to fetch additional info about the signature
and also to perform integrity check of data signed by the given signature field.public PdfSignature getSignature(String name)
PdfSignature dictionary based on the provided name.name - signature namePdfSignature instance corresponding to the provided name. null otherwisepublic PdfDictionary getSignatureDictionary(String name)
name - the field namenull if the field is not
a signaturepublic PdfDictionary getSignatureFormFieldDictionary(String name)
public List<String> getSignatureNames()
public List<String> getBlankSignatureNames()
public int getTotalRevisions()
int amount of signed document revisionspublic int getRevision(String field)
field - signature nameint revision numberpublic String getTranslatedFieldName(String name)
name - field name to be translatedpublic InputStream extractRevision(String field)
field - the signature field namepublic boolean signatureCoversWholeDocument(String name)
If this method does not return true it means that signature in question does not cover the entire
contents of current PdfDocument. Such signatures cannot be considered as verifying the PDF document,
because content that is not covered by signature might have been modified since the signature creation.
name - the signature field namepublic boolean doesSignatureFieldExist(String name)
name - name of the fieldCopyright © 1998–2025 Apryse Group NV. All rights reserved.