Top Fields Constructors Methods
org.apache.catalina.util

public abstract Class SessionIdGeneratorBase

extends LifecycleBase
implements SessionIdGenerator
Class Inheritance
All Implemented Interfaces
org.apache.catalina.SessionIdGenerator
Known Direct Subclasses
org.apache.catalina.util.StandardSessionIdGenerator
Imports
java.security.NoSuchAlgorithmException, .NoSuchProviderException, .SecureRandom, .Security, java.util.Queue, .Set, java.util.concurrent.ConcurrentLinkedQueue, org.apache.catalina.LifecycleException, .LifecycleState, .SessionIdGenerator, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.util.res.StringManager

Field Summary

Modifier and TypeField and Description
public static final String
private String
jvmRoute

Node identifier when in a cluster.

private final Log
private final Queue<SecureRandom>
randoms

Queue of random number generator objects to be used when creating session identifiers.

private String
private String
private String
private int
sessionIdLength

Number of bytes in a session ID. Defaults to 16.

private static final StringManager

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private SecureRandom
createSecureRandom()

Create a new random number generator instance we should use for generating session identifiers.

protected void
destroyInternal()

Implements abstract org.apache.catalina.util.LifecycleBase.destroyInternal.

Sub-classes implement this method to perform any instance destruction required.

public String
generateSessionId()

Implements org.apache.catalina.SessionIdGenerator.generateSessionId.

Generate and return a new session identifier.

public String
getJvmRoute()

Implements org.apache.catalina.SessionIdGenerator.getJvmRoute.

Return the node identifier associated with this node which will be included in the generated session ID.

protected void
getRandomBytes(byte[] bytes)

public String

Returns:

The name of the algorithm. null or the empty string means that platform default will be used
getSecureRandomAlgorithm
()

Get the name of the algorithm used to create the SecureRandom instances which generate new session IDs.

public String

Returns:

The fully qualified class name. null indicates that the JRE provided SecureRandom implementation will be used
getSecureRandomClass
()

Get the class name of the SecureRandom implementation used to generate session IDs.

public String

Returns:

The name of the provider. null or the empty string means that platform default will be used
getSecureRandomProvider
()

Get the name of the provider used to create the SecureRandom instances which generate new session IDs.

public int
getSessionIdLength()

Implements org.apache.catalina.SessionIdGenerator.getSessionIdLength.

Return the number of bytes for a session ID

protected void
initInternal()

Implements abstract org.apache.catalina.util.LifecycleBase.initInternal.

Sub-classes implement this method to perform any instance initialisation required.

public void
setJvmRoute(String
The node identifier
jvmRoute
)

Implements org.apache.catalina.SessionIdGenerator.setJvmRoute.

Specify the node identifier associated with this node which will be included in the generated session ID.

public void
setSecureRandomAlgorithm(String
The name of the algorithm
secureRandomAlgorithm
)

Specify a non-default algorithm to use to create instances of SecureRandom which are used to generate session IDs.

public void
setSecureRandomClass(String
The fully-qualified class name
secureRandomClass
)

Specify a non-default SecureRandom implementation to use.

public void
setSecureRandomProvider(String
The name of the provider
secureRandomProvider
)

Specify a non-default provider to use to create instances of SecureRandom which are used to generate session IDs.

public void
setSessionIdLength(int
Number of bytes
sessionIdLength
)

Implements org.apache.catalina.SessionIdGenerator.setSessionIdLength.

Specify the number of bytes for a session ID

protected void
startInternal()

Implements abstract org.apache.catalina.util.LifecycleBase.startInternal.

Sub-classes must ensure that the state is changed to LifecycleState#STARTING during the execution of this method.

protected void
stopInternal()

Implements abstract org.apache.catalina.util.LifecycleBase.stopInternal.

Sub-classes must ensure that the state is changed to LifecycleState#STOPPING during the execution of this method.

Inherited from org.apache.catalina.util.LifecycleBase:
addLifecycleListenerdestroyfindLifecycleListenersfireLifecycleEventgetStategetStateNamegetThrowOnFailureinitremoveLifecycleListenersetStatesetStatesetThrowOnFailurestartstop

Field Detail

DEFAULT_SECURE_RANDOM_ALGORITHMback to summary
public static final String DEFAULT_SECURE_RANDOM_ALGORITHM
jvmRouteback to summary
private String jvmRoute

Node identifier when in a cluster. Defaults to the empty string.

logback to summary
private final Log log

Hides org.apache.catalina.util.LifecycleBase.log.

randomsback to summary
private final Queue<SecureRandom> randoms

Queue of random number generator objects to be used when creating session identifiers. If the queue is empty when a random number generator is required, a new random number generator object is created. This is designed this way since random number generators use a sync to make them thread-safe and the sync makes using a single object slow(er).

secureRandomAlgorithmback to summary
private String secureRandomAlgorithm
secureRandomClassback to summary
private String secureRandomClass
secureRandomProviderback to summary
private String secureRandomProvider
sessionIdLengthback to summary
private int sessionIdLength

Number of bytes in a session ID. Defaults to 16.

smback to summary
private static final StringManager sm

Hides org.apache.catalina.util.LifecycleBase.sm.

Constructor Detail

SessionIdGeneratorBaseback to summary
public SessionIdGeneratorBase()

Method Detail

createSecureRandomback to summary
private SecureRandom createSecureRandom()

Create a new random number generator instance we should use for generating session identifiers.

destroyInternalback to summary
protected void destroyInternal() throws LifecycleException

Implements abstract org.apache.catalina.util.LifecycleBase.destroyInternal.

Doc from org.apache.catalina.util.LifecycleBase.destroyInternal.

Sub-classes implement this method to perform any instance destruction required.

Annotations
@Override
Exceptions
LifecycleException:
If the destruction fails
generateSessionIdback to summary
public String generateSessionId()

Implements org.apache.catalina.SessionIdGenerator.generateSessionId.

Generate and return a new session identifier.

Returns:String

Doc from org.apache.catalina.SessionIdGenerator.generateSessionId.

the newly generated session id

Annotations
@Override
getJvmRouteback to summary
public String getJvmRoute()

Implements org.apache.catalina.SessionIdGenerator.getJvmRoute.

Return the node identifier associated with this node which will be included in the generated session ID.

Returns:String

Doc from org.apache.catalina.SessionIdGenerator.getJvmRoute.

the node identifier associated with this node which will be included in the generated session ID.

Annotations
@Override
getRandomBytesback to summary
protected void getRandomBytes(byte[] bytes)
getSecureRandomAlgorithmback to summary
public String getSecureRandomAlgorithm()

Get the name of the algorithm used to create the SecureRandom instances which generate new session IDs.

Returns:String

The name of the algorithm. null or the empty string means that platform default will be used

getSecureRandomClassback to summary
public String getSecureRandomClass()

Get the class name of the SecureRandom implementation used to generate session IDs.

Returns:String

The fully qualified class name. null indicates that the JRE provided SecureRandom implementation will be used

getSecureRandomProviderback to summary
public String getSecureRandomProvider()

Get the name of the provider used to create the SecureRandom instances which generate new session IDs.

Returns:String

The name of the provider. null or the empty string means that platform default will be used

getSessionIdLengthback to summary
public int getSessionIdLength()

Implements org.apache.catalina.SessionIdGenerator.getSessionIdLength.

Return the number of bytes for a session ID

Returns:int

Doc from org.apache.catalina.SessionIdGenerator.getSessionIdLength.

the number of bytes for a session ID

Annotations
@Override
initInternalback to summary
protected void initInternal() throws LifecycleException

Implements abstract org.apache.catalina.util.LifecycleBase.initInternal.

Doc from org.apache.catalina.util.LifecycleBase.initInternal.

Sub-classes implement this method to perform any instance initialisation required.

Annotations
@Override
Exceptions
LifecycleException:
If the initialisation fails
setJvmRouteback to summary
public void setJvmRoute(String jvmRoute)

Implements org.apache.catalina.SessionIdGenerator.setJvmRoute.

Specify the node identifier associated with this node which will be included in the generated session ID.

Parameters
jvmRoute:String

The node identifier

Annotations
@Override
setSecureRandomAlgorithmback to summary
public void setSecureRandomAlgorithm(String secureRandomAlgorithm)

Specify a non-default algorithm to use to create instances of SecureRandom which are used to generate session IDs. If no algorithm is specified, SHA1PRNG will be used. If SHA1PRNG is not available, the platform default will be used. To use the platform default (which may be SHA1PRNG), specify null or the empty string. If an invalid algorithm and/or provider is specified the SecureRandom instances will be created using the defaults for this SessionIdGenerator implementation. If that fails, the SecureRandom instances will be created using platform defaults.

Parameters
secureRandomAlgorithm:String

The name of the algorithm

setSecureRandomClassback to summary
public void setSecureRandomClass(String secureRandomClass)

Specify a non-default SecureRandom implementation to use. The implementation must be self-seeding and have a zero-argument constructor. If not specified, an instance of SecureRandom will be generated.

Parameters
secureRandomClass:String

The fully-qualified class name

setSecureRandomProviderback to summary
public void setSecureRandomProvider(String secureRandomProvider)

Specify a non-default provider to use to create instances of SecureRandom which are used to generate session IDs. If no provider is specified, the platform default is used. To use the platform default specify null or the empty string. If an invalid algorithm and/or provider is specified the SecureRandom instances will be created using the defaults for this SessionIdGenerator implementation. If that fails, the SecureRandom instances will be created using platform defaults.

Parameters
secureRandomProvider:String

The name of the provider

setSessionIdLengthback to summary
public void setSessionIdLength(int sessionIdLength)

Implements org.apache.catalina.SessionIdGenerator.setSessionIdLength.

Specify the number of bytes for a session ID

Parameters
sessionIdLength:int

Number of bytes

Annotations
@Override
startInternalback to summary
protected void startInternal() throws LifecycleException

Implements abstract org.apache.catalina.util.LifecycleBase.startInternal.

Doc from org.apache.catalina.util.LifecycleBase.startInternal.

Sub-classes must ensure that the state is changed to LifecycleState#STARTING during the execution of this method. Changing state will trigger the Lifecycle#START_EVENT event. If a component fails to start it may either throw a LifecycleException which will cause it's parent to fail to start or it can place itself in the error state in which case stop() will be called on the failed component but the parent component will continue to start normally.

Annotations
@Override
Exceptions
LifecycleException:
Start error occurred
stopInternalback to summary
protected void stopInternal() throws LifecycleException

Implements abstract org.apache.catalina.util.LifecycleBase.stopInternal.

Doc from org.apache.catalina.util.LifecycleBase.stopInternal.

Sub-classes must ensure that the state is changed to LifecycleState#STOPPING during the execution of this method. Changing state will trigger the Lifecycle#STOP_EVENT event.

Annotations
@Override
Exceptions
LifecycleException:
Stop error occurred