pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1747263 - /pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java
Date Tue, 07 Jun 2016 15:50:45 GMT
Author: tilman
Date: Tue Jun  7 15:50:45 2016
New Revision: 1747263

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

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

Modified: pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java?rev=1747263&r1=1747262&r2=1747263&view=diff
==============================================================================
--- pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java
(original)
+++ pdfbox/branches/2.0/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java
Tue Jun  7 15:50:45 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,16 +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