pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1867894 - in /pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature: cert/CRLVerifier.java cert/CertificateVerifier.java validation/CertInformationHelper.java
Date Wed, 02 Oct 2019 17:37:05 GMT
Author: tilman
Date: Wed Oct  2 17:37:05 2019
New Revision: 1867894

URL: http://svn.apache.org/viewvc?rev=1867894&view=rev
Log:
PDFBOX-4662: avoid ClassCastException by using base classes, because of different BC behaviour
1.62 and 1.63

Modified:
    pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CRLVerifier.java
    pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CertificateVerifier.java
    pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/CertInformationHelper.java

Modified: pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CRLVerifier.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CRLVerifier.java?rev=1867894&r1=1867893&r2=1867894&view=diff
==============================================================================
--- pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CRLVerifier.java
(original)
+++ pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CRLVerifier.java
Wed Oct  2 17:37:05 2019
@@ -47,9 +47,9 @@ import org.apache.commons.logging.LogFac
 import org.apache.pdfbox.pdmodel.encryption.SecurityProvider;
 
 import org.bouncycastle.asn1.ASN1InputStream;
+import org.bouncycastle.asn1.ASN1OctetString;
 import org.bouncycastle.asn1.ASN1Primitive;
 import org.bouncycastle.asn1.DERIA5String;
-import org.bouncycastle.asn1.DEROctetString;
 import org.bouncycastle.asn1.x509.CRLDistPoint;
 import org.bouncycastle.asn1.x509.DistributionPoint;
 import org.bouncycastle.asn1.x509.DistributionPointName;
@@ -305,7 +305,7 @@ public final class CRLVerifier
         }
         ASN1InputStream oAsnInStream = new ASN1InputStream(new ByteArrayInputStream(crldpExt));
         ASN1Primitive derObjCrlDP = oAsnInStream.readObject();
-        DEROctetString dosCrlDP = (DEROctetString) derObjCrlDP;
+        ASN1OctetString dosCrlDP = (ASN1OctetString) derObjCrlDP;
         byte[] crldpExtOctets = dosCrlDP.getOctets();
         ASN1InputStream oAsnInStream2 = new ASN1InputStream(new ByteArrayInputStream(crldpExtOctets));
         ASN1Primitive derObj2 = oAsnInStream2.readObject();

Modified: pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CertificateVerifier.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CertificateVerifier.java?rev=1867894&r1=1867893&r2=1867894&view=diff
==============================================================================
--- pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CertificateVerifier.java
(original)
+++ pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CertificateVerifier.java
Wed Oct  2 17:37:05 2019
@@ -50,10 +50,10 @@ import org.apache.commons.logging.LogFac
 import org.apache.pdfbox.io.IOUtils;
 import org.apache.pdfbox.pdmodel.encryption.SecurityProvider;
 import org.bouncycastle.asn1.ASN1ObjectIdentifier;
+import org.bouncycastle.asn1.ASN1OctetString;
 import org.bouncycastle.asn1.ASN1Primitive;
 import org.bouncycastle.asn1.ASN1Sequence;
-import org.bouncycastle.asn1.DEROctetString;
-import org.bouncycastle.asn1.DERTaggedObject;
+import org.bouncycastle.asn1.ASN1TaggedObject;
 import org.bouncycastle.asn1.ocsp.OCSPObjectIdentifiers;
 import org.bouncycastle.asn1.x509.Extension;
 import org.bouncycastle.asn1.x509.GeneralName;
@@ -302,8 +302,8 @@ public final class CertificateVerifier
             {
                 continue;
             }
-            DERTaggedObject location = (DERTaggedObject) obj.getObjectAt(1);
-            DEROctetString uri = (DEROctetString) location.getObject();
+            ASN1TaggedObject location = (ASN1TaggedObject) obj.getObjectAt(1);
+            ASN1OctetString uri = (ASN1OctetString) location.getObject();
             InputStream in = null;
             try
             {
@@ -413,11 +413,11 @@ public final class CertificateVerifier
                 ASN1Sequence obj = (ASN1Sequence) objects.nextElement();
                 ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) obj.getObjectAt(0);
                 // accessLocation
-                DERTaggedObject location = (DERTaggedObject) obj.getObjectAt(1);
+                ASN1TaggedObject location = (ASN1TaggedObject) obj.getObjectAt(1);
                 if (oid.equals(X509ObjectIdentifiers.id_ad_ocsp)
                         && location.getTagNo() == GeneralName.uniformResourceIdentifier)
                 {
-                    DEROctetString url = (DEROctetString) location.getObject();
+                    ASN1OctetString url = (ASN1OctetString) location.getObject();
                     String ocspURL = new String(url.getOctets());
                     LOG.info("OCSP URL: " + ocspURL);
                     return ocspURL;

Modified: pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/CertInformationHelper.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/CertInformationHelper.java?rev=1867894&r1=1867893&r2=1867894&view=diff
==============================================================================
--- pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/CertInformationHelper.java
(original)
+++ pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/CertInformationHelper.java
Wed Oct  2 17:37:05 2019
@@ -26,8 +26,9 @@ import org.apache.commons.logging.LogFac
 import org.apache.pdfbox.examples.signature.validation.CertInformationCollector.CertSignatureInformation;
 import org.apache.pdfbox.util.Hex;
 import org.bouncycastle.asn1.ASN1ObjectIdentifier;
+import org.bouncycastle.asn1.ASN1OctetString;
 import org.bouncycastle.asn1.ASN1Sequence;
-import org.bouncycastle.asn1.DEROctetString;
+import org.bouncycastle.asn1.ASN1TaggedObject;
 import org.bouncycastle.asn1.DERTaggedObject;
 import org.bouncycastle.asn1.DLSequence;
 import org.bouncycastle.asn1.x509.GeneralName;
@@ -81,17 +82,17 @@ public class CertInformationHelper
             ASN1Sequence obj = (ASN1Sequence) objects.nextElement();
             ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) obj.getObjectAt(0);
             // accessLocation
-            DERTaggedObject location = (DERTaggedObject) obj.getObjectAt(1);
+            ASN1TaggedObject location = (ASN1TaggedObject) obj.getObjectAt(1);
 
             if (oid.equals(X509ObjectIdentifiers.id_ad_ocsp)
                     && location.getTagNo() == GeneralName.uniformResourceIdentifier)
             {
-                DEROctetString url = (DEROctetString) location.getObject();
+                ASN1OctetString url = (ASN1OctetString) location.getObject();
                 certInfo.setOcspUrl(new String(url.getOctets()));
             }
             else if (oid.equals(X509ObjectIdentifiers.id_ad_caIssuers))
             {
-                DEROctetString uri = (DEROctetString) location.getObject();
+                ASN1OctetString uri = (ASN1OctetString) location.getObject();
                 certInfo.setIssuerUrl(new String(uri.getOctets()));
             }
         }
@@ -117,12 +118,12 @@ public class CertInformationHelper
             DERTaggedObject derTagged = (DERTaggedObject) obj.getObjectAt(0);
             derTagged = (DERTaggedObject) derTagged.getObject();
             derTagged = (DERTaggedObject) derTagged.getObject();
-            if (!(derTagged.getObject() instanceof DEROctetString))
+            if (!(derTagged.getObject() instanceof ASN1OctetString))
             {
                 // happens with SampleSignedPDFDocument.pdf
                 continue;
             }
-            DEROctetString uri = (DEROctetString) derTagged.getObject();
+            ASN1OctetString uri = (ASN1OctetString) derTagged.getObject();
             String url = new String(uri.getOctets());
             // TODO Check for: DistributionPoint ::= SEQUENCE (see RFC 2459), multiples can
be possible.
 



Mime
View raw message