From b2d5e374d9dfb10475d49c2395ebb98fbcc13ce7 Mon Sep 17 00:00:00 2001 From: Kelven Yang Date: Fri, 10 Jan 2014 17:58:26 -0800 Subject: [PATCH] CLOUDSTACK-5734: Fix the regression caused by adding hyper-V support --- .../cloud/servlet/ConsoleProxyServlet.java | 2 ++ .../ConsoleProxyHttpHandlerHelper.java | 35 +++++++++++++++---- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/server/src/com/cloud/servlet/ConsoleProxyServlet.java b/server/src/com/cloud/servlet/ConsoleProxyServlet.java index 8a55b396fd2..796cb31b47e 100644 --- a/server/src/com/cloud/servlet/ConsoleProxyServlet.java +++ b/server/src/com/cloud/servlet/ConsoleProxyServlet.java @@ -334,6 +334,8 @@ public class ConsoleProxyServlet extends HttpServlet { } } else if (hostInfo.startsWith("instanceId")) { host = hostInfo.substring(hostInfo.indexOf('=') + 1); + } else { + host = hostInfo; } } else { host = hostInfo; diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyHttpHandlerHelper.java b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyHttpHandlerHelper.java index 0facd3f26c4..b5c9ce4f9e4 100644 --- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyHttpHandlerHelper.java +++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyHttpHandlerHelper.java @@ -23,7 +23,7 @@ import com.cloud.consoleproxy.util.Logger; public class ConsoleProxyHttpHandlerHelper { private static final Logger s_logger = Logger.getLogger(ConsoleProxyHttpHandlerHelper.class); - + public static Map getQueryMap(String query) { String[] params = query.split("&"); Map map = new HashMap(); @@ -43,26 +43,45 @@ public class ConsoleProxyHttpHandlerHelper { s_logger.debug("Invalid paramemter in URL found. param: " + param); } } - + // This is a ugly solution for now. We will do encryption/decryption translation // here to make it transparent to rest of the code. if(map.get("token") != null) { ConsoleProxyPasswordBasedEncryptor encryptor = new ConsoleProxyPasswordBasedEncryptor( ConsoleProxy.getEncryptorPassword()); - + ConsoleProxyClientParam param = encryptor.decryptObject(ConsoleProxyClientParam.class, map.get("token")); // make sure we get information from token only guardUserInput(map); if(param != null) { - if(param.getClientHostAddress() != null) + if (param.getClientHostAddress() != null) { + s_logger.debug("decode token. host: " + param.getClientHostAddress()); map.put("host", param.getClientHostAddress()); - if(param.getClientHostPort() != 0) + } else { + s_logger.error("decode token. host info is not found!"); + } + + if (param.getClientHostPort() != 0) { + s_logger.debug("decode token. port: " + param.getClientHostPort()); map.put("port", String.valueOf(param.getClientHostPort())); - if(param.getClientTag() != null) + } else { + s_logger.error("decode token. port info is not found!"); + } + + if (param.getClientTag() != null) { + s_logger.debug("decode token. tag: " + param.getClientTag()); map.put("tag", param.getClientTag()); - if(param.getClientHostPassword() != null) + } else { + s_logger.error("decode token. tag info is not found!"); + } + + if (param.getClientHostPassword() != null) { map.put("sid", param.getClientHostPassword()); + } else { + s_logger.error("decode token. sid info is not found!"); + } + if(param.getClientTunnelUrl() != null) map.put("consoleurl", param.getClientTunnelUrl()); if(param.getClientTunnelSession() != null) @@ -77,6 +96,8 @@ public class ConsoleProxyHttpHandlerHelper { map.put("username", param.getUsername()); if (param.getPassword() != null) map.put("password", param.getPassword()); + } else { + s_logger.error("Unable to decode token"); } } else { // we no longer accept information from parameter other than token