tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Petr Jiricka <petr.jiri...@netbeans.com>
Subject RE: Tomcat startup time
Date Fri, 18 Aug 2000 09:05:24 GMT
You mean something like this ?
Will this work then ?

Petr


Index: etc/server.xml
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/etc/server.xml,v
retrieving revision 1.29.2.2
diff -u -r1.29.2.2 server.xml
--- etc/server.xml      2000/07/25 20:34:05     1.29.2.2
+++ etc/server.xml      2000/08/18 08:49:20
@@ -81,7 +81,12 @@
          all relative paths. If none is set, the TOMCAT_HOME property
          will be used, and if not set "." will be used.
          webapps/, work/ and log/ will be relative to this ( unless
-         set explicitely to absolute paths )
+         set explicitely to absolute paths ).
+         You can also specify a "randomClass" attribute, which determines
+         a subclass of java.util.Random will be used for generating session
IDs.
+         By default this is "java.security.SecureRandom".
+         Specifying "java.util.Random" will speed up Tomcat startup,
+         but it will cause sessions to be less secure.
       -->
     <ContextManager debug="0" workDir="work" >
         <!--
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.jav
a,v
retrieving revision 1.100.2.2
diff -u -r1.100.2.2 ContextManager.java
--- share/org/apache/tomcat/core/ContextManager.java    2000/07/25 21:00:24
1.100.2.2
+++ share/org/apache/tomcat/core/ContextManager.java    2000/08/18 08:49:30
@@ -295,6 +295,21 @@
     public void setPermissions(Object permissions) {
        this.permissions = permissions;
     }
+
+    /** Get the name of the class to be used for generating random numbers
by the
+     * session id generator. By default this is
<code>java.security.SecureRandom</code>.
+     **/
+    public String getRandomClass() {
+        String randomClass =
System.getProperty("tomcat.sessionid.randomclass");
+        return randomClass == null ? "java.security.SecureRandom" :
randomClass;
+    }
+
+    /** Sets the name of the class used for generating random numbers by
the
+     *  session id generator.
+     */
+    public void setRandomClass(String randomClass) {
+        System.setProperty("tomcat.sessionid.randomclass", randomClass);
+    }

Index: share/org/apache/tomcat/util/SessionIdGenerator.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/SessionIdGenerator
.java,v
retrieving revision 1.3
diff -u -r1.3 SessionIdGenerator.java
--- share/org/apache/tomcat/util/SessionIdGenerator.java        2000/06/17
00:24:45     1.3
+++ share/org/apache/tomcat/util/SessionIdGenerator.java        2000/08/18
08:49:34
@@ -89,7 +89,7 @@
      */
     static private int session_count = 0;
     static private long lastTimeVal = 0;
-    static private java.util.Random randomSource = new
java.security.SecureRandom();
+    static private java.util.Random randomSource;

     // MAX_RADIX is 36
     /*
@@ -118,6 +118,21 @@
     static synchronized public String getIdentifier (String jsIdent)
     {
         StringBuffer sessionId = new StringBuffer();
+
+        if (randomSource == null) {
+            String className =
System.getProperty("tomcat.sessionid.randomclass");
+            if (className != null) {
+                try {
+                    Class randomClass = Class.forName(className);
+                    randomSource =
(java.util.Random)randomClass.newInstance();
+                }
+                catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+            if (randomSource == null)
+                randomSource = new java.security.SecureRandom();
+        }

         // random value ..
         long n = randomSource.nextLong();









> -----Original Message-----
> From: cmanolache@yahoo.com [mailto:cmanolache@yahoo.com]
> Sent: Friday, August 18, 2000 9:47 AM
> To: tomcat-dev@jakarta.apache.org; alex@jguru.com
> Subject: Re: Tomcat startup time
> 
> 
> > On Thu, Aug 17, 2000 at 05:31:19PM +0200, Petr Jiricka wrote:
> > > I agree with Alex's suggestion, although we probably 
> don't want to change
> > > the format of server.xml for 3.2, right ?
> > 
> > Why not?  Costin seems to think it's straightforward, and 
> in any case,
> > we'd just be adding functionality, not breaking anything.  
> I think we
> > should just implement things as best we can, and let the 3.2 build
> > manager decide if a solution is fully-baked enough to allow 
> into 3.2.
> 
> Yes, I agree with that. The patch looks great, except that I would not
> touch Tomcat.java - all you need to do is add the get/set methods in
> ContextManager, and use <contextManager property="value" />.
> 
> By default any String/int/boolean property that has get/set method is
> mapped to xml attributes, no need to do anything. That's true for
> ContextManager, Context and Interceptors.
> 
> I think it's safe and fine to do the change for 3.2.
> 
> Do we have any plan for 3.2 release ?
> 
> Costin
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> 

Mime
View raw message