You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wss4j-dev@ws.apache.org by co...@apache.org on 2009/10/19 12:49:05 UTC

svn commit: r826631 - /webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoBase.java

Author: coheigea
Date: Mon Oct 19 10:49:05 2009
New Revision: 826631

URL: http://svn.apache.org/viewvc?rev=826631&view=rev
Log:
[WSS-210] - Fix for NPE in CryptoBase.getAliasForX509Cert() if Keystore does not contain a Certifcate entry for each alias

Modified:
    webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoBase.java

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoBase.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoBase.java?rev=826631&r1=826630&r2=826631&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoBase.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoBase.java Mon Oct 19 10:49:05 2009
@@ -310,7 +310,7 @@
         //
         try {
             X500Principal issuerRDN = new X500Principal(issuer);
-            issuerName =  createBCX509Name(issuerRDN.getName());
+            issuerName = createBCX509Name(issuerRDN.getName());
         } catch (java.lang.IllegalArgumentException ex) {
             issuerName = createBCX509Name(issuer);
         }
@@ -515,7 +515,7 @@
             for (Enumeration e = keystore.aliases(); e.hasMoreElements();) {
                 String alias = (String) e.nextElement();
                 Certificate retrievedCert = keystore.getCertificate(alias);
-                if (retrievedCert.equals(cert)) {
+                if (retrievedCert != null && retrievedCert.equals(cert)) {
                     return alias;
                 }
             }
@@ -828,9 +828,11 @@
                     String alias = (String) truststoreAliases.nextElement();
                     X509Certificate cert = 
                         (X509Certificate) truststore.getCertificate(alias);
-                    TrustAnchor anchor = 
-                        new TrustAnchor(cert, cert.getExtensionValue(NAME_CONSTRAINTS_OID));
-                    set.add(anchor);
+                    if (cert != null) {
+                        TrustAnchor anchor = 
+                            new TrustAnchor(cert, cert.getExtensionValue(NAME_CONSTRAINTS_OID));
+                        set.add(anchor);
+                    }
                 }
             }
 
@@ -841,9 +843,11 @@
                     String alias = (String) aliases.nextElement();
                     X509Certificate cert = 
                         (X509Certificate) keystore.getCertificate(alias);
-                    TrustAnchor anchor = 
-                        new TrustAnchor(cert, cert.getExtensionValue(NAME_CONSTRAINTS_OID));
-                    set.add(anchor);
+                    if (cert != null) {
+                        TrustAnchor anchor = 
+                            new TrustAnchor(cert, cert.getExtensionValue(NAME_CONSTRAINTS_OID));
+                        set.add(anchor);
+                    }
                 }
             }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org