public class KeyFactory
extends java.lang.Object
Key
) into key
specifications (transparent representations of the underlying key material), and vice versa.
Key factories are bi-directional. That is, they allow you 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.
Multiple compatible key specifications may exist for the same key. A key factory can be used to translate between compatible key specifications.
Key
,
PublicKey
,
PrivateKey
,
KeySpec
Constructor and Description |
---|
KeyFactory() |
Modifier and Type | Method and Description |
---|---|
PrivateKey |
generatePrivate(KeySpec keySpec)
Generates a private key object from the provided key specification (key material).
|
java.lang.String |
getAlgorithm()
Gets the name of the algorithm associated with this
KeyFactory . |
static KeyFactory |
getInstance(java.lang.String algorithm)
Returns a KeyFactory object that converts public/private keys of the specified algorithm.
|
public static KeyFactory getInstance(java.lang.String algorithm) throws NoSuchAlgorithmException
algorithm
- the name of the requested key algorithm. See the KeyFactory section in the
Java Cryptography
Architecture Standard Algorithm Name Documentation for information about standard algorithm names.NoSuchAlgorithmException
- if the KeyFactorySpi has no implementation for the specified algorithm.public final java.lang.String getAlgorithm()
KeyFactory
.KeyFactory
public final PrivateKey generatePrivate(KeySpec keySpec) throws InvalidKeySpecException
keySpec
- the specification (key material) of the private key.InvalidKeySpecException
- if the given key specification is inappropriate for this key factory to produce a private key.