You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2019/11/25 18:11:37 UTC

svn commit: r1870402 - /pdfbox/branches/issue4569/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/AddValidationInformation.java

Author: tilman
Date: Mon Nov 25 18:11:37 2019
New Revision: 1870402

URL: http://svn.apache.org/viewvc?rev=1870402&view=rev
Log:
PDFBOX-3017: compare certificates and not just serial numbers; add link to author bachelor thesis; add a TODO

Modified:
    pdfbox/branches/issue4569/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/AddValidationInformation.java

Modified: pdfbox/branches/issue4569/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/AddValidationInformation.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue4569/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/AddValidationInformation.java?rev=1870402&r1=1870401&r2=1870402&view=diff
==============================================================================
--- pdfbox/branches/issue4569/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/AddValidationInformation.java (original)
+++ pdfbox/branches/issue4569/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/AddValidationInformation.java Mon Nov 25 18:11:37 2019
@@ -22,7 +22,6 @@ import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.math.BigInteger;
 import java.security.GeneralSecurityException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
@@ -64,6 +63,8 @@ import org.bouncycastle.cert.ocsp.OCSPRe
  * V1.1.2 (2009-12), Part 4: PAdES Long Term - PAdES-LTV Profile. This procedure appends the
  * Validation Information of the last signature (more precise its signer(s)) to a copy of the
  * document. The signature and the signed data will not be touched and stay valid.
+ * <p>
+ * See also <a href="http://eprints.hsr.ch/id/eprint/616">Bachelor thesis (in German) about LTV</a>
  *
  * @author Alexis Suter
  */
@@ -79,9 +80,12 @@ public class AddValidationInformation
     private COSArray crls;
     private COSArray certs;
     private PDDocument document;
-    private final Set<BigInteger> foundRevocationInformation = new HashSet<>();
+    private final Set<X509Certificate> foundRevocationInformation = new HashSet<>();
     private Calendar signDate;
     private final Set<X509Certificate> ocspChecked = new HashSet<>();
+    //TODO foundRevocationInformation and ocspChecked have a similar purpose. One of them should likely
+    // be removed and the code improved. When doing so, keep in mind that ocspChecked was added last,
+    // because of a problem with freetsa.
 
     /**
      * Signs the given PDF file.
@@ -240,8 +244,7 @@ public class AddValidationInformation
             return;
         }
         // To avoid getting same revocation information twice.
-        boolean isRevocationInfoFound = foundRevocationInformation
-                .contains(certInfo.getCertificate().getSerialNumber());
+        boolean isRevocationInfoFound = foundRevocationInformation.contains(certInfo.getCertificate());
         if (!isRevocationInfoFound)
         {
             if (certInfo.getOcspUrl() != null && certInfo.getIssuerCertificate() != null)
@@ -383,7 +386,7 @@ public class AddValidationInformation
         {
             correspondingOCSPs.add(ocspStream);
         }
-        foundRevocationInformation.add(certInfo.getCertificate().getSerialNumber());
+        foundRevocationInformation.add(certInfo.getCertificate());
     }
 
     /**
@@ -454,7 +457,7 @@ public class AddValidationInformation
                 correspondingCRLs = savedCorrespondingCRLs;
             }
         }
-        foundRevocationInformation.add(certInfo.getCertificate().getSerialNumber());
+        foundRevocationInformation.add(certInfo.getCertificate());
     }
 
     private void updateVRI(CertSignatureInformation certInfo, COSDictionary vri) throws IOException