Modifier | Constructor and Description |
---|---|
protected |
SecretKeyFactory(SecretKeyFactorySpi skfSpi,
Provider provider,
String algorithm)
Create a new secret key factory.
|
Modifier and Type | Method and Description |
---|---|
SecretKey |
generateSecret(KeySpec keySpec)
Generate a secret key from a key specification, if possible.
|
String |
getAlgorithm()
Get the algorithm name.
|
static SecretKeyFactory |
getInstance(String algorithm)
Create a new secret key factory from the first appropriate instance.
|
static SecretKeyFactory |
getInstance(String algorithm,
Provider provider)
Create a new secret key factory from the specified provider.
|
static SecretKeyFactory |
getInstance(String algorithm,
String provider)
Create a new secret key factory from the named provider.
|
KeySpec |
getKeySpec(SecretKey key,
Class keySpec)
Get the key specification from a secret key.
|
Provider |
getProvider()
Get the provider of this implementation.
|
SecretKey |
translateKey(SecretKey key)
Translate a secret key into another form.
|
protected SecretKeyFactory(SecretKeyFactorySpi skfSpi, Provider provider, String algorithm)
skfSpi
- The underlying factory implementation.provider
- The provider.algorithm
- The algorithm name.public static final SecretKeyFactory getInstance(String algorithm) throws NoSuchAlgorithmException
algorithm
- The algorithm name.NoSuchAlgorithmException
- If no provider implements the specified
algorithm.IllegalArgumentException
- if algorithm
is
null
or is an empty string.public static final SecretKeyFactory getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
algorithm
- The algorithm name.provider
- The provider name.NoSuchAlgorithmException
- If the named provider does not implement
the algorithm.NoSuchProviderException
- If the named provider does not exist.IllegalArgumentException
- if either algorithm
or
provider
is null
, or if
algorithm
is an empty string.public static final SecretKeyFactory getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException
algorithm
- The algorithm name.provider
- The provider.NoSuchAlgorithmException
- If the provider does not implement the
algorithm.IllegalArgumentException
- if either algorithm
or
provider
is null
, or if
algorithm
is an empty string.public final SecretKey generateSecret(KeySpec keySpec) throws InvalidKeySpecException
keySpec
- The key specification.java.security.InvalidKeySpecException
- If the key specification
cannot be transformed into a secret key.InvalidKeySpecException
public final String getAlgorithm()
public final KeySpec getKeySpec(SecretKey key, Class keySpec) throws InvalidKeySpecException
key
- The secret key.keySpec
- The target key specification class.InvalidKeySpecException
- If the secret key cannot
be transformed into the specified key specification.public final Provider getProvider()
public final SecretKey translateKey(SecretKey key) throws InvalidKeyException
key
- The key to translate.InvalidKeyException
- If the argument cannot be
translated.