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) |
PdfSignature |
getSignature(String name) |
PdfDictionary |
getSignatureDictionary(String name)
Gets the signature dictionary, the one keyed by /V.
|
List<String> |
getSignatureNames()
Gets the field names that have signatures and are signed.
|
int |
getTotalRevisions() |
String |
getTranslatedFieldName(String name) |
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)
public PdfDictionary getSignatureDictionary(String name)
name - the field namenull if the field is not
a signaturepublic List<String> getSignatureNames()
public List<String> getBlankSignatureNames()
public int getTotalRevisions()
public int getRevision(String field)
public 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–2024 Apryse Group NV. All rights reserved.