You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2015/04/21 16:20:43 UTC

[1/5] cxf git commit: Cater for null signature algorithms

Repository: cxf
Updated Branches:
  refs/heads/master 9bcc593c1 -> 7e9519ec8


Cater for null signature algorithms


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/7e9519ec
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/7e9519ec
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/7e9519ec

Branch: refs/heads/master
Commit: 7e9519ec8b0e92ffb176d25437ed3e99a9444a4d
Parents: 57f7475
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Tue Apr 21 15:18:42 2015 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Tue Apr 21 15:20:29 2015 +0100

----------------------------------------------------------------------
 .../apache/cxf/rs/security/jose/jws/JwsUtils.java   | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/7e9519ec/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsUtils.java b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsUtils.java
index eabbea0..5fc23db 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsUtils.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsUtils.java
@@ -97,10 +97,18 @@ public final class JwsUtils {
         return theSigProvider;
     }
     public static JwsSignatureProvider getRSAKeySignatureProvider(RSAPrivateKey key, String algo) {
+        if (algo == null) {
+            LOG.warning("No signature algorithm was defined");
+            throw new JwsException(JwsException.Error.ALGORITHM_NOT_SET);
+        }
         return new PrivateKeyJwsSignatureProvider(key, SignatureAlgorithm.getAlgorithm(algo));
     }
     public static JwsSignatureProvider getHmacSignatureProvider(byte[] key, String algo) {
         if (AlgorithmUtils.isHmacSign(algo)) {
+            if (algo == null) {
+                LOG.warning("No signature algorithm was defined");
+                throw new JwsException(JwsException.Error.ALGORITHM_NOT_SET);
+            }
             return new HmacJwsSignatureProvider(key, SignatureAlgorithm.getAlgorithm(algo));
         }
         return null;
@@ -126,10 +134,18 @@ public final class JwsUtils {
         return getRSAKeySignatureVerifier((RSAPublicKey)cert.getPublicKey(), algo);
     }
     public static JwsSignatureVerifier getRSAKeySignatureVerifier(RSAPublicKey key, String algo) {
+        if (algo == null) {
+            LOG.warning("No signature algorithm was defined");
+            throw new JwsException(JwsException.Error.ALGORITHM_NOT_SET);
+        }
         return new PublicKeyJwsSignatureVerifier(key, SignatureAlgorithm.getAlgorithm(algo));
     }
     public static JwsSignatureVerifier getHmacSignatureVerifier(byte[] key, String algo) {
         if (AlgorithmUtils.isHmacSign(algo)) {
+            if (algo == null) {
+                LOG.warning("No signature algorithm was defined");
+                throw new JwsException(JwsException.Error.ALGORITHM_NOT_SET);
+            }
             return new HmacJwsSignatureVerifier(key, SignatureAlgorithm.getAlgorithm(algo));
         }
         return null;


[5/5] cxf git commit: Avoid NPE if the keystore does not contain the given alias

Posted by co...@apache.org.
Avoid NPE if the keystore does not contain the given alias


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/8c8ed166
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/8c8ed166
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/8c8ed166

Branch: refs/heads/master
Commit: 8c8ed16605a2d7468da380155e9aa4c4bbd62031
Parents: e4feffb
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Tue Apr 21 14:48:50 2015 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Tue Apr 21 15:20:29 2015 +0100

----------------------------------------------------------------------
 .../main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java  | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/8c8ed166/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java b/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java
index 1b732e5..5495fbc 100644
--- a/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java
@@ -637,6 +637,9 @@ public final class CryptoUtils {
     }
     public static Certificate loadCertificate(KeyStore keyStore, String alias) {
         try {
+            if (!keyStore.containsAlias(alias)) {
+                throw new SecurityException("No alias exists in the keystore for the given alias: " + alias);
+            }
             return keyStore.getCertificate(alias);
         } catch (Exception ex) { 
             throw new SecurityException(ex);


[2/5] cxf git commit: Avoid NPE if no keystore password was provided

Posted by co...@apache.org.
Avoid NPE if no keystore password was provided


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/4fdb9510
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/4fdb9510
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/4fdb9510

Branch: refs/heads/master
Commit: 4fdb951039dd8c7bd840d85e68e4225057f2d52d
Parents: 8c8ed16
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Tue Apr 21 14:50:43 2015 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Tue Apr 21 15:20:29 2015 +0100

----------------------------------------------------------------------
 .../apache/cxf/rs/security/jose/jaxrs/KeyManagementUtils.java    | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/4fdb9510/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jaxrs/KeyManagementUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jaxrs/KeyManagementUtils.java b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jaxrs/KeyManagementUtils.java
index c434fa5..0447a19 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jaxrs/KeyManagementUtils.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jaxrs/KeyManagementUtils.java
@@ -226,6 +226,10 @@ public final class KeyManagementUtils {
         String keyStoreType = props.getProperty(RSSEC_KEY_STORE_TYPE);
         String keyStoreLoc = props.getProperty(RSSEC_KEY_STORE_FILE);
         String keyStorePswd = props.getProperty(RSSEC_KEY_STORE_PSWD);
+        
+        if (keyStorePswd == null) {
+            throw new JoseException("No keystore password was defined");
+        }
         try {
             InputStream is = ResourceUtils.getResourceStream(keyStoreLoc, bus);
             return CryptoUtils.loadKeyStore(is, keyStorePswd.toCharArray(), keyStoreType);


[3/5] cxf git commit: Avoid a NPE if the keystore file is not configured

Posted by co...@apache.org.
Avoid a NPE if the keystore file is not configured


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/e4feffb6
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/e4feffb6
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/e4feffb6

Branch: refs/heads/master
Commit: e4feffb6f13fd5ba1c8c76bb2301d2d1a13fd43a
Parents: 9bcc593
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Tue Apr 21 14:41:02 2015 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Tue Apr 21 15:20:29 2015 +0100

----------------------------------------------------------------------
 .../apache/cxf/rs/security/jose/jaxrs/KeyManagementUtils.java    | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/e4feffb6/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jaxrs/KeyManagementUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jaxrs/KeyManagementUtils.java b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jaxrs/KeyManagementUtils.java
index 5a1fe60..c434fa5 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jaxrs/KeyManagementUtils.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jaxrs/KeyManagementUtils.java
@@ -211,6 +211,10 @@ public final class KeyManagementUtils {
         return (RSAPrivateKey)loadPrivateKey(keyStore, m, props, bus, cb, keyOper, alias);
     }
     public static KeyStore loadPersistKeyStore(Message m, Properties props) {
+        if (!props.containsKey(RSSEC_KEY_STORE_FILE)) {
+            LOG.warning("No keystore file has been configured");
+            throw new JoseException("No keystore file has been configured");
+        }
         KeyStore keyStore = (KeyStore)m.getExchange().get(props.get(RSSEC_KEY_STORE_FILE));
         if (keyStore == null) {
             keyStore = loadKeyStore(props, m.getExchange().getBus());


[4/5] cxf git commit: Also cater for null aliases

Posted by co...@apache.org.
Also cater for null aliases


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/57f74751
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/57f74751
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/57f74751

Branch: refs/heads/master
Commit: 57f74751675a5339e0cacf48a480be994f4ee064
Parents: 4fdb951
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Tue Apr 21 15:18:29 2015 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Tue Apr 21 15:20:29 2015 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/common/util/crypto/CryptoUtils.java   | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/57f74751/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java b/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java
index 5495fbc..7cbda36 100644
--- a/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java
@@ -637,8 +637,11 @@ public final class CryptoUtils {
     }
     public static Certificate loadCertificate(KeyStore keyStore, String alias) {
         try {
+            if (alias == null) {
+                throw new SecurityException("No keystore alias was defined");
+            }
             if (!keyStore.containsAlias(alias)) {
-                throw new SecurityException("No alias exists in the keystore for the given alias: " + alias);
+                throw new SecurityException("No alias exists in the keystore for: " + alias);
             }
             return keyStore.getCertificate(alias);
         } catch (Exception ex) { 
@@ -689,6 +692,12 @@ public final class CryptoUtils {
                                             char[] keyPassword, 
                                             String alias) {
         try {
+            if (alias == null) {
+                throw new SecurityException("No keystore alias was defined");
+            }
+            if (!keyStore.containsAlias(alias)) {
+                throw new SecurityException("No alias exists in the keystore for: " + alias);
+            }
             KeyStore.PrivateKeyEntry pkEntry = (KeyStore.PrivateKeyEntry)
                 keyStore.getEntry(alias, new KeyStore.PasswordProtection(keyPassword));
             return pkEntry.getPrivateKey();