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 <[email protected]> Authored: Tue Apr 21 15:18:42 2015 +0100 Committer: Colm O hEigeartaigh <[email protected]> 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;
