java.lang.Object
es.juntadeandalucia.afirma.client.util.signatureFormat.PDFFormatDetector
All Implemented Interfaces:
SpecificFormatDetectorI

public class PDFFormatDetector extends Object implements SpecificFormatDetectorI

Class that represents a format checker for signatures on PDF documents.

Project:

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

Version:
1.0, 25/04/2011.
  • Constructor Details

    • PDFFormatDetector

      public PDFFormatDetector(Object sig) throws AfirmaException
      Constructor method for the class PDFFormatDetector.java.
      Parameters:
      sig - Parameter that allows to access to the fields in a PDF document.
      Throws:
      AfirmaException - If the method fails.
    • PDFFormatDetector

      public PDFFormatDetector(com.itextpdf.text.pdf.PdfReader rd) throws AfirmaException
      Constructor method for the class PDFFormatDetector.java.
      Parameters:
      rd - Parameter that allows to access to the fields in a PDF document.
      Throws:
      AfirmaException - If the method fails.
  • Method Details

    • isBES

      public boolean isBES()
      Métodos para comprobar si la firma contiene los atributos firmados del formato BES.
      Specified by:
      isBES in interface SpecificFormatDetectorI
      Returns:
      boolean, true si contiene los elementos del formato BES. false si no contiene los elementos del formato BES.
      See Also:
    • isBES

      public boolean isBES(com.itextpdf.text.pdf.PdfDictionary pdfDic)
      Method that indicates if a signature dictionary refers to a PAdES-BES signature (true) or not (false)
      Parameters:
      pdfDic - Parameter that represents the signature dictionary.
      Returns:
      a boolean that indicates if a signature dictionary refers to a PAdES-BES signature (true) or not (false)
    • isEPES

      public boolean isEPES()
      Métodos para comprobar si la firma contiene los atributos firmados del formato EPES.
      Specified by:
      isEPES in interface SpecificFormatDetectorI
      Returns:
      boolean, true si contiene los elementos del formato EPES. false si no contiene los elementos del formato EPEs.
      See Also:
    • isT

      public boolean isT()
      Métodos para comprobar si la firma contiene los atributos no firmados del formato T.
      Specified by:
      isT in interface SpecificFormatDetectorI
      Returns:
      boolean, true si contiene los elementos del formato T. false si no contiene los elementos del formato T.
      See Also:
    • isC

      public boolean isC()
      Métodos para comprobar si la firma contiene los atributos no firmados del formato C.
      Specified by:
      isC in interface SpecificFormatDetectorI
      Returns:
      boolean, true si contiene los elementos del formato C. false si no contiene los elementos del formato C.
      See Also:
    • isX1

      public boolean isX1()
      Métodos para comprobar si la firma contiene los atributos no firmados del formato X Type1.
      Specified by:
      isX1 in interface SpecificFormatDetectorI
      Returns:
      boolean, true si contiene los elementos del formato X Type1. false si no contiene los elementos del formato X Type1.
      See Also:
    • isX2

      public boolean isX2()
      Métodos para comprobar si la firma contiene los atributos no firmados del formato X Type2.
      Specified by:
      isX2 in interface SpecificFormatDetectorI
      Returns:
      boolean, true si contiene los elementos del formato X Type2. false si no contiene los elementos del formato X Type2.
      See Also:
    • isXL

      public boolean isXL()
      Métodos para comprobar si la firma contiene los atributos no firmados del formato X Long.
      Specified by:
      isXL in interface SpecificFormatDetectorI
      Returns:
      boolean, true si contiene los elementos del formato X Long. false si no contiene los elementos del formato X Long.
      See Also:
    • isX1L

      public boolean isX1L()
      Métodos para comprobar si la firma contiene los atributos no firmados del formato X Long Type1.
      Specified by:
      isX1L in interface SpecificFormatDetectorI
      Returns:
      boolean, true si contiene los elementos del formato X Long Type1. false si no contiene los elementos del formato X Long Type1.
      See Also:
    • isX2L

      public boolean isX2L()
      Métodos para comprobar si la firma contiene los atributos no firmados del formato X Long Type2.
      Specified by:
      isX2L in interface SpecificFormatDetectorI
      Returns:
      boolean, true si contiene los elementos del formato X Long Type2. false si no contiene los elementos del formato X Long type2.
      See Also:
    • isA

      public boolean isA()
      Métodos para comprobar si la firma contiene los atributos no firmados del formato A.
      Specified by:
      isA in interface SpecificFormatDetectorI
      Returns:
      boolean, true si contiene los elementos del formato A. false si no contiene los elementos del formato A.
      See Also:
    • getBasicFormat

      public String getBasicFormat()
      Método que devuelve el formato básico de la firma electrónica detectado hasta el momento.
      Specified by:
      getBasicFormat in interface SpecificFormatDetectorI
      Returns:
      String, Devuelve el formato de la firma de entre los formatos básicos definidos en esta interfaz.
      See Also:
    • getSpecificFormat

      public String getSpecificFormat()
      Método que devuelve el formato específico de la firma electrónica detectado hasta el momento.
      Specified by:
      getSpecificFormat in interface SpecificFormatDetectorI
      Returns:
      String, Devuelve el formato de la firma de entre los formatos específicos definidos en esta interfaz.
      See Also:
    • resolveBasicFormat

      public String resolveBasicFormat()
      Método que resuelve el formato básico de una firma electrónica con formato desconocido.

      Este método se ejecuta automaticamente al crear el objeto con el siguiente constructor:


      new XXXFormatDetector(Object sig)


      Para otros constructores será necesario invocar el método para hallar el formato básico.

      Specified by:
      resolveBasicFormat in interface SpecificFormatDetectorI
      Returns:
      String, Devuelve el formato básico de la firma de entre los formatos BES definidos en esta interfaz.
      See Also:
    • resolveSignatureFormat

      public String resolveSignatureFormat()
      Método que resuelve el formato extendido de una firma electrónica con formato desconocido.
      Specified by:
      resolveSignatureFormat in interface SpecificFormatDetectorI
      Returns:
      String, Devuelve el formato extendido de la firma de entre los formatos definidos en esta interfaz.
      See Also:
    • isSignatureFormatUpperThanTheFormat

      public boolean isSignatureFormatUpperThanTheFormat(String signatureFormat, String formatToTest)
      Method that indicates whether the signature format contained in signatureFormat input parameter is more advanced than indicated in formatToTest.
      Specified by:
      isSignatureFormatUpperThanTheFormat in interface SpecificFormatDetectorI
      Parameters:
      signatureFormat - Signature format you want to check if it is more advanced.
      formatToTest - Signature format taking as a basis for comparison.
      Returns:
      true if the indicated signature format is more advanced than the taking as a basis for comparison. false otherwise.
      See Also:
    • isSignatureFormatUpperOrEqualThanTheFormat

      public boolean isSignatureFormatUpperOrEqualThanTheFormat(String signatureFormat, String formatToTest)
      Method that indicates whether the signature format contained in signatureFormat input parameter is equal or more advanced than indicated in formatToTest.
      Specified by:
      isSignatureFormatUpperOrEqualThanTheFormat in interface SpecificFormatDetectorI
      Parameters:
      signatureFormat - Signature format you want to check if it is equal or more advanced.
      formatToTest - Signature format taking as a basis for comparison.
      Returns:
      true if the indicated signature format is equal or more advanced than the taking as a basis for comparison. false otherwise.
      See Also:
    • isPDF

      public boolean isPDF(com.itextpdf.text.pdf.PdfDictionary pdfDic)
      Method that indicates if a signature dictionary refers to a PDF signature (non PAdES signature) (true) or not (false).
      Parameters:
      pdfDic - Parameter that represents the signature dictionary.
      Returns:
      a boolean that indicates if a signature dictionary refers to a PDF signature (non PAdES signature) (true) or not (false).
    • isPDF

      public boolean isPDF()
      Method that indicates if the signature of a PDF document is a PDF signature, i.e., any of the signature of the PDF document is a PAdES signature.
      Returns:
      a boolean that indicates if the signature of a PDF document is a PDF signature, i.e., any of the signature of the PDF document is a PAdES signature.
    • isPAdESBasic

      public boolean isPAdESBasic(com.itextpdf.text.pdf.PdfDictionary pdfDic)
      Method that indicates if a signature dictionary refers to a PAdES-Basic signature (true) or not (false).
      Parameters:
      pdfDic - Parameter that represents the signature dictionary.
      Returns:
      a boolean that indicates if a signature dictionary refers to a PAdES-Basic signature (true) or not (false)
    • isPAdESBasic

      public boolean isPAdESBasic()
      Method that indicates if the most advanced signature in a PDF document is a PAdES-Basic signature (true) or not (false).
      Returns:
      a boolean that indicates if the most advanced signature in a PDF document is a PAdES-Basic signature (true) or not (false).
    • getDigestAlgorithmImplementation

      public String getDigestAlgorithmImplementation() throws NoSuchAlgorithmException
      Specified by:
      getDigestAlgorithmImplementation in interface SpecificFormatDetectorI
      Throws:
      NoSuchAlgorithmException