From: markt Date: Fri, 25 Mar 2011 11:50:27 +0000 (+0000) Subject: Include the seed time when calculating the time taken to create SecureRandom instance... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=e793c14157c7ad4dac011157210a85f44b1cc0b8;p=tomcat7.0 Include the seed time when calculating the time taken to create SecureRandom instances for session ID generation, report excessive times (greater than 100ms) at INFO level and provide a value for the message key so a meaningful message appears in the logs. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1085336 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/util/LocalStrings.properties b/java/org/apache/catalina/util/LocalStrings.properties index 70d9eaa53..af98d775f 100644 --- a/java/org/apache/catalina/util/LocalStrings.properties +++ b/java/org/apache/catalina/util/LocalStrings.properties @@ -36,6 +36,7 @@ requestUtil.parseParameters.uee=Unable to parse the parameters since the encodin requestUtil.urlDecode.missingDigit=The % character must be followed by two hexademical digits requestUtil.urlDecode.uee=Unable to URL decode the specified input since the encoding [{0}] is not supported. SecurityUtil.doAsPrivilege=An exception occurs when running the PrivilegedExceptionAction block. +sessionIdGenerator.createRandom=Creation of SecureRandom instance for session ID generation using [{0}] took [{1}] milliseconds. sessionIdGenerator.random=Exception initializing random number generator of class [{0}]. Falling back to java.secure.SecureRandom sessionIdGenerator.randomAlgorithm=Exception initializing random number generator using algorithm [{0}] sessionIdGenerator.randomProviderException initializing random number generator using provider [{0}] diff --git a/java/org/apache/catalina/util/SessionIdGenerator.java b/java/org/apache/catalina/util/SessionIdGenerator.java index 8d5a42903..49ce6b76f 100644 --- a/java/org/apache/catalina/util/SessionIdGenerator.java +++ b/java/org/apache/catalina/util/SessionIdGenerator.java @@ -242,12 +242,13 @@ public class SessionIdGenerator { result = new SecureRandom(); } - if(log.isDebugEnabled()) { - long t2=System.currentTimeMillis(); - if( (t2-t1) > 100 ) - log.debug(sm.getString("sessionIdGenerator.createRandom", - Long.valueOf(t2-t1))); - } + // Force seeding to take place + result.nextInt(); + + long t2=System.currentTimeMillis(); + if( (t2-t1) > 100 ) + log.info(sm.getString("sessionIdGenerator.createRandom", + result.getAlgorithm(), Long.valueOf(t2-t1))); return result; } } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index ad1dfed9c..b9be91e42 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -85,6 +85,12 @@ Resolve some refactoring TODOs in the implementation of the new Context attribute "swallowAbortedUploads". (markt) + + Include the seed time when calculating the time taken to create + SecureRandom instances for session ID generation, report excessive times + (greater than 100ms) at INFO level and provide a value for the message + key so a meaningful message appears in the logs. (markt) +