pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1818181 - in /pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature: CreateSignatureBase.java ShowSignature.java
Date Thu, 14 Dec 2017 18:40:44 GMT
Author: tilman
Date: Thu Dec 14 18:40:43 2017
New Revision: 1818181

URL: http://svn.apache.org/viewvc?rev=1818181&view=rev
Log:
PDFBOX-4020: simplify code, by Alexis Suter

Modified:
    pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.java
    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/CreateSignatureBase.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.java?rev=1818181&r1=1818180&r2=1818181&view=diff
==============================================================================
--- pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.java
(original)
+++ pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.java
Thu Dec 14 18:40:43 2017
@@ -53,7 +53,6 @@ import org.bouncycastle.operator.Content
 import org.bouncycastle.operator.OperatorCreationException;
 import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
 import org.bouncycastle.operator.jcajce.JcaDigestCalculatorProviderBuilder;
-import org.bouncycastle.tsp.TSPException;
 import org.bouncycastle.util.Store;
 
 public abstract class CreateSignatureBase implements SignatureInterface
@@ -135,10 +134,9 @@ public abstract class CreateSignatureBas
      * @param signedData Generated CMS signed data
      * @return CMSSignedData Extended CMS signed data
      * @throws IOException
-     * @throws org.bouncycastle.tsp.TSPException
      */
     private CMSSignedData signTimeStamps(CMSSignedData signedData)
-            throws IOException, TSPException
+            throws IOException
     {
         SignerInformationStore signerStore = signedData.getSignerInfos();
         List<SignerInformation> newSigners = new ArrayList<SignerInformation>();
@@ -158,8 +156,7 @@ public abstract class CreateSignatureBas
      * @param signer information about signer
      * @return information about SignerInformation
      */
-    private SignerInformation signTimeStamp(SignerInformation signer)
-            throws IOException, TSPException
+    private SignerInformation signTimeStamp(SignerInformation signer) throws IOException
     {
         AttributeTable unsignedAttributes = signer.getUnsignedAttributes();
 
@@ -230,10 +227,6 @@ public abstract class CreateSignatureBas
         {
             throw new IOException(e);
         }
-        catch (TSPException e)
-        {
-            throw new IOException(e);
-        }
         catch (OperatorCreationException e)
         {
             throw new IOException(e);

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=1818181&r1=1818180&r2=1818181&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 Dec 14 18:40:43 2017
@@ -73,13 +73,12 @@ public final class ShowSignature
      * @throws IOException If there is an error reading the file.
      * @throws CertificateException
      * @throws java.security.NoSuchAlgorithmException
-     * @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,

+                                                  NoSuchAlgorithmException, 
                                                   NoSuchProviderException, SignatureException,
                                                   TSPException
     {
@@ -88,7 +87,7 @@ public final class ShowSignature
     }
 
     private void showSignature(String[] args) throws IOException, CertificateException,
-                                                     NoSuchAlgorithmException, InvalidKeyException,
+                                                     NoSuchAlgorithmException,
                                                      NoSuchProviderException, SignatureException,
                                                      TSPException
     {
@@ -259,8 +258,8 @@ public final class ShowSignature
         Store certificatesStore = signedData.getCertificates();
         Collection<SignerInformation> signers = signedData.getSignerInfos().getSigners();
         SignerInformation signerInformation = signers.iterator().next();
-        Collection matches = certificatesStore.getMatches(signerInformation.getSID());
-        X509CertificateHolder certificateHolder = (X509CertificateHolder) matches.iterator().next();
+        Collection<X509CertificateHolder> matches = certificatesStore.getMatches(signerInformation.getSID());
+        X509CertificateHolder certificateHolder = matches.iterator().next();
         X509Certificate certFromSignedData = new JcaX509CertificateConverter().getCertificate(certificateHolder);
         System.out.println("certFromSignedData: " + certFromSignedData);
         certFromSignedData.checkValidity(sig.getSignDate().getTime());



Mime
View raw message