Author: coheigea
Date: Sun Sep 12 17:32:46 2010
New Revision: 996345

URL: http://svn.apache.org/viewvc?rev=996345&view=rev
Log:
[WSS-244] -  Loading of Signature and Encryption property files not trimming 
trailing whitespace

Modified:
    webservices/wss4j/trunk/   (props changed)
    
webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/AbstractCrypto.java
    
webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoFactory.java
    webservices/wss4j/trunk/test/wssec/PackageTests.java

Propchange: webservices/wss4j/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Sep 12 17:32:46 2010
@@ -1 +1 @@
-/webservices/wss4j/branches/1_5_x-fixes:996180,996298
+/webservices/wss4j/branches/1_5_x-fixes:996180,996298,996339

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/AbstractCrypto.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/AbstractCrypto.java?rev=996345&r1=996344&r2=996345&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/AbstractCrypto.java
 (original)
+++ 
webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/AbstractCrypto.java
 Sun Sep 12 17:32:46 2010
@@ -112,6 +112,9 @@ public abstract class AbstractCrypto ext
         if (provider == null) {
             provider = properties.getProperty(OLD_CRYPTO_PROVIDER);
         }
+        if (provider != null) {
+            provider = provider.trim();
+        }
         //
         // Load the KeyStore
         //
@@ -120,11 +123,18 @@ public abstract class AbstractCrypto ext
             keyStoreLocation = properties.getProperty(OLD_KEYSTORE_FILE);
         }
         if (keyStoreLocation != null) {
+            keyStoreLocation = keyStoreLocation.trim();
             InputStream is = loadInputStream(loader, keyStoreLocation);
 
             try {
                 String passwd = properties.getProperty(KEYSTORE_PASSWORD, 
"security");
+                if (passwd != null) {
+                    passwd = passwd.trim();
+                }
                 String type = properties.getProperty(KEYSTORE_TYPE, 
KeyStore.getDefaultType());
+                if (type != null) {
+                    type = type.trim();
+                }
                 keystore = load(is, passwd, provider, type);
                 if (doDebug) {
                     log.debug(
@@ -148,11 +158,18 @@ public abstract class AbstractCrypto ext
         //
         String trustStoreLocation = properties.getProperty(TRUSTSTORE_FILE);
         if (trustStoreLocation != null) {
+            trustStoreLocation = trustStoreLocation.trim();
             InputStream is = loadInputStream(loader, trustStoreLocation);
 
             try {
                 String passwd = properties.getProperty(TRUSTSTORE_PASSWORD, 
"changeit");
+                if (passwd != null) {
+                    passwd.trim();
+                }
                 String type = properties.getProperty(TRUSTSTORE_TYPE, 
KeyStore.getDefaultType());
+                if (type != null) {
+                    type = type.trim();
+                }
                 truststore = load(is, passwd, provider, type);
                 if (doDebug) {
                     log.debug(
@@ -167,11 +184,20 @@ public abstract class AbstractCrypto ext
             }
         } else {
             String loadCacerts = properties.getProperty(LOAD_CA_CERTS, 
"false");
+            if (loadCacerts != null) {
+                loadCacerts = loadCacerts.trim();
+            }
             if (Boolean.valueOf(loadCacerts).booleanValue()) {
                 String cacertsPath = System.getProperty("java.home") + 
"/lib/security/cacerts";
+                if (cacertsPath != null) {
+                    cacertsPath = cacertsPath.trim();
+                }
                 InputStream is = new FileInputStream(cacertsPath);
                 try {
                     String cacertsPasswd = 
properties.getProperty(TRUSTSTORE_PASSWORD, "changeit");
+                    if (cacertsPasswd != null) {
+                        cacertsPasswd = cacertsPasswd.trim();
+                    }
                     truststore = load(is, cacertsPasswd, null, 
KeyStore.getDefaultType());
                     if (doDebug) {
                         log.debug("CA certs have been loaded");
@@ -269,6 +295,9 @@ public abstract class AbstractCrypto ext
         if (provider == null) {
             provider = properties.getProperty(OLD_CRYPTO_CERT_PROVIDER);
         }
+        if (provider != null) {
+            provider = provider.trim();
+        }
         return provider;
     }
     
@@ -285,6 +314,10 @@ public abstract class AbstractCrypto ext
         if (properties == null) {
             return null;
         }
-        return properties.getProperty(KEYSTORE_ALIAS);
+        String alias = properties.getProperty(KEYSTORE_ALIAS);
+        if (alias != null) {
+            alias = alias.trim();
+        }
+        return alias;
     }
 }

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoFactory.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoFactory.java?rev=996345&r1=996344&r2=996345&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoFactory.java
 (original)
+++ 
webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoFactory.java
 Sun Sep 12 17:32:46 2010
@@ -172,6 +172,10 @@ public abstract class CryptoFactory {
     private static Crypto loadClass(String cryptoClassName, Map map, 
ClassLoader loader) {
         Class cryptogenClass = null;
         Crypto crypto = null;
+        
+        if (cryptoClassName != null) {
+            cryptoClassName = cryptoClassName.trim();
+        }
         try {
             // instruct the class loader to load the crypto implementation
             cryptogenClass = Loader.loadClass(loader, cryptoClassName);

Modified: webservices/wss4j/trunk/test/wssec/PackageTests.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/PackageTests.java?rev=996345&r1=996344&r2=996345&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/PackageTests.java (original)
+++ webservices/wss4j/trunk/test/wssec/PackageTests.java Sun Sep 12 17:32:46 
2010
@@ -78,6 +78,7 @@ public class PackageTests extends TestCa
         suite.addTestSuite(TestModifiedRequest.class);
         suite.addTestSuite(TestWSSecurityWSS199.class);
         suite.addTestSuite(TestWSSecurityWSS234.class);
+        suite.addTestSuite(TestWSSecurityWSS245.class);
         
         return suite;
     }



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

Reply via email to