org.codehaus.wadi.core.manager
Class TomcatSessionIdFactory

java.lang.Object
  extended by org.codehaus.wadi.core.manager.TomcatSessionIdFactory
All Implemented Interfaces:
SessionIdFactory

public class TomcatSessionIdFactory
extends java.lang.Object
implements SessionIdFactory

An IdGenerator borrowed from Tomcat

Version:
$Revision: 2285 $
Author:
Jules Gosnell

Field Summary
protected  org.apache.commons.logging.Log _log
           
protected  java.lang.String algorithm
          The message digest algorithm to be used when generating session identifiers.
protected static java.lang.String DEFAULT_ALGORITHM
          The default message digest algorithm to use if we cannot use the requested one.
protected  java.lang.String devRandomSource
           
protected  java.security.MessageDigest digest
          Return the MessageDigest implementation to be used when creating session identifiers.
protected  java.lang.String entropy
          A String initialization parameter used to increase the entropy of the initialization of our random number generator.
protected  org.apache.commons.logging.Log log
           
protected  java.util.Random random
          A random number generator to use when generating session identifiers.
protected  java.lang.String randomClass
          The Java class name of the random number generator class to be used when generating session identifiers.
protected  java.io.DataInputStream randomIS
           
protected static int SESSION_ID_BYTES
          The number of random bytes to include when generating a session identifier.
protected  org.codehaus.wadi.core.manager.TomcatSessionIdFactory.StringManager sm
           
protected  org.codehaus.wadi.core.manager.TomcatSessionIdFactory.Support support
           
 
Constructor Summary
TomcatSessionIdFactory()
           
 
Method Summary
 java.lang.String create()
           
protected  java.lang.String generateSessionId()
          Generate and return a new session identifier.
 java.security.MessageDigest getDigest()
          Return the MessageDigest object to be used for calculating session identifiers.
 java.lang.String getEntropy()
          Return the entropy increaser value, or compute a semi-useful value if this String has not yet been set.
 java.util.Random getRandom()
          Return the random number generator instance we should use for generating session identifiers.
protected  void getRandomBytes(byte[] bytes)
           
 int getSessionIdLength()
           
 void setEntropy(java.lang.String entropy)
          Set the entropy increaser value.
 void setRandomFile(java.lang.String s)
          Use /dev/random-type special device.
 void setSessionIdLength(int l)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_log

protected final org.apache.commons.logging.Log _log

log

protected final org.apache.commons.logging.Log log

sm

protected org.codehaus.wadi.core.manager.TomcatSessionIdFactory.StringManager sm

support

protected org.codehaus.wadi.core.manager.TomcatSessionIdFactory.Support support

randomIS

protected java.io.DataInputStream randomIS

devRandomSource

protected java.lang.String devRandomSource

DEFAULT_ALGORITHM

protected static final java.lang.String DEFAULT_ALGORITHM
The default message digest algorithm to use if we cannot use the requested one.

See Also:
Constant Field Values

SESSION_ID_BYTES

protected static final int SESSION_ID_BYTES
The number of random bytes to include when generating a session identifier.

See Also:
Constant Field Values

algorithm

protected java.lang.String algorithm
The message digest algorithm to be used when generating session identifiers. This must be an algorithm supported by the java.security.MessageDigest class on your platform.


digest

protected java.security.MessageDigest digest
Return the MessageDigest implementation to be used when creating session identifiers.


random

protected java.util.Random random
A random number generator to use when generating session identifiers.


randomClass

protected java.lang.String randomClass
The Java class name of the random number generator class to be used when generating session identifiers.


entropy

protected java.lang.String entropy
A String initialization parameter used to increase the entropy of the initialization of our random number generator.

Constructor Detail

TomcatSessionIdFactory

public TomcatSessionIdFactory()
Method Detail

create

public java.lang.String create()
Specified by:
create in interface SessionIdFactory

getSessionIdLength

public int getSessionIdLength()
Specified by:
getSessionIdLength in interface SessionIdFactory

setSessionIdLength

public void setSessionIdLength(int l)
Specified by:
setSessionIdLength in interface SessionIdFactory

getEntropy

public java.lang.String getEntropy()
Return the entropy increaser value, or compute a semi-useful value if this String has not yet been set.


setEntropy

public void setEntropy(java.lang.String entropy)
Set the entropy increaser value.

Parameters:
entropy - The new entropy increaser value

getRandom

public java.util.Random getRandom()
Return the random number generator instance we should use for generating session identifiers. If there is no such generator currently defined, construct and seed a new one.


setRandomFile

public void setRandomFile(java.lang.String s)
Use /dev/random-type special device. This is new code, but may reduce the big delay in generating the random. You must specify a path to a random generator file. Use /dev/urandom for linux ( or similar ) systems. Use /dev/random for maximum security ( it may block if not enough "random" exist ). You can also use a pipe that generates random. The code will check if the file exists, and default to java Random if not found. There is a significant performance difference, very visible on the first call to getSession ( like in the first JSP ) - so use it if available.


generateSessionId

protected java.lang.String generateSessionId()
Generate and return a new session identifier.


getDigest

public java.security.MessageDigest getDigest()
Return the MessageDigest object to be used for calculating session identifiers. If none has been created yet, initialize one the first time this method is called.


getRandomBytes

protected void getRandomBytes(byte[] bytes)


Copyright © 2008. All Rights Reserved.