Search in sources :

Example 76 with HttpConnectionFactory

use of org.eclipse.jetty.server.HttpConnectionFactory in project wiquery by WiQuery.

the class Start method main.

public static void main(String[] args) {
    Server server = new Server();
    ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory());
    // Set some timeout options to make debugging easier.
    connector.setIdleTimeout(1000 * 60 * 60);
    connector.setSoLingerTime(-1);
    connector.setPort(8080);
    server.setConnectors(new Connector[] { connector });
    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/main/webapp");
    server.setHandler(bb);
    try {
        System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
        server.start();
        System.in.read();
        System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(100);
    }
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) WebAppContext(org.eclipse.jetty.webapp.WebAppContext) Server(org.eclipse.jetty.server.Server) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory)

Example 77 with HttpConnectionFactory

use of org.eclipse.jetty.server.HttpConnectionFactory in project spring-boot by spring-projects.

the class JettyServletWebServerFactory method createSslConnector.

private AbstractConnector createSslConnector(Server server, SslContextFactory sslContextFactory, int port) {
    HttpConfiguration config = new HttpConfiguration();
    config.setSendServerVersion(false);
    config.addCustomizer(new SecureRequestCustomizer());
    HttpConnectionFactory connectionFactory = new HttpConnectionFactory(config);
    SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString());
    ServerConnector serverConnector = new ServerConnector(server, sslConnectionFactory, connectionFactory);
    serverConnector.setPort(port);
    return serverConnector;
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory)

Example 78 with HttpConnectionFactory

use of org.eclipse.jetty.server.HttpConnectionFactory in project async-http-client by AsyncHttpClient.

the class TestUtils method addHttpsConnector.

public static ServerConnector addHttpsConnector(Server server) throws IOException, URISyntaxException {
    String keyStoreFile = resourceAsFile("ssltest-keystore.jks").getAbsolutePath();
    SslContextFactory sslContextFactory = new SslContextFactory(keyStoreFile);
    sslContextFactory.setKeyStorePassword("changeit");
    String trustStoreFile = resourceAsFile("ssltest-cacerts.jks").getAbsolutePath();
    sslContextFactory.setTrustStorePath(trustStoreFile);
    sslContextFactory.setTrustStorePassword("changeit");
    HttpConfiguration httpsConfig = new HttpConfiguration();
    httpsConfig.setSecureScheme("https");
    httpsConfig.addCustomizer(new SecureRequestCustomizer());
    ServerConnector connector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, "http/1.1"), new HttpConnectionFactory(httpsConfig));
    server.addConnector(connector);
    return connector;
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory)

Example 79 with HttpConnectionFactory

use of org.eclipse.jetty.server.HttpConnectionFactory in project symmetric-ds by JumpMind.

the class SymmetricWebServer method getConnectors.

protected Connector[] getConnectors(Server server, int port, int securePort, Mode mode) {
    ArrayList<Connector> connectors = new ArrayList<Connector>();
    HttpConfiguration httpConfig = new HttpConfiguration();
    if (mode.equals(Mode.HTTPS) || mode.equals(Mode.MIXED)) {
        httpConfig.setSecureScheme("https");
        httpConfig.setSecurePort(securePort);
    }
    httpConfig.setOutputBufferSize(32768);
    if (mode.equals(Mode.HTTP) || mode.equals(Mode.MIXED)) {
        ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
        http.setPort(port);
        http.setHost(host);
        http.setIdleTimeout(maxIdleTime);
        connectors.add(http);
        log.info(String.format("About to start %s web server on host:port %s:%s", name, host == null ? "default" : host, port));
    }
    if (mode.equals(Mode.HTTPS) || mode.equals(Mode.MIXED)) {
        ISecurityService securityService = SecurityServiceFactory.create(SecurityServiceType.SERVER, new TypedProperties(System.getProperties()));
        securityService.installDefaultSslCert(host);
        String keyStorePassword = System.getProperty(SecurityConstants.SYSPROP_KEYSTORE_PASSWORD);
        keyStorePassword = (keyStorePassword != null) ? keyStorePassword : SecurityConstants.KEYSTORE_PASSWORD;
        SslContextFactory sslConnectorFactory = new SslContextFactory();
        sslConnectorFactory.setKeyManagerPassword(keyStorePassword);
        /* Prevent POODLE attack */
        String ignoredProtocols = System.getProperty(SecurityConstants.SYSPROP_SSL_IGNORE_PROTOCOLS);
        if (ignoredProtocols != null && ignoredProtocols.length() > 0) {
            String[] protocols = ignoredProtocols.split(",");
            sslConnectorFactory.addExcludeProtocols(protocols);
        } else {
            sslConnectorFactory.addExcludeProtocols("SSLv3");
        }
        String ignoredCiphers = System.getProperty(SecurityConstants.SYSPROP_SSL_IGNORE_CIPHERS);
        if (ignoredCiphers != null && ignoredCiphers.length() > 0) {
            String[] ciphers = ignoredCiphers.split(",");
            sslConnectorFactory.addExcludeCipherSuites(ciphers);
        }
        sslConnectorFactory.setCertAlias(System.getProperty(SecurityConstants.SYSPROP_KEYSTORE_CERT_ALIAS, SecurityConstants.ALIAS_SYM_PRIVATE_KEY));
        sslConnectorFactory.setKeyStore(securityService.getKeyStore());
        sslConnectorFactory.setTrustStore(securityService.getTrustStore());
        HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
        httpsConfig.addCustomizer(new SecureRequestCustomizer());
        ServerConnector https = new ServerConnector(server, new SslConnectionFactory(sslConnectorFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(httpsConfig));
        https.setPort(securePort);
        https.setIdleTimeout(maxIdleTime);
        https.setHost(host);
        connectors.add(https);
        log.info(String.format("About to start %s web server on secure host:port %s:%s", name, host == null ? "default" : host, securePort));
    }
    return connectors.toArray(new Connector[connectors.size()]);
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) Connector(org.eclipse.jetty.server.Connector) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) ArrayList(java.util.ArrayList) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) TypedProperties(org.jumpmind.properties.TypedProperties) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) ServerConnector(org.eclipse.jetty.server.ServerConnector) ISecurityService(org.jumpmind.security.ISecurityService) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory)

Example 80 with HttpConnectionFactory

use of org.eclipse.jetty.server.HttpConnectionFactory in project voltdb by VoltDB.

the class HTTPAdminListener method getSSLServerConnector.

private ServerConnector getSSLServerConnector(SslContextFactory sslContextFactory, String intf, int port) throws IOException {
    // SSL HTTP Configuration
    HttpConfiguration httpsConfig = new HttpConfiguration();
    httpsConfig.setSecureScheme("ssl");
    httpsConfig.setSecurePort(port);
    //Add this customizer to indicate we are in ssl land
    httpsConfig.addCustomizer(new SecureRequestCustomizer());
    HttpConnectionFactory factory = new HttpConnectionFactory(httpsConfig);
    // SSL Connector
    ServerConnector connector = new ServerConnector(m_server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), factory);
    if (intf != null && !intf.trim().isEmpty()) {
        connector.setHost(intf);
    }
    connector.setPort(port);
    connector.setName("VoltDB-HTTPS");
    connector.open();
    return connector;
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory)

Aggregations

HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)90 ServerConnector (org.eclipse.jetty.server.ServerConnector)79 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)69 Server (org.eclipse.jetty.server.Server)56 SslConnectionFactory (org.eclipse.jetty.server.SslConnectionFactory)44 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)43 SecureRequestCustomizer (org.eclipse.jetty.server.SecureRequestCustomizer)39 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)18 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)16 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)15 File (java.io.File)12 Connector (org.eclipse.jetty.server.Connector)12 IOException (java.io.IOException)11 ServletException (javax.servlet.ServletException)10 HttpServletRequest (javax.servlet.http.HttpServletRequest)9 HTTP2ServerConnectionFactory (org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory)9 Before (org.junit.Before)9 HttpServletResponse (javax.servlet.http.HttpServletResponse)8 ALPNServerConnectionFactory (org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory)8 Request (org.eclipse.jetty.server.Request)8