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 17:06:53 UTC

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

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/2df8ea0b
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/2df8ea0b
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/2df8ea0b

Branch: refs/heads/3.0.x-fixes
Commit: 2df8ea0b32d7abbfbfb4710501e3489f913a6d37
Parents: a12ca52
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:54:04 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/2df8ea0b/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 3d8d38c..207f2a2 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;