Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinston Prakash2012-02-03 21:13:21 -0500
committerWinston Prakash2012-02-03 21:13:21 -0500
commiteb6c9ed2ac9e97e5eb681d356ef448d375cb2252 (patch)
tree11230dcabc1d7d92c7bfcdadf65a1fafe0f574bd
parentb434f5ca058525ea55e677dac1008bed058178ab (diff)
downloadorg.eclipse.hudson.core-eb6c9ed2ac9e97e5eb681d356ef448d375cb2252.tar.gz
org.eclipse.hudson.core-eb6c9ed2ac9e97e5eb681d356ef448d375cb2252.tar.xz
org.eclipse.hudson.core-eb6c9ed2ac9e97e5eb681d356ef448d375cb2252.zip
Add SSL options to the Jetty Launcher
-rw-r--r--hudson-jetty-war-executable/nbactions.xml6
-rw-r--r--hudson-jetty-war-executable/src/main/java/org/eclipse/hudson/jetty/JettyLauncher.java51
-rwxr-xr-xhudson-jetty-war-executable/src/main/java/org/eclipse/hudson/war/Executable.java12
3 files changed, 57 insertions, 12 deletions
diff --git a/hudson-jetty-war-executable/nbactions.xml b/hudson-jetty-war-executable/nbactions.xml
index 2692b445..d740fbca 100644
--- a/hudson-jetty-war-executable/nbactions.xml
+++ b/hudson-jetty-war-executable/nbactions.xml
@@ -7,7 +7,7 @@
<goal>org.codehaus.mojo:exec-maven-plugin:1.2:exec</goal>
</goals>
<properties>
- <exec.args>-classpath %classpath org.eclipse.hudson.war.Executable --prefix=jetty</exec.args>
+ <exec.args>-classpath %classpath org.eclipse.hudson.war.Executable --usage</exec.args>
<exec.executable>java</exec.executable>
<exec.classpathScope>runtime</exec.classpathScope>
</properties>
@@ -19,7 +19,7 @@
<goal>org.codehaus.mojo:exec-maven-plugin:1.2:exec</goal>
</goals>
<properties>
- <exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath org.eclipse.hudson.war.Executable --prefix=jetty</exec.args>
+ <exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath org.eclipse.hudson.war.Executable --usage</exec.args>
<exec.executable>java</exec.executable>
<exec.classpathScope>runtime</exec.classpathScope>
<jpda.listen>true</jpda.listen>
@@ -32,7 +32,7 @@
<goal>org.codehaus.mojo:exec-maven-plugin:1.2:exec</goal>
</goals>
<properties>
- <exec.args>${profiler.args} -classpath %classpath org.eclipse.hudson.war.Executable --prefix=jetty</exec.args>
+ <exec.args>${profiler.args} -classpath %classpath org.eclipse.hudson.war.Executable --usage</exec.args>
<exec.executable>${profiler.java}</exec.executable>
<profiler.action>profile</profiler.action>
</properties>
diff --git a/hudson-jetty-war-executable/src/main/java/org/eclipse/hudson/jetty/JettyLauncher.java b/hudson-jetty-war-executable/src/main/java/org/eclipse/hudson/jetty/JettyLauncher.java
index abf93e10..1b132816 100644
--- a/hudson-jetty-war-executable/src/main/java/org/eclipse/hudson/jetty/JettyLauncher.java
+++ b/hudson-jetty-war-executable/src/main/java/org/eclipse/hudson/jetty/JettyLauncher.java
@@ -18,8 +18,12 @@ package org.eclipse.hudson.jetty;
import java.io.File;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
-import org.mortbay.jetty.bio.SocketConnector;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.mortbay.jetty.security.SslSocketConnector;
import org.mortbay.jetty.webapp.WebAppContext;
/**
@@ -33,19 +37,56 @@ public class JettyLauncher {
public static void start(String[] args, URL warUrl) throws Exception {
- int port = 8080;
+ int httpPort = 8080;
+ int httpsPort = -1;
+
+ String keyStorePath = null;
+ String keyStorePassword = null;
for (int i = 0; i < args.length; i++) {
if (args[i].startsWith("--httpPort=")) {
String portStr = args[i].substring("--httpPort=".length());
- port = Integer.parseInt(portStr);
+ httpPort = Integer.parseInt(portStr);
+ }
+ if (args[i].startsWith("--httpsPort=")) {
+ String portStr = args[i].substring("--httpsPort=".length());
+ httpsPort = Integer.parseInt(portStr);
+ }
+ if (args[i].startsWith("--httpsKeyStore=")) {
+ keyStorePath = args[i].substring("--httpsKeyStore=".length());
+ }
+ if (args[i].startsWith("--httpsKeyStorePassword=")) {
+ keyStorePassword = args[i].substring("--httpsKeyStorePassword=".length());
} else if (args[i].startsWith("--prefix=")) {
contextPath = "/" + args[i].substring("--prefix=".length());
}
}
- final Server server = new Server(port);
- SocketConnector connector = new SocketConnector();
+ Server server = new Server();
+
+ List<Connector> connectors = new ArrayList<Connector>();
+
+ // HTTP connector
+ if (httpPort != -1) {
+ SelectChannelConnector httpConnector = new SelectChannelConnector();
+ httpConnector.setPort(httpPort);
+ connectors.add(httpConnector);
+ }
+
+ // HTTPS (SSL) connector
+ if (httpsPort != -1) {
+ SslSocketConnector httpsConnector = new SslSocketConnector();
+ httpsConnector.setPort(httpsPort);
+ if (keyStorePath != null) {
+ httpsConnector.setKeystore(keyStorePath);
+ }
+ if (keyStorePassword != null){
+ httpsConnector.setKeyPassword(keyStorePassword);
+ }
+ connectors.add(httpsConnector);
+ }
+
+ server.setConnectors(connectors.toArray(new Connector[connectors.size()]));
WebAppContext context = new WebAppContext();
diff --git a/hudson-jetty-war-executable/src/main/java/org/eclipse/hudson/war/Executable.java b/hudson-jetty-war-executable/src/main/java/org/eclipse/hudson/war/Executable.java
index 79d4aa84..5bd11b6e 100755
--- a/hudson-jetty-war-executable/src/main/java/org/eclipse/hudson/war/Executable.java
+++ b/hudson-jetty-war-executable/src/main/java/org/eclipse/hudson/war/Executable.java
@@ -92,10 +92,14 @@ public class Executable {
+ "Usage: java -jar hudson.war [--option=value] [--option=value] ... \n"
+ "\n"
+ "Options:\n"
- + " --httpPort=<value> HTTP listening port. Default value is 8080\n"
- + " --version Show Hudson version and quit\n"
- + " --logfile=<filename> Send the output log to this file\n"
- + " --prefix=<prefix> Add this prefix to all URLs (eg http://localhost:8080/prefix/resource). Default is none\n";;
+ + " --version Show Hudson version and quit\n"
+ + " --logfile=<filename> Send the output log to this file\n"
+ + " --prefix=<prefix-string> Add this prefix to all URLs (eg http://localhost:8080/prefix/resource). Default is none\n\n"
+ + " --httpPort=<value> HTTP listening port. Default value is 8080\n\n"
+ + " --httpsPort=<value> HTTPS listening port. Disabled by default\n"
+ + " --httpsKeyStore=<filepath> Location of the SSL KeyStore file.\n"
+ + " --httpsKeyStorePassword=<value> Password for the SSL KeyStore file\n\n";
+
System.out.println(usageStr);
System.exit(0);
}

Back to the top