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 62E98200CD7 for ; Mon, 17 Jul 2017 20:21:40 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 615C9165629; Mon, 17 Jul 2017 18:21:40 +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 B076516562F for ; Mon, 17 Jul 2017 20:21:39 +0200 (CEST) Received: (qmail 81836 invoked by uid 500); 17 Jul 2017 18:21:38 -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 81784 invoked by uid 99); 17 Jul 2017 18:21:37 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Jul 2017 18:21:37 +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 782443A012C for ; Mon, 17 Jul 2017 18:21:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1802185 - /pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.java Date: Mon, 17 Jul 2017 18:21:37 -0000 To: commits@pdfbox.apache.org From: tilman@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170717182137.782443A012C@svn01-us-west.apache.org> archived-at: Mon, 17 Jul 2017 18:21:40 -0000 Author: tilman Date: Mon Jul 17 18:21:37 2017 New Revision: 1802185 URL: http://svn.apache.org/viewvc?rev=1802185&view=rev Log: PDFBOX-3017: remove certificate and use certificateChain[0] instead Modified: pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.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=1802185&r1=1802184&r2=1802185&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 Mon Jul 17 18:21:37 2017 @@ -65,7 +65,6 @@ import org.bouncycastle.util.Store; public abstract class CreateSignatureBase implements SignatureInterface { private PrivateKey privateKey; - private Certificate certificate; private Certificate[] certificateChain; private TSAClient tsaClient; private boolean externalSigning; @@ -101,8 +100,7 @@ public abstract class CreateSignatureBas continue; } setCertificateChain(certChain); - cert = keystore.getCertificate(alias); - setCertificate(cert); + cert = certChain[0]; if (cert instanceof X509Certificate) { // avoid expired certificate @@ -122,11 +120,6 @@ public abstract class CreateSignatureBas this.privateKey = privateKey; } - public final void setCertificate(Certificate certificate) - { - this.certificate = certificate; - } - public final void setCertificateChain(final Certificate[] certificateChain) { this.certificateChain = certificateChain; @@ -221,10 +214,9 @@ public abstract class CreateSignatureBas { List certList = new ArrayList(); certList.addAll(Arrays.asList(certificateChain)); - certList.add(certificate); Store certs = new JcaCertStore(certList); CMSSignedDataGenerator gen = new CMSSignedDataGenerator(); - org.bouncycastle.asn1.x509.Certificate cert = org.bouncycastle.asn1.x509.Certificate.getInstance(certificate.getEncoded()); + org.bouncycastle.asn1.x509.Certificate cert = org.bouncycastle.asn1.x509.Certificate.getInstance(certificateChain[0].getEncoded()); ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA256WithRSA").build(privateKey); gen.addSignerInfoGenerator(new JcaSignerInfoGeneratorBuilder(new JcaDigestCalculatorProviderBuilder().build()).build(sha1Signer, new X509CertificateHolder(cert))); gen.addCertificates(certs);