Skip to content

Commit

Permalink
Add getters.
Browse files Browse the repository at this point in the history
Improve Javadoc.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1636541 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed Nov 4, 2014
1 parent 176189b commit df615ec
Showing 1 changed file with 58 additions and 29 deletions.
87 changes: 58 additions & 29 deletions java/org/apache/catalina/util/SessionIdGeneratorBase.java
Expand Up @@ -48,36 +48,10 @@ public abstract class SessionIdGeneratorBase extends LifecycleBase
*/
private final Queue<SecureRandom> randoms = new ConcurrentLinkedQueue<>();


/**
* The Java class name of the secure random number generator class to be
* used when generating session identifiers. The random number generator
* class must be self-seeding and have a zero-argument constructor. If not
* specified, an instance of {@link SecureRandom} will be generated.
*/
private String secureRandomClass = null;


/**
* The name of the algorithm to use to create instances of
* {@link SecureRandom} which are used to generate session IDs. If no
* algorithm is specified, SHA1PRNG is used. To use the platform default
* (which may be SHA1PRNG), specify the empty string. If an invalid
* algorithm and/or provider is specified the {@link SecureRandom} instances
* will be created using the defaults. If that fails, the {@link
* SecureRandom} instances will be created using platform defaults.
*/
private String secureRandomAlgorithm = "SHA1PRNG";


/**
* The name of the provider to use to create instances of
* {@link SecureRandom} which are used to generate session IDs. If
* no algorithm is specified the of SHA1PRNG default is used. If an invalid
* algorithm and/or provider is specified the {@link SecureRandom} instances
* will be created using the defaults. If that fails, the {@link
* SecureRandom} instances will be created using platform defaults.
*/
private String secureRandomProvider = null;


Expand All @@ -90,7 +64,21 @@ public abstract class SessionIdGeneratorBase extends LifecycleBase


/**
* Specify a non-default @{link {@link SecureRandom} implementation to use.
* Get the class name of the {@link SecureRandom} implementation used to
* generate session IDs.
*
* @return The fully qualified class name. {@code null} indicates that the
* JRE provided {@link SecureRandom} implementation will be used
*/
public String getSecureRandomClass() {
return secureRandomClass;
}


/**
* Specify a non-default {@link SecureRandom} implementation to use. The
* implementation must be self-seeding and have a zero-argument constructor.
* If not specified, an instance of {@link SecureRandom} will be generated.
*
* @param secureRandomClass The fully-qualified class name
*/
Expand All @@ -100,7 +88,26 @@ public void setSecureRandomClass(String secureRandomClass) {


/**
* Specify a non-default algorithm to use to generate random numbers.
* Get the name of the algorithm used to create the {@link SecureRandom}
* instances which generate new session IDs.
*
* @return The name of the algorithm. {@code null} or the empty string means
* that platform default will be used
*/
public String getSecureRandomAlgorithm() {
return secureRandomAlgorithm;
}


/**
* Specify a non-default algorithm to use to create instances of
* {@link SecureRandom} which are used to generate session IDs. If no
* algorithm is specified, SHA1PRNG is used. To use the platform default
* (which may be SHA1PRNG), specify {@code null} or the empty string. If an
* invalid algorithm and/or provider is specified the {@link SecureRandom}
* instances will be created using the defaults for this
* {@link SessionIdGenerator} implementation. If that fails, the
* {@link SecureRandom} instances will be created using platform defaults.
*
* @param secureRandomAlgorithm The name of the algorithm
*/
Expand All @@ -110,7 +117,26 @@ public void setSecureRandomAlgorithm(String secureRandomAlgorithm) {


/**
* Specify a non-default provider to use to generate random numbers.
* Get the name of the provider used to create the {@link SecureRandom}
* instances which generate new session IDs.
*
* @return The name of the provider. {@code null} or the empty string means
* that platform default will be used
*/
public String getSecureRandomProvider() {
return secureRandomProvider;
}


/**
* Specify a non-default provider to use to create instances of
* {@link SecureRandom} which are used to generate session IDs. If no
* provider is specified, the platform default is used. To use the platform
* default specify {@code null} or the empty string. If an invalid algorithm
* and/or provider is specified the {@link SecureRandom} instances will be
* created using the defaults for this {@link SessionIdGenerator}
* implementation. If that fails, the {@link SecureRandom} instances will be
* created using platform defaults.
*
* @param secureRandomProvider The name of the provider
*/
Expand Down Expand Up @@ -148,6 +174,8 @@ public void setJvmRoute(String jvmRoute) {
public int getSessionIdLength() {
return sessionIdLength;
}


/**
* Specify the number of bytes for a session ID
*
Expand All @@ -167,6 +195,7 @@ public String generateSessionId() {
return generateSessionId(jvmRoute);
}


protected void getRandomBytes(byte bytes[]) {

SecureRandom random = randoms.poll();
Expand Down

0 comments on commit df615ec

Please sign in to comment.