mirror of https://github.com/apache/jclouds.git
Merge pull request #169 from iocanel/master
Don't fail when the JCE provider fails.
This commit is contained in:
commit
24d5b13747
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue