cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r759962 - /cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
Date Mon, 30 Mar 2009 13:34:43 GMT
Author: dkulp
Date: Mon Mar 30 13:34:43 2009
New Revision: 759962

URL: http://svn.apache.org/viewvc?rev=759962&view=rev
Log:
Throw a better exception than a NPE if the crypto properties are not given

Modified:
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java?rev=759962&r1=759961&r2=759962&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
(original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
Mon Mar 30 13:34:43 2009
@@ -995,25 +995,28 @@
         String encrUser = (String)message.getContextualProperty(sign 
                                                                 ? SecurityConstants.SIGNATURE_USERNAME
                                                                 : SecurityConstants.ENCRYPT_USERNAME);
-        if (encrUser == null) {
-            encrUser = crypto.getDefaultX509Alias();
-        }
-        if (encrUser == null) {
-            try {
-                Enumeration<String> en = crypto.getKeyStore().aliases();
-                if (en.hasMoreElements()) {
-                    encrUser = en.nextElement();
-                }
-                if (en.hasMoreElements()) {
-                    //more than one alias in the keystore, user WILL need
-                    //to specify
-                    encrUser = null;
-                }            
-            } catch (KeyStoreException e) {
-                //ignore
+        if (crypto != null) {
+            if (encrUser == null) {
+                encrUser = crypto.getDefaultX509Alias();
             }
+            if (encrUser == null) {
+                try {
+                    Enumeration<String> en = crypto.getKeyStore().aliases();
+                    if (en.hasMoreElements()) {
+                        encrUser = en.nextElement();
+                    }
+                    if (en.hasMoreElements()) {
+                        //more than one alias in the keystore, user WILL need
+                        //to specify
+                        encrUser = null;
+                    }            
+                } catch (KeyStoreException e) {
+                    //ignore
+                }
+            }
+        } else if (encrUser == null || "".equals(encrUser)) {
+            policyNotAsserted(token, "No " + (sign ? "signature" : "encryption") + " crypto
object found.");
         }
-
         if (encrUser == null || "".equals(encrUser)) {
             policyNotAsserted(token, "No " + (sign ? "signature" : "encryption") + " username
found.");
         }



Mime
View raw message