tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r802064 - /tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java
Date Fri, 07 Aug 2009 16:10:27 GMT
Author: markt
Date: Fri Aug  7 16:10:27 2009
New Revision: 802064

URL: http://svn.apache.org/viewvc?rev=802064&view=rev
Log:
Get SSL session tracking working again.
If you use http you'll get new session ID on every request
If you use https you get the SSL session ID

Modified:
    tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java

Modified: tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java?rev=802064&r1=802063&r2=802064&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java Fri Aug  7 16:10:27
2009
@@ -47,8 +47,11 @@
 import javax.servlet.SessionTrackingMode;
 
 import org.apache.catalina.Context;
+import org.apache.catalina.Engine;
 import org.apache.catalina.Host;
+import org.apache.catalina.Service;
 import org.apache.catalina.Wrapper;
+import org.apache.catalina.connector.Connector;
 import org.apache.catalina.deploy.ApplicationParameter;
 import org.apache.catalina.util.Enumerator;
 import org.apache.catalina.util.RequestUtil;
@@ -90,8 +93,8 @@
         this.context = context;
         this.basePath = basePath;
         
-        // Populate default session tracking modes
-        populateDefaultSessionTrackingModes();
+        // Populate session tracking modes
+        populateSessionTrackingModes();
     }
 
 
@@ -175,6 +178,7 @@
      */
     private EnumSet<SessionTrackingMode> sessionTrackingModes = null;
     private EnumSet<SessionTrackingMode> defaultSessionTrackingModes = null;
+    private EnumSet<SessionTrackingMode> supportedSessionTrackingModes = null;
 
     // --------------------------------------------------------- Public Methods
 
@@ -980,15 +984,27 @@
         return defaultSessionTrackingModes;
     }
 
-    private void populateDefaultSessionTrackingModes() {
+    private void populateSessionTrackingModes() {
         // URL re-writing is always enabled by default
         defaultSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL); 
+        supportedSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL);
         
         if (context.getCookies()) {
             defaultSessionTrackingModes.add(SessionTrackingMode.COOKIE);
+            supportedSessionTrackingModes.add(SessionTrackingMode.COOKIE);
         }
 
         // SSL not enabled by default as it can only used on its own 
+        // Context > Host > Engine > Service
+        Service s = ((Engine) context.getParent().getParent()).getService();
+        Connector[] connectors = s.findConnectors();
+        // Need at least one SSL enabled connector to use the SSL session ID.
+        for (Connector connector : connectors) {
+            if (Boolean.TRUE.equals(connector.getAttribute("SSLEnabled"))) {
+                supportedSessionTrackingModes.add(SessionTrackingMode.SSL);
+                break;
+            }
+        } 
     }
 
     /**
@@ -1025,7 +1041,7 @@
         
         // Check that only supported tracking modes have been requested
         for (SessionTrackingMode sessionTrackingMode : sessionTrackingModes) {
-            if (!defaultSessionTrackingModes.contains(sessionTrackingMode)) {
+            if (!supportedSessionTrackingModes.contains(sessionTrackingMode)) {
                 throw new IllegalArgumentException(sm.getString(
                         "applicationContext.setSessionTracking.iae.invalid",
                         sessionTrackingMode.toString(), getContextPath()));



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message