tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util MessageBytes.java MimeHeaders.java MimeMap.java SessionIdGenerator.java
Date Wed, 01 Nov 2000 21:43:31 GMT
costin      00/11/01 13:43:29

  Modified:    src/share/org/apache/tomcat/util MessageBytes.java
                        MimeHeaders.java MimeMap.java
                        SessionIdGenerator.java
  Log:
  - added indexOf( c, starting ) to MessageBytes
  
  - in SessionIdGenerator, allow the caller to pass a Random source.
  That will allow to configure the SessionInterceptor to use a certain
  random instead of making config decisions at tomcat.util level.
  
  Revision  Changes    Path
  1.12      +8 -4      jakarta-tomcat/src/share/org/apache/tomcat/util/MessageBytes.java
  
  Index: MessageBytes.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/MessageBytes.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- MessageBytes.java	2000/10/08 21:28:59	1.11
  +++ MessageBytes.java	2000/11/01 21:43:28	1.12
  @@ -643,27 +643,31 @@
   	return code;
       }
   
  +    public int indexOf(char c) {
  +	return indexOf( c, 0);
  +    }
  +    
       /**
        * Returns true if the message bytes starts with the specified string.
        * @param s the string
        */
  -    public int indexOf(char c) {
  +    public int indexOf(char c, int starting) {
   	switch (type) {
   	case T_INT:
   	case T_DATE:
   	    String s1=toString();
   	    // continue with T_STR - it now have a strValue
   	case T_STR:
  -	    return strValue.indexOf( c );
  +	    return strValue.indexOf( c, starting );
   	case T_CHARS:
  -	    for (int i = charsOff; i < charsOff + charsLen; i++) {
  +	    for (int i = charsOff+starting; i < charsOff + charsLen; i++) {
   		if( c == chars[i] ) return i;
   	    }
   	    return -1;
   	case T_BYTES:
   	    int max=bytesOff+bytesLen;
   	    byte bb[]=bytes;
  -	    for (int i = bytesOff; i < max ; i++) {
  +	    for (int i = bytesOff+starting; i < max ; i++) {
   		if( (byte)c == bb[i]) return i;
   	    }
   	    return -1;
  
  
  
  1.16      +0 -3      jakarta-tomcat/src/share/org/apache/tomcat/util/MimeHeaders.java
  
  Index: MimeHeaders.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/MimeHeaders.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- MimeHeaders.java	2000/09/22 20:31:43	1.15
  +++ MimeHeaders.java	2000/11/01 21:43:28	1.16
  @@ -1,7 +1,4 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/MimeHeaders.java,v
1.15 2000/09/22 20:31:43 nacho Exp $
  - * $Revision: 1.15 $
  - * $Date: 2000/09/22 20:31:43 $
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  
  
  
  1.6       +0 -4      jakarta-tomcat/src/share/org/apache/tomcat/util/MimeMap.java
  
  Index: MimeMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/MimeMap.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MimeMap.java	2000/06/10 17:54:29	1.5
  +++ MimeMap.java	2000/11/01 21:43:28	1.6
  @@ -1,8 +1,4 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/MimeMap.java,v 1.5
2000/06/10 17:54:29 costin Exp $
  - * $Revision: 1.5 $
  - * $Date: 2000/06/10 17:54:29 $
  - *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  
  
  
  1.5       +24 -10    jakarta-tomcat/src/share/org/apache/tomcat/util/SessionIdGenerator.java
  
  Index: SessionIdGenerator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/SessionIdGenerator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SessionIdGenerator.java	2000/08/23 20:21:49	1.4
  +++ SessionIdGenerator.java	2000/11/01 21:43:28	1.5
  @@ -1,8 +1,4 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/SessionIdGenerator.java,v
1.4 2000/08/23 20:21:49 jiricka Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/08/23 20:21:49 $
  - *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  @@ -64,6 +60,8 @@
   
   package org.apache.tomcat.util;
   
  +import java.util.Random;
  +
   /**
    * This class generates a unique 10+ character id. This is good
    * for authenticating users or tracking users around.
  @@ -89,7 +87,7 @@
        */
       static private int session_count = 0;
       static private long lastTimeVal = 0;
  -    static private java.util.Random randomSource;
  +    static private java.util.Random globalRandomSource;
   
       // MAX_RADIX is 36
       /*
  @@ -115,12 +113,16 @@
   
       // ** NOTE that this must work together with get_jserv_session_balance()
       // ** in jserv_balance.c
  -    static synchronized public String getIdentifier (String jsIdent)
  +    static synchronized public String getIdentifier (Random randomSource,
  +						     String jsIdent)
       {
           StringBuffer sessionId = new StringBuffer();
  -        
  +	if( randomSource==null)
  +	    randomSource= globalRandomSource;
  +	
           if (randomSource == null) {
  -            String className = System.getProperty("tomcat.sessionid.randomclass");
  +            String className = System.
  +		getProperty("tomcat.sessionid.randomclass");
               if (className != null) {
                   try {
                       Class randomClass = Class.forName(className);
  @@ -132,6 +134,8 @@
               }
               if (randomSource == null)
                   randomSource = new java.security.SecureRandom();
  +	    
  +	    globalRandomSource = randomSource;
           }
   
           // random value ..
  @@ -172,7 +176,17 @@
           return sessionId.toString();
       }
   
  -    public static synchronized String generateId() {
  -        return getIdentifier(null);
  +    static synchronized public String getIdentifier (String jsIdent)
  +    {
  +	return getIdentifier( globalRandomSource, jsIdent);
  +    }
  +    
  +    static synchronized public String getIdentifier ()
  +    {
  +	return getIdentifier( globalRandomSource, null);
  +    }
  +    
  +    public static synchronized String generateId(Random randomSource) {
  +        return getIdentifier(randomSource, null);
       }
   }
  
  
  

Mime
View raw message