Package eu.europa.esig.dss.pades
Class PAdESUtils
java.lang.Object
eu.europa.esig.dss.pades.PAdESUtils
Utils for dealing with PAdES
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefines a number of the first page in a documentstatic final InMemoryResourcesHandlerBuilderThe default resources handler builder to be used across the code -
Method Summary
Modifier and TypeMethodDescriptionstatic SigFieldPermissionsextractPermissionsDictionary(PdfDict wrapper) This method extractsSigFieldPermissions(for instance /Lock dictionary) from a wrapping dictionarystatic InMemoryDocumentgetOriginalPDF(PAdESSignature padesSignature) Returns the original signed content for thepadesSignaturestatic InMemoryDocumentgetOriginalPDF(PdfCMSRevision pdfRevision) Returns the original signed content for thepdfRevisionstatic byte[]getRevisionContent(DSSDocument dssDocument, ByteRange byteRange) Returns the revision content according to the provided byteRange ([0]-[3])static RevocationInfoArchivalgetRevocationInfoArchival(org.bouncycastle.asn1.ASN1Encodable encodable) ReturnsRevocationInfoArchivalfrom the given encodablestatic byte[]getSignedContentFromRevision(byte[] revisionBinaries, ByteRange byteRange) Returns a signed content according to the provided byteRange ([0]-[1] and [2]-[3]) from the extracted revisionstatic List<PdfVRIDict>getVRIsWithName(PdfDssDict pdfDssDict, String vriName) Returns a list of VRI dictionaries, corresponding to the given signature (VRI) SHA-1 name NOTE:vriNamecan be null.static DSSResourcesHandlerThis method initializes a newDSSResourcesHandlerobjectstatic booleanisPDFDocument(DSSDocument document) Checks if the givenDSSDocumentrepresents a PDF documentstatic DSSDocumentreplaceSignature(DSSDocument toBeSignedDocument, byte[] cmsSignedData, DSSResourcesHandlerBuilder resourcesHandlerBuilder) This method replaces /Contents field value with a givencmsSignedDatabinariesstatic InMemoryDocumentretrievePreviousPDFRevision(DSSDocument document, ByteRange byteRange) Retrieves the PDF document up to the previous PDF Revision, an empty document if such revision is not found
-
Field Details
-
DEFAULT_FIRST_PAGE
public static final int DEFAULT_FIRST_PAGEDefines a number of the first page in a document- See Also:
-
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:
InMemoryDocument
-
getOriginalPDF
Returns the original signed content for thepdfRevision- Parameters:
pdfRevision-PdfRevision- Returns:
InMemoryDocument
-
retrievePreviousPDFRevision
public static InMemoryDocument retrievePreviousPDFRevision(DSSDocument document, ByteRange byteRange) Retrieves the PDF document up to the previous PDF Revision, an empty document if such revision is not found- Parameters:
document-DSSDocumentthe original documentbyteRange-ByteRangerepresenting the signed revision, to get the previous covered PDF for- Returns:
InMemoryDocumentthe PDF document up to the signed revision
-
getRevisionContent
public static byte[] getRevisionContent(DSSDocument dssDocument, ByteRange byteRange) throws IOException Returns the revision content according to the provided byteRange ([0]-[3])- Parameters:
dssDocument-DSSDocumentto extract the content frombyteRange-ByteRangeindicating the revision boundaries- Returns:
- revision binaries
- Throws:
IOException- in case if an exception occurs
-
getSignedContentFromRevision
public static byte[] getSignedContentFromRevision(byte[] revisionBinaries, ByteRange byteRange) throws IOException Returns a signed content according to the provided byteRange ([0]-[1] and [2]-[3]) from the extracted revision- Parameters:
revisionBinaries- a byte array representing an extracted revision contentbyteRange-ByteRangeindicating which content range should be extracted- Returns:
- extracted signed data
- Throws:
IOException- in case if an exception occurs
-
replaceSignature
public static DSSDocument replaceSignature(DSSDocument toBeSignedDocument, byte[] cmsSignedData, DSSResourcesHandlerBuilder resourcesHandlerBuilder) This method replaces /Contents field value with a givencmsSignedDatabinaries- Parameters:
toBeSignedDocument-DSSDocumentrepresenting 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 defaultInMemoryResourcesHandlerBuilderwill be used.- Returns:
DSSDocumentPDF document containing the inserted CMS signature
-
getRevocationInfoArchival
public static RevocationInfoArchival getRevocationInfoArchival(org.bouncycastle.asn1.ASN1Encodable encodable) ReturnsRevocationInfoArchivalfrom 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 givenDSSDocumentrepresents a PDF document- Parameters:
document-DSSDocumentto 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-PdfDictwrapping the dictionary having permissions- Returns:
SigFieldPermissions
-
getVRIsWithName
Returns a list of VRI dictionaries, corresponding to the given signature (VRI) SHA-1 name NOTE:vriNamecan be null. In this case all /VRI dictionaries are returned- Parameters:
pdfDssDict-PdfDssDictto extract /VRI dictionaries fromvriName-Stringname of the /VRI dictionary to retrieve (optional)- Returns:
- list of
PdfVRIDicts
-
initializeDSSResourcesHandler
This method initializes a newDSSResourcesHandlerobject- Returns:
DSSResourcesHandler
-