java.security
Class KeyFactory
java.lang.Object
|
+--java.security.KeyFactory
public class
KeyFactoryextends
ObjectKey factories are used to convert keys (opaque cryptographic
keys of type Key) into key specifications (transparent
representations of the underlying key material).
Key factories are bi-directional. They allow a key class
to be converted into a key specification (key material) and
back again.
For example DSA public keys can be specified as
DSAPublicKeySpec or X509EncodedKeySpec. The key factory
translate these key specifications.
Since:Author:KeyFactory
protected KeyFactory(java.security.KeyFactorySpi keyFacSpi, java.security.Provider provider, java.lang.String algorithm)
Constructs a new keyFactory with the specified parameters.
Parameters:
generatePrivate
public final PrivateKey generatePrivate(java.security.spec.KeySpec keySpec)
Generates a private key from the provided key specification.
Parameters:
Returns:
Throws:
generatePublic
public final PublicKey generatePublic(java.security.spec.KeySpec keySpec)
Generates a public key from the provided key specification.
Parameters:
Returns:
Throws:
getAlgorithm
public final String getAlgorithm()
Returns the name of the algorithm used
Returns:
- A string with the name of the algorithm
getInstance
public static KeyFactory getInstance(java.lang.String algorithm)
Gets an instance of the KeyFactory class representing
the specified key factory. If the algorithm is not
found then, it throws NoSuchAlgorithmException.
Parameters:
Returns:
- a KeyFactory repesenting the desired algorithm
Throws:
getInstance
public static KeyFactory getInstance(java.lang.String algorithm, java.lang.String provider)
Gets an instance of the KeyFactory class representing
the specified key factory from the specified provider.
If the algorithm is not found then, it throws
NoSuchAlgorithmException. If the provider is not found, then
it throws NoSuchProviderException.
Parameters:
Returns:
- a KeyFactory repesenting the desired algorithm
Throws:
getKeySpec
public final KeySpec getKeySpec(java.security.Key key, java.lang.Class keySpec)
Returns a key specification for the given key. keySpec
identifies the specification class to return the key
material in.
Parameters:
Returns:
- the key specification in an instance of the requested
specification class
Throws:
InvalidKeySpecException
- the requested key specification
is inappropriate for this key or the key is
unrecognized.
getProvider
public final Provider getProvider()
Gets the provider that the class is from.
Returns:
- the provider of this class
translateKey
public final Key translateKey(java.security.Key key)
Translates the key from an unknown or untrusted provider
into a key for this key factory.
Parameters:
Returns:
Throws: