public class SecurityUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
BOUNCY_CASTLE
Identifier for the BouncyCastle JCE provider
|
| Constructor and Description |
|---|
SecurityUtils() |
| Modifier and Type | Method and Description |
|---|---|
static javax.crypto.Cipher |
getCipher(java.lang.String transformation) |
static java.lang.String |
getFingerprint(java.security.PublicKey key)
Computes the fingerprint for a public key, in the standard SSH format, e.g.
|
static javax.crypto.KeyAgreement |
getKeyAgreement(java.lang.String algorithm)
Creates a new instance of
KeyAgreement with the given algorithm. |
static java.security.KeyFactory |
getKeyFactory(java.lang.String algorithm)
Creates a new instance of
KeyFactory with the given algorithm. |
static java.security.KeyPairGenerator |
getKeyPairGenerator(java.lang.String algorithm)
Creates a new instance of
KeyPairGenerator with the given algorithm. |
static javax.crypto.Mac |
getMAC(java.lang.String algorithm)
Create a new instance of
Mac with the given algorithm. |
static java.security.MessageDigest |
getMessageDigest(java.lang.String algorithm)
Create a new instance of
MessageDigest with the given algorithm. |
static java.lang.String |
getSecurityProvider()
Get the identifier for the registered security provider.
|
static java.security.Signature |
getSignature(java.lang.String algorithm) |
static boolean |
isBouncyCastleRegistered()
Attempts registering BouncyCastle as security provider if it has not been previously attempted and returns
whether the registration succeeded.
|
static void |
setRegisterBouncyCastle(boolean registerBouncyCastle) |
static void |
setSecurityProvider(java.lang.String securityProvider)
Specifies the JCE security provider that should be used.
|
public static final java.lang.String BOUNCY_CASTLE
public static javax.crypto.Cipher getCipher(java.lang.String transformation)
throws java.security.NoSuchAlgorithmException,
javax.crypto.NoSuchPaddingException,
java.security.NoSuchProviderException
java.security.NoSuchAlgorithmExceptionjavax.crypto.NoSuchPaddingExceptionjava.security.NoSuchProviderExceptionpublic static java.lang.String getFingerprint(java.security.PublicKey key)
key - the public keypublic static javax.crypto.KeyAgreement getKeyAgreement(java.lang.String algorithm)
throws java.security.NoSuchAlgorithmException,
java.security.NoSuchProviderException
KeyAgreement with the given algorithm.algorithm - key agreement algorithmjava.security.NoSuchAlgorithmExceptionjava.security.NoSuchProviderExceptionpublic static java.security.KeyFactory getKeyFactory(java.lang.String algorithm)
throws java.security.NoSuchAlgorithmException,
java.security.NoSuchProviderException
KeyFactory with the given algorithm.algorithm - key factory algorithm e.g. RSA, DSAjava.security.NoSuchAlgorithmExceptionjava.security.NoSuchProviderExceptionpublic static java.security.KeyPairGenerator getKeyPairGenerator(java.lang.String algorithm)
throws java.security.NoSuchAlgorithmException,
java.security.NoSuchProviderException
KeyPairGenerator with the given algorithm.algorithm - key pair generator algorithmjava.security.NoSuchAlgorithmExceptionjava.security.NoSuchProviderExceptionpublic static javax.crypto.Mac getMAC(java.lang.String algorithm)
throws java.security.NoSuchAlgorithmException,
java.security.NoSuchProviderException
Mac with the given algorithm.algorithm - MAC algorithmjava.security.NoSuchAlgorithmExceptionjava.security.NoSuchProviderExceptionpublic static java.security.MessageDigest getMessageDigest(java.lang.String algorithm)
throws java.security.NoSuchAlgorithmException,
java.security.NoSuchProviderException
MessageDigest with the given algorithm.algorithm - MessageDigest algorithm namejava.security.NoSuchAlgorithmExceptionjava.security.NoSuchProviderExceptionpublic static java.lang.String getSecurityProvider()
public static java.security.Signature getSignature(java.lang.String algorithm)
throws java.security.NoSuchAlgorithmException,
java.security.NoSuchProviderException
java.security.NoSuchAlgorithmExceptionjava.security.NoSuchProviderExceptionpublic static boolean isBouncyCastleRegistered()
public static void setRegisterBouncyCastle(boolean registerBouncyCastle)
public static void setSecurityProvider(java.lang.String securityProvider)
securityProvider - identifier for the security provider