You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2012/11/27 10:59:01 UTC

git commit: WICKET-4873 Support different session id parameter

Updated Branches:
  refs/heads/master 9de66fbf5 -> 81165d82d


WICKET-4873 Support different session id parameter


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/81165d82
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/81165d82
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/81165d82

Branch: refs/heads/master
Commit: 81165d82d3c3daa830a8dd3f9c4fd78734e0c002
Parents: 9de66fb
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Tue Nov 27 10:58:02 2012 +0100
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Tue Nov 27 10:58:56 2012 +0100

----------------------------------------------------------------------
 .../org/apache/wicket/util/string/Strings.java     |   16 ++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/81165d82/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java b/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java
index 27a9987..c04e1fb 100755
--- a/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java
@@ -64,6 +64,20 @@ public final class Strings
 	
 	private static final String[] NO_STRINGS = new String[0];
 
+	/**
+	 * The name of the parameter used to keep the session id.
+	 * The Servlet specification mandates <em>jsessionid</em> but the web containers
+	 * provide ways to set a custom one, e.g. <em>sid</em>.
+	 * Since Wicket doesn't have access to the web container internals the name should be set explicitly.
+	 */
+	public static final String SESSION_ID_PARAM_NAME = System.getProperty("wicket.jsessionid.name", "jsessionid");
+
+	/**
+	 * Constructs something like <em>;jsessionid=</em>. This is what {@linkplain Strings#stripJSessionId(String)}
+	 * actually uses.
+	 */
+	private static final String SESSION_ID_PARAM = ';' + SESSION_ID_PARAM_NAME + '=';
+
 	static
 	{
 		LINE_SEPARATOR = AccessController.doPrivileged(new PrivilegedAction<String>()
@@ -913,7 +927,7 @@ public final class Strings
 		}
 
 		// http://.../abc;jsessionid=...?param=...
-		int ixSemiColon = url.toLowerCase(Locale.ENGLISH).indexOf(";jsessionid=");
+		int ixSemiColon = url.toLowerCase(Locale.ENGLISH).indexOf(SESSION_ID_PARAM);
 		if (ixSemiColon == -1)
 		{
 			return url;