diff --git a/pom.xml b/pom.xml
index 14f015e0..c326cd9f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,14 +16,6 @@
Winstone is a command line wrapper around Jetty
https://github.com/jenkinsci/${project.artifactId}
-
- 6.20
- -SNAPSHOT
- 10.0.20
- 2.0.13
- jenkinsci/winstone
-
-
GNU Lesser General Public License version 2.1
@@ -35,6 +27,161 @@
+
+ scm:git:https://github.com/${gitHubRepo}.git
+ scm:git:git@github.com:${gitHubRepo}.git
+ ${scmTag}
+ https://github.com/${gitHubRepo}
+
+
+
+ 6.20
+ -SNAPSHOT
+ 10.0.20
+ 2.0.13
+ jenkinsci/winstone
+ true
+
+
+
+
+
+ org.eclipse.jetty
+ jetty-bom
+ ${jetty.version}
+ pom
+ import
+
+
+
+ org.slf4j
+ slf4j-api
+ ${slf4j.version}
+
+
+ org.slf4j
+ slf4j-jdk14
+ ${slf4j.version}
+
+
+
+
+
+
+ com.github.spotbugs
+ spotbugs-annotations
+ true
+
+
+ com.google.code.findbugs
+ jsr305
+
+
+
+
+ io.jenkins.lib
+ support-log-formatter
+ 1.2
+
+
+ org.eclipse.jetty
+ jetty-alpn-java-server
+
+
+ org.eclipse.jetty
+ jetty-alpn-server
+
+
+ org.eclipse.jetty
+ jetty-jmx
+
+
+ org.eclipse.jetty
+ jetty-server
+
+
+ org.eclipse.jetty
+ jetty-servlet
+
+
+ org.eclipse.jetty
+ jetty-unixdomain-server
+
+
+ org.eclipse.jetty
+ jetty-util
+
+
+ org.eclipse.jetty
+ jetty-webapp
+
+
+ org.eclipse.jetty.http2
+ http2-hpack
+
+
+ org.eclipse.jetty.http2
+ http2-server
+
+
+ org.eclipse.jetty.websocket
+ websocket-jetty-server
+
+
+
+
+ org.eclipse.jetty
+ jetty-annotations
+
+
+
+
+ org.slf4j
+ slf4j-jdk14
+
+
+ org.awaitility
+ awaitility
+ 4.2.1
+ test
+
+
+ org.eclipse.jetty
+ jetty-client
+ test
+
+
+ org.jenkins-ci
+ test-annotations
+ 1.4
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+ test
+
+
+
+
+
+ repo.jenkins-ci.org
+ https://repo.jenkins-ci.org/public/
+
+
+
+
+
+ repo.jenkins-ci.org
+ https://repo.jenkins-ci.org/public/
+
+
+
@@ -43,10 +190,10 @@
prepare-testwebapp
- process-test-classes
run
+ process-test-classes
@@ -70,10 +217,10 @@
false
alphabetical
-
-
-
-
+
+
+
+
@@ -143,10 +290,10 @@
- package
shade
+ package
true
@@ -172,161 +319,17 @@
flatten
- pre-integration-test
+
flatten
+ pre-integration-test
-
-
- repo.jenkins-ci.org
- https://repo.jenkins-ci.org/public/
-
-
-
-
-
- repo.jenkins-ci.org
- https://repo.jenkins-ci.org/public/
-
-
-
-
- scm:git:https://github.com/${gitHubRepo}.git
- scm:git:git@github.com:${gitHubRepo}.git
- https://github.com/${gitHubRepo}
- ${scmTag}
-
-
-
-
-
- org.eclipse.jetty
- jetty-bom
- ${jetty.version}
- pom
- import
-
-
-
- org.slf4j
- slf4j-api
- ${slf4j.version}
-
-
- org.slf4j
- slf4j-jdk14
- ${slf4j.version}
-
-
-
-
-
-
- com.github.spotbugs
- spotbugs-annotations
- true
-
-
- com.google.code.findbugs
- jsr305
-
-
-
-
- io.jenkins.lib
- support-log-formatter
- 1.2
-
-
- org.eclipse.jetty
- jetty-alpn-java-server
-
-
- org.eclipse.jetty
- jetty-alpn-server
-
-
- org.eclipse.jetty
- jetty-jmx
-
-
- org.eclipse.jetty
- jetty-server
-
-
- org.eclipse.jetty
- jetty-servlet
-
-
- org.eclipse.jetty
- jetty-unixdomain-server
-
-
- org.eclipse.jetty
- jetty-util
-
-
- org.eclipse.jetty
- jetty-webapp
-
-
- org.eclipse.jetty.http2
- http2-hpack
-
-
- org.eclipse.jetty.http2
- http2-server
-
-
- org.eclipse.jetty.websocket
- websocket-jetty-server
-
-
-
- org.eclipse.jetty
- jetty-annotations
-
-
-
-
- org.slf4j
- slf4j-jdk14
-
-
- org.awaitility
- awaitility
- 4.2.1
- test
-
-
- org.jenkins-ci
- test-annotations
- 1.4
- test
-
-
- org.junit.jupiter
- junit-jupiter
- test
-
-
- org.junit.vintage
- junit-vintage-engine
- test
-
-
- org.eclipse.jetty
- jetty-client
- test
-
-
-
enable-jacoco
diff --git a/src/main/java/winstone/AbstractSecuredConnectorFactory.java b/src/main/java/winstone/AbstractSecuredConnectorFactory.java
index 08fea469..a887861d 100644
--- a/src/main/java/winstone/AbstractSecuredConnectorFactory.java
+++ b/src/main/java/winstone/AbstractSecuredConnectorFactory.java
@@ -7,12 +7,6 @@
package winstone;
-import java.util.Locale;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.util.ssl.SslContextFactory;
-import winstone.cmdline.Option;
-
-import javax.net.ssl.KeyManagerFactory;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -22,36 +16,39 @@
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Enumeration;
+import java.util.Locale;
import java.util.Map;
import java.util.logging.Level;
import java.util.stream.Stream;
+import javax.net.ssl.KeyManagerFactory;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
+import winstone.cmdline.Option;
/**
*
*/
-public abstract class AbstractSecuredConnectorFactory implements ConnectorFactory
-{
+public abstract class AbstractSecuredConnectorFactory implements ConnectorFactory {
protected static final WinstoneResourceBundle SSL_RESOURCES = new WinstoneResourceBundle("winstone.LocalStrings");
protected KeyStore keystore;
protected String keystorePassword;
- protected void configureSsl( Map args, Server server ) throws IOException
- {
+ protected void configureSsl(Map args, Server server) throws IOException {
try {
- File keyStore = Option.HTTPS_KEY_STORE.get(args);
- String pwd = Option.HTTPS_KEY_STORE_PASSWORD.get(args);
+ File keyStore = Option.HTTPS_KEY_STORE.get(args);
+ String pwd = Option.HTTPS_KEY_STORE_PASSWORD.get(args);
- if (keyStore!=null) {
+ if (keyStore != null) {
// load from default Keystore
if (!keyStore.exists() || !keyStore.isFile())
- throw new WinstoneException(SSL_RESOURCES.getString(
- "HttpsListener.KeyStoreNotFound", keyStore.getPath()));
+ throw new WinstoneException(
+ SSL_RESOURCES.getString("HttpsListener.KeyStoreNotFound", keyStore.getPath()));
this.keystorePassword = pwd;
keystore = KeyStore.getInstance(KeyStore.getDefaultType());
- try(InputStream inputStream = new FileInputStream(keyStore)){
- keystore.load( inputStream, this.keystorePassword.toCharArray());
+ try (InputStream inputStream = new FileInputStream(keyStore)) {
+ keystore.load(inputStream, this.keystorePassword.toCharArray());
}
} else {
throw new WinstoneException(MessageFormat.format("Please set --{0}", Option.HTTPS_KEY_STORE));
@@ -65,7 +62,7 @@ protected void configureSsl( Map args, Server server ) throws IO
* Used to get the base ssl context in which to create the server socket.
* This is basically just so we can have a custom location for key stores.
*/
- protected SslContextFactory.Server getSSLContext( Map args) {
+ protected SslContextFactory.Server getSSLContext(Map args) {
try {
String privateKeyPassword;
@@ -82,18 +79,20 @@ protected SslContextFactory.Server getSSLContext( Map args) {
// Dump the content of the keystore if log level is FULL_DEBUG
// Note: The kmf is instantiated here only to access the keystore,
// the SslContextFactory will instantiate its own KeyManager
- KeyManagerFactory kmf = KeyManagerFactory.getInstance( Option.HTTPS_KEY_MANAGER_TYPE.get( args));
+ KeyManagerFactory kmf = KeyManagerFactory.getInstance(Option.HTTPS_KEY_MANAGER_TYPE.get(args));
// In case the KeyStore password and the KeyPassword are not the same,
// the KeyManagerFactory needs the KeyPassword because it will access the individual key(s)
kmf.init(keystore, keystorePassword.toCharArray());
- Logger.log(Level.FINEST, SSL_RESOURCES,
- "HttpsListener.KeyCount", keystore.size() + "");
- for ( Enumeration e = keystore.aliases(); e.hasMoreElements();) {
+ Logger.log(Level.FINEST, SSL_RESOURCES, "HttpsListener.KeyCount", keystore.size() + "");
+ for (Enumeration e = keystore.aliases(); e.hasMoreElements(); ) {
String alias = e.nextElement();
- Logger.log(Level.FINEST, SSL_RESOURCES,
- "HttpsListener.KeyFound", alias,
- keystore.getCertificate(alias) + "");
+ Logger.log(
+ Level.FINEST,
+ SSL_RESOURCES,
+ "HttpsListener.KeyFound",
+ alias,
+ keystore.getCertificate(alias) + "");
}
SslContextFactory.Server ssl = new SslContextFactory.Server();
@@ -103,21 +102,26 @@ protected SslContextFactory.Server getSSLContext( Map args) {
ssl.setKeyManagerFactoryAlgorithm(Option.HTTPS_KEY_MANAGER_TYPE.get(args));
ssl.setCertAlias(Option.HTTPS_CERTIFICATE_ALIAS.get(args));
String excludeProtos = Option.HTTPS_EXCLUDE_PROTOCOLS.get(args);
- if(excludeProtos!=null&&excludeProtos.length()>0) {
- String[] protos = Stream.of(excludeProtos.split(",")).map(String::trim).toArray(String[]::new);
+ if (excludeProtos != null && excludeProtos.length() > 0) {
+ String[] protos =
+ Stream.of(excludeProtos.split(",")).map(String::trim).toArray(String[]::new);
ssl.setExcludeProtocols(protos);
}
String excludeCiphers = Option.HTTPS_EXCLUDE_CIPHER_SUITES.get(args);
- if(excludeCiphers!=null&&excludeCiphers.length()>0) {
+ if (excludeCiphers != null && excludeCiphers.length() > 0) {
String[] cipherSuites = excludeCiphers.split(",");
ssl.setExcludeCipherSuites(cipherSuites);
}
- Logger.log(Level.INFO, SSL_RESOURCES, //
- "HttpsListener.ExcludeProtocols", //
- Arrays.asList(ssl.getExcludeProtocols()));
- Logger.log(Level.INFO, SSL_RESOURCES, //
- "HttpsListener.ExcludeCiphers", //
- Arrays.asList(ssl.getExcludeCipherSuites()));
+ Logger.log(
+ Level.INFO,
+ SSL_RESOURCES, //
+ "HttpsListener.ExcludeProtocols", //
+ Arrays.asList(ssl.getExcludeProtocols()));
+ Logger.log(
+ Level.INFO,
+ SSL_RESOURCES, //
+ "HttpsListener.ExcludeCiphers", //
+ Arrays.asList(ssl.getExcludeCipherSuites()));
switch (Option.HTTPS_VERIFY_CLIENT.get(args).toLowerCase(Locale.ROOT)) {
case "yes":
@@ -128,14 +132,12 @@ protected SslContextFactory.Server getSSLContext( Map args) {
ssl.setWantClientAuth(true);
break;
default:
- ssl.setNeedClientAuth(false);
- break;
+ ssl.setNeedClientAuth(false);
+ break;
}
return ssl;
} catch (Throwable err) {
- throw new WinstoneException(SSL_RESOURCES
- .getString("HttpsListener.ErrorGettingContext"), err);
+ throw new WinstoneException(SSL_RESOURCES.getString("HttpsListener.ErrorGettingContext"), err);
}
}
-
}
diff --git a/src/main/java/winstone/ConnectorFactory.java b/src/main/java/winstone/ConnectorFactory.java
index f47bd961..3f16b321 100644
--- a/src/main/java/winstone/ConnectorFactory.java
+++ b/src/main/java/winstone/ConnectorFactory.java
@@ -6,16 +6,15 @@
*/
package winstone;
-import org.eclipse.jetty.server.Connector;
-import org.eclipse.jetty.server.Server;
-
import java.io.IOException;
import java.util.Map;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Server;
/**
* Interface that defines the necessary methods for being a connection listener
* within winstone.
- *
+ *
* @author Rick Knowles
*/
public interface ConnectorFactory {
@@ -23,6 +22,5 @@ public interface ConnectorFactory {
* After the listener is loaded and initialized, this starts the thread
* @return the Connector instance or null
if not started
*/
- Connector start( Map args, Server server) throws IOException;
-
+ Connector start(Map args, Server server) throws IOException;
}
diff --git a/src/main/java/winstone/HostConfiguration.java b/src/main/java/winstone/HostConfiguration.java
index ddb185f1..9cc6a596 100644
--- a/src/main/java/winstone/HostConfiguration.java
+++ b/src/main/java/winstone/HostConfiguration.java
@@ -8,17 +8,6 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import org.eclipse.jetty.http.MimeTypes;
-import org.eclipse.jetty.security.LoginService;
-import org.eclipse.jetty.server.Handler;
-import org.eclipse.jetty.server.RequestLog;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.handler.RequestLogHandler;
-import org.eclipse.jetty.webapp.WebAppContext;
-import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer;
-import winstone.cmdline.Option;
-
-import javax.servlet.SessionTrackingMode;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -40,6 +29,16 @@
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.logging.Level;
+import javax.servlet.SessionTrackingMode;
+import org.eclipse.jetty.http.MimeTypes;
+import org.eclipse.jetty.security.LoginService;
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.RequestLog;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.RequestLogHandler;
+import org.eclipse.jetty.webapp.WebAppContext;
+import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer;
+import winstone.cmdline.Option;
/**
* Manages the references to individual webapps within the container. This object handles
@@ -52,7 +51,7 @@ public class HostConfiguration {
private final Server server;
private String hostname;
private Map args;
- private Map webapps;
+ private Map webapps;
private ClassLoader commonLibCL;
private MimeTypes mimeTypes = new MimeTypes();
private final LoginService loginService;
@@ -67,7 +66,8 @@ public HostConfiguration(Server server, String hostname, ClassLoader commonLibCL
try {
// Build the realm
- Class extends LoginService> realmClass = Option.REALM_CLASS_NAME.get(this.args, LoginService.class, commonLibCL);
+ Class extends LoginService> realmClass =
+ Option.REALM_CLASS_NAME.get(this.args, LoginService.class, commonLibCL);
Constructor extends LoginService> realmConstr = realmClass.getConstructor(Map.class);
loginService = realmConstr.newInstance(this.args);
} catch (Throwable err) {
@@ -85,16 +85,15 @@ public HostConfiguration(Server server, String hostname, ClassLoader commonLibCL
}
Handler handler = configureAccessLog(create(getWebRoot(webroot, warfile), prefix), "webapp");
- {// load additional mime types
+ { // load additional mime types
loadBuiltinMimeTypes();
String types = Option.MIME_TYPES.get(this.args);
- if (types!=null) {
+ if (types != null) {
StringTokenizer mappingST = new StringTokenizer(types, ":", false);
while (mappingST.hasMoreTokens()) {
String mapping = mappingST.nextToken();
int delimPos = mapping.indexOf('=');
- if (delimPos == -1)
- continue;
+ if (delimPos == -1) continue;
String extension = mapping.substring(0, delimPos);
String mimeType = mapping.substring(delimPos + 1);
this.mimeTypes.addMimeMapping(extension.toLowerCase(), mimeType);
@@ -103,8 +102,12 @@ public HostConfiguration(Server server, String hostname, ClassLoader commonLibCL
}
server.setHandler(handler);
- Logger.log(Level.FINER, Launcher.RESOURCES, "HostConfig.InitComplete",
- this.webapps.size() + "", this.webapps.keySet() + "");
+ Logger.log(
+ Level.FINER,
+ Launcher.RESOURCES,
+ "HostConfig.InitComplete",
+ this.webapps.size() + "",
+ this.webapps.keySet() + "");
}
private void loadBuiltinMimeTypes() {
@@ -112,22 +115,22 @@ private void loadBuiltinMimeTypes() {
Properties props = new Properties();
props.load(in);
for (Entry