Search in sources :

Example 81 with HttpConfiguration

use of org.eclipse.jetty.server.HttpConfiguration in project Openfire by igniterealtime.

the class HttpBindManager method createSSLConnector.

private void createSSLConnector(int securePort) {
    httpsConnector = null;
    try {
        final IdentityStore identityStore = XMPPServer.getInstance().getCertificateStoreManager().getIdentityStore(ConnectionType.BOSH_C2S);
        if (securePort > 0 && identityStore.getStore().aliases().hasMoreElements()) {
            if (!identityStore.containsDomainCertificate("RSA")) {
                Log.warn("HTTP binding: Using RSA certificates but they are not valid for " + "the hosted domain");
            }
            final ConnectionManagerImpl connectionManager = ((ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager());
            final ConnectionConfiguration configuration = connectionManager.getListener(ConnectionType.BOSH_C2S, true).generateConnectionConfiguration();
            final SslContextFactory sslContextFactory = new EncryptionArtifactFactory(configuration).getSslContextFactory();
            final HttpConfiguration httpsConfig = new HttpConfiguration();
            httpsConfig.setSecureScheme("https");
            httpsConfig.setSecurePort(securePort);
            configureProxiedConnector(httpsConfig);
            httpsConfig.addCustomizer(new SecureRequestCustomizer());
            final ServerConnector sslConnector;
            if ("npn".equals(JiveGlobals.getXMLProperty("spdy.protocol", ""))) {
                sslConnector = new HTTPSPDYServerConnector(httpBindServer, sslContextFactory);
            } else {
                sslConnector = new ServerConnector(httpBindServer, new SslConnectionFactory(sslContextFactory, "http/1.1"), new HttpConnectionFactory(httpsConfig));
            }
            sslConnector.setHost(getBindInterface());
            sslConnector.setPort(securePort);
            httpsConnector = sslConnector;
        }
    } catch (Exception e) {
        Log.error("Error creating SSL connector for Http bind", e);
    }
}
Also used : HTTPSPDYServerConnector(org.eclipse.jetty.spdy.server.http.HTTPSPDYServerConnector) ServerConnector(org.eclipse.jetty.server.ServerConnector) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) ConnectionManagerImpl(org.jivesoftware.openfire.spi.ConnectionManagerImpl) ConnectionConfiguration(org.jivesoftware.openfire.spi.ConnectionConfiguration) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) EncryptionArtifactFactory(org.jivesoftware.openfire.spi.EncryptionArtifactFactory) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) HTTPSPDYServerConnector(org.eclipse.jetty.spdy.server.http.HTTPSPDYServerConnector) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) IdentityStore(org.jivesoftware.openfire.keystore.IdentityStore) ServletException(javax.servlet.ServletException)

Example 82 with HttpConfiguration

use of org.eclipse.jetty.server.HttpConfiguration in project killbill by killbill.

the class HttpServer method configure.

public void configure(final HttpServerConfig config, final Iterable<EventListener> eventListeners, final Map<FilterHolder, String> filterHolders) {
    server.setStopAtShutdown(true);
    // Setup JMX
    configureJMX(ManagementFactory.getPlatformMBeanServer());
    // HTTP Configuration
    final HttpConfiguration httpConfiguration = new HttpConfiguration();
    httpConfiguration.setSecurePort(config.getServerSslPort());
    // Configure main connector
    final ServerConnector http = configureMainConnector(httpConfiguration, config.isJettyStatsOn(), config.getServerHost(), config.getServerPort());
    // Configure SSL, if enabled
    final ServerConnector https;
    if (config.isSSLEnabled()) {
        https = configureSslConnector(httpConfiguration, config.isJettyStatsOn(), config.getServerSslPort(), config.getSSLkeystoreLocation(), config.getSSLkeystorePassword());
        server.setConnectors(new Connector[] { http, https });
    } else {
        server.setConnectors(new Connector[] { http });
    }
    // Configure the thread pool
    configureThreadPool(config);
    // Configure handlers
    final HandlerCollection handlers = new HandlerCollection();
    final ServletContextHandler servletContextHandler = createServletContextHandler(config.getResourceBase(), eventListeners, filterHolders);
    handlers.addHandler(servletContextHandler);
    final RequestLogHandler logHandler = createLogHandler(config);
    handlers.addHandler(logHandler);
    final HandlerList rootHandlers = new HandlerList();
    rootHandlers.addHandler(handlers);
    server.setHandler(rootHandlers);
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) HandlerList(org.eclipse.jetty.server.handler.HandlerList) RequestLogHandler(org.eclipse.jetty.server.handler.RequestLogHandler) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Example 83 with HttpConfiguration

use of org.eclipse.jetty.server.HttpConfiguration in project rest.li by linkedin.

the class HttpJettyServer method getConnectors.

protected Connector[] getConnectors(Server server) {
    HttpConfiguration configuration = new HttpConfiguration();
    ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(configuration, HttpCompliance.RFC2616));
    connector.setPort(_port);
    return new Connector[] { connector };
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) ServerConnector(org.eclipse.jetty.server.ServerConnector) Connector(org.eclipse.jetty.server.Connector) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration)

Example 84 with HttpConfiguration

use of org.eclipse.jetty.server.HttpConfiguration in project camel by apache.

the class CxfPayloadRouterContentLengthTest method setUp.

@Before
public void setUp() throws Exception {
    /*
         * We start a Jetty for the service in order to have better control over
         * the response The response must contain only a Content-Type and a
         * Content-Length but no other header
         */
    log.info("Starting jetty server at port {}", JETTY_PORT);
    server = new Server();
    // Do not send a Server header
    HttpConfiguration httpconf = new HttpConfiguration();
    httpconf.setSendServerVersion(false);
    ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpconf));
    http.setPort(JETTY_PORT);
    server.addConnector(http);
    server.setHandler(new AbstractHandler() {

        @Override
        public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
            response.setContentType("text/xml");
            // the Content-Length is correct for this response message
            response.setContentLength(RESPONSE_MESSAGE.length());
            response.setStatus(HttpServletResponse.SC_OK);
            baseRequest.setHandled(true);
            PrintWriter pw = response.getWriter();
            pw.write(RESPONSE_MESSAGE);
            pw.close();
        }
    });
    server.start();
    // Load the CXF endpoints for the route
    log.info("Start Routing Scenario at port {}", CXFTestSupport.getPort1());
    applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/CxfPayloadRouterContentLengthBeans.xml");
    super.setUp();
    assertNotNull("Should have created a valid spring context", applicationContext);
}
Also used : Server(org.eclipse.jetty.server.Server) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) Request(org.eclipse.jetty.server.Request) HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) IOException(java.io.IOException) AbstractHandler(org.eclipse.jetty.server.handler.AbstractHandler) ServerConnector(org.eclipse.jetty.server.ServerConnector) HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletException(javax.servlet.ServletException) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PrintWriter(java.io.PrintWriter) Before(org.junit.Before)

Example 85 with HttpConfiguration

use of org.eclipse.jetty.server.HttpConfiguration in project sonarqube by SonarSource.

the class SSLTest method startSSLTransparentReverseProxy.

public static void startSSLTransparentReverseProxy(boolean requireClientAuth) throws Exception {
    int httpPort = NetworkUtils.getNextAvailablePort();
    httpsPort = NetworkUtils.getNextAvailablePort();
    // Setup Threadpool
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setMaxThreads(500);
    server = new Server(threadPool);
    // HTTP Configuration
    HttpConfiguration httpConfig = new HttpConfiguration();
    httpConfig.setSecureScheme("https");
    httpConfig.setSecurePort(httpsPort);
    httpConfig.setSendServerVersion(true);
    httpConfig.setSendDateHeader(false);
    // Handler Structure
    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers(new Handler[] { proxyHandler(), new DefaultHandler() });
    server.setHandler(handlers);
    ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
    http.setPort(httpPort);
    server.addConnector(http);
    Path serverKeyStore = Paths.get(SSLTest.class.getResource("/analysis/SSLTest/serverkeystore.jks").toURI()).toAbsolutePath();
    String keyStorePassword = "serverkeystorepwd";
    String serverKeyPassword = "serverp12pwd";
    Path serverTrustStore = Paths.get(SSLTest.class.getResource("/analysis/SSLTest/servertruststore.jks").toURI()).toAbsolutePath();
    String trustStorePassword = "servertruststorepwd";
    // SSL Context Factory
    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStorePath(serverKeyStore.toString());
    sslContextFactory.setKeyStorePassword(keyStorePassword);
    sslContextFactory.setKeyManagerPassword(serverKeyPassword);
    sslContextFactory.setTrustStorePath(serverTrustStore.toString());
    sslContextFactory.setTrustStorePassword(trustStorePassword);
    sslContextFactory.setNeedClientAuth(requireClientAuth);
    sslContextFactory.setExcludeCipherSuites("SSL_RSA_WITH_DES_CBC_SHA", "SSL_DHE_RSA_WITH_DES_CBC_SHA", "SSL_DHE_DSS_WITH_DES_CBC_SHA", "SSL_RSA_EXPORT_WITH_RC4_40_MD5", "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA");
    // SSL HTTP Configuration
    HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
    // SSL Connector
    ServerConnector sslConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(httpsConfig));
    sslConnector.setPort(httpsPort);
    server.addConnector(sslConnector);
    server.start();
}
Also used : Path(java.nio.file.Path) Server(org.eclipse.jetty.server.Server) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) DefaultHandler(org.eclipse.jetty.server.handler.DefaultHandler) ServerConnector(org.eclipse.jetty.server.ServerConnector) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection)

Aggregations

HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)99 ServerConnector (org.eclipse.jetty.server.ServerConnector)71 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)70 Server (org.eclipse.jetty.server.Server)55 SecureRequestCustomizer (org.eclipse.jetty.server.SecureRequestCustomizer)40 SslConnectionFactory (org.eclipse.jetty.server.SslConnectionFactory)40 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)36 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)25 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)23 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)19 HTTP2ServerConnectionFactory (org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory)15 HttpServletRequest (javax.servlet.http.HttpServletRequest)11 Connector (org.eclipse.jetty.server.Connector)11 IOException (java.io.IOException)10 File (java.io.File)9 ServletException (javax.servlet.ServletException)9 HttpServletResponse (javax.servlet.http.HttpServletResponse)9 ALPNServerConnectionFactory (org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory)8 HTTP2CServerConnectionFactory (org.eclipse.jetty.http2.server.HTTP2CServerConnectionFactory)7 Request (org.eclipse.jetty.server.Request)7