diff --git a/client/conf/server.properties.in b/client/conf/server.properties.in index 7140bd26e26..f255128555c 100644 --- a/client/conf/server.properties.in +++ b/client/conf/server.properties.in @@ -24,6 +24,9 @@ context.path=/client # The HTTP port to be used by the management server http.port=8080 +# Max inactivity time in minutes for the session +session.timeout=30 + # Options to configure and enable HTTPS on management server # # For management server to pickup these configuration settings, the configured diff --git a/client/pom.xml b/client/pom.xml index 1545bfa11f2..63980b9a1f2 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -491,7 +491,7 @@ org.eclipse.jetty jetty-maven-plugin - ${cs.jetty.version} + ${cs.jetty-maven-plugin.version} diff --git a/client/src/org/apache/cloudstack/ServerDaemon.java b/client/src/org/apache/cloudstack/ServerDaemon.java index 65e9a907cfd..985b67b755a 100644 --- a/client/src/org/apache/cloudstack/ServerDaemon.java +++ b/client/src/org/apache/cloudstack/ServerDaemon.java @@ -22,13 +22,8 @@ import java.io.File; import java.io.IOException; import java.lang.management.ManagementFactory; import java.net.URL; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Map; import java.util.Properties; -import javax.servlet.DispatcherType; - import org.apache.commons.daemon.Daemon; import org.apache.commons.daemon.DaemonContext; import org.eclipse.jetty.jmx.MBeanContainer; @@ -42,9 +37,9 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.SslConnectionFactory; import org.eclipse.jetty.server.handler.HandlerCollection; +import org.eclipse.jetty.server.handler.MovedContextHandler; import org.eclipse.jetty.server.handler.RequestLogHandler; -import org.eclipse.jetty.servlet.FilterHolder; -import org.eclipse.jetty.servlets.GzipFilter; +import org.eclipse.jetty.server.handler.gzip.GzipHandler; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler; @@ -70,6 +65,7 @@ public class ServerDaemon implements Daemon { private static final String BIND_INTERFACE = "bind.interface"; private static final String CONTEXT_PATH = "context.path"; + private static final String SESSION_TIMEOUT = "session.timeout"; private static final String HTTP_PORT = "http.port"; private static final String HTTPS_ENABLE = "https.enable"; private static final String HTTPS_PORT = "https.port"; @@ -86,6 +82,7 @@ public class ServerDaemon implements Daemon { private int httpPort = 8080; private int httpsPort = 8443; + private int sessionTimeout = 30; private boolean httpsEnable = false; private String accessLogFile = "access.log"; private String bindInterface = ""; @@ -129,6 +126,7 @@ public class ServerDaemon implements Daemon { setKeystorePassword(properties.getProperty(KEYSTORE_PASSWORD)); setWebAppLocation(properties.getProperty(WEBAPP_DIR)); setAccessLogFile(properties.getProperty(ACCESS_LOG, "access.log")); + setSessionTimeout(Integer.valueOf(properties.getProperty(SESSION_TIMEOUT, "30"))); } catch (final IOException e) { LOG.warn("Failed to load configuration from server.properties file", e); } @@ -221,13 +219,14 @@ public class ServerDaemon implements Daemon { final WebAppContext webApp = new WebAppContext(); webApp.setContextPath(contextPath); webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false"); + webApp.getSessionHandler().setMaxInactiveInterval(sessionTimeout * 60); - final FilterHolder filter = webApp.addFilter(GzipFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); - final Map params = new HashMap<>(); - params.put("mimeTypes", "text/html,text/xml,text/css,text/plain,text/javascript,application/javascript,application/json,application/xml"); - params.put("methods", "GET,POST"); - params.put("deflateCompressionLevel", "9"); - filter.setInitParameters(params); + // GZIP handler + final GzipHandler gzipHandler = new GzipHandler(); + gzipHandler.addIncludedMimeTypes("text/html", "text/xml", "text/css", "text/plain", "text/javascript", "application/javascript", "application/json", "application/xml"); + gzipHandler.setIncludedMethods("GET", "POST"); + gzipHandler.setCompressionLevel(9); + gzipHandler.setHandler(webApp); if (Strings.isNullOrEmpty(webAppLocation)) { webApp.setWar(getShadedWarUrl()); @@ -235,14 +234,18 @@ public class ServerDaemon implements Daemon { webApp.setWar(webAppLocation); } + // Request log handler final RequestLogHandler log = new RequestLogHandler(); log.setRequestLog(createRequestLog()); - final HandlerCollection handlerCollection = new HandlerCollection(); - handlerCollection.addHandler(log); - handlerCollection.addHandler(webApp); + // Redirect root context handler + MovedContextHandler rootRedirect = new MovedContextHandler(); + rootRedirect.setContextPath("/"); + rootRedirect.setNewContextURL(contextPath); + rootRedirect.setPermanent(true); - return handlerCollection; + // Put rootRedirect at the end! + return new HandlerCollection(log, gzipHandler, rootRedirect); } private RequestLog createRequestLog() { @@ -307,4 +310,8 @@ public class ServerDaemon implements Daemon { public void setWebAppLocation(String webAppLocation) { this.webAppLocation = webAppLocation; } + + public void setSessionTimeout(int sessionTimeout) { + this.sessionTimeout = sessionTimeout; + } } diff --git a/plugins/integrations/cloudian/pom.xml b/plugins/integrations/cloudian/pom.xml index 3e2b63562fb..3138bb668ff 100644 --- a/plugins/integrations/cloudian/pom.xml +++ b/plugins/integrations/cloudian/pom.xml @@ -52,7 +52,7 @@ com.github.tomakehurst - wiremock + wiremock-standalone ${cs.wiremock.version} test diff --git a/pom.xml b/pom.xml index 8c3c6997d76..caa26cdff70 100644 --- a/pom.xml +++ b/pom.xml @@ -120,8 +120,9 @@ 3.2.0 2.4.12 10.1 - 2.8.0 - 9.2.22.v20170606 + 2.11.0 + 9.4.7.v20170914 + 9.2.22.v20170606