From bd65271ce7bc4ffe28eebe16bf16796b18b9c424 Mon Sep 17 00:00:00 2001 From: Ioannis Canellos Date: Fri, 18 Nov 2011 17:18:52 +0200 Subject: [PATCH] Added a check for JCE providers that are not working. --- .../org/jclouds/encryption/internal/JCECrypto.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/jclouds/encryption/internal/JCECrypto.java b/core/src/main/java/org/jclouds/encryption/internal/JCECrypto.java index 9b539b94ec..4efa54abe0 100644 --- a/core/src/main/java/org/jclouds/encryption/internal/JCECrypto.java +++ b/core/src/main/java/org/jclouds/encryption/internal/JCECrypto.java @@ -63,7 +63,18 @@ public class JCECrypto implements Crypto { @Override public Mac hmac(String algorithm, byte[] key) throws NoSuchAlgorithmException, InvalidKeyException { - Mac mac = provider == null ? Mac.getInstance(algorithm) : Mac.getInstance(algorithm, provider); + Mac mac = null; + if(provider != null) { + try { + mac = Mac.getInstance(algorithm, provider); + } catch(Exception e) { + //Provider does not function. + //Do nothing and let it fallback to the default way. + } + } + if(mac == null) { + mac = Mac.getInstance(algorithm); + } SecretKeySpec signingKey = new SecretKeySpec(key, algorithm); mac.init(signingKey); return mac;