# com.beasys.commerce.ebusiness.security
KeyFactory Class

public class KeyFactory
extends `Object`

Factory for both a private and public key. This class is a singleton class. The `KeyFactory` class is bound in JNDI to prevent the cached singleton from being garbage collected.

Hierarchy
  `Object`
  `KeyFactory`

## Field Summary

`protected static `KeyFactory`` | `singletonInstance` KeyFactory

## Method Summary

`public static `KeyFactory`` | `getInstance`() Retrieves the singleton instance of a `KeyFactory`.
`public `RSAPrivateKeyPKCS8`` | `getPrivateKey`() Returns the private key associated with the `KeyFactory`.
`public `RSAPublicKey`` | `getPublicKey`() Returns the public key associated with the `KeyFactory`.
`public void` | `init`(`String` password) Initializes the `KeyFactory` with a private password used for private key decryption.

Methods from class `java.lang.`Object``
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Detail

### singletonInstance

    protected static KeyFactory singletonInstance

## Method Detail

### getInstance() Method

    public static KeyFactory getInstance()

Retrieves the singleton instance of a `KeyFactory`.

#### Returns

The singleton

### getPrivateKey() Method

    public RSAPrivateKeyPKCS8 getPrivateKey()
         throws InconsistentStateException

Returns the private key associated with the `KeyFactory`.

#### Returns

The private key associated with the `KeyFactory`.

#### Exceptions

``InconsistentStateException``
  if the `KeyFactory` has not been initialized.

### getPublicKey() Method

    public RSAPublicKey getPublicKey()

Returns the public key associated with the `KeyFactory`.

#### Returns

The public key associated with the `KeyFactory`.

### init(String) Method

    public void init(String password)

Initializes the `KeyFactory` with a private password used for private key decryption.

#### Parameters

password
  The private password.