Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.security

Class KeyFactory

java.lang.Object
|
+--java.security.KeyFactory


public class KeyFactory

extends Object

Key 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:

Constructor Summary

KeyFactory(java.security.KeyFactorySpi keyFacSpi, java.security.Provider provider, java.lang.String algorithm)

Constructs a new keyFactory with the specified parameters.

Method Summary

java.security.PrivateKeygeneratePrivate(java.security.spec.KeySpec keySpec)

Generates a private key from the provided key specification.
java.security.PublicKeygeneratePublic(java.security.spec.KeySpec keySpec)

Generates a public key from the provided key specification.
java.lang.StringgetAlgorithm()

Returns the name of the algorithm used
static java.security.KeyFactorygetInstance(java.lang.String algorithm)

Gets an instance of the KeyFactory class representing the specified key factory.
static java.security.KeyFactorygetInstance(java.lang.String algorithm, java.lang.String provider)

Gets an instance of the KeyFactory class representing the specified key factory from the specified provider.
java.security.spec.KeySpecgetKeySpec(java.security.Key key, java.lang.Class keySpec)

Returns a key specification for the given key.
java.security.ProvidergetProvider()

Gets the provider that the class is from.
java.security.KeytranslateKey(java.security.Key key)

Translates the key from an unknown or untrusted provider into a key for this key factory.

Constructor Details

KeyFactory

protected KeyFactory(java.security.KeyFactorySpi keyFacSpi, java.security.Provider provider, java.lang.String algorithm)

Constructs a new keyFactory with the specified parameters.

Parameters:


Method Details

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:


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:

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:

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:

Throws:


getProvider

public final Provider getProvider()

Gets the provider that the class is from.

Returns:


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: