Author: supun
Date: Mon Sep 27 13:28:11 2010
New Revision: 1001731

URL: http://svn.apache.org/viewvc?rev=1001731&view=rev
Log:
SYNAPSE-688

Modified:
    
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/AbstractDispatcher.java
    
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/HttpSessionDispatcher.java

Modified: 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/AbstractDispatcher.java
URL: 
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/AbstractDispatcher.java?rev=1001731&r1=1001730&r2=1001731&view=diff
==============================================================================
--- 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/AbstractDispatcher.java
 (original)
+++ 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/AbstractDispatcher.java
 Mon Sep 27 13:28:11 2010
@@ -72,12 +72,34 @@ public abstract class AbstractDispatcher
 
         if (key != null) {
             Map headerMap = getTransportHeaderMap(synCtx);
+
             if (headerMap != null) {
+                Object cookieObj = headerMap.get(key);
+
+                if (cookieObj instanceof String) {
+                    String cookie = (String) cookieObj;
+                    
+                    // extract the first name value pair of the Set-Cookie 
header, which is considered
+                    // as the session id which will be sent back from the 
client with the Cookie header
+                    // for example;
+                    //      Set-Cookie: 
JSESSIONID=760764CB72E96A7221506823748CF2AE; Path=/
+                    // will result in the session id 
"JSESSIONID=760764CB72E96A7221506823748CF2AE"
+                    String[] sessionIds = cookie.split(";");
+
+                    if (sessionIds == null || sessionIds.length == 0) {
+                        if (log.isDebugEnabled()) {
+                            log.debug("Cannot find a session id for the cookie 
: " + cookie);
+                        }
+                        return null;
+                    }
 
-                Object cookie = headerMap.get(key);
+                    for(String sessionId : sessionIds){
+                        if(sessionId != null && 
sessionId.indexOf("JSESSIONID") != -1){
+                            return sessionId;
+                        }
+                    }
 
-                if (cookie instanceof String) {
-                    return (String) cookie;
+                    return null;
                 } else {
                     if (log.isDebugEnabled()) {
                         log.debug("Couldn't find the " + key + " header to 
find the session");

Modified: 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/HttpSessionDispatcher.java
URL: 
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/HttpSessionDispatcher.java?rev=1001731&r1=1001730&r2=1001731&view=diff
==============================================================================
--- 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/HttpSessionDispatcher.java
 (original)
+++ 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/HttpSessionDispatcher.java
 Mon Sep 27 13:28:11 2010
@@ -55,33 +55,12 @@ public class HttpSessionDispatcher exten
      */
     public void updateSession(MessageContext synCtx) {
 
-        String cookie = extractSessionID(synCtx, SET_COOKIE);
+        String sessionId = extractSessionID(synCtx, SET_COOKIE);
 
-        if (cookie != null) {
-
-            // extract the first name value pair of the Set-Cookie header, 
which is considered
-            // as the session id which will be sent back from the client with 
the Cookie header
-            // for example;
-            //      Set-Cookie: JSESSIONID=760764CB72E96A7221506823748CF2AE; 
Path=/
-            // will result in the session id 
"JSESSIONID=760764CB72E96A7221506823748CF2AE"
-            // and the client is expected to send the Cookie header as;
-            //      Cookie: JSESSIONID=760764CB72E96A7221506823748CF2AE
+        if (sessionId != null) {
             if (log.isDebugEnabled()) {
                 log.debug("Found the HTTP header 'Set-Cookie: "
-                        + cookie + "' for updating the session");
-            }
-
-            String[] sessionIds = cookie.split(";");
-            if (sessionIds == null || sessionIds.length == 0) {
-                if (log.isDebugEnabled()) {
-                    log.debug("Cannot find a session id for the cookie : " + 
cookie);
-                }
-                return;
-            }
-
-            String sessionId = sessionIds[0];
-
-            if (log.isDebugEnabled()) {
+                        + sessionId + "' for updating the session");
                 log.debug("Using the session id '" + sessionId +
                         "' extracted from the Set-Cookie header ");
             }


Reply via email to