pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1847912 - /pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CertificateVerifier.java
Date Sat, 01 Dec 2018 19:09:53 GMT
Author: tilman
Date: Sat Dec  1 19:09:52 2018
New Revision: 1847912

URL: http://svn.apache.org/viewvc?rev=1847912&view=rev
Log:
PDFBOX-3017: less nesting

Modified:
    pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CertificateVerifier.java

Modified: pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CertificateVerifier.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CertificateVerifier.java?rev=1847912&r1=1847911&r2=1847912&view=diff
==============================================================================
--- pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CertificateVerifier.java
(original)
+++ pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/cert/CertificateVerifier.java
Sat Dec  1 19:09:52 2018
@@ -331,37 +331,37 @@ public final class CertificateVerifier
             // AccessDescription
             ASN1Sequence obj = (ASN1Sequence) objects.nextElement();
             ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) obj.getObjectAt(0);
-            if (oid.equals(X509ObjectIdentifiers.id_ad_caIssuers))
+            if (!oid.equals(X509ObjectIdentifiers.id_ad_caIssuers))
             {
-                DERTaggedObject location = (DERTaggedObject) obj.getObjectAt(1);
-                DEROctetString uri = (DEROctetString) location.getObject();
-                InputStream in = null;
-                try
-                {
-                    URL certUrl = new URL(new String(uri.getOctets()));
-                    LOG.info("CA issuers URL: " + certUrl);
-                    CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
-
-                    in = certUrl.openStream();
-                    Collection<? extends Certificate> altCerts = certFactory.generateCertificates(in);
-                    for (Certificate altCert : altCerts)
-                    {
-                        resultSet.add((X509Certificate) altCert);
-                    }
-                    LOG.info("CA issuers URL: " + altCerts.size() + " certificate(s) downloaded");
-                }
-                catch (IOException ex)
-                {
-                    LOG.warn(ex.getMessage(), ex);
-                }
-                catch (CertificateException ex)
-                {
-                    LOG.warn(ex.getMessage(), ex);
-                }
-                finally
+                continue;
+            }
+            DERTaggedObject location = (DERTaggedObject) obj.getObjectAt(1);
+            DEROctetString uri = (DEROctetString) location.getObject();
+            InputStream in = null;
+            try
+            {
+                URL certUrl = new URL(new String(uri.getOctets()));
+                LOG.info("CA issuers URL: " + certUrl);
+                CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
+                in = certUrl.openStream();
+                Collection<? extends Certificate> altCerts = certFactory.generateCertificates(in);
+                for (Certificate altCert : altCerts)
                 {
-                    IOUtils.closeQuietly(in);
+                    resultSet.add((X509Certificate) altCert);
                 }
+                LOG.info("CA issuers URL: " + altCerts.size() + " certificate(s) downloaded");
+            }
+            catch (IOException ex)
+            {
+                LOG.warn(ex.getMessage(), ex);
+            }
+            catch (CertificateException ex)
+            {
+                LOG.warn(ex.getMessage(), ex);
+            }
+            finally
+            {
+                IOUtils.closeQuietly(in);
             }
         }
         LOG.info("CA issuers: Downloaded " + resultSet.size() + " certificate(s) total");



Mime
View raw message