X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=eclipse%2Forg.argeo.ext.equinox.jetty%2Fsrc%2Forg%2Fargeo%2Fequinox%2Fjetty%2FCmsJettyCustomizer.java;fp=eclipse%2Forg.argeo.ext.equinox.jetty%2Fsrc%2Forg%2Fargeo%2Fequinox%2Fjetty%2FCmsJettyCustomizer.java;h=0000000000000000000000000000000000000000;hb=4e548693acc16f97b74eaaa95d6841054a172b85;hp=ab291b5456ee2f5a5230c81137462bfe474e760d;hpb=7b242851c0094d13cbaca5b68261ad92c873a59f;p=lgpl%2Fargeo-commons.git diff --git a/eclipse/org.argeo.ext.equinox.jetty/src/org/argeo/equinox/jetty/CmsJettyCustomizer.java b/eclipse/org.argeo.ext.equinox.jetty/src/org/argeo/equinox/jetty/CmsJettyCustomizer.java deleted file mode 100644 index ab291b545..000000000 --- a/eclipse/org.argeo.ext.equinox.jetty/src/org/argeo/equinox/jetty/CmsJettyCustomizer.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.argeo.equinox.jetty; - -import java.util.Dictionary; - -import javax.servlet.ServletContext; -import javax.websocket.DeploymentException; -import javax.websocket.server.ServerContainer; - -import org.eclipse.equinox.http.jetty.JettyCustomizer; -import org.eclipse.jetty.server.ConnectionFactory; -import org.eclipse.jetty.server.ServerConnector; -import org.eclipse.jetty.server.SslConnectionFactory; -import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.util.ssl.SslContextFactory; -import org.eclipse.jetty.websocket.javax.server.config.JavaxWebSocketServletContainerInitializer; -import org.eclipse.jetty.websocket.javax.server.config.JavaxWebSocketServletContainerInitializer.Configurator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; - -/** Customises the Jetty HTTP server. */ -public class CmsJettyCustomizer extends JettyCustomizer { - static final String SSL_TRUSTSTORE = "ssl.truststore"; - static final String SSL_TRUSTSTOREPASSWORD = "ssl.truststorepassword"; - static final String SSL_TRUSTSTORETYPE = "ssl.truststoretype"; - - private BundleContext bc = FrameworkUtil.getBundle(CmsJettyCustomizer.class).getBundleContext(); - - public final static String WEBSOCKET_ENABLED = "argeo.websocket.enabled"; - - @Override - public Object customizeContext(Object context, Dictionary settings) { - // WebSocket - Object webSocketEnabled = settings.get(WEBSOCKET_ENABLED); - if (webSocketEnabled != null && webSocketEnabled.toString().equals("true")) { - ServletContextHandler servletContextHandler = (ServletContextHandler) context; - JavaxWebSocketServletContainerInitializer.configure(servletContextHandler, new Configurator() { - - @Override - public void accept(ServletContext servletContext, ServerContainer serverContainer) - throws DeploymentException { - bc.registerService(javax.websocket.server.ServerContainer.class, serverContainer, null); - } - }); - } - return super.customizeContext(context, settings); - - } - - @Override - public Object customizeHttpsConnector(Object connector, Dictionary settings) { - ServerConnector httpsConnector = (ServerConnector) connector; - if (httpsConnector != null) - for (ConnectionFactory connectionFactory : httpsConnector.getConnectionFactories()) { - if (connectionFactory instanceof SslConnectionFactory) { - SslContextFactory.Server sslConnectionFactory = ((SslConnectionFactory) connectionFactory) - .getSslContextFactory(); - sslConnectionFactory.setTrustStorePath((String) settings.get(SSL_TRUSTSTORE)); - sslConnectionFactory.setTrustStoreType((String) settings.get(SSL_TRUSTSTORETYPE)); - sslConnectionFactory.setTrustStorePassword((String) settings.get(SSL_TRUSTSTOREPASSWORD)); - } - } - return super.customizeHttpsConnector(connector, settings); - } - -}