java.security
Class KeyFactorySpi

java.lang.Object
  extended by java.security.KeyFactorySpi

public abstract class KeyFactorySpi
extends Object

KeyFactorySpi is the Service Provider Interface (SPI) for the KeyFactory class. This is the interface for providers to supply to implement a key factory for an algorithm. 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:
JDK 1.2

Constructor Summary
KeyFactorySpi()
          Constucts a new KeyFactorySpi.
 
Method Summary
protected abstract  PrivateKey engineGeneratePrivate(KeySpec keySpec)
          Generates a private key from the provided key specification.
protected abstract  PublicKey engineGeneratePublic(KeySpec keySpec)
          Generates a public key from the provided key specification.
protected abstract
<T extends KeySpec>
T
engineGetKeySpec(Key key, Class<T> keySpec)
          Returns a key specification for the given key. keySpec identifies the specification class to return the key material in.
protected abstract  Key engineTranslateKey(Key key)
          Translates the key from an unknown or untrusted provider into a key for this key factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyFactorySpi

public KeyFactorySpi()
Constucts a new KeyFactorySpi.

Method Detail

engineGeneratePublic

protected abstract PublicKey engineGeneratePublic(KeySpec keySpec)
                                           throws InvalidKeySpecException
Generates a public key from the provided key specification.

Parameters:
keySpec - key specification
Returns:
the public key
Throws:
InvalidKeySpecException - invalid key specification for this key factory to produce a public key

engineGeneratePrivate

protected abstract PrivateKey engineGeneratePrivate(KeySpec keySpec)
                                             throws InvalidKeySpecException
Generates a private key from the provided key specification.

Parameters:
keySpec - key specification
Returns:
the private key
Throws:
InvalidKeySpecException - invalid key specification for this key factory to produce a private key

engineGetKeySpec

protected abstract <T extends KeySpec> T engineGetKeySpec(Key key,
                                                          Class<T> keySpec)
                                               throws InvalidKeySpecException
Returns a key specification for the given key. keySpec identifies the specification class to return the key material in.

Parameters:
key - the key
keySpec - the specification class to return the key material in.
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.

engineTranslateKey

protected abstract Key engineTranslateKey(Key key)
                                   throws InvalidKeyException
Translates the key from an unknown or untrusted provider into a key for this key factory.

Parameters:
key - key from an unknown or untrusted provider
Returns:
the translated key
Throws:
InvalidKeyException - if the key cannot be processed by this key factory