Class PDDocumentUtils

java.lang.Object
br.ufsc.labsec.signature.conformanceVerifier.pdf.PDDocumentUtils
Direct Known Subclasses:
ObjectEvaluation

public class PDDocumentUtils
extends Object
Esta classe engloba métodos úteis para lidar com modificações no arquivo PDF.
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  PDDocumentUtils.OurPDSignature  
  • Field Summary

    Fields
    Modifier and Type Field Description
    static org.apache.pdfbox.cos.COSName ACTION  
    static org.apache.pdfbox.cos.COSName ETSI_RFC3161  
    static org.apache.pdfbox.cos.COSName LOCK  
  • Constructor Summary

    Constructors
    Constructor Description
    PDDocumentUtils()  
  • Method Summary

    Modifier and Type Method Description
    static <T extends org.apache.pdfbox.cos.COSBase>
    T
    as​(org.apache.pdfbox.cos.COSBase b, Class<T> clazz)  
    static org.apache.pdfbox.cos.COSObject asCOSObject​(org.apache.pdfbox.cos.COSBase b)  
    static <T extends org.apache.pdfbox.cos.COSBase>
    Optional<T>
    asOptional​(org.apache.pdfbox.cos.COSBase b, Class<T> clazz)  
    static void closePDDocument​(org.apache.pdfbox.pdmodel.PDDocument document)  
    static <T extends org.apache.pdfbox.cos.COSBase>
    boolean
    compare​(org.apache.pdfbox.cos.COSArray array1, org.apache.pdfbox.cos.COSArray array2, Class<T> clazz)  
    static int comparePosition​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature1, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature2)  
    static boolean containsTransformMethod​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)  
    static void copyVisualSignature​(org.apache.pdfbox.pdmodel.PDDocument document, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)
    Copia a representação visual de uma assinatura para todas as páginas.
    static byte[] digest​(PadesSignature signature)  
    static byte[] digest​(org.bouncycastle.asn1.ASN1ObjectIdentifier identifier, PadesSignature signature)  
    static byte[] DIGEST​(PadesSignature signature)  
    static byte[] DIGEST​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature, byte[] pdfBytes)  
    static byte[] DIGEST​(org.bouncycastle.asn1.ASN1ObjectIdentifier identifier, PadesSignature signature)  
    static boolean equalLock​(org.apache.pdfbox.cos.COSBase base, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)  
    static org.apache.pdfbox.cos.COSName fieldTypeFromHierarchy​(org.apache.pdfbox.cos.COSBase base)  
    static String formatXpath​(String before, String now)
    Formata o XPath de uma assinatura PDF, dado o Xpath anterior e o que deve ser concatenado
    static org.apache.pdfbox.pdmodel.PDDocument GET_SIGNED_DOCUMENT​(byte[] pdfBytes, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)  
    static Optional<org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm> getAcroForm​(org.apache.pdfbox.pdmodel.PDDocument document)  
    static List<org.apache.pdfbox.cos.COSBase> getAnnotations​(org.apache.pdfbox.pdmodel.PDDocument document)  
    static List<PDDocumentUtils.OurPDSignature> getApprovalSignatures​(org.apache.pdfbox.pdmodel.PDDocument document, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature certificationSignature)  
    static Optional<org.apache.pdfbox.cos.COSDictionary> getBaseAcroForm​(org.apache.pdfbox.pdmodel.PDDocument document)  
    static String getBaseIdentification​(boolean isSignature)  
    static int[] getByteRangeForRemovingLastSignature​(org.apache.pdfbox.pdmodel.PDDocument document)
    Retorna o byte range que removerá a última assinatura do documento.
    static Optional<org.apache.pdfbox.pdmodel.PDDocumentCatalog> getCatalog​(org.apache.pdfbox.pdmodel.PDDocument document)  
    static PDDocumentUtils.OurPDSignature getCertificationSignature​(org.apache.pdfbox.pdmodel.PDDocument document)  
    static org.apache.pdfbox.cos.COSBase getDocMDP​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)  
    static List<org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature> getDocTimestampsOfSignature​(PadesSignature signature)  
    static List<org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature> getDocTimestampsOfSignature​(org.apache.pdfbox.pdmodel.PDDocument document, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature currentSignature)  
    static List<org.apache.commons.lang3.tuple.Pair<org.apache.pdfbox.cos.COSString,​org.apache.pdfbox.cos.COSBase>> getEmbeddedFiles​(org.apache.pdfbox.pdmodel.PDDocument document)  
    static List<org.apache.commons.lang3.tuple.Pair<byte[],​String>> getEmbeddedFiles​(org.apache.pdfbox.pdmodel.PDDocument pdfDoc, String xpathBefore)
    Checa se há EmbeddedFiles no documento que está sendo analisado e, caso possua, faça recursão de geração de relatório
    static org.apache.pdfbox.cos.COSBase getEntry​(org.apache.pdfbox.cos.COSBase base, org.apache.pdfbox.cos.COSName name)  
    static org.apache.pdfbox.cos.COSBase getFieldMDP​(org.apache.pdfbox.cos.COSBase base)  
    static org.apache.pdfbox.cos.COSBase getFieldMDP​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)  
    static List<org.apache.pdfbox.cos.COSBase> getFieldsFromHierarchy​(org.apache.pdfbox.cos.COSArray array)  
    static void getFieldsFromHierarchy​(org.apache.pdfbox.cos.COSArray array, List<org.apache.pdfbox.cos.COSBase> leafFields)  
    static List<org.apache.pdfbox.cos.COSObjectKey> getFieldsFromHierarchy​(org.apache.pdfbox.cos.COSObject field)  
    static List<org.apache.pdfbox.cos.COSBase> getFieldsFromHierarchy​(org.apache.pdfbox.pdmodel.PDDocument document)  
    static org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature getFirstSignature​(org.apache.pdfbox.pdmodel.PDDocument document, boolean withUpdateRules)
    Retorna a primeira assinatura realizada no documento, conforme o byte range de atualizações incrementais
    static int[] getFirstSignatureByteRange​(org.apache.pdfbox.pdmodel.PDDocument document)
    Retorna o byte range da primeira assinatura no documento
    static String getFullyQualifiedName​(org.apache.pdfbox.cos.COSBase base)  
    static org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature getLastSignature​(org.apache.pdfbox.pdmodel.PDDocument document)
    Retorna a última assinatura realizada no documento
    static void getNamedObjects​(org.apache.pdfbox.cos.COSDictionary treeNode, List<org.apache.commons.lang3.tuple.Pair<org.apache.pdfbox.cos.COSString,​org.apache.pdfbox.cos.COSBase>> namedObjects)  
    static List<org.apache.commons.lang3.tuple.Pair<org.apache.pdfbox.cos.COSString,​org.apache.pdfbox.cos.COSBase>> getNamedObjects​(org.apache.pdfbox.cos.COSDictionary nameDictionary, org.apache.pdfbox.cos.COSName entry)  
    static List<org.apache.commons.lang3.tuple.Pair<org.apache.pdfbox.cos.COSString,​org.apache.pdfbox.cos.COSBase>> getNamedPages​(org.apache.pdfbox.pdmodel.PDDocument document)  
    static Optional<org.apache.pdfbox.pdmodel.PDDocumentNameDictionary> getNamesDictionary​(org.apache.pdfbox.pdmodel.PDDocument document)  
    static String getObjectIdentification​(org.apache.pdfbox.cos.COSObject object, boolean isSignature)
    Formata as Strings que representam a identificação de uma assinatura no documento PDF (equivalente a XPath)
    static List<org.apache.pdfbox.cos.COSBase> getPageObjects​(org.apache.pdfbox.pdmodel.PDDocument document)  
    static List<org.apache.pdfbox.cos.COSObject> getPagesFromDocument​(org.apache.pdfbox.pdmodel.PDDocument document)  
    static org.apache.pdfbox.cos.COSBase getReference​(org.apache.pdfbox.cos.COSBase base, org.apache.pdfbox.cos.COSName method)  
    static org.apache.pdfbox.cos.COSBase getReference​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature, org.apache.pdfbox.cos.COSName method)  
    static String getReferenceFromSignature​(List<org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField> rawSignatures, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)
    Correlacionar o COSObject de rawSignatures com a instância de PDSignature, por seus dicionários
    static org.apache.pdfbox.cos.COSArray getReferences​(org.apache.pdfbox.cos.COSBase base)  
    static org.apache.pdfbox.cos.COSArray getReferences​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)  
    static List<org.apache.pdfbox.cos.COSDictionary> getReferencesAsList​(org.apache.pdfbox.cos.COSBase base)  
    static List<org.apache.pdfbox.cos.COSDictionary> getReferencesAsList​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)  
    static Optional<org.apache.pdfbox.cos.COSArray> getRootFields​(org.apache.pdfbox.pdmodel.PDDocument document)  
    static List<org.apache.pdfbox.cos.COSObject> getRootFieldsFromDocument​(org.apache.pdfbox.pdmodel.PDDocument document)  
    static List<org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature> getSignatures​(org.apache.pdfbox.pdmodel.PDDocument document)  
    static org.apache.pdfbox.pdmodel.PDDocument getSignedDocument​(byte[] pdfBytes, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)  
    static List<org.apache.commons.lang3.tuple.Pair<org.apache.pdfbox.cos.COSBase,​org.apache.pdfbox.cos.COSBase>> getValuesFromNameTree​(org.apache.pdfbox.cos.COSDictionary nameTreeNode)  
    static org.apache.pdfbox.cos.COSBase getWidgetParent​(org.apache.pdfbox.cos.COSBase base)  
    static boolean hasDocMDP​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)  
    static boolean hasEntry​(org.apache.pdfbox.cos.COSBase base, org.apache.pdfbox.cos.COSName entry)  
    static boolean hasFieldMDP​(org.apache.pdfbox.cos.COSBase base)  
    static boolean hasFieldMDP​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)  
    static boolean isAcroForm​(org.apache.pdfbox.cos.COSBase base)  
    static boolean isAnnotation​(org.apache.pdfbox.cos.COSBase base)  
    static boolean isCatalog​(org.apache.pdfbox.cos.COSBase base)  
    static boolean isField​(org.apache.pdfbox.cos.COSBase base)  
    static boolean isFieldEntry​(String entry)  
    static boolean isNonTerminalField​(org.apache.pdfbox.cos.COSBase base)  
    static boolean isPage​(org.apache.pdfbox.cos.COSBase base)  
    static boolean isPageNode​(org.apache.pdfbox.cos.COSBase base)  
    static boolean isPageObject​(org.apache.pdfbox.cos.COSBase base)  
    static boolean isSignatureDictionary​(org.apache.pdfbox.cos.COSBase base)  
    static boolean isSignatureField​(org.apache.pdfbox.cos.COSBase base)  
    static boolean isSignatureWidget​(org.apache.pdfbox.cos.COSBase base)  
    static boolean isSignedSignatureField​(org.apache.pdfbox.cos.COSBase base)  
    static boolean isTerminalField​(org.apache.pdfbox.cos.COSBase base)  
    static boolean isTimestampField​(org.apache.pdfbox.cos.COSBase base)  
    static boolean isTimestampWidget​(org.apache.pdfbox.cos.COSBase base)  
    static boolean isUnsignedSignatureField​(org.apache.pdfbox.cos.COSBase base)  
    static boolean isWidget​(org.apache.pdfbox.cos.COSBase base)  
    static org.apache.pdfbox.pdmodel.PDDocument openPDDocument​(byte[] documentBytes)  
    static org.apache.pdfbox.pdmodel.PDDocument openPDDocument​(InputStream documentStream)  
    static org.apache.pdfbox.pdmodel.PDDocument openPDDocument​(InputStream documentStream, int size)  
    protected static long retrieveAddress​(org.apache.pdfbox.pdmodel.PDDocument document, org.apache.pdfbox.cos.COSObjectKey key)
    Retorna o endereço do objeto segundo a tabela 'xrefTable'
    static boolean signs​(org.apache.pdfbox.cos.COSDictionary signature, long offset)  
    static boolean signs​(org.apache.pdfbox.cos.COSDictionary signature, org.apache.pdfbox.cos.COSObjectKey key, org.apache.pdfbox.pdmodel.PDDocument document)  
    static boolean signs​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature, long offset)  
    static boolean signs​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature, org.apache.pdfbox.cos.COSObjectKey key, org.apache.pdfbox.pdmodel.PDDocument document)  
    static boolean signs​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature, org.apache.pdfbox.cos.COSObject object, org.apache.pdfbox.pdmodel.PDDocument document)  
    static List<org.apache.pdfbox.cos.COSObjectKey> toCOSObjectKey​(List<org.apache.pdfbox.cos.COSObject> objects)  

    Methods inherited from class java.lang.Object

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

    • LOCK

      public static final org.apache.pdfbox.cos.COSName LOCK
    • ACTION

      public static final org.apache.pdfbox.cos.COSName ACTION
    • ETSI_RFC3161

      public static final org.apache.pdfbox.cos.COSName ETSI_RFC3161
  • Constructor Details

    • PDDocumentUtils

      public PDDocumentUtils()
  • Method Details

    • getByteRangeForRemovingLastSignature

      public static int[] getByteRangeForRemovingLastSignature​(org.apache.pdfbox.pdmodel.PDDocument document)
      Retorna o byte range que removerá a última assinatura do documento. Caso o arquivo contenha mais de uma assinatura, será o byteRange da penúltima assinatura.
      Parameters:
      document - O documento assinado
      Returns:
      O byte range de remoção da última assinatura
    • getLastSignature

      public static org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature getLastSignature​(org.apache.pdfbox.pdmodel.PDDocument document)
      Retorna a última assinatura realizada no documento
      Parameters:
      document - Documento PDF
      Returns:
      A última assinatura do documento
    • getFirstSignature

      public static org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature getFirstSignature​(org.apache.pdfbox.pdmodel.PDDocument document, boolean withUpdateRules)
      Retorna a primeira assinatura realizada no documento, conforme o byte range de atualizações incrementais
      Parameters:
      document - Documento PDF
      Returns:
      A primeira assinatura do documento
    • getReferences

      public static org.apache.pdfbox.cos.COSArray getReferences​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)
    • getReferences

      public static org.apache.pdfbox.cos.COSArray getReferences​(org.apache.pdfbox.cos.COSBase base)
    • getReferencesAsList

      public static List<org.apache.pdfbox.cos.COSDictionary> getReferencesAsList​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)
    • getReferencesAsList

      public static List<org.apache.pdfbox.cos.COSDictionary> getReferencesAsList​(org.apache.pdfbox.cos.COSBase base)
    • containsTransformMethod

      public static boolean containsTransformMethod​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)
    • getFirstSignatureByteRange

      public static int[] getFirstSignatureByteRange​(org.apache.pdfbox.pdmodel.PDDocument document)
      Retorna o byte range da primeira assinatura no documento
      Parameters:
      document - O documento assinado
      Returns:
      O byte range da primeira assinatura
    • getFullyQualifiedName

      public static String getFullyQualifiedName​(org.apache.pdfbox.cos.COSBase base)
    • retrieveAddress

      protected static long retrieveAddress​(org.apache.pdfbox.pdmodel.PDDocument document, org.apache.pdfbox.cos.COSObjectKey key)
      Retorna o endereço do objeto segundo a tabela 'xrefTable'
      Parameters:
      document - O documento assinado
      key - A chave do objeto procurado
      Returns:
      O endereço do objeto dado
    • getFieldsFromHierarchy

      public static List<org.apache.pdfbox.cos.COSObjectKey> getFieldsFromHierarchy​(org.apache.pdfbox.cos.COSObject field)
    • toCOSObjectKey

      public static List<org.apache.pdfbox.cos.COSObjectKey> toCOSObjectKey​(List<org.apache.pdfbox.cos.COSObject> objects)
    • getAnnotations

      public static List<org.apache.pdfbox.cos.COSBase> getAnnotations​(org.apache.pdfbox.pdmodel.PDDocument document)
    • getRootFieldsFromDocument

      public static List<org.apache.pdfbox.cos.COSObject> getRootFieldsFromDocument​(org.apache.pdfbox.pdmodel.PDDocument document)
    • isWidget

      public static boolean isWidget​(org.apache.pdfbox.cos.COSBase base)
    • isPage

      public static boolean isPage​(org.apache.pdfbox.cos.COSBase base)
    • isPageNode

      public static boolean isPageNode​(org.apache.pdfbox.cos.COSBase base)
    • isPageObject

      public static boolean isPageObject​(org.apache.pdfbox.cos.COSBase base)
    • getPagesFromDocument

      public static List<org.apache.pdfbox.cos.COSObject> getPagesFromDocument​(org.apache.pdfbox.pdmodel.PDDocument document)
    • getPageObjects

      public static List<org.apache.pdfbox.cos.COSBase> getPageObjects​(org.apache.pdfbox.pdmodel.PDDocument document)
    • getCatalog

      public static Optional<org.apache.pdfbox.pdmodel.PDDocumentCatalog> getCatalog​(org.apache.pdfbox.pdmodel.PDDocument document)
    • getAcroForm

      public static Optional<org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm> getAcroForm​(org.apache.pdfbox.pdmodel.PDDocument document)
    • getBaseAcroForm

      public static Optional<org.apache.pdfbox.cos.COSDictionary> getBaseAcroForm​(org.apache.pdfbox.pdmodel.PDDocument document)
    • getRootFields

      public static Optional<org.apache.pdfbox.cos.COSArray> getRootFields​(org.apache.pdfbox.pdmodel.PDDocument document)
    • getFieldsFromHierarchy

      public static List<org.apache.pdfbox.cos.COSBase> getFieldsFromHierarchy​(org.apache.pdfbox.pdmodel.PDDocument document)
    • signs

      public static boolean signs​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature, org.apache.pdfbox.cos.COSObject object, org.apache.pdfbox.pdmodel.PDDocument document)
    • signs

      public static boolean signs​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature, org.apache.pdfbox.cos.COSObjectKey key, org.apache.pdfbox.pdmodel.PDDocument document)
    • signs

      public static boolean signs​(org.apache.pdfbox.cos.COSDictionary signature, org.apache.pdfbox.cos.COSObjectKey key, org.apache.pdfbox.pdmodel.PDDocument document)
    • getEntry

      public static org.apache.pdfbox.cos.COSBase getEntry​(org.apache.pdfbox.cos.COSBase base, org.apache.pdfbox.cos.COSName name)
    • hasEntry

      public static boolean hasEntry​(org.apache.pdfbox.cos.COSBase base, org.apache.pdfbox.cos.COSName entry)
    • equalLock

      public static boolean equalLock​(org.apache.pdfbox.cos.COSBase base, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature) throws IOException
      Throws:
      IOException
    • compare

      public static <T extends org.apache.pdfbox.cos.COSBase> boolean compare​(org.apache.pdfbox.cos.COSArray array1, org.apache.pdfbox.cos.COSArray array2, Class<T> clazz)
    • signs

      public static boolean signs​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature, long offset)
    • signs

      public static boolean signs​(org.apache.pdfbox.cos.COSDictionary signature, long offset)
    • getFieldsFromHierarchy

      public static List<org.apache.pdfbox.cos.COSBase> getFieldsFromHierarchy​(org.apache.pdfbox.cos.COSArray array)
    • getFieldsFromHierarchy

      public static void getFieldsFromHierarchy​(org.apache.pdfbox.cos.COSArray array, List<org.apache.pdfbox.cos.COSBase> leafFields)
    • getNamesDictionary

      public static Optional<org.apache.pdfbox.pdmodel.PDDocumentNameDictionary> getNamesDictionary​(org.apache.pdfbox.pdmodel.PDDocument document)
    • getEmbeddedFiles

      public static List<org.apache.commons.lang3.tuple.Pair<org.apache.pdfbox.cos.COSString,​org.apache.pdfbox.cos.COSBase>> getEmbeddedFiles​(org.apache.pdfbox.pdmodel.PDDocument document)
    • getNamedPages

      public static List<org.apache.commons.lang3.tuple.Pair<org.apache.pdfbox.cos.COSString,​org.apache.pdfbox.cos.COSBase>> getNamedPages​(org.apache.pdfbox.pdmodel.PDDocument document)
    • getNamedObjects

      public static List<org.apache.commons.lang3.tuple.Pair<org.apache.pdfbox.cos.COSString,​org.apache.pdfbox.cos.COSBase>> getNamedObjects​(org.apache.pdfbox.cos.COSDictionary nameDictionary, org.apache.pdfbox.cos.COSName entry)
    • getNamedObjects

      public static void getNamedObjects​(org.apache.pdfbox.cos.COSDictionary treeNode, List<org.apache.commons.lang3.tuple.Pair<org.apache.pdfbox.cos.COSString,​org.apache.pdfbox.cos.COSBase>> namedObjects)
    • isAnnotation

      public static boolean isAnnotation​(org.apache.pdfbox.cos.COSBase base)
    • isCatalog

      public static boolean isCatalog​(org.apache.pdfbox.cos.COSBase base)
    • isField

      public static boolean isField​(org.apache.pdfbox.cos.COSBase base)
    • isSignedSignatureField

      public static boolean isSignedSignatureField​(org.apache.pdfbox.cos.COSBase base)
    • isUnsignedSignatureField

      public static boolean isUnsignedSignatureField​(org.apache.pdfbox.cos.COSBase base)
    • isSignatureField

      public static boolean isSignatureField​(org.apache.pdfbox.cos.COSBase base)
    • isSignatureDictionary

      public static boolean isSignatureDictionary​(org.apache.pdfbox.cos.COSBase base)
    • comparePosition

      public static int comparePosition​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature1, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature2)
    • getCertificationSignature

      public static PDDocumentUtils.OurPDSignature getCertificationSignature​(org.apache.pdfbox.pdmodel.PDDocument document)
    • getReference

      public static org.apache.pdfbox.cos.COSBase getReference​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature, org.apache.pdfbox.cos.COSName method)
    • getReference

      public static org.apache.pdfbox.cos.COSBase getReference​(org.apache.pdfbox.cos.COSBase base, org.apache.pdfbox.cos.COSName method)
    • getDocMDP

      public static org.apache.pdfbox.cos.COSBase getDocMDP​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)
    • hasDocMDP

      public static boolean hasDocMDP​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)
    • getFieldMDP

      public static org.apache.pdfbox.cos.COSBase getFieldMDP​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)
    • getFieldMDP

      public static org.apache.pdfbox.cos.COSBase getFieldMDP​(org.apache.pdfbox.cos.COSBase base)
    • hasFieldMDP

      public static boolean hasFieldMDP​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)
    • hasFieldMDP

      public static boolean hasFieldMDP​(org.apache.pdfbox.cos.COSBase base)
    • getApprovalSignatures

      public static List<PDDocumentUtils.OurPDSignature> getApprovalSignatures​(org.apache.pdfbox.pdmodel.PDDocument document, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature certificationSignature)
    • GET_SIGNED_DOCUMENT

      public static org.apache.pdfbox.pdmodel.PDDocument GET_SIGNED_DOCUMENT​(byte[] pdfBytes, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)
    • getSignedDocument

      public static org.apache.pdfbox.pdmodel.PDDocument getSignedDocument​(byte[] pdfBytes, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature) throws IOException
      Throws:
      IOException
    • getWidgetParent

      public static org.apache.pdfbox.cos.COSBase getWidgetParent​(org.apache.pdfbox.cos.COSBase base)
    • isSignatureWidget

      public static boolean isSignatureWidget​(org.apache.pdfbox.cos.COSBase base)
    • isTimestampWidget

      public static boolean isTimestampWidget​(org.apache.pdfbox.cos.COSBase base)
    • isTimestampField

      public static boolean isTimestampField​(org.apache.pdfbox.cos.COSBase base)
    • isTerminalField

      public static boolean isTerminalField​(org.apache.pdfbox.cos.COSBase base)
    • isNonTerminalField

      public static boolean isNonTerminalField​(org.apache.pdfbox.cos.COSBase base)
    • fieldTypeFromHierarchy

      public static org.apache.pdfbox.cos.COSName fieldTypeFromHierarchy​(org.apache.pdfbox.cos.COSBase base)
    • isAcroForm

      public static boolean isAcroForm​(org.apache.pdfbox.cos.COSBase base)
    • isFieldEntry

      public static boolean isFieldEntry​(String entry)
    • closePDDocument

      public static void closePDDocument​(org.apache.pdfbox.pdmodel.PDDocument document)
    • as

      public static <T extends org.apache.pdfbox.cos.COSBase> T as​(org.apache.pdfbox.cos.COSBase b, Class<T> clazz)
    • asCOSObject

      public static org.apache.pdfbox.cos.COSObject asCOSObject​(org.apache.pdfbox.cos.COSBase b)
    • asOptional

      public static <T extends org.apache.pdfbox.cos.COSBase> Optional<T> asOptional​(org.apache.pdfbox.cos.COSBase b, Class<T> clazz)
    • openPDDocument

      public static org.apache.pdfbox.pdmodel.PDDocument openPDDocument​(byte[] documentBytes) throws IOException
      Throws:
      IOException
    • openPDDocument

      public static org.apache.pdfbox.pdmodel.PDDocument openPDDocument​(InputStream documentStream) throws IOException
      Throws:
      IOException
    • openPDDocument

      public static org.apache.pdfbox.pdmodel.PDDocument openPDDocument​(InputStream documentStream, int size) throws IOException
      Throws:
      IOException
    • getValuesFromNameTree

      public static List<org.apache.commons.lang3.tuple.Pair<org.apache.pdfbox.cos.COSBase,​org.apache.pdfbox.cos.COSBase>> getValuesFromNameTree​(org.apache.pdfbox.cos.COSDictionary nameTreeNode)
    • getEmbeddedFiles

      public static List<org.apache.commons.lang3.tuple.Pair<byte[],​String>> getEmbeddedFiles​(org.apache.pdfbox.pdmodel.PDDocument pdfDoc, String xpathBefore) throws IOException
      Checa se há EmbeddedFiles no documento que está sendo analisado e, caso possua, faça recursão de geração de relatório
      Parameters:
      pdfDoc - Documento PDF analisado no momento
      xpathBefore - XPath anterior analisado (para montar hierarquias de assinaturas)
      Throws:
      IOException - Caso haja algum erro ao pegar os Names dos EmbeddedFiles
    • formatXpath

      public static String formatXpath​(String before, String now)
      Formata o XPath de uma assinatura PDF, dado o Xpath anterior e o que deve ser concatenado
      Parameters:
      before - XPath anterior
      now - Xpath a ser concatenado
      Returns:
      XPath concatenado
    • getReferenceFromSignature

      public static String getReferenceFromSignature​(List<org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField> rawSignatures, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature)
      Correlacionar o COSObject de rawSignatures com a instância de PDSignature, por seus dicionários
      Parameters:
      rawSignatures - Lista de COSObject correspondentes à assinaturas
      signature - Instância de PDSignature que deve ser feita correlação
      Returns:
      XPath de referência da assinatura
    • getObjectIdentification

      public static String getObjectIdentification​(org.apache.pdfbox.cos.COSObject object, boolean isSignature)
      Formata as Strings que representam a identificação de uma assinatura no documento PDF (equivalente a XPath)
      Parameters:
      object - Objeto que detém a informação de identificação no documento
      Returns:
      XPath formatado de identificação da assinatura no documento PDF
    • getBaseIdentification

      public static String getBaseIdentification​(boolean isSignature)
    • getSignatures

      public static List<org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature> getSignatures​(org.apache.pdfbox.pdmodel.PDDocument document)
    • getDocTimestampsOfSignature

      public static List<org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature> getDocTimestampsOfSignature​(PadesSignature signature)
    • getDocTimestampsOfSignature

      public static List<org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature> getDocTimestampsOfSignature​(org.apache.pdfbox.pdmodel.PDDocument document, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature currentSignature)
    • digest

      public static byte[] digest​(PadesSignature signature) throws IOException
      Throws:
      IOException
    • digest

      public static byte[] digest​(org.bouncycastle.asn1.ASN1ObjectIdentifier identifier, PadesSignature signature) throws IOException
      Throws:
      IOException
    • DIGEST

      public static byte[] DIGEST​(PadesSignature signature)
    • DIGEST

      public static byte[] DIGEST​(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature, byte[] pdfBytes)
    • DIGEST

      public static byte[] DIGEST​(org.bouncycastle.asn1.ASN1ObjectIdentifier identifier, PadesSignature signature)
    • copyVisualSignature

      public static void copyVisualSignature​(org.apache.pdfbox.pdmodel.PDDocument document, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature) throws IOException
      Copia a representação visual de uma assinatura para todas as páginas. Não faz nada caso a assinatura não seja encontrada no documento ou não tenha representação visual.
      Parameters:
      document - Documento com assinatura
      signature - Assinatura com representação visual a ser copiada
      Throws:
      IOException