cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject [26/50] [abbrv] git commit: refs/heads/gslb-wip - Fix a bug in retrieving cookie from Vmware connection by replacing Kawai's patch by parsing request header ourselves instead of using BrowserCompatSpec.
Date Mon, 18 Mar 2013 10:14:49 GMT
Fix a bug in retrieving cookie from Vmware connection by replacing
Kawai's patch by parsing request header ourselves instead of using
BrowserCompatSpec.

Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/eca1a708
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/eca1a708
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/eca1a708

Branch: refs/heads/gslb-wip
Commit: eca1a7089ab422d3e673c14ba6af52d137d7f5a7
Parents: 89f4ac0
Author: Min Chen <min.chen@citrix.com>
Authored: Thu Mar 7 16:07:58 2013 -0800
Committer: Min Chen <min.chen@citrix.com>
Committed: Thu Mar 7 16:07:58 2013 -0800

----------------------------------------------------------------------
 .../cloud/hypervisor/vmware/util/VmwareClient.java |   25 +++++----------
 1 files changed, 8 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/eca1a708/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
index cbae5a9..e69a3d2 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
@@ -17,11 +17,11 @@
 package com.cloud.hypervisor.vmware.util;
 
 import java.lang.reflect.Method;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import java.util.StringTokenizer;
 
 import javax.net.ssl.HostnameVerifier;
 import javax.net.ssl.SSLSession;
@@ -29,10 +29,6 @@ import javax.net.ssl.HttpsURLConnection;
 import javax.xml.ws.BindingProvider;
 import javax.xml.ws.handler.MessageContext;
 
-import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieOrigin;
-import org.apache.http.impl.cookie.BrowserCompatSpec;
-import org.apache.http.message.BasicHeader;
 
 import com.vmware.vim25.DynamicProperty;
 import com.vmware.vim25.InvalidCollectorVersionFaultMsg;
@@ -143,20 +139,15 @@ public class VmwareClient {
         serviceContent = vimPort.retrieveServiceContent(SVC_INST_REF);
 
         // Extract a cookie. See vmware sample program com.vmware.httpfileaccess.GetVMFiles
-        URL urlUrl = new URL(url);
         Map<String, List<String>> headers = (Map<String, List<String>>)
((BindingProvider) vimPort)
                 .getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
-        for (String header_raw_value : (List<String>) headers.get("Set-cookie")) {
-            List<Cookie> cookies = new BrowserCompatSpec().parse(
-                    new BasicHeader("Set-cookie", header_raw_value),
-                    new CookieOrigin(urlUrl.getHost(), urlUrl.getPort(), 
-                            urlUrl.getPath(), true));
-            if (cookies.size() > 0) {
-                serviceCookie = cookies.get(0).getValue();
-                break;
-            }
-        }
-        
+        List<String> cookies = (List<String>) headers.get("Set-cookie");
+        String cookieValue = cookies.get(0);
+        StringTokenizer tokenizer = new StringTokenizer(cookieValue, ";");
+        cookieValue = tokenizer.nextToken();
+        String pathData = "$" + tokenizer.nextToken();
+        serviceCookie = "$Version=\"1\"; " + cookieValue + "; " + pathData;
+
         vimPort.login(serviceContent.getSessionManager(), userName, password, null);
         isConnected = true;
 


Mime
View raw message