java.lang.Object
es.juntadeandalucia.afirma.client.util.signatureFormat.PadesUtils

public final class PadesUtils extends Object

Class .

Project:

Horizontal platform of validation services of multiPKI certificates and electronic signature.

Version:
1.0, 11/03/2011.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Constant attribute that represents the string to identify the value for the key SubFilter of the signature dictionary for a PAdES Enhanced signature.
    static final String
    Constant attribute that represents the string to identify the value for the key SubFilter of a Document Time-stamp dictionary.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    equalsHash(com.itextpdf.text.pdf.PdfArray pdfArrayByteRange, MessageDigest messageDigestSignature, byte[] pdfDocument, byte[] hashSignature)
    Method that compares two bytes arrays and indicates if the hash of each is equals (true) or not (false).
    static Object
    getCMSSignature(byte[] eSignature, com.itextpdf.text.pdf.PdfArray byteRange, byte[] pdfDocument)
    Method that obtains the SignedData associated to a signature in PKCS#7 format.
    static byte[]
    getOriginalDocument(com.itextpdf.text.pdf.PdfReader reader)
    Method that obtains the original bytes from a PDF document.
    static com.itextpdf.text.pdf.PdfDictionary
    obtainLatestSignatureFromPDF(com.itextpdf.text.pdf.PdfReader reader)
    Method that obtains the signature dictionary with major review.

    Methods inherited from class java.lang.Object

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

    • CADES_SUBFILTER_VALUE

      public static final String CADES_SUBFILTER_VALUE
      Constant attribute that represents the string to identify the value for the key SubFilter of the signature dictionary for a PAdES Enhanced signature.
      See Also:
    • TST_SUBFILTER_VALUE

      public static final String TST_SUBFILTER_VALUE
      Constant attribute that represents the string to identify the value for the key SubFilter of a Document Time-stamp dictionary.
      See Also:
  • Method Details

    • getCMSSignature

      public static Object getCMSSignature(byte[] eSignature, com.itextpdf.text.pdf.PdfArray byteRange, byte[] pdfDocument) throws AfirmaException, iaik.cms.CMSParsingException, IOException, NoSuchAlgorithmException, AfirmaException
      Method that obtains the SignedData associated to a signature in PKCS#7 format.
      Parameters:
      eSignature - Parameter that represents the signature in PKCS#7 format as a bytes array.
      byteRange - Parameter that represents the contents of the key /ByteArray for the signature in the PDF document.
      pdfDocument - Parameter that represents the bytes of the original PDF document.
      Returns:
      the SignedData associated.
      Throws:
      AfirmaException - If the method fails.
      iaik.cms.CMSParsingException - If the method fails.
      IOException - If the method fails.
      NoSuchAlgorithmException - If the method fails.
      AfirmaException - If the method fails.
    • getOriginalDocument

      public static byte[] getOriginalDocument(com.itextpdf.text.pdf.PdfReader reader) throws IOException
      Method that obtains the original bytes from a PDF document.
      Parameters:
      reader - Parameter that represents the reader object associated to a PDF document.
      Returns:
      the original bytes from a PDF document.
      Throws:
      IOException
    • obtainLatestSignatureFromPDF

      public static com.itextpdf.text.pdf.PdfDictionary obtainLatestSignatureFromPDF(com.itextpdf.text.pdf.PdfReader reader)
      Method that obtains the signature dictionary with major review.
      Parameters:
      reader - Parameter that represents the reader for the PDF document.
      Returns:
      the signature dictionary with major review.
    • equalsHash

      public static boolean equalsHash(com.itextpdf.text.pdf.PdfArray pdfArrayByteRange, MessageDigest messageDigestSignature, byte[] pdfDocument, byte[] hashSignature)
      Method that compares two bytes arrays and indicates if the hash of each is equals (true) or not (false).
      Parameters:
      pdfArrayByteRange - Parameter that represents the exact byte range for the digest calculation.
      messageDigestSignature - Parameter that represents the message digest algorithm.
      pdfDocument - Parameter that represents the first bytes array to compare.
      hashSignature - Parameter that represents the second bytes array to compare.
      Returns:
      a boolean that indicates if the hash of each is equals (true) or not (false).