jsdsi.util
Class KeyPairFactory

java.lang.Object
  extended byjsdsi.util.KeyPairFactory

public final class KeyPairFactory
extends java.lang.Object

Convenience class for generating java.security.KeyPair 's.

This class maintains a cache of KeyPairGenerators retrieved from the JCE for performance.

Note: Care should be taken when creating Keys without specifying a keysize, SecureRandom, or any AlgorithmParameterSpec, as it has been noted that without, keys are predictable when using some Providers.

Version:
$Revision: 1.7 $ $Date: 2004/11/12 09:53:49 $
Author:
Sean Radford

Method Summary
static java.security.KeyPair create(KeyEnum keyEnum)
          Generates a KeyPair of the given keyEnum type.
static java.security.KeyPair create(KeyEnum keyEnum, int keysize)
          Generates a KeyPair of the given keyEnum type and key size.
static java.security.KeyPair create(KeyEnum keyEnum, int keysize, java.net.URI[] uris)
          Generates a KeyPair of the given keyEnum type and uris.
static java.security.KeyPair create(KeyEnum keyEnum, java.net.URI[] uris)
          Generates a KeyPair of the given keyEnum type with the given uris.
static java.security.KeyPairGenerator getKeyPairGenerator(KeyEnum keyEnum, int keysize, java.net.URI[] uris)
          Retrieves a KeyPairGenerator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static java.security.KeyPair create(KeyEnum keyEnum)
                                    throws java.security.NoSuchAlgorithmException
Generates a KeyPair of the given keyEnum type. The public key of the KeyPair is a jsdsi.Principal.

Parameters:
keyEnum - the key algorithm.
Returns:
the new KeyPair
Throws:
java.security.NoSuchAlgorithmException - if the algorithm is not available in the environment.

create

public static java.security.KeyPair create(KeyEnum keyEnum,
                                           int keysize)
                                    throws java.security.NoSuchAlgorithmException
Generates a KeyPair of the given keyEnum type and key size. The public key of the KeyPair is a jsdsi.Principal.

Parameters:
keyEnum - the key algorithm.
keysize - the keysize. This is an algorithm-specific metric, such as modulus length, specified in number of bits.
Returns:
the new KeyPair
Throws:
java.security.NoSuchAlgorithmException - if the algorithm is not available in the environment.

create

public static java.security.KeyPair create(KeyEnum keyEnum,
                                           java.net.URI[] uris)
                                    throws java.security.NoSuchAlgorithmException
Generates a KeyPair of the given keyEnum type with the given uris. The public key of the KeyPair is a jsdsi.Principal.

Parameters:
keyEnum - the key algorithm.
uris - URI's where information about the Principal may be sought
Returns:
the new KeyPair
Throws:
java.security.NoSuchAlgorithmException - if the algorithm is not available in the environment.

create

public static java.security.KeyPair create(KeyEnum keyEnum,
                                           int keysize,
                                           java.net.URI[] uris)
                                    throws java.security.NoSuchAlgorithmException
Generates a KeyPair of the given keyEnum type and uris. The public key of the KeyPair is a jsdsi.Principal.

Parameters:
keyEnum - the key algorithm.
keysize - the keysize. This is an algorithm-specific metric, such as modulus length, specified in number of bits.
uris - URI's where information about the Principal may be sought
Returns:
the new KeyPair
Throws:
java.security.NoSuchAlgorithmException - if the algorithm is not available in the environment.

getKeyPairGenerator

public static java.security.KeyPairGenerator getKeyPairGenerator(KeyEnum keyEnum,
                                                                 int keysize,
                                                                 java.net.URI[] uris)
                                                          throws java.security.NoSuchAlgorithmException
Retrieves a KeyPairGenerator.

Parameters:
keyEnum -
keysize -
uris -
Returns:
the KeyPairGenerator
Throws:
java.security.NoSuchAlgorithmException


Copyright © 2002-2006 JSDSI. All Rights Reserved.