pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1814042 - /pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java
Date Thu, 02 Nov 2017 07:21:06 GMT
Author: tilman
Date: Thu Nov  2 07:21:06 2017
New Revision: 1814042

URL: http://svn.apache.org/viewvc?rev=1814042&view=rev
Log:
PDFBOX-1848: show timestamp

Modified:
    pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java

Modified: pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java?rev=1814042&r1=1814041&r2=1814042&view=diff
==============================================================================
--- pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java
(original)
+++ pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java
Thu Nov  2 07:21:06 2017
@@ -47,6 +47,8 @@ import org.bouncycastle.cms.CMSSignedDat
 import org.bouncycastle.cms.SignerInformation;
 import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder;
 import org.bouncycastle.operator.OperatorCreationException;
+import org.bouncycastle.tsp.TSPException;
+import org.bouncycastle.tsp.TimeStampToken;
 import org.bouncycastle.util.Store;
 import org.bouncycastle.util.StoreException;
 
@@ -74,10 +76,12 @@ public final class ShowSignature
      * @throws java.security.InvalidKeyException
      * @throws java.security.NoSuchProviderException
      * @throws java.security.SignatureException
+     * @throws org.bouncycastle.tsp.TSPException
      */
     public static void main(String[] args) throws IOException, CertificateException,
                                                   NoSuchAlgorithmException, InvalidKeyException,

-                                                  NoSuchProviderException, SignatureException
+                                                  NoSuchProviderException, SignatureException,
+                                                  TSPException
     {
         ShowSignature show = new ShowSignature();
         show.showSignature( args );
@@ -85,7 +89,8 @@ public final class ShowSignature
 
     private void showSignature(String[] args) throws IOException, CertificateException,
                                                      NoSuchAlgorithmException, InvalidKeyException,
-                                                     NoSuchProviderException, SignatureException
+                                                     NoSuchProviderException, SignatureException,
+                                                     TSPException
     {
         if( args.length != 2 )
         {
@@ -189,6 +194,19 @@ public final class ShowSignature
                             
                             //TODO verify signature
                         }
+                        else if (subFilter.equals("ETSI.RFC3161"))
+                        {
+                            TimeStampToken timeStampToken = new TimeStampToken(new CMSSignedData(contents.getBytes()));
+                            System.out.println("Time stamp gen time: " + timeStampToken.getTimeStampInfo().getGenTime());
+                            System.out.println("Time stamp tsa name: " + timeStampToken.getTimeStampInfo().getTsa().getName());
+
+                            CertificateFactory factory = CertificateFactory.getInstance("X.509");
+                            ByteArrayInputStream certStream = new ByteArrayInputStream(contents.getBytes());
+                            Collection<? extends Certificate> certs = factory.generateCertificates(certStream);
+                            System.out.println("certs=" + certs);
+
+                            //TODO verify signature
+                        }
                         else
                         {
                             System.err.println("Unknown certificate type: " + subFilter);



Mime
View raw message