org.hd.d.efs.servlet
Class GathererServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.hd.d.efs.servlet.GathererServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class GathererServlet
extends javax.servlet.http.HttpServlet

Basic servlet to hold and gather noise for entropy pool(s). This actually supports more than one entropy pool if need be, each with its own name. For example, one pool might be for high-security bits such as key generation, and another for good statistical randomness but less security such as nonce generation.

Since this servlet does not implement SingleThreadModel then there will only be one instance of this servlet per JVM instance (though in a distributed WAR application running in several JVMs, there will be one instance per VM).

As this does not implement any servlet actions other than init() and destroy() it will not directly respond to external requests. Normally this servlet would be mounted somewhere innocuous in the URI space and marked for load-on-startup to act as a holder for the EntropyPool and Gatherer objects from when the Web service starts (ie ASAP) to when the whole Web service shuts down (ie to avoid losing all its carefully harvested noise).

To all this to host threads, run external processes, etc, you may need to widen permissions. To allow external Web-site access you may need to set proxy parameters for the VM and/or (carefully) open access through firewalls.

The basic configuration for the pools is from the servlet's init-param configuration information.

When the servlet is shut down, if a seed file has been set, an attempt is made to store a seed for the next startup.

See Also:
Serialized Form

Field Summary
static java.lang.String DEFAULT_POOL_NAME
          By default this pool exists.
static java.lang.String PNAME__POOLBYTES
          Top-level property (attribute) name for (strictly positive) size of pool in bytes if present.
 
Constructor Summary
GathererServlet()
           
 
Method Summary
 void destroy()
          Shut down, saving a seed file from each pool if possible.
static EntropyPool getPool(java.lang.String poolName)
          Get entropy pool by name.
 void init()
          Capture any config info and then create the selected entropy pools.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_POOL_NAME

public static final java.lang.String DEFAULT_POOL_NAME
By default this pool exists.

See Also:
Constant Field Values

PNAME__POOLBYTES

public static final java.lang.String PNAME__POOLBYTES
Top-level property (attribute) name for (strictly positive) size of pool in bytes if present.

See Also:
Constant Field Values
Constructor Detail

GathererServlet

public GathererServlet()
Method Detail

init

public void init()
Capture any config info and then create the selected entropy pools. By default, this created one pool, but can create as many as required.

This creates them as soon as possible to allow them to accrue some real entropy as soon as possible.

Overrides:
init in class javax.servlet.GenericServlet

destroy

public void destroy()
Shut down, saving a seed file from each pool if possible. The seed data is somewhat sensitive and does not represent all the data in the pool to minimise its examination helping with recovering random data previously extracted from the pool.

Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet

getPool

public static EntropyPool getPool(java.lang.String poolName)
                           throws java.util.NoSuchElementException
Get entropy pool by name. The requested pool (and others) may be created and initialised on first use.

Throws:
java.lang.IllegalArgumentException - if poolName is null or if there is no pool with the given name
java.util.NoSuchElementException