Search in sources :

Example 66 with HttpConnectionFactory

use of org.eclipse.jetty.server.HttpConnectionFactory in project gocd by gocd.

the class FakeGoServer method sslConnector.

public Connector sslConnector(File keystore, File truststore, int sslPort) {
    HttpConfiguration httpsConfig = new HttpConfiguration();
    httpsConfig.setOutputBufferSize(RESPONSE_BUFFER_SIZE);
    httpsConfig.addCustomizer(new SecureRequestCustomizer());
    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStorePath(keystore.getAbsolutePath());
    sslContextFactory.setKeyStorePassword(PASSWORD);
    sslContextFactory.setKeyManagerPassword(PASSWORD);
    sslContextFactory.setTrustStorePath(truststore.getAbsolutePath());
    sslContextFactory.setTrustStorePassword(PASSWORD);
    sslContextFactory.setWantClientAuth(true);
    ServerConnector https = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, "http/1.1"), new HttpConnectionFactory(httpsConfig));
    https.setPort(sslPort);
    https.setIdleTimeout(MAX_IDLE_TIME);
    return https;
}
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 67 with HttpConnectionFactory

use of org.eclipse.jetty.server.HttpConnectionFactory 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 68 with HttpConnectionFactory

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

the class HttpServer method configureMainConnector.

private ServerConnector configureMainConnector(final HttpConfiguration httpConfiguration, final boolean isStatsOn, final String localIp, final int localPort) {
    final ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfiguration));
    http.setHost(localIp);
    http.setPort(localPort);
    if (isStatsOn) {
        final ConnectorStatistics stats = new ConnectorStatistics();
        http.addBean(stats);
    }
    return http;
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) ConnectorStatistics(org.eclipse.jetty.server.ConnectorStatistics)

Example 69 with HttpConnectionFactory

use of org.eclipse.jetty.server.HttpConnectionFactory 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 70 with HttpConnectionFactory

use of org.eclipse.jetty.server.HttpConnectionFactory 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)

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