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_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 DSSDocument getOriginalPDF(PAdESSignature padesSignature)
      Returns the original signed content for the padesSignature
      Parameters:
      padesSignature - PAdESSignature
      Returns:
      DSSDocument
    • getOriginalPDF

      public static DSSDocument getOriginalPDF(PdfCMSRevision pdfRevision)
      Returns the original signed content for the pdfRevision
      Parameters:
      pdfRevision - PdfRevision
      Returns:
      DSSDocument
    • getRevisionContent

      public static DSSDocument getRevisionContent(DSSDocument dssDocument, ByteRange byteRange)
      Returns the complete 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
    • getPreviousRevision

      public static DSSDocument getPreviousRevision(ByteRange byteRange, Collection<PdfByteRangeDocument> revisions)
      This method returns the best previous revision from revisions collection corresponding to the byteRange
      Parameters:
      byteRange - ByteRange of a signature to get previous revision for
      revisions - a collection of PdfByteRangeDocument revisions
      Returns:
      DSSDocument previous revision content if found, empty document otherwise
    • getSignatureValue

      public static byte[] getSignatureValue(DSSDocument dssDocument, ByteRange byteRange)
      Gets the SignatureValue from the dssDocument according to the byteRange Example: extracts bytes from 841 to 959. [0, 840, 960, 1200]
      Parameters:
      dssDocument - DSSDocument to process
      byteRange - 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 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
    • extractRevisions

      public static List<PdfByteRangeDocument> extractRevisions(DSSDocument document)
      Parses document and extracts all revisions based on %%EOF string
      Parameters:
      document - DSSDocument PDF document to extract revisions from
      Returns:
      a list of PdfByteRangeDocuments representing extracted revisions
    • 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