Key factories are used to convert keys (opaque
cryptographic keys of type Key) into key specifications
(transparent representations of the underlying key material), and vice
versa.
Secret key factories operate only on secret (symmetric) keys.
Key factories are bidirectional, i.e., they allow to build an opaque key object from a given key specification (key material), or to retrieve the underlying key material of a key object in a suitable format.
Application developers should refer to their provider's documentation
to find out which key specifications are supported by the
generateSecret and
getKeySpec
methods.
For example, the DESede (Triple DES) secret key factory supplied by the
"SunJCE" provider supports DESedeKeySpec as a transparent
representation of Triple DES keys.
Every implementation of the Java platform is required to support the
following standard SecretKeyFactory algorithms:
PBEWithHmacSHA256AndAES_128PBEWithHmacSHA256AndAES_256PBKDF2WithHmacSHA256SecretKey, javax.crypto.spec.DESedeKeySpec , javax.crypto.spec.PBEKeySpec
| Modifier and Type | Field and Description |
|---|---|
| private final String | |
| private final Object | |
| private Provider | |
| private Iterator | |
| private volatile SecretKeyFactorySpi |
| Access | Constructor and Description |
|---|---|
| protected | SecretKeyFactory(SecretKeyFactorySpi
the delegate keyFacSpi, Provider the provider provider, String the secret key algorithm algorithm)Creates a |
| private |
| Modifier and Type | Method and Description |
|---|---|
| public final SecretKey | Returns: the secret keythe specification (key material) of the secret key keySpec)Generates a |
| public final String | Returns: the algorithm name of thisSecretKeyFactory
object.Returns the algorithm name of this |
| public static final SecretKeyFactory | Returns: the newSecretKeyFactory objectthe standard name of the requested secret key
algorithm.
See the SecretKeyFactory section in the
Java Security Standard Algorithm Names Specification
for information about standard algorithm names. algorithm)Returns a |
| public static final SecretKeyFactory | Returns: the newSecretKeyFactory objectthe standard name of the requested secret key
algorithm.
See the SecretKeyFactory section in the
Java Security Standard Algorithm Names Specification
for information about standard algorithm names. algorithm, String the name of the provider. provider)Returns a |
| public static final SecretKeyFactory | Returns: the newSecretKeyFactory objectthe standard name of the requested secret key
algorithm.
See the SecretKeyFactory section in the
Java Security Standard Algorithm Names Specification
for information about standard algorithm names. algorithm, Provider the provider. provider)Returns a |
| public final KeySpec | Returns: the underlying key specification (key material) in the requested formatthe key key, Class<?> the requested format in which the key material shall be
returned keySpec)Returns a specification (key material) of the given key object in the requested format. |
| public final Provider | Returns: the provider of thisSecretKeyFactory objectReturns the provider of this |
| private SecretKeyFactorySpi | nextSpi(SecretKeyFactorySpi oldSpi)
Update the active spi of this class and return the next implementation for failover. |
| public final SecretKey | Returns: the translated keythe key whose provider is unknown or untrusted key)Translates a key object, whose provider may be unknown or potentially untrusted, into a corresponding key object of this secret key factory. |
| algorithm | back to summary |
|---|---|
| private final String algorithm | |
| lock | back to summary |
|---|---|
| private final Object lock | |
| provider | back to summary |
|---|---|
| private Provider provider | |
| serviceIterator | back to summary |
|---|---|
| private Iterator<Provider. | |
| spi | back to summary |
|---|---|
| private volatile SecretKeyFactorySpi spi | |
| SecretKeyFactory | back to summary |
|---|---|
| protected SecretKeyFactory(SecretKeyFactorySpi keyFacSpi, Provider provider, String algorithm) Creates a
| |
| SecretKeyFactory | back to summary |
|---|---|
| private SecretKeyFactory(String algorithm) throws NoSuchAlgorithmException | |
| generateSecret | back to summary |
|---|---|
| public final SecretKey generateSecret(KeySpec keySpec) throws InvalidKeySpecException Generates a
| |
| getAlgorithm | back to summary |
|---|---|
| public final String getAlgorithm() Returns the algorithm name of this This is the same name that was specified in one of the
| |
| getInstance | back to summary |
|---|---|
| public static final SecretKeyFactory getInstance(String algorithm) throws NoSuchAlgorithmException Returns a This method traverses the list of registered security providers,
starting with the most preferred provider.
A new Note that the list of registered providers may be retrieved via
the Implementation Note The JDK Reference Implementation additionally uses the
| |
| getInstance | back to summary |
|---|---|
| public static final SecretKeyFactory getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException Returns a A new Note that the list of registered providers may be retrieved via
the
| |
| getInstance | back to summary |
|---|---|
| public static final SecretKeyFactory getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException Returns a A new
| |
| getKeySpec | back to summary |
|---|---|
| public final KeySpec getKeySpec(SecretKey key, Class<?> keySpec) throws InvalidKeySpecException Returns a specification (key material) of the given key object in the requested format.
| |
| getProvider | back to summary |
|---|---|
| public final Provider getProvider() Returns the provider of this
| |
| nextSpi | back to summary |
|---|---|
| private SecretKeyFactorySpi nextSpi(SecretKeyFactorySpi oldSpi) Update the active spi of this class and return the next
implementation for failover. If no more implementations are
available, this method returns | |
| translateKey | back to summary |
|---|---|
| public final SecretKey translateKey(SecretKey key) throws InvalidKeyException Translates a key object, whose provider may be unknown or potentially untrusted, into a corresponding key object of this secret key factory.
| |