Build 1.1_r1 (from source)

java.security
Class KeyFactory

java.lang.Object
  extended by java.security.KeyFactory

public class KeyFactory
extends Object

KeyFactory is an engine class that can be used to translate between public and private key objects and convert keys between their external representation, that can be easily transported and their internal representation.

Since:
Android 1.0

Constructor Summary
protected KeyFactory(KeyFactorySpi keyFacSpi, Provider provider, String algorithm)
          Constructs a new instance of KeyFactory with the specified arguments.
 
Method Summary
 PrivateKey generatePrivate(KeySpec keySpec)
          Generates a instance of PrivateKey from the given key specification.
 PublicKey generatePublic(KeySpec keySpec)
          Generates a instance of PublicKey from the given key specification.
 String getAlgorithm()
          Returns the name of the algorithm associated with this KeyFactory .
static KeyFactory getInstance(String algorithm)
          Returns a new instance of KeyFactory that utilizes the specified algorithm.
static KeyFactory getInstance(String algorithm, Provider provider)
          Returns a new instance of KeyFactory that utilizes the specified algorithm from the specified provider.
static KeyFactory getInstance(String algorithm, String provider)
          Returns a new instance of KeyFactory that utilizes the specified algorithm from the specified provider.
<T extends KeySpec>
T
getKeySpec(Key key, Class<T> keySpec)
          Returns the key specification for the specified key.
 Provider getProvider()
          Returns the provider associated with this KeyFactory.
 Key translateKey(Key key)
          Translates the given key into a key from this key factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyFactory

protected KeyFactory(KeyFactorySpi keyFacSpi,
                     Provider provider,
                     String algorithm)
Constructs a new instance of KeyFactory with the specified arguments.

Parameters:
keyFacSpi - the concrete key factory service.
provider - the provider.
algorithm - the algorithm to use.
Since:
Android 1.0
Method Detail

getInstance

public static KeyFactory getInstance(String algorithm)
                              throws NoSuchAlgorithmException
Returns a new instance of KeyFactory that utilizes the specified algorithm.

Parameters:
algorithm - the name of the algorithm.
Returns:
a new instance of KeyFactory that utilizes the specified algorithm.
Throws:
NoSuchAlgorithmException - if no provider provides the requested algorithm.
Since:
Android 1.0

getInstance

public static KeyFactory getInstance(String algorithm,
                                     String provider)
                              throws NoSuchAlgorithmException,
                                     NoSuchProviderException
Returns a new instance of KeyFactory that utilizes the specified algorithm from the specified provider.

Parameters:
algorithm - the name of the algorithm.
provider - the name of the provider.
Returns:
a new instance of KeyFactory that utilizes the specified algorithm from the specified provider.
Throws:
NoSuchAlgorithmException - if the provider does not provide the requested algorithm.
NoSuchProviderException - if the requested provider is not available.
IllegalArgumentException - if provider is null or empty.
Since:
Android 1.0

getInstance

public static KeyFactory getInstance(String algorithm,
                                     Provider provider)
                              throws NoSuchAlgorithmException
Returns a new instance of KeyFactory that utilizes the specified algorithm from the specified provider.

Parameters:
algorithm - the name of the algorithm.
provider - the security provider.
Returns:
a new instance of KeyFactory that utilizes the specified algorithm from the specified provider.
Throws:
NoSuchAlgorithmException - if the provider does not provide the requested algorithm.
Since:
Android 1.0

getProvider

public final Provider getProvider()
Returns the provider associated with this KeyFactory.

Returns:
the provider associated with this KeyFactory.
Since:
Android 1.0

getAlgorithm

public final String getAlgorithm()
Returns the name of the algorithm associated with this KeyFactory .

Returns:
the name of the algorithm associated with this KeyFactory .
Since:
Android 1.0

generatePublic

public final PublicKey generatePublic(KeySpec keySpec)
                               throws InvalidKeySpecException
Generates a instance of PublicKey from the given key specification.

Parameters:
keySpec - the specification of the public key
Returns:
the public key
Throws:
InvalidKeySpecException - if the specified keySpec is invalid
Since:
Android 1.0

generatePrivate

public final PrivateKey generatePrivate(KeySpec keySpec)
                                 throws InvalidKeySpecException
Generates a instance of PrivateKey from the given key specification.

Parameters:
keySpec - the specification of the private key.
Returns:
the private key.
Throws:
InvalidKeySpecException - if the specified keySpec is invalid.
Since:
Android 1.0

getKeySpec

public final <T extends KeySpec> T getKeySpec(Key key,
                                              Class<T> keySpec)
                                   throws InvalidKeySpecException
Returns the key specification for the specified key.

Parameters:
key - the key from which the specification is requested.
keySpec - the type of the requested KeySpec.
Returns:
the key specification for the specified key.
Throws:
InvalidKeySpecException - if the key can not be processed, or the requested requested KeySpec is inappropriate for the given key.
Since:
Android 1.0

translateKey

public final Key translateKey(Key key)
                       throws InvalidKeyException
Translates the given key into a key from this key factory.

Parameters:
key - the key to translate.
Returns:
the translated key.
Throws:
InvalidKeyException - if the specified key can not be translated by this key factory.
Since:
Android 1.0

Build 1.1_r1 (from source)

Please submit a feedback, bug or feature