edu.nyu.cs.pdsg.util
Class Reservoir

java.lang.Object
  extended byedu.nyu.cs.pdsg.util.Reservoir

public class Reservoir
extends java.lang.Object

An automatic key generator. Uses spare procesor cycles to build a reserve of public/private keys which it dispenses as needed


Nested Class Summary
private  class Reservoir.ReservoirKeyFactory
          The Key Generation Factory
 
Field Summary
protected  int capacity
           
private  Reservoir.ReservoirKeyFactory generator
           
private  int incrementBy
           
private  int incrementTrig
           
protected  javax.crypto.KeyGenerator keyGen
           
protected  java.security.KeyPairGenerator keypGen
           
protected  java.util.Vector keys
           
(package private)  Semaphore lock
           
protected  int size
           
protected static int TIME_TO_SLEEP
           
 
Constructor Summary
  Reservoir(javax.crypto.KeyGenerator keyGen, int capacity)
          Initiate a key generating reservoir
  Reservoir(java.security.KeyPairGenerator keypGen, int capacity)
          Initiate a key generating reservoir
protected Reservoir(java.security.KeyPairGenerator keypGen, javax.crypto.KeyGenerator keyGen, int capacity)
          Initiate a key generating reservoir
 
Method Summary
 javax.crypto.SecretKey getKey()
           
 java.security.KeyPair getKeyPair()
           
 void increaseCapacity(int newCapacity)
          Alter the capacity of the reservoir
protected  boolean needsMoreKeys()
           
 void startGenerating()
          DEPRECATED
 void stopGenerating()
          DEPRECATED
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

capacity

protected int capacity

size

protected int size

generator

private Reservoir.ReservoirKeyFactory generator

incrementTrig

private int incrementTrig

incrementBy

private int incrementBy

lock

Semaphore lock

keys

protected java.util.Vector keys

keypGen

protected java.security.KeyPairGenerator keypGen

keyGen

protected javax.crypto.KeyGenerator keyGen

TIME_TO_SLEEP

protected static final int TIME_TO_SLEEP
See Also:
Constant Field Values
Constructor Detail

Reservoir

public Reservoir(java.security.KeyPairGenerator keypGen,
                 int capacity)
Initiate a key generating reservoir

Parameters:
keypGen - a class capable of generating key pairs
capacity - the maximum amount of keys to generate

Reservoir

public Reservoir(javax.crypto.KeyGenerator keyGen,
                 int capacity)
Initiate a key generating reservoir

Parameters:
keyGen - a class capable of generating keys
capacity - the maximum amount of keys to generate

Reservoir

protected Reservoir(java.security.KeyPairGenerator keypGen,
                    javax.crypto.KeyGenerator keyGen,
                    int capacity)
Initiate a key generating reservoir

Parameters:
keypGen - a class capable of generating key pairs
keyGen - a class capable of generating keys
capacity - the maximum amount of keys to generate
Method Detail

increaseCapacity

public void increaseCapacity(int newCapacity)
Alter the capacity of the reservoir


getKeyPair

public java.security.KeyPair getKeyPair()
                                 throws java.lang.InterruptedException
Returns:
a randomly generated keypair
Throws:
java.lang.InterruptedException - thrown if something goes horribly wrong
java.lang.ClassCastException - thrown if this is a synchronous reservoir

getKey

public javax.crypto.SecretKey getKey()
                              throws java.lang.InterruptedException
Returns:
a randomly generated keypair
Throws:
java.lang.InterruptedException - thrown if something goes horribly wrong
java.lang.ClassCastException - thrown if this is an asynchronous reservoir

stopGenerating

public void stopGenerating()
DEPRECATED


startGenerating

public void startGenerating()
DEPRECATED


needsMoreKeys

protected boolean needsMoreKeys()


Copyright (c) 2002-2003 New York University RLAB