axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r551523 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: Constants.java transport/http/AbstractHTTPSender.java
Date Thu, 28 Jun 2007 10:11:33 GMT
Author: deepal
Date: Thu Jun 28 03:11:30 2007
New Revision: 551523

URL: http://svn.apache.org/viewvc?view=rev&rev=551523
Log:
fixing AXIS2-2282
 - By default we support JSESSIONID , if someone wants to have custom session cookie id then
he need to set the following property with value as cookie name.
  option.setOption(Constants.CUSTOM_COOKIE_ID);

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java?view=diff&rev=551523&r1=551522&r2=551523
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java Thu Jun
28 03:11:30 2007
@@ -223,6 +223,7 @@
     public static final String COOKIE_STRING = "Cookie";
     public static final String SESSION_COOKIE = "axis_session";
     public static final String SESSION_COOKIE_JSESSIONID = "JSESSIONID";
+    public static final String CUSTOM_COOKIE_ID = "customCookieID";
 
     /**
      * Addressing Constants

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java?view=diff&rev=551523&r1=551522&r2=551523
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
Thu Jun 28 03:11:30 2007
@@ -140,13 +140,17 @@
         String sessionCookie = null;
         // Process old style headers first
         Header[] cookieHeaders = method.getResponseHeaders(HTTPConstants.HEADER_SET_COOKIE);
+        String customCoookiId = (String) msgContext.getProperty(Constants.CUSTOM_COOKIE_ID);
         for (int i = 0; i < cookieHeaders.length; i++) {
             HeaderElement[] elements = cookieHeaders[i].getElements();
             for (int e = 0; e < elements.length; e++) {
                 HeaderElement element = elements[e];
                 if (Constants.SESSION_COOKIE.equalsIgnoreCase(element.getName()) ||
                         Constants.SESSION_COOKIE_JSESSIONID.equalsIgnoreCase(element.getName()))
{
-                    sessionCookie = element.getValue();
+                    sessionCookie = processCookieHeader(element);
+                }
+                if (customCoookiId != null && customCoookiId.equalsIgnoreCase(element.getName()))
{
+                    sessionCookie = processCookieHeader(element);
                 }
             }
         }
@@ -158,7 +162,10 @@
                 HeaderElement element = elements[e];
                 if (Constants.SESSION_COOKIE.equalsIgnoreCase(element.getName()) ||
                         Constants.SESSION_COOKIE_JSESSIONID.equalsIgnoreCase(element.getName()))
{
-                    sessionCookie = element.getValue();
+                    sessionCookie = processCookieHeader(element);
+                }
+                if(customCoookiId!=null&&customCoookiId.equalsIgnoreCase(element.getName())){
+                    sessionCookie = processCookieHeader(element);
                 }
             }
         }
@@ -168,6 +175,16 @@
         }
     }
 
+    private String processCookieHeader(HeaderElement element) {
+        String cookie = element.getName() + "=" + element.getValue();
+        NameValuePair[] parameters =  element.getParameters();
+        for (int j = 0; j < parameters.length; j++) {
+            NameValuePair parameter = parameters[j];
+            cookie = cookie + "; " + parameter.getName() + "=" + parameter.getValue();
+        }
+        return cookie;
+    }
+
     protected void processResponse(HttpMethodBase httpMethod,
                                    MessageContext msgContext)
             throws IOException {
@@ -378,8 +395,6 @@
 
         if (cookieString != null) {
             StringBuffer buffer = new StringBuffer();
-            buffer.append(Constants.SESSION_COOKIE_JSESSIONID);
-            buffer.append("=");
             buffer.append(cookieString);
             httpMethod.setRequestHeader(HTTPConstants.HEADER_COOKIE, buffer.toString());
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message