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:34 UTC

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

Author: tilman
Date: Mon Nov 25 18:11:33 2019
New Revision: 1870401

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

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

Modified: pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/AddValidationInformation.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/AddValidationInformation.java?rev=1870401&r1=1870400&r2=1870401&view=diff
==============================================================================
--- pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/AddValidationInformation.java (original)
+++ pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/AddValidationInformation.java Mon Nov 25 18:11:33 2019
@@ -23,7 +23,6 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.lang.reflect.InvocationTargetException;
-import java.math.BigInteger;
 import java.security.GeneralSecurityException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
@@ -65,6 +64,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
  */
@@ -80,9 +81,12 @@ public class AddValidationInformation
     private COSArray crls;
     private COSArray certs;
     private PDDocument document;
-    private final Set<BigInteger> foundRevocationInformation = new HashSet<BigInteger>();
+    private final Set<X509Certificate> foundRevocationInformation = new HashSet<X509Certificate>();
     private Calendar signDate;
     private final Set<X509Certificate> ocspChecked = new HashSet<X509Certificate>();
+    //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.
@@ -266,8 +270,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)
@@ -434,7 +437,7 @@ public class AddValidationInformation
         {
             correspondingOCSPs.add(ocspStream);
         }
-        foundRevocationInformation.add(certInfo.getCertificate().getSerialNumber());
+        foundRevocationInformation.add(certInfo.getCertificate());
     }
 
     /**
@@ -505,7 +508,7 @@ public class AddValidationInformation
                 correspondingCRLs = savedCorrespondingCRLs;
             }
         }
-        foundRevocationInformation.add(certInfo.getCertificate().getSerialNumber());
+        foundRevocationInformation.add(certInfo.getCertificate());
     }
 
     private void updateVRI(CertSignatureInformation certInfo, COSDictionary vri) throws IOException