com.cinnabarsystems.clm
Class KeyManager

java.lang.Object
  extended by com.cinnabarsystems.clm.KeyManager

public class KeyManager
extends Object

A utility class to read and write encryption keys


Constructor Summary
KeyManager()
           
 
Method Summary
static KeyPair generateKeyPair()
          Generate a new random keypair
static PrivateKey readPrivateKey(InputStream input)
          Read a private key
static PublicKey readPublicKey(InputStream input)
          Read a public key
static void saveKey(Key key, OutputStream output)
          Save a key
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyManager

public KeyManager()
Method Detail

generateKeyPair

public static KeyPair generateKeyPair()
                               throws GeneralSecurityException
Generate a new random keypair

Returns:
The keypair
Throws:
GeneralSecurityException

saveKey

public static void saveKey(Key key,
                           OutputStream output)
                    throws IOException,
                           GeneralSecurityException
Save a key

Parameters:
key - The key to save
output - The stream the key should be saved to
Throws:
IOException
GeneralSecurityException

readPrivateKey

public static PrivateKey readPrivateKey(InputStream input)
                                 throws IOException,
                                        GeneralSecurityException
Read a private key

Parameters:
input - The stream from which to read the private key
Returns:
The private key
Throws:
IOException
GeneralSecurityException

readPublicKey

public static PublicKey readPublicKey(InputStream input)
                               throws IOException,
                                      GeneralSecurityException
Read a public key

Parameters:
input - The stream from which to read the public key
Returns:
The public key
Throws:
IOException
GeneralSecurityException