Class PAdESUtils

java.lang.Object
eu.europa.esig.dss.pades.PAdESUtils

public final class PAdESUtils extends Object
Utils for dealing with PAdES
  • Field Details

    • DEFAULT_FIRST_PAGE

      public static final int DEFAULT_FIRST_PAGE
      Defines a number of the first page in a document
      See Also:
    • DEFAULT_RESOURCES_HANDLER_BUILDER

      public static final InMemoryResourcesHandlerBuilder DEFAULT_RESOURCES_HANDLER_BUILDER
      The default resources handler builder to be used across the code
  • Method Details

    • getOriginalPDF

      public static InMemoryDocument getOriginalPDF(PAdESSignature padesSignature)
      Returns the original signed content for the padesSignature
      Parameters:
      padesSignature - PAdESSignature
      Returns:
      InMemoryDocument
    • getOriginalPDF

      public static InMemoryDocument getOriginalPDF(PdfCMSRevision pdfRevision)
      Returns the original signed content for the pdfRevision
      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 - DSSDocument the original document
      byteRange - ByteRange representing the signed revision, to get the previous covered PDF for
      Returns:
      InMemoryDocument the 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 - DSSDocument to extract the content from
      byteRange - ByteRange indicating 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 content
      byteRange - ByteRange indicating 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 given cmsSignedData 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 Data
      resourcesHandlerBuilder - DSSResourcesHandlerBuilder. Optional. If non is provided, a default InMemoryResourcesHandlerBuilder will be used.
      Returns:
      DSSDocument PDF document containing the inserted CMS signature
    • getRevocationInfoArchival

      public static RevocationInfoArchival getRevocationInfoArchival(org.bouncycastle.asn1.ASN1Encodable encodable)
      Returns RevocationInfoArchival from the given encodable
      Parameters:
      encodable - the encoded data to be parsed
      Returns:
      an instance of RevocationValues or null if the parsing failed
    • isPDFDocument

      public static boolean isPDFDocument(DSSDocument document)
      Checks if the given DSSDocument represents a PDF document
      Parameters:
      document - DSSDocument to check
      Returns:
      TRUE if the document is a PDF, FALSE otherwise
    • extractPermissionsDictionary

      public static SigFieldPermissions extractPermissionsDictionary(PdfDict wrapper)
      This method extracts SigFieldPermissions (for instance /Lock dictionary) from a wrapping dictionary
      Parameters:
      wrapper - PdfDict wrapping the dictionary having permissions
      Returns:
      SigFieldPermissions
    • getVRIsWithName

      public 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. In this case all /VRI dictionaries are returned
      Parameters:
      pdfDssDict - PdfDssDict to extract /VRI dictionaries from
      vriName - String name of the /VRI dictionary to retrieve (optional)
      Returns:
      list of PdfVRIDicts
    • initializeDSSResourcesHandler

      public static DSSResourcesHandler initializeDSSResourcesHandler()
      This method initializes a new DSSResourcesHandler object
      Returns:
      DSSResourcesHandler