Class PAdESUtils

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

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

    Fields
    Modifier and Type
    Field
    Description
    static final eu.europa.esig.dss.signature.resources.InMemoryResourcesHandlerBuilder
    The default resources handler builder to be used across the code
  • Method Summary

    Modifier and Type
    Method
    Description
    This method extracts SigFieldPermissions (for instance /Lock dictionary) from a wrapping dictionary
    extractRevisions(eu.europa.esig.dss.model.DSSDocument document)
    Parses document and extracts all revisions based on %%EOF string
    static eu.europa.esig.dss.model.DSSDocument
    Returns the original signed content for the padesSignature
    static eu.europa.esig.dss.model.DSSDocument
    Returns the original signed content for the pdfRevision
    static eu.europa.esig.dss.model.DSSDocument
    This method returns the best previous revision from revisions collection corresponding to the byteRange
    static eu.europa.esig.dss.model.DSSDocument
    getRevisionContent(eu.europa.esig.dss.model.DSSDocument dssDocument, ByteRange byteRange)
    Returns the complete revision content according to the provided byteRange ([0]-[3])
    getRevocationInfoArchival(org.bouncycastle.asn1.ASN1Encodable encodable)
    Returns RevocationInfoArchival from the given encodable
    static byte[]
    getSignatureValue(eu.europa.esig.dss.model.DSSDocument dssDocument, ByteRange byteRange)
    Gets the SignatureValue from the dssDocument according to the byteRange Example: extracts bytes from 841 to 959.
    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 eu.europa.esig.dss.signature.resources.DSSResourcesHandler
    This method initializes a new DSSResourcesHandler object
    static boolean
    isPDFDocument(eu.europa.esig.dss.model.DSSDocument document)
    Checks if the given DSSDocument represents a PDF document
    static eu.europa.esig.dss.model.DSSDocument
    replaceSignature(eu.europa.esig.dss.model.DSSDocument toBeSignedDocument, byte[] cmsSignedData, eu.europa.esig.dss.signature.resources.DSSResourcesHandlerBuilder resourcesHandlerBuilder)
    This method replaces /Contents field value with a given cmsSignedData binaries

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_RESOURCES_HANDLER_BUILDER

      public static final eu.europa.esig.dss.signature.resources.InMemoryResourcesHandlerBuilder DEFAULT_RESOURCES_HANDLER_BUILDER
      The default resources handler builder to be used across the code
  • Method Details

    • getOriginalPDF

      public static eu.europa.esig.dss.model.DSSDocument getOriginalPDF(PAdESSignature padesSignature)
      Returns the original signed content for the padesSignature
      Parameters:
      padesSignature - PAdESSignature
      Returns:
      DSSDocument
    • getOriginalPDF

      public static eu.europa.esig.dss.model.DSSDocument getOriginalPDF(PdfCMSRevision pdfRevision)
      Returns the original signed content for the pdfRevision
      Parameters:
      pdfRevision - PdfRevision
      Returns:
      DSSDocument
    • getRevisionContent

      public static eu.europa.esig.dss.model.DSSDocument getRevisionContent(eu.europa.esig.dss.model.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 eu.europa.esig.dss.model.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(eu.europa.esig.dss.model.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 eu.europa.esig.dss.model.DSSDocument replaceSignature(eu.europa.esig.dss.model.DSSDocument toBeSignedDocument, byte[] cmsSignedData, eu.europa.esig.dss.signature.resources.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(eu.europa.esig.dss.model.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(eu.europa.esig.dss.model.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 eu.europa.esig.dss.signature.resources.DSSResourcesHandler initializeDSSResourcesHandler()
      This method initializes a new DSSResourcesHandler object
      Returns:
      DSSResourcesHandler