Package eu.europa.esig.dss.pades
Class PAdESUtils
java.lang.Object
eu.europa.esig.dss.pades.PAdESUtils
Utils for dealing with PAdES
-
Field Summary
Modifier and TypeFieldDescriptionstatic final InMemoryResourcesHandlerBuilder
The default resources handler builder to be used across the code -
Method Summary
Modifier and TypeMethodDescriptionstatic SigFieldPermissions
extractPermissionsDictionary
(PdfDict wrapper) This method extractsSigFieldPermissions
(for instance /Lock dictionary) from a wrapping dictionarystatic List<PdfByteRangeDocument>
extractRevisions
(DSSDocument document) Parsesdocument
and extracts all revisions based on%%EOF
stringstatic DSSDocument
getOriginalPDF
(PAdESSignature padesSignature) Returns the original signed content for thepadesSignature
static DSSDocument
getOriginalPDF
(PdfCMSRevision pdfRevision) Returns the original signed content for thepdfRevision
static DSSDocument
getPreviousRevision
(ByteRange byteRange, Collection<PdfByteRangeDocument> revisions) This method returns the best previous revision fromrevisions
collection corresponding to thebyteRange
static DSSDocument
getRevisionContent
(DSSDocument dssDocument, ByteRange byteRange) Returns the complete revision content according to the provided byteRange ([0]-[3])static RevocationInfoArchival
getRevocationInfoArchival
(org.bouncycastle.asn1.ASN1Encodable encodable) ReturnsRevocationInfoArchival
from the given encodablestatic byte[]
getSignatureValue
(DSSDocument dssDocument, ByteRange byteRange) Gets the SignatureValue from thedssDocument
according to thebyteRange
Example: extracts bytes from 841 to 959.static List<PdfVriDict>
getVRIsWithName
(PdfDssDict pdfDssDict, String vriName) Returns a list of VRI dictionaries, corresponding to the given signature (VRI) SHA-1 name NOTE:vriName
can be null.static DSSResourcesHandler
This method initializes a newDSSResourcesHandler
objectstatic boolean
isPDFDocument
(DSSDocument document) Checks if the givenDSSDocument
represents a PDF documentstatic DSSDocument
replaceSignature
(DSSDocument toBeSignedDocument, byte[] cmsSignedData, DSSResourcesHandlerBuilder resourcesHandlerBuilder) This method replaces /Contents field value with a givencmsSignedData
binaries
-
Field Details
-
DEFAULT_RESOURCES_HANDLER_BUILDER
The default resources handler builder to be used across the code
-
-
Method Details
-
getOriginalPDF
Returns the original signed content for thepadesSignature
- Parameters:
padesSignature
-PAdESSignature
- Returns:
DSSDocument
-
getOriginalPDF
Returns the original signed content for thepdfRevision
- Parameters:
pdfRevision
-PdfRevision
- Returns:
DSSDocument
-
getRevisionContent
Returns the complete revision content according to the provided byteRange ([0]-[3])- Parameters:
dssDocument
-DSSDocument
to extract the content frombyteRange
-ByteRange
indicating the revision boundaries- Returns:
- revision binaries
-
getPreviousRevision
public static DSSDocument getPreviousRevision(ByteRange byteRange, Collection<PdfByteRangeDocument> revisions) This method returns the best previous revision fromrevisions
collection corresponding to thebyteRange
- Parameters:
byteRange
-ByteRange
of a signature to get previous revision forrevisions
- a collection ofPdfByteRangeDocument
revisions- Returns:
DSSDocument
previous revision content if found, empty document otherwise
-
getSignatureValue
Gets the SignatureValue from thedssDocument
according to thebyteRange
Example: extracts bytes from 841 to 959. [0, 840, 960, 1200]- Parameters:
dssDocument
-DSSDocument
to processbyteRange
-ByteRange
specifying the signatureValue- Returns:
- signatureValue binaries
-
replaceSignature
public static DSSDocument replaceSignature(DSSDocument toBeSignedDocument, byte[] cmsSignedData, DSSResourcesHandlerBuilder resourcesHandlerBuilder) This method replaces /Contents field value with a givencmsSignedData
binaries- Parameters:
toBeSignedDocument
-DSSDocument
representing a document to be signed with an empty signature value (Ex.:/Contents <00000 ... 000000>
)cmsSignedData
- byte array representing DER-encoded CMS Signed DataresourcesHandlerBuilder
-DSSResourcesHandlerBuilder
. Optional. If non is provided, a defaultInMemoryResourcesHandlerBuilder
will be used.- Returns:
DSSDocument
PDF document containing the inserted CMS signature
-
extractRevisions
Parsesdocument
and extracts all revisions based on%%EOF
string- Parameters:
document
-DSSDocument
PDF document to extract revisions from- Returns:
- a list of
PdfByteRangeDocument
s representing extracted revisions
-
getRevocationInfoArchival
public static RevocationInfoArchival getRevocationInfoArchival(org.bouncycastle.asn1.ASN1Encodable encodable) ReturnsRevocationInfoArchival
from the given encodable- Parameters:
encodable
- the encoded data to be parsed- Returns:
- an instance of RevocationValues or null if the parsing failed
-
isPDFDocument
Checks if the givenDSSDocument
represents a PDF document- Parameters:
document
-DSSDocument
to check- Returns:
- TRUE if the document is a PDF, FALSE otherwise
-
extractPermissionsDictionary
This method extractsSigFieldPermissions
(for instance /Lock dictionary) from a wrapping dictionary- Parameters:
wrapper
-PdfDict
wrapping the dictionary having permissions- Returns:
SigFieldPermissions
-
getVRIsWithName
Returns a list of VRI dictionaries, corresponding to the given signature (VRI) SHA-1 name NOTE:vriName
can be null. In this case all /VRI dictionaries are returned- Parameters:
pdfDssDict
-PdfDssDict
to extract /VRI dictionaries fromvriName
-String
name of the /VRI dictionary to retrieve (optional)- Returns:
- list of
PdfVriDict
s
-
initializeDSSResourcesHandler
This method initializes a newDSSResourcesHandler
object- Returns:
DSSResourcesHandler
-