public class SignatureUtil extends Object
Constructor and Description |
---|
SignatureUtil(PdfDocument document)
Creates a SignatureUtil instance.
|
Modifier and Type | Method and Description |
---|---|
static long[] |
asLongArray(PdfArray pdfArray)
Deprecated.
Will be removed in 7.2. Use
PdfArray.toLongArray() instead
|
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.
|
PdfPKCS7 |
verifySignature(String name)
Deprecated.
This method is deprecated and will be removed in future versions. Please use
readSignatureData(String) instead.
|
PdfPKCS7 |
verifySignature(String name, String provider)
Deprecated.
This method is deprecated and will be removed in future versions. Please use
readSignatureData(String, String) instead.
|
public SignatureUtil(PdfDocument document)
document
- PdfDocument to be inspected
@Deprecated public static long[] asLongArray(PdfArray pdfArray)
PdfArray.toLongArray()
instead
PdfArray
to an array of longs
pdfArray
- PdfArray to be converted
@Deprecated public PdfPKCS7 verifySignature(String name)
readSignatureData(String)
instead.
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 check that given signature covers the current PdfDocument revision please use signatureCoversWholeDocument(String)
method.
name
- the signature field name
PdfPKCS7
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.
@Deprecated public PdfPKCS7 verifySignature(String name, String provider)
readSignatureData(String, String)
instead.
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 check that given signature covers the current PdfDocument revision please use signatureCoversWholeDocument(String)
method.
name
- the signature field name
provider
- the security provider or null for the default provider
PdfPKCS7
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)
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 name
PdfPKCS7
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 name
securityProvider
- the security provider or null for the default provider
PdfPKCS7
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 name
null
if the field is not a signature
public List<String> getSignatureNames()
public List<String> getBlankSignatureNames()
public int getTotalRevisions()
public int getRevision(String field)
public InputStream extractRevision(String field)
field
- the signature field name
public 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 name
public boolean doesSignatureFieldExist(String name)
name
- name of the field
Copyright © 1998–2023 iText Group NV. All rights reserved.