You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2013/03/07 12:17:16 UTC

svn commit: r1453775 - /webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/CryptoFactory.java

Author: coheigea
Date: Thu Mar  7 11:17:15 2013
New Revision: 1453775

URL: http://svn.apache.org/r1453775
Log:
Avoid a NPE in CryptoFactory on a null Properties object


Conflicts:
	ws-security-common/src/main/java/org/apache/wss4j/common/crypto/CryptoFactory.java

Modified:
    webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/CryptoFactory.java

Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/CryptoFactory.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/CryptoFactory.java?rev=1453775&r1=1453774&r2=1453775&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/CryptoFactory.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/CryptoFactory.java Thu Mar  7 11:17:15 2013
@@ -73,6 +73,13 @@ public abstract class CryptoFactory {
      * @throws WSSecurityException if there is an error in loading the crypto properties
      */
     public static Crypto getInstance(Properties properties) throws WSSecurityException {
+        if (properties == null) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Cannot load Crypto instance as properties object is null");
+            }
+            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
+                    "empty", null, "Cannot load Crypto instance as properties object is null");
+        }
         return getInstance(properties, Loader.getClassLoader(CryptoFactory.class));
     }
 
@@ -96,6 +103,14 @@ public abstract class CryptoFactory {
         Properties properties, 
         ClassLoader classLoader
     ) throws WSSecurityException {
+        if (properties == null) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Cannot load Crypto instance as properties object is null");
+            }
+            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
+                    "empty", null, "Cannot load Crypto instance as properties object is null");
+        }
+
         String cryptoClassName = properties.getProperty("org.apache.wss4j.crypto.provider");
         if (cryptoClassName == null) {
             cryptoClassName = properties.getProperty("org.apache.ws.security.crypto.provider");