public final class SecurityUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
SecurityUtils.BouncyCastleRandom
BouncyCastle
Random . |
static class |
SecurityUtils.BouncyCastleRandomFactory
Named factory for the BouncyCastle
Random |
Modifier and Type | Field and Description |
---|---|
static String |
BOUNCY_CASTLE
Bouncycastle JCE provider name
|
static int |
DEFAULT_DHGEX_KEY_SIZE |
static String |
ECC_SUPPORTED_PROP
System property used to control whether Elliptic Curves are supported or not.
|
static int |
MAX_DHGEX_KEY_SIZE |
static String |
MAX_DHGEX_KEY_SIZE_PROP
System property used to configure the value for the maximum supported Diffie-Hellman
Group Exchange key size.
|
static int |
MIN_DHGEX_KEY_SIZE
The min.
|
static int |
PREFERRED_DHGEX_KEY_SIZE |
static String |
REGISTER_BOUNCY_CASTLE_PROP
System property used to control whether to automatically register the
Bouncyastle JCE provider |
public static final String BOUNCY_CASTLE
public static final String MAX_DHGEX_KEY_SIZE_PROP
public static final int MIN_DHGEX_KEY_SIZE
public static final int DEFAULT_DHGEX_KEY_SIZE
public static final int PREFERRED_DHGEX_KEY_SIZE
public static final int MAX_DHGEX_KEY_SIZE
public static final String REGISTER_BOUNCY_CASTLE_PROP
Bouncyastle
JCE providerpublic static final String ECC_SUPPORTED_PROP
true
it is up to the user to make sure that indeed there is a provider for thempublic static boolean hasEcc()
true
if Elliptic Curve Cryptography is supportedECC_SUPPORTED_PROP
public static boolean isDHGroupExchangeSupported()
true
if Diffie-Hellman Group Exchange is supportedgetMaxDHGroupExchangeKeySize()
public static boolean isDHOakelyGroupSupported(int keySize)
keySize
- The expected key sizetrue
if Oakely Diffie-Hellman Group Exchange is supported
for the specified key sizegetMaxDHGroupExchangeKeySize()
public static int getMaxDHGroupExchangeKeySize()
public static void setMaxDHGroupExchangeKeySize(int keySize)
getMaxDHGroupExchangeKeySize()
keySize
- The reported key size - if zero, then it will be auto-detected, if
negative then DH group exchange will be disabledpublic static boolean isDHGroupExchangeSupported(int maxKeySize)
public static void setSecurityProvider(String securityProvider)
public static void setRegisterBouncyCastle(boolean registerBouncyCastle)
public static String getSecurityProvider()
public static boolean isBouncyCastleRegistered()
public static KeyPair loadKeyPairIdentity(String resourceKey, InputStream inputStream, FilePasswordProvider provider) throws IOException, GeneralSecurityException
resourceKey
- An identifier of the key being loaded - used as
argument to the FilePasswordProvider.getPassword(String)
invocationinputStream
- The InputStream
for the private keyprovider
- A FilePasswordProvider
- may be null
if the loaded key is guaranteed not to be encryptedKeyPair
IOException
- If failed to read/parse the input streamGeneralSecurityException
- If failed to generate the keys - specifically,
NoSuchProviderException
is thrown also if isBouncyCastleRegistered()
is false
public static AbstractFileKeyPairProvider createFileKeyPairProvider()
public static AbstractClassLoadableResourceKeyPairProvider createClassLoadableResourceKeyPairProvider()
public static AbstractGeneratorHostKeyProvider createGeneratorHostKeyProvider(Path path)
public static RandomFactory getRandomFactory()
isBouncyCastleRegistered()
then a SecurityUtils.BouncyCastleRandomFactory
instance, otherwise a JceRandomFactory
onepublic static KeyFactory getKeyFactory(String algorithm) throws GeneralSecurityException
GeneralSecurityException
public static Cipher getCipher(String transformation) throws GeneralSecurityException
GeneralSecurityException
public static MessageDigest getMessageDigest(String algorithm) throws GeneralSecurityException
GeneralSecurityException
public static KeyPairGenerator getKeyPairGenerator(String algorithm) throws GeneralSecurityException
GeneralSecurityException
public static KeyAgreement getKeyAgreement(String algorithm) throws GeneralSecurityException
GeneralSecurityException
public static Mac getMac(String algorithm) throws GeneralSecurityException
GeneralSecurityException
public static Signature getSignature(String algorithm) throws GeneralSecurityException
GeneralSecurityException
public static CertificateFactory getCertificateFactory(String type) throws GeneralSecurityException
GeneralSecurityException
Copyright © 2008–2016 The Apache Software Foundation. All rights reserved.