Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions client/conf/server.properties.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${cs.jetty.version}</version>
<version>${cs.jetty-maven-plugin.version}</version>
<dependencies>
<!-- specify the dependent jdbc driver here -->
<dependency>
Expand Down
41 changes: 24 additions & 17 deletions client/src/org/apache/cloudstack/ServerDaemon.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,8 @@
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;
Expand All @@ -42,9 +37,9 @@
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;
Expand All @@ -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";
Expand All @@ -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 = "";
Expand Down Expand Up @@ -129,6 +126,7 @@ public void init(final DaemonContext context) {
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);
}
Expand Down Expand Up @@ -221,28 +219,33 @@ private HandlerCollection createHandlers() {
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<String, String> 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());
} else {
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() {
Expand Down Expand Up @@ -307,4 +310,8 @@ public void setAccessLogFile(String accessLogFile) {
public void setWebAppLocation(String webAppLocation) {
this.webAppLocation = webAppLocation;
}

public void setSessionTimeout(int sessionTimeout) {
this.sessionTimeout = sessionTimeout;
}
}
2 changes: 1 addition & 1 deletion plugins/integrations/cloudian/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<artifactId>wiremock-standalone</artifactId>
<version>${cs.wiremock.version}</version>
<scope>test</scope>
</dependency>
Expand Down
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@
<cs.cxf.version>3.2.0</cs.cxf.version>
<cs.groovy.version>2.4.12</cs.groovy.version>
<cs.nitro.version>10.1</cs.nitro.version>
<cs.wiremock.version>2.8.0</cs.wiremock.version>
<cs.jetty.version>9.2.22.v20170606</cs.jetty.version>
<cs.wiremock.version>2.11.0</cs.wiremock.version>
<cs.jetty.version>9.4.7.v20170914</cs.jetty.version>
<cs.jetty-maven-plugin.version>9.2.22.v20170606</cs.jetty-maven-plugin.version>
</properties>

<distributionManagement>
Expand Down