tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1240857 - in /tomcat/trunk/java/org/apache/catalina: connector/CoyoteAdapter.java connector/Response.java core/ApplicationSessionCookieConfig.java realm/RealmBase.java util/SessionConfig.java
Date Sun, 05 Feb 2012 23:24:36 GMT
Author: markt
Date: Sun Feb  5 23:24:36 2012
New Revision: 1240857

URL: http://svn.apache.org/viewvc?rev=1240857&view=rev
Log:
Remove a package dependency

Added:
    tomcat/trunk/java/org/apache/catalina/util/SessionConfig.java
Modified:
    tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
    tomcat/trunk/java/org/apache/catalina/connector/Response.java
    tomcat/trunk/java/org/apache/catalina/core/ApplicationSessionCookieConfig.java
    tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java

Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java?rev=1240857&r1=1240856&r2=1240857&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java Sun Feb  5 23:24:36
2012
@@ -29,9 +29,9 @@ import org.apache.catalina.Host;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.comet.CometEvent;
 import org.apache.catalina.comet.CometEvent.EventType;
-import org.apache.catalina.core.ApplicationSessionCookieConfig;
 import org.apache.catalina.core.AsyncContextImpl;
 import org.apache.catalina.util.ServerInfo;
+import org.apache.catalina.util.SessionConfig;
 import org.apache.catalina.util.URLEncoder;
 import org.apache.coyote.ActionCode;
 import org.apache.coyote.Adapter;
@@ -676,7 +676,7 @@ public class CoyoteAdapter implements Ad
 
                 // Get the session ID if there was one
                 sessionID = request.getPathParameter(
-                        ApplicationSessionCookieConfig.getSessionUriParamName(
+                        SessionConfig.getSessionUriParamName(
                                 request.getContext()));
                 if (sessionID != null) {
                     request.setRequestedSessionId(sessionID);
@@ -731,7 +731,7 @@ public class CoyoteAdapter implements Ad
                 // This is not optimal, but as this is not very common, it
                 // shouldn't matter
                 redirectPath = redirectPath + ";" +
-                    ApplicationSessionCookieConfig.getSessionUriParamName(
+                        SessionConfig.getSessionUriParamName(
                             request.getContext()) +
                     "=" + request.getRequestedSessionId();
             }
@@ -921,8 +921,7 @@ public class CoyoteAdapter implements Ad
             return;
         }
 
-        String sessionCookieName =
-            ApplicationSessionCookieConfig.getSessionCookieName(context);
+        String sessionCookieName = SessionConfig.getSessionCookieName(context);
 
         for (int i = 0; i < count; i++) {
             ServerCookie scookie = serverCookies.getCookie(i);

Modified: tomcat/trunk/java/org/apache/catalina/connector/Response.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/Response.java?rev=1240857&r1=1240856&r2=1240857&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/Response.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/Response.java Sun Feb  5 23:24:36 2012
@@ -42,11 +42,11 @@ import org.apache.catalina.Context;
 import org.apache.catalina.Globals;
 import org.apache.catalina.Session;
 import org.apache.catalina.Wrapper;
-import org.apache.catalina.core.ApplicationSessionCookieConfig;
 import org.apache.catalina.security.SecurityUtil;
 import org.apache.catalina.util.CharsetMapper;
 import org.apache.catalina.util.DateTool;
 import org.apache.catalina.util.RequestUtil;
+import org.apache.catalina.util.SessionConfig;
 import org.apache.tomcat.util.buf.CharChunk;
 import org.apache.tomcat.util.buf.UEncoder;
 import org.apache.tomcat.util.http.FastHttpDateFormat;
@@ -1502,8 +1502,7 @@ public class Response
                 return (false);
             }
             String tok = ";" +
-                    ApplicationSessionCookieConfig.getSessionUriParamName(
-                                request.getContext()) +
+                    SessionConfig.getSessionUriParamName(request.getContext()) +
                     "=" + session.getIdInternal();
             if( file.indexOf(tok, contextPath.length()) >= 0 ) {
                 return (false);
@@ -1676,7 +1675,7 @@ public class Response
         StringBuilder sb = new StringBuilder(path);
         if( sb.length() > 0 ) { // jsessionid can't be first.
             sb.append(";");
-            sb.append(ApplicationSessionCookieConfig.getSessionUriParamName(
+            sb.append(SessionConfig.getSessionUriParamName(
                     request.getContext()));
             sb.append("=");
             sb.append(sessionId);

Modified: tomcat/trunk/java/org/apache/catalina/core/ApplicationSessionCookieConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ApplicationSessionCookieConfig.java?rev=1240857&r1=1240856&r2=1240857&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationSessionCookieConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/ApplicationSessionCookieConfig.java Sun Feb
 5 23:24:36 2012
@@ -21,12 +21,10 @@ import javax.servlet.SessionCookieConfig
 import javax.servlet.http.Cookie;
 
 import org.apache.catalina.Context;
+import org.apache.catalina.util.SessionConfig;
 
 public class ApplicationSessionCookieConfig implements SessionCookieConfig {
 
-    private static final String DEFAULT_SESSION_COOKIE_NAME = "JSESSIONID";
-    private static final String DEFAULT_SESSION_PARAMETER_NAME = "jsessionid";
-
     private boolean httpOnly;
     private boolean secure;
     private int maxAge = -1;
@@ -124,7 +122,8 @@ public class ApplicationSessionCookieCon
         //       2. Values from SessionCookieConfig
         //       3. Defaults
 
-        Cookie cookie = new Cookie(getSessionCookieName(context), sessionId);
+        Cookie cookie = new Cookie(
+                SessionConfig.getSessionCookieName(context), sessionId);
 
         // Just apply the defaults.
         cookie.setMaxAge(scc.getMaxAge());
@@ -176,60 +175,31 @@ public class ApplicationSessionCookieCon
         return cookie;
     }
 
-
-    private static String getConfiguredSessionCookieName(Context context) {
-
-        // Priority is:
-        // 1. Cookie name defined in context
-        // 2. Cookie name configured for app
-        // 3. Default defined by spec
-        if (context != null) {
-            String cookieName = context.getSessionCookieName();
-            if (cookieName != null && cookieName.length() > 0) {
-                return cookieName;
-            }
-
-            SessionCookieConfig scc =
-                context.getServletContext().getSessionCookieConfig();
-            cookieName = scc.getName();
-            if (cookieName != null && cookieName.length() > 0) {
-                return cookieName;
-            }
-        }
-
-        return null;
-    }
-
-
     /**
      * Determine the name to use for the session cookie for the provided
      * context.
      * @param context
+     *
+     * @deprecated  Replaced by
+     *              {@link SessionConfig#getSessionCookieName(Context)}. This
+     *              will be removed in Tomcat 8.0.x.
      */
+    @Deprecated
     public static String getSessionCookieName(Context context) {
-
-        String result = getConfiguredSessionCookieName(context);
-
-        if (result == null) {
-            result = DEFAULT_SESSION_COOKIE_NAME;
-        }
-
-        return result;
+        return SessionConfig.getSessionCookieName(context);
     }
 
     /**
      * Determine the name to use for the session cookie for the provided
      * context.
      * @param context
+     *
+     * @deprecated  Replaced by
+     *              {@link SessionConfig#getSessionUriParamName(Context)}. This
+     *              will be removed in Tomcat 8.0.x.
      */
+    @Deprecated
     public static String getSessionUriParamName(Context context) {
-
-        String result = getConfiguredSessionCookieName(context);
-
-        if (result == null) {
-            result = DEFAULT_SESSION_PARAMETER_NAME;
-        }
-
-        return result;
+        return SessionConfig.getSessionUriParamName(context);
     }
 }

Modified: tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java?rev=1240857&r1=1240856&r2=1240857&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java Sun Feb  5 23:24:36 2012
@@ -42,12 +42,12 @@ import org.apache.catalina.Service;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
-import org.apache.catalina.core.ApplicationSessionCookieConfig;
 import org.apache.catalina.deploy.LoginConfig;
 import org.apache.catalina.deploy.SecurityCollection;
 import org.apache.catalina.deploy.SecurityConstraint;
 import org.apache.catalina.util.LifecycleMBeanBase;
 import org.apache.catalina.util.MD5Encoder;
+import org.apache.catalina.util.SessionConfig;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.buf.B2CConverter;
@@ -994,7 +994,7 @@ public abstract class RealmBase extends 
         if ((requestedSessionId != null) &&
             request.isRequestedSessionIdFromURL()) {
             file.append(";");
-            file.append(ApplicationSessionCookieConfig.getSessionUriParamName(
+            file.append(SessionConfig.getSessionUriParamName(
                     request.getContext()));
             file.append("=");
             file.append(requestedSessionId);

Added: tomcat/trunk/java/org/apache/catalina/util/SessionConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/SessionConfig.java?rev=1240857&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/SessionConfig.java (added)
+++ tomcat/trunk/java/org/apache/catalina/util/SessionConfig.java Sun Feb  5 23:24:36 2012
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.util;
+
+import javax.servlet.SessionCookieConfig;
+
+import org.apache.catalina.Context;
+
+public class SessionConfig {
+
+    private static final String DEFAULT_SESSION_COOKIE_NAME = "JSESSIONID";
+    private static final String DEFAULT_SESSION_PARAMETER_NAME = "jsessionid";
+
+    /**
+     * Determine the name to use for the session cookie for the provided
+     * context.
+     * @param context
+     */
+    public static String getSessionCookieName(Context context) {
+
+        String result = getConfiguredSessionCookieName(context);
+
+        if (result == null) {
+            result = DEFAULT_SESSION_COOKIE_NAME;
+        }
+
+        return result;
+    }
+
+    /**
+     * Determine the name to use for the session cookie for the provided
+     * context.
+     * @param context
+     */
+    public static String getSessionUriParamName(Context context) {
+
+        String result = getConfiguredSessionCookieName(context);
+
+        if (result == null) {
+            result = DEFAULT_SESSION_PARAMETER_NAME;
+        }
+
+        return result;
+    }
+
+
+    private static String getConfiguredSessionCookieName(Context context) {
+
+        // Priority is:
+        // 1. Cookie name defined in context
+        // 2. Cookie name configured for app
+        // 3. Default defined by spec
+        if (context != null) {
+            String cookieName = context.getSessionCookieName();
+            if (cookieName != null && cookieName.length() > 0) {
+                return cookieName;
+            }
+
+            SessionCookieConfig scc =
+                context.getServletContext().getSessionCookieConfig();
+            cookieName = scc.getName();
+            if (cookieName != null && cookieName.length() > 0) {
+                return cookieName;
+            }
+        }
+
+        return null;
+    }
+
+
+    private SessionConfig() {
+        // Utility class. Hide default constructor.
+    }
+}



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


Mime
View raw message