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