pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1747261 - /pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java
Date Tue, 07 Jun 2016 15:49:36 GMT
Author: tilman
Date: Tue Jun  7 15:49:36 2016
New Revision: 1747261

URL: http://svn.apache.org/viewvc?rev=1747261&view=rev
Log:
PDFBOX-3017: enable verify

Modified:
    pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java

Modified: pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java?rev=1747261&r1=1747260&r2=1747261&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java
(original)
+++ pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java
Tue Jun  7 15:49:36 2016
@@ -47,6 +47,7 @@ import org.bouncycastle.cms.CMSException
 import org.bouncycastle.cms.CMSProcessableByteArray;
 import org.bouncycastle.cms.CMSSignedData;
 import org.bouncycastle.cms.SignerInformation;
+import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder;
 import org.bouncycastle.operator.OperatorCreationException;
 import org.bouncycastle.tsp.TSPValidationException;
 import org.bouncycastle.util.Store;
@@ -218,17 +219,15 @@ public class TestCreateSignature extends
                 
                 assertEquals(certificate, certFromSignedData);
 
-                // code below doesn't work - maybe because the signature can indeed not be
verified?
-                
-//                if (signerInformation.verify(new JcaSimpleSignerInfoVerifierBuilder().build(certFromSignedData)))
-//                {
-//                    System.out.println("Signature verified");
-//                }
-//                else
-//                {
-//                    System.out.println("Signature verification failed");
-//                }
-
+                // CMSVerifierCertificateNotValidException means that the keystore wasn't
valid at signing time
+                if (signerInformation.verify(new JcaSimpleSignerInfoVerifierBuilder().build(certFromSignedData)))
+                {
+                    System.out.println("Signature verified");
+                }
+                else
+                {
+                    System.out.println("Signature verification failed");
+                }                
                 break;
             }
         }



Mime
View raw message