tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util SessionIdGenerator.java SessionUtil.java
Date Sat, 18 Nov 2000 01:34:00 GMT
craigmcc    00/11/17 17:34:00

  Modified:    src/share/org/apache/tomcat/request Tag: tomcat_32
                        SessionInterceptor.java
               src/share/org/apache/tomcat/session Tag: tomcat_32
                        StandardManager.java
                        StandardSessionInterceptor.java
               src/share/org/apache/tomcat/util Tag: tomcat_32
                        SessionIdGenerator.java SessionUtil.java
  Log:
  Enable the use of load balancing (behind Apache), even when URL rewriting
  is used to maintain session state.  A *big* thank you to Shai Fultheim for
  creating and testing this patch, and then submitting it multiple times
  because the underlying source files were being changed for other fixes.
  
  Submitted by:	Shai Fultheim <shai@brm.com>
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.24.2.3  +2 -26     jakarta-tomcat/src/share/org/apache/tomcat/request/SessionInterceptor.java
  
  Index: SessionInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/request/SessionInterceptor.java,v
  retrieving revision 1.24.2.2
  retrieving revision 1.24.2.3
  diff -u -r1.24.2.2 -r1.24.2.3
  --- SessionInterceptor.java	2000/11/11 02:07:02	1.24.2.2
  +++ SessionInterceptor.java	2000/11/18 01:33:59	1.24.2.3
  @@ -75,6 +75,8 @@
    * This implementation only handles Cookies sessions, please extend or
    * add new interceptors for other methods.
    *
  + * @author costin@eng.sun.com
  + * @author Shai Fultheim [shai@brm.com]
    */
   public class SessionInterceptor extends  BaseInterceptor
   {
  @@ -112,8 +114,6 @@
   
   	if ((foundAt=uri.indexOf(sig))!=-1){
   	    sessionId=uri.substring(foundAt+sig.length());
  -	    // I hope the optimizer does it's job:-)
  -	    sessionId = fixSessionId( request, sessionId );
   
   	    // rewrite URL, do I need to do anything more?
   	    request.setRequestURI(uri.substring(0, foundAt));
  @@ -126,24 +126,6 @@
   	return 0;
       }
   
  -    /** Fix the session id. If the session is not valid return null.
  -     *  It will also clean up the session from load-balancing strings.
  -     * @return sessionId, or null if not valid
  -     */
  -    private String fixSessionId(Request request, String sessionId){
  -	// GS, We piggyback the JVM id on top of the session cookie
  -	// Separate them ...
  -
  -	if( debug>0 ) cm.log(" Orig sessionId  " + sessionId );
  -	if (null != sessionId) {
  -	    int idex = sessionId.lastIndexOf(SESSIONID_ROUTE_SEP);
  -	    if(idex > 0) {
  -		sessionId = sessionId.substring(0, idex);
  -	    }
  -	}
  -	return sessionId;
  -    }
  -
       public int beforeBody( Request rrequest, Response response ) {
       	String reqSessionId = response.getSessionId();
   	if( debug>0 ) cm.log("Before Body " + reqSessionId );
  @@ -157,12 +139,6 @@
           String sessionPath = rrequest.getContext().getPath();
           if(sessionPath.length() == 0) {
               sessionPath = "/";
  -        }
  -
  -        // GS, piggyback the jvm route on the session id.
  -        String jvmRoute = rrequest.getJvmRoute();
  -        if(null != jvmRoute) {
  -            reqSessionId = reqSessionId + SESSIONID_ROUTE_SEP + jvmRoute;
           }
   
   	Cookie cookie = new Cookie("JSESSIONID",
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.11.2.1  +7 -6      jakarta-tomcat/src/share/org/apache/tomcat/session/Attic/StandardManager.java
  
  Index: StandardManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/session/Attic/StandardManager.java,v
  retrieving revision 1.11
  retrieving revision 1.11.2.1
  diff -u -r1.11 -r1.11.2.1
  --- StandardManager.java	2000/06/18 20:14:13	1.11
  +++ StandardManager.java	2000/11/18 01:33:59	1.11.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/session/Attic/StandardManager.java,v
1.11 2000/06/18 20:14:13 jon Exp $
  - * $Revision: 1.11 $
  - * $Date: 2000/06/18 20:14:13 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/session/Attic/StandardManager.java,v
1.11.2.1 2000/11/18 01:33:59 craigmcc Exp $
  + * $Revision: 1.11.2.1 $
  + * $Date: 2000/11/18 01:33:59 $
    *
    * ====================================================================
    *
  @@ -102,7 +102,8 @@
    * @author Craig R. McClanahan
    * @author costin@eng.sun.com
    * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
  - * @version $Revision: 1.11 $ $Date: 2000/06/18 20:14:13 $
  + * @author Shai Fultheim [shai@brm.com]
  + * @version $Revision: 1.11.2.1 $ $Date: 2000/11/18 01:33:59 $
    */
   public final class StandardManager implements Runnable  {
       // ----------------------------------------------------- Instance Variables
  @@ -351,7 +352,7 @@
        * @exception IllegalStateException if a new session cannot be
        *  instantiated for any reason
        */
  -    public HttpSession getNewSession() {
  +    public HttpSession getNewSession(String jsIdent) {
   
   	if ((maxActiveSessions >= 0) &&
   	  (sessions.size() >= maxActiveSessions))
  @@ -375,7 +376,7 @@
   	session.setValid(true);
   	session.setCreationTime(System.currentTimeMillis());
   	session.setMaxInactiveInterval(this.maxInactiveInterval);
  -	session.setId(SessionUtil.generateSessionId());
  +	session.setId(SessionUtil.generateSessionId(jsIdent));
   
   	return (session);
       }
  
  
  
  1.5.2.3   +2 -16     jakarta-tomcat/src/share/org/apache/tomcat/session/StandardSessionInterceptor.java
  
  Index: StandardSessionInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/session/StandardSessionInterceptor.java,v
  retrieving revision 1.5.2.2
  retrieving revision 1.5.2.3
  diff -u -r1.5.2.2 -r1.5.2.3
  --- StandardSessionInterceptor.java	2000/11/15 04:19:19	1.5.2.2
  +++ StandardSessionInterceptor.java	2000/11/18 01:33:59	1.5.2.3
  @@ -86,6 +86,7 @@
    *
    * @author costin@eng.sun.com
    * @author hans@gefionsoftware.com (fixed it so that URL session ID is used)
  + * @author Shai Fultheim [shai@brm.com]
    */
   public final class StandardSessionInterceptor  extends BaseInterceptor {
       int manager_note;
  @@ -145,7 +146,6 @@
   
   		if (cookie.getName().equals("JSESSIONID")) {
   			sessionId = cookie.getValue();
  -			sessionId = fixSessionId( request, sessionId );
                           if (debug > 0) log("Found session id cookie " + sessionId);
                           request.setRequestedSessionId( sessionId );
                           request.setSessionIdSource( Request.SESSIONID_FROM_COOKIE );
  @@ -174,7 +174,7 @@
   
   	if( request.getSession( false ) != null )
   	    return 0; // somebody already set the session
  -	HttpSession newS=sM.getNewSession();
  +	HttpSession newS=sM.getNewSession(request.getJvmRoute());
   	request.setSession( newS );
   	return 0;
       }
  @@ -237,20 +237,6 @@
   	} catch(IllegalStateException ex ) {
   	    throw new TomcatException( ex );
   	}
  -    }
  -
  -    private String fixSessionId(Request request, String sessionId){
  -	// GS, We piggyback the JVM id on top of the session cookie
  -	// Separate them ...
  -
  -	if( debug>0 ) cm.log(" Orig sessionId  " + sessionId );
  -	if (null != sessionId) {
  -	    int idex = sessionId.lastIndexOf(SESSIONID_ROUTE_SEP);
  -	    if(idex > 0) {
  -		sessionId = sessionId.substring(0, idex);
  -	    }
  -	}
  -	return sessionId;
       }
   
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.3.2.2   +6 -5      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.3.2.1
  retrieving revision 1.3.2.2
  diff -u -r1.3.2.1 -r1.3.2.2
  --- SessionIdGenerator.java	2000/08/23 20:23:16	1.3.2.1
  +++ SessionIdGenerator.java	2000/11/18 01:33:59	1.3.2.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/SessionIdGenerator.java,v
1.3.2.1 2000/08/23 20:23:16 jiricka Exp $
  - * $Revision: 1.3.2.1 $
  - * $Date: 2000/08/23 20:23:16 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/SessionIdGenerator.java,v
1.3.2.2 2000/11/18 01:33:59 craigmcc Exp $
  + * $Revision: 1.3.2.2 $
  + * $Date: 2000/11/18 01:33:59 $
    *
    * ====================================================================
    *
  @@ -76,6 +76,7 @@
    * @author James Duncan Davidson [duncan@eng.sun.com]
    * @author Jason Hunter [jhunter@acm.org]
    * @author Jon S. Stevens <a href="mailto:jon@latchkey.com">jon@latchkey.com</a>
  + * @author Shai Fultheim [shai@brm.com]
    */
   public class SessionIdGenerator {
   
  @@ -172,7 +173,7 @@
           return sessionId.toString();
       }
   
  -    public static synchronized String generateId() {
  -        return getIdentifier(null);
  +    public static synchronized String generateId(String jsIdent) {
  +        return getIdentifier(jsIdent);
       }
   }
  
  
  
  1.5.2.2   +7 -6      jakarta-tomcat/src/share/org/apache/tomcat/util/Attic/SessionUtil.java
  
  Index: SessionUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/Attic/SessionUtil.java,v
  retrieving revision 1.5.2.1
  retrieving revision 1.5.2.2
  diff -u -r1.5.2.1 -r1.5.2.2
  --- SessionUtil.java	2000/08/25 23:01:15	1.5.2.1
  +++ SessionUtil.java	2000/11/18 01:34:00	1.5.2.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/Attic/SessionUtil.java,v
1.5.2.1 2000/08/25 23:01:15 nacho Exp $
  - * $Revision: 1.5.2.1 $
  - * $Date: 2000/08/25 23:01:15 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/Attic/SessionUtil.java,v
1.5.2.2 2000/11/18 01:34:00 craigmcc Exp $
  + * $Revision: 1.5.2.2 $
  + * $Date: 2000/11/18 01:34:00 $
    *
    * ====================================================================
    *
  @@ -74,7 +74,8 @@
    * <code>Session</code> implementations.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.5.2.1 $ $Date: 2000/08/25 23:01:15 $
  + * @author Shai Fultheim [shai@brm.com]
  + * @version $Revision: 1.5.2.2 $ $Date: 2000/11/18 01:34:00 $
    */
   
   public final class SessionUtil {
  @@ -175,8 +176,8 @@
       /**
        * Generate and return a new session identifier.
        */
  -    public static String generateSessionId() {
  -        return SessionIdGenerator.generateId();
  +    public static String generateSessionId(String jsIdent) {
  +        return SessionIdGenerator.generateId(jsIdent);
       }
   
       /**
  
  
  

Mime
View raw message