Exemplo n.º 1
0
 /**
  * Checks if the signature covers the whole document and throws an exception if the document was
  * altered
  *
  * @return a PdfPKCS7 object
  * @throws GeneralSecurityException
  */
 protected PdfPKCS7 coversWholeDocument() throws GeneralSecurityException {
   PdfPKCS7 pkcs7 = fields.verifySignature(signatureName);
   if (fields.signatureCoversWholeDocument(signatureName)) {
     LOGGER.info("The timestamp covers whole document.");
   } else {
     throw new VerificationException(null, "Signature doesn't cover whole document.");
   }
   if (pkcs7.verify()) {
     LOGGER.info("The signed document has not been modified.");
     return pkcs7;
   } else {
     throw new VerificationException(
         null, "The document was altered after the final signature was applied.");
   }
 }