From eaca20d2a41ba2771bd379408d87673b12646390 Wed, 27 Feb 2013 09:33:50 +0100
From: Krzysztof Daniel
org.mortbay.jetty.servlet.Context
-+ * the Jetty context; in case of Jetty 7 the context is of
-+ * type org.eclipse.jetty.servlet.ServletContextHandler
- * @param settings
- * the settings as passed to {@link JettyConfigurator#startServer(String, Dictionary)}
- * @return context
-- * the customized context; in case of Jetty 6 the context is of
-- * type org.mortbay.jetty.servlet.Context
-+ * the customized context; in case of Jetty 7 the context is of
-+ * type org.eclipse.jetty.servlet.ServletContextHandler
- */
- public Object customizeContext(Object context, Dictionary settings) {
- return context;
-@@ -52,13 +52,13 @@
- * Implementors may perform additional configuration of the Jetty Connector.
- *
- * @param connector
-- * the Jetty connector; in case of Jetty 6 the context is of
-- * type org.mortbay.jetty.Connector
-+ * the Jetty connector; in case of Jetty 7 the context is of
-+ * type org.eclipse.jetty.server.Connector
- * @param settings
- * the settings as passed to {@link JettyConfigurator#startServer(String, Dictionary)}
- * @return connector
- * the customized connector; in case of Jetty 6 the connector is of
-- * type org.mortbay.jetty.Connector
-+ * type org.eclipse.jetty.server.Connector
- */
- public Object customizeHttpConnector(Object connector, Dictionary settings) {
- return connector;
-@@ -71,13 +71,13 @@
- * Implementors may perform additional configuration of the Jetty Connector.
- *
- * @param connector
-- * the Jetty connector; in case of Jetty 6 the connector is of
-- * type org.mortbay.jetty.Connector
-+ * the Jetty connector; in case of Jetty 7 the connector is of
-+ * type oorg.eclipse.jetty.server.Connector
- * @param settings
- * the settings as passed to {@link JettyConfigurator#startServer(String, Dictionary)}
- * @return connector
-- * the customized connector; in case of Jetty 6 the connector is of
-- * type org.mortbay.jetty.Connector
-+ * the customized connector; in case of Jetty 7 the connector is of
-+ * type org.eclipse.jetty.server.Connector
- */
- public Object customizeHttpsConnector(Object connector, Dictionary settings) {
- return connector;
-Index: src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java
-===================================================================
-RCS file: /cvsroot/rt/org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.http.jetty6/src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java,v
-retrieving revision 1.20
-diff -u -r1.20 HttpServerManager.java
---- src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java 20 May 2009 21:12:37 -0000 1.20
-+++ src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java 16 Apr 2010 21:35:58 -0000
-@@ -18,12 +18,15 @@
- import org.eclipse.equinox.http.jetty.JettyConstants;
- import org.eclipse.equinox.http.jetty.JettyCustomizer;
- import org.eclipse.equinox.http.servlet.HttpServiceServlet;
--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.servlet.*;
-+import org.eclipse.jetty.server.Connector;
-+import org.eclipse.jetty.server.Server;
-+import org.eclipse.jetty.server.bio.SocketConnector;
-+import org.eclipse.jetty.server.nio.SelectChannelConnector;
-+import org.eclipse.jetty.server.session.HashSessionManager;
-+import org.eclipse.jetty.server.session.SessionHandler;
-+import org.eclipse.jetty.server.ssl.SslSocketConnector;
-+import org.eclipse.jetty.servlet.ServletContextHandler;
-+import org.eclipse.jetty.servlet.ServletHolder;
- import org.osgi.framework.Constants;
- import org.osgi.service.cm.ConfigurationException;
- import org.osgi.service.cm.ManagedServiceFactory;
-@@ -98,12 +101,12 @@
- if (otherInfo != null)
- holder.setInitParameter(JettyConstants.OTHER_INFO, otherInfo);
-
-- Context httpContext = createHttpContext(dictionary);
-+ ServletContextHandler httpContext = createHttpContext(dictionary);
- if (null != customizer)
-- httpContext = (Context) customizer.customizeContext(httpContext, dictionary);
-+ httpContext = (ServletContextHandler) customizer.customizeContext(httpContext, dictionary);
-
- httpContext.addServlet(holder, "/*"); //$NON-NLS-1$
-- server.addHandler(httpContext);
-+ server.setHandler(httpContext);
-
- try {
- server.start();
-@@ -241,8 +244,8 @@
- return sslConnector;
- }
-
-- private Context createHttpContext(Dictionary dictionary) {
-- Context httpContext = new Context();
-+ private ServletContextHandler createHttpContext(Dictionary dictionary) {
-+ ServletContextHandler httpContext = new ServletContextHandler();
- httpContext.setAttribute(INTERNAL_CONTEXT_CLASSLOADER, Thread.currentThread().getContextClassLoader());
- httpContext.setClassLoader(this.getClass().getClassLoader());
-
-Index: src/org/slf4j/Logger.java
-===================================================================
-RCS file: /cvsroot/rt/org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.http.jetty6/src/org/slf4j/Logger.java,v
-retrieving revision 1.2
-diff -u -r1.2 Logger.java
---- src/org/slf4j/Logger.java 17 Apr 2009 20:24:43 -0000 1.2
-+++ src/org/slf4j/Logger.java 16 Apr 2010 21:35:58 -0000
-@@ -10,8 +10,8 @@
- *******************************************************************************/
- package org.slf4j;
-
--import org.mortbay.log.Log;
--import org.mortbay.log.StdErrLog;
-+import org.eclipse.jetty.util.log.Log;
-+import org.eclipse.jetty.util.log.StdErrLog;
-
- // NOTE: This class is not a real SLF4J implementation and MUST NOT be exported as a general implementation!
- // It is a place-holder to allow overriding the default logging done in Jetty
-@@ -80,7 +80,7 @@
- setDebugEnabled(true);
- }
-
-- public org.mortbay.log.Logger getLogger(String name) {
-+ public org.eclipse.jetty.util.log.Logger getLogger(String name) {
- if ((name == null && this.localName == null) || (name != null && name.equals(this.localName)))
- return this;
- return new Logger(name);
--- rt.equinox.bundles/bundles/org.eclipse.equinox.http.jetty8/src/org/eclipse/equinox/http/jetty/internal/EquinoxStdErrLog.java.orig 2014-03-24 10:46:20.000000000 +0000
+++ rt.equinox.bundles/bundles/org.eclipse.equinox.http.jetty8/src/org/eclipse/equinox/http/jetty/internal/EquinoxStdErrLog.java 2014-03-24 14:59:31.662164402 +0000
@@ -169,6 +169,12 @@ public class EquinoxStdErrLog implements Logger {
realLogger.debug(thrown);
}
+ public void debug(String msg, long value) {
+ if (threshold > DEBUG)
+ return;
+ realLogger.debug(msg, value);
+ }
+
public void ignore(Throwable ignored) {
// Just post this to debug
debug(ignored);
--- rt.equinox.bundles/bundles/org.eclipse.equinox.http.jetty8/src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java.orig 2014-03-24 10:46:20.000000000 +0000
+++ rt.equinox.bundles/bundles/org.eclipse.equinox.http.jetty8/src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java 2014-03-24 14:59:31.662164402 +0000
@@ -18,21 +18,21 @@
import org.eclipse.equinox.http.jetty.JettyConstants;
import org.eclipse.equinox.http.jetty.JettyCustomizer;
import org.eclipse.equinox.http.servlet.HttpServiceServlet;
-import org.eclipse.jetty.server.Connector;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.bio.SocketConnector;
-import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.server.*;
import org.eclipse.jetty.server.session.HashSessionManager;
import org.eclipse.jetty.server.session.SessionHandler;
-import org.eclipse.jetty.server.ssl.SslSocketConnector;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.osgi.framework.Constants;
import org.osgi.service.cm.ConfigurationException;
import org.osgi.service.cm.ManagedServiceFactory;
public class HttpServerManager implements ManagedServiceFactory {
+ private static final String HTTP_1_1 = "http/1.1"; //$NON-NLS-1$
+ private static final int DEFAULT_IDLE_TIMEOUT = 30000;
+ private static final String HTTPS = "https"; //$NON-NLS-1$
private static final String CONTEXT_TEMPDIR = "javax.servlet.context.tempdir"; //$NON-NLS-1$
private static final String DIR_PREFIX = "pid_"; //$NON-NLS-1$
private static final String INTERNAL_CONTEXT_CLASSLOADER = "org.eclipse.equinox.http.jetty.internal.ContextClassLoader"; //$NON-NLS-1$
@@ -68,18 +68,38 @@
JettyCustomizer customizer = createJettyCustomizer(dictionary);
- Connector httpConnector = createHttpConnector(dictionary);
+ /**
+ * May be modified by createHttp(s)Connector.
+ */
+ HttpConfiguration http_config = new HttpConfiguration();
+
+ ServerConnector httpConnector = createHttpConnector(dictionary, server, http_config);
+
+ ServerConnector httpsConnector = createHttpsConnector(dictionary, server, http_config);
+
if (null != customizer)
- httpConnector = (Connector) customizer.customizeHttpConnector(httpConnector, dictionary);
+ httpConnector = (ServerConnector) customizer.customizeHttpConnector(httpConnector, dictionary);
- if (httpConnector != null)
+ if (httpConnector != null) {
+ try {
+ httpConnector.open();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
server.addConnector(httpConnector);
+ }
- Connector httpsConnector = createHttpsConnector(dictionary);
if (null != customizer)
- httpsConnector = (Connector) customizer.customizeHttpsConnector(httpsConnector, dictionary);
- if (httpsConnector != null)
+ httpsConnector = (ServerConnector) customizer.customizeHttpsConnector(httpsConnector, dictionary);
+
+ if (httpsConnector != null) {
+ try {
+ httpsConnector.open();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
server.addConnector(httpsConnector);
+ }
ServletHolder holder = new ServletHolder(new InternalHttpServiceServlet());
holder.setInitOrder(0);
@@ -111,11 +131,76 @@
try {
server.start();
} catch (Exception e) {
- throw new ConfigurationException(pid, e.getMessage(), e);
+ //throw new ConfigurationException(pid, e.getMessage(), e);
}
servers.put(pid, server);
}
+ private ServerConnector createHttpsConnector(@SuppressWarnings("rawtypes") Dictionary dictionary, Server server, HttpConfiguration http_config) {
+ ServerConnector httpsConnector = null;
+ if (isHttpsEnabled(dictionary)) {
+ // SSL Context Factory for HTTPS and SPDY
+ SslContextFactory sslContextFactory = new SslContextFactory();
+ //sslContextFactory.setKeyStore(KeyS)
+ //Not sure if the next tree are properly migrated from jetty 8...
+ sslContextFactory.setKeyStorePath((String) dictionary.get(JettyConstants.SSL_KEYSTORE));
+ sslContextFactory.setKeyStorePassword((String) dictionary.get(JettyConstants.SSL_PASSWORD));
+ sslContextFactory.setKeyManagerPassword((String) dictionary.get(JettyConstants.SSL_KEYPASSWORD));
+
+ String keystoreType = (String) dictionary.get(JettyConstants.SSL_KEYSTORETYPE);
+ if (keystoreType != null) {
+ sslContextFactory.setKeyStoreType(keystoreType);
+ }
+
+ String protocol = (String) dictionary.get(JettyConstants.SSL_PROTOCOL);
+ if (protocol != null) {
+ sslContextFactory.setProtocol(protocol);
+ }
+
+ Object wantClientAuth = dictionary.get(JettyConstants.SSL_WANTCLIENTAUTH);
+ if (wantClientAuth != null) {
+ if (wantClientAuth instanceof String)
+ wantClientAuth = Boolean.valueOf((String) wantClientAuth);
+
+ sslContextFactory.setWantClientAuth((Boolean) wantClientAuth);
+ }
+
+ Object needClientAuth = dictionary.get(JettyConstants.SSL_NEEDCLIENTAUTH);
+ if (needClientAuth != null) {
+ if (needClientAuth instanceof String)
+ needClientAuth = Boolean.valueOf((String) needClientAuth);
+
+ sslContextFactory.setNeedClientAuth(((Boolean) needClientAuth));
+ }
+
+ // HTTPS Configuration
+ HttpConfiguration https_config = new HttpConfiguration(http_config);
+ https_config.addCustomizer(new SecureRequestCustomizer());
+
+ // HTTPS connector
+ httpsConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HTTP_1_1), new HttpConnectionFactory(https_config));
+ httpsConnector.setPort(getIntProperty(dictionary, JettyConstants.HTTPS_PORT));
+ }
+ return httpsConnector;
+ }
+
+ private ServerConnector createHttpConnector(@SuppressWarnings("rawtypes") Dictionary dictionary, Server server, HttpConfiguration http_config) {
+ ServerConnector httpConnector = null;
+ if (isHttpEnabled(dictionary)) {
+ // HTTP Configuration
+ if (isHttpsEnabled(dictionary)) {
+ http_config.setSecureScheme(HTTPS);
+ http_config.setSecurePort(getIntProperty(dictionary, JettyConstants.HTTPS_PORT));
+ }
+ // HTTP connector
+ httpConnector = new ServerConnector(server, new HttpConnectionFactory(http_config));
+ httpConnector.setPort(getIntProperty(dictionary, JettyConstants.HTTP_PORT));
+ httpConnector.setHost((String) dictionary.get(JettyConstants.HTTP_HOST));
+ httpConnector.setIdleTimeout(DEFAULT_IDLE_TIMEOUT);
+ }
+ return httpConnector;
+ }
+
public synchronized void shutdown() throws Exception {
for (Iterator