mirror of https://github.com/apache/jclouds.git
Add support for getting ciphers through the Crypto interface
This commit is contained in:
parent
a50c092836
commit
3a53a4e5fa
|
@ -25,7 +25,9 @@ import java.security.MessageDigest;
|
|||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
|
||||
import org.jclouds.encryption.internal.JCECrypto;
|
||||
|
||||
|
@ -61,4 +63,6 @@ public interface Crypto {
|
|||
|
||||
MessageDigest sha512();
|
||||
|
||||
Cipher cipher(String algorithm) throws NoSuchAlgorithmException, NoSuchPaddingException;
|
||||
|
||||
}
|
|
@ -28,7 +28,10 @@ import java.security.cert.CertificateException;
|
|||
import java.security.cert.CertificateFactory;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
@ -86,6 +89,11 @@ public class JCECrypto implements Crypto {
|
|||
return provider == null ? MessageDigest.getInstance(algorithm) : MessageDigest.getInstance(algorithm, provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cipher cipher(String algorithm) throws NoSuchAlgorithmException, NoSuchPaddingException {
|
||||
return provider == null ? Cipher.getInstance(algorithm) : Cipher.getInstance(algorithm, provider);
|
||||
}
|
||||
|
||||
public final static String MD5 = "MD5";
|
||||
public final static String SHA1 = "SHA1";
|
||||
public final static String SHA256 = "SHA-256";
|
||||
|
|
Loading…
Reference in New Issue