You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2019/11/15 05:00:14 UTC

svn commit: r1869827 - /pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/CertInformationCollector.java

Author: tilman
Date: Fri Nov 15 05:00:14 2019
New Revision: 1869827

URL: http://svn.apache.org/viewvc?rev=1869827&view=rev
Log:
PDFBOX-3017: remove unneeded cast

Modified:
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/CertInformationCollector.java

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/CertInformationCollector.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/CertInformationCollector.java?rev=1869827&r1=1869826&r2=1869827&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/CertInformationCollector.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/CertInformationCollector.java Fri Nov 15 05:00:14 2019
@@ -40,7 +40,6 @@ import org.apache.pdfbox.examples.signat
 import org.apache.pdfbox.pdmodel.encryption.SecurityProvider;
 import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature;
 import org.bouncycastle.asn1.ASN1Object;
-import org.bouncycastle.asn1.ASN1Set;
 import org.bouncycastle.asn1.cms.Attribute;
 import org.bouncycastle.asn1.cms.AttributeTable;
 import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
@@ -145,28 +144,23 @@ public class CertInformationCollector
         }
         Attribute tsAttribute = signerInformation.getUnsignedAttributes()
                 .get(PKCSObjectIdentifiers.id_aa_signatureTimeStampToken);
-        if (tsAttribute.getAttrValues() instanceof ASN1Set)
+
+        ASN1Object tsSeq = (ASN1Object) tsAttribute.getAttrValues().getObjectAt(0);
+
+        try
         {
-            ASN1Set tsSet = (ASN1Set) tsAttribute.getAttrValues();
-            ASN1Object tsSeq = (ASN1Object) tsSet.getObjectAt(0);
+            TimeStampToken tsToken = new TimeStampToken(new CMSSignedData(tsSeq.getEncoded("DER")));
+
+            rootCertInfo.tsaCerts = new CertSignatureInformation();
 
-            try
-            {
-                TimeStampToken tsToken = new TimeStampToken(
-                        new CMSSignedData(tsSeq.getEncoded("DER")));
-
-                rootCertInfo.tsaCerts = new CertSignatureInformation();
-
-                @SuppressWarnings("unchecked")
-                Store<X509CertificateHolder> certificatesStore = tsToken.getCertificates();
-
-                processSignerStore(certificatesStore, tsToken.toCMSSignedData(),
-                        rootCertInfo.tsaCerts);
-            }
-            catch (TSPException | CMSException e)
-            {
-                throw new IOException("Error parsing timestamp token", e);
-            }
+            @SuppressWarnings("unchecked")
+            Store<X509CertificateHolder> certificatesStore = tsToken.getCertificates();
+
+            processSignerStore(certificatesStore, tsToken.toCMSSignedData(), rootCertInfo.tsaCerts);
+        }
+        catch (TSPException | CMSException e)
+        {
+            throw new IOException("Error parsing timestamp token", e);
         }
     }