public class SecurityUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
BOUNCY_CASTLE
Identifier for the BouncyCastle JCE provider
|
Constructor and Description |
---|
SecurityUtils() |
Modifier and Type | Method and Description |
---|---|
static Cipher |
getCipher(String transformation) |
static String |
getFingerprint(PublicKey key)
Computes the fingerprint for a public key, in the standard SSH format, e.g.
|
static KeyAgreement |
getKeyAgreement(String algorithm)
Creates a new instance of
KeyAgreement with the given algorithm. |
static KeyFactory |
getKeyFactory(String algorithm)
Creates a new instance of
KeyFactory with the given algorithm. |
static KeyPairGenerator |
getKeyPairGenerator(String algorithm)
Creates a new instance of
KeyPairGenerator with the given algorithm. |
static Mac |
getMAC(String algorithm)
Create a new instance of
Mac with the given algorithm. |
static MessageDigest |
getMessageDigest(String algorithm)
Create a new instance of
MessageDigest with the given algorithm. |
static String |
getSecurityProvider()
Get the identifier for the registered security provider.
|
static Signature |
getSignature(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(String securityProvider)
Specifies the JCE security provider that should be used.
|
public static final String BOUNCY_CASTLE
public static Cipher getCipher(String transformation) throws NoSuchAlgorithmException, NoSuchPaddingException, NoSuchProviderException
public static String getFingerprint(PublicKey key)
key
- the public keypublic static KeyAgreement getKeyAgreement(String algorithm) throws NoSuchAlgorithmException, NoSuchProviderException
KeyAgreement
with the given algorithm.algorithm
- key agreement algorithmNoSuchAlgorithmException
NoSuchProviderException
public static KeyFactory getKeyFactory(String algorithm) throws NoSuchAlgorithmException, NoSuchProviderException
KeyFactory
with the given algorithm.algorithm
- key factory algorithm e.g. RSA, DSANoSuchAlgorithmException
NoSuchProviderException
public static KeyPairGenerator getKeyPairGenerator(String algorithm) throws NoSuchAlgorithmException, NoSuchProviderException
KeyPairGenerator
with the given algorithm.algorithm
- key pair generator algorithmNoSuchAlgorithmException
NoSuchProviderException
public static Mac getMAC(String algorithm) throws NoSuchAlgorithmException, NoSuchProviderException
Mac
with the given algorithm.algorithm
- MAC algorithmNoSuchAlgorithmException
NoSuchProviderException
public static MessageDigest getMessageDigest(String algorithm) throws NoSuchAlgorithmException, NoSuchProviderException
MessageDigest
with the given algorithm.algorithm
- MessageDigest algorithm nameNoSuchAlgorithmException
NoSuchProviderException
public static String getSecurityProvider()
public static Signature getSignature(String algorithm) throws NoSuchAlgorithmException, NoSuchProviderException
public static boolean isBouncyCastleRegistered()
public static void setRegisterBouncyCastle(boolean registerBouncyCastle)
public static void setSecurityProvider(String securityProvider)
securityProvider
- identifier for the security providerCopyright © 2009–2013. All rights reserved.