Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 80C60200D5A for ; Thu, 14 Dec 2017 19:40:49 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 7F201160C16; Thu, 14 Dec 2017 18:40:49 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C5ABB160BFC for ; Thu, 14 Dec 2017 19:40:48 +0100 (CET) Received: (qmail 92229 invoked by uid 500); 14 Dec 2017 18:40:48 -0000 Mailing-List: contact commits-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pdfbox.apache.org Delivered-To: mailing list commits@pdfbox.apache.org Received: (qmail 92220 invoked by uid 99); 14 Dec 2017 18:40:48 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Dec 2017 18:40:47 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id AEF7B3A00A2 for ; Thu, 14 Dec 2017 18:40:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@pdfbox.apache.org From: tilman@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20171214184046.AEF7B3A00A2@svn01-us-west.apache.org> archived-at: Thu, 14 Dec 2017 18:40:49 -0000 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 newSigners = new ArrayList(); @@ -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 signers = signedData.getSignerInfos().getSigners(); SignerInformation signerInformation = signers.iterator().next(); - Collection matches = certificatesStore.getMatches(signerInformation.getSID()); - X509CertificateHolder certificateHolder = (X509CertificateHolder) matches.iterator().next(); + Collection 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());