Search in sources :

Example 1 with NullEventClient

use of io.airlift.event.client.NullEventClient in project airlift by airlift.

the class TestHttpServerCipher method createServer.

private static HttpServer createServer(HttpServlet servlet, NodeInfo nodeInfo, HttpServerInfo httpServerInfo, HttpServerConfig config) {
    HashLoginServiceProvider loginServiceProvider = new HashLoginServiceProvider(config);
    HttpServerProvider serverProvider = new HttpServerProvider(httpServerInfo, nodeInfo, config, servlet, ImmutableSet.of(new DummyFilter()), ImmutableSet.of(), ImmutableSet.of(), new RequestStats(), new NullEventClient());
    serverProvider.setTheAdminServlet(new DummyServlet());
    serverProvider.setLoginService(loginServiceProvider.get());
    serverProvider.setTokenManager(new TraceTokenManager());
    return serverProvider.get();
}
Also used : NullEventClient(io.airlift.event.client.NullEventClient) TraceTokenManager(io.airlift.tracetoken.TraceTokenManager)

Example 2 with NullEventClient

use of io.airlift.event.client.NullEventClient in project airlift by airlift.

the class TestHttpServerProvider method createServer.

private void createServer(HttpServlet servlet) {
    HashLoginServiceProvider loginServiceProvider = new HashLoginServiceProvider(config);
    HttpServerProvider serverProvider = new HttpServerProvider(httpServerInfo, nodeInfo, config, optionalHttpsConfig(), servlet, ImmutableSet.of(new DummyFilter()), ImmutableSet.of(), ImmutableSet.of(), clientCertificate, new RequestStats(), new NullEventClient(), Optional.empty());
    serverProvider.setTheAdminServlet(new DummyServlet());
    serverProvider.setLoginService(loginServiceProvider.get());
    serverProvider.setTokenManager(new TraceTokenManager());
    server = serverProvider.get();
}
Also used : NullEventClient(io.airlift.event.client.NullEventClient) TraceTokenManager(io.airlift.tracetoken.TraceTokenManager)

Example 3 with NullEventClient

use of io.airlift.event.client.NullEventClient in project airlift by airlift.

the class TestHttpServerCipher method createServer.

private static HttpServer createServer(HttpServlet servlet, NodeInfo nodeInfo, HttpServerInfo httpServerInfo, HttpServerConfig config, HttpsConfig httpsConfig) {
    HashLoginServiceProvider loginServiceProvider = new HashLoginServiceProvider(config);
    HttpServerProvider serverProvider = new HttpServerProvider(httpServerInfo, nodeInfo, config, Optional.of(httpsConfig), servlet, ImmutableSet.of(new DummyFilter()), ImmutableSet.of(), ImmutableSet.of(), ClientCertificate.NONE, new RequestStats(), new NullEventClient(), Optional.empty());
    serverProvider.setTheAdminServlet(new DummyServlet());
    serverProvider.setLoginService(loginServiceProvider.get());
    serverProvider.setTokenManager(new TraceTokenManager());
    return serverProvider.get();
}
Also used : NullEventClient(io.airlift.event.client.NullEventClient) TraceTokenManager(io.airlift.tracetoken.TraceTokenManager)

Example 4 with NullEventClient

use of io.airlift.event.client.NullEventClient in project airlift by airlift.

the class TestJettyMultipleCerts method test.

@Test
public void test() throws Exception {
    HttpServlet servlet = new HttpServlet() {

        @Override
        protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
            response.setStatus(200);
            response.getOutputStream().write((request.getServerName() + " OK").getBytes(UTF_8));
        }
    };
    HttpServerConfig config = new HttpServerConfig().setLogEnabled(false).setHttpEnabled(false).setHttpPort(0).setHttpsEnabled(true);
    HttpsConfig httpsConfig = new HttpsConfig().setHttpsPort(0).setKeystorePath(getResource("multiple-certs/server.p12").getPath()).setKeystorePassword("airlift");
    HashLoginServiceProvider loginServiceProvider = new HashLoginServiceProvider(config);
    NodeInfo nodeInfo = new NodeInfo(new NodeConfig().setEnvironment("test").setNodeInternalAddress("localhost"));
    HttpServerInfo httpServerInfo = new HttpServerInfo(config, Optional.of(httpsConfig), nodeInfo);
    HttpServerProvider serverProvider = new HttpServerProvider(httpServerInfo, nodeInfo, config, Optional.of(httpsConfig), servlet, ImmutableSet.of(new DummyFilter()), ImmutableSet.of(), ImmutableSet.of(), ClientCertificate.NONE, new RequestStats(), new NullEventClient(), Optional.empty());
    serverProvider.setTheAdminServlet(new DummyServlet());
    serverProvider.setLoginService(loginServiceProvider.get());
    serverProvider.setTokenManager(new TraceTokenManager());
    try (Closer closer = Closer.create()) {
        HttpServer server = serverProvider.get();
        closer.register(() -> {
            try {
                server.stop();
            } catch (Exception ignore) {
            }
        });
        server.start();
        JettyHttpClient client = new JettyHttpClient(new HttpClientConfig().setTrustStorePath(getResource("multiple-certs/server.p12").getPath()).setTrustStorePassword("airlift"));
        closer.register(client);
        int httpsPort = httpServerInfo.getHttpsUri().getPort();
        tryHost(client, HostAndPort.fromParts("localhost", httpsPort));
        for (String name : List.of("127.0.0.1", "::1")) {
            assertThatThrownBy(() -> tryHost(client, HostAndPort.fromParts(name, httpsPort))).hasMessageStartingWith(name + " Failed communicating with server").hasRootCauseMessage("No subject alternative names present");
        }
        // 
        for (String name : List.of("single1", "single2", "single3", "single4")) {
            if (doesDomainResolveToLocalhost(name)) {
                tryHost(client, HostAndPort.fromParts(name, httpsPort));
            }
        }
    }
}
Also used : Closer(com.google.common.io.Closer) HttpClientConfig(io.airlift.http.client.HttpClientConfig) NullEventClient(io.airlift.event.client.NullEventClient) HttpServlet(javax.servlet.http.HttpServlet) HttpServletResponse(javax.servlet.http.HttpServletResponse) TraceTokenManager(io.airlift.tracetoken.TraceTokenManager) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) HttpServletRequest(javax.servlet.http.HttpServletRequest) NodeInfo(io.airlift.node.NodeInfo) JettyHttpClient(io.airlift.http.client.jetty.JettyHttpClient) NodeConfig(io.airlift.node.NodeConfig) Test(org.testng.annotations.Test)

Aggregations

NullEventClient (io.airlift.event.client.NullEventClient)4 TraceTokenManager (io.airlift.tracetoken.TraceTokenManager)4 Closer (com.google.common.io.Closer)1 HttpClientConfig (io.airlift.http.client.HttpClientConfig)1 JettyHttpClient (io.airlift.http.client.jetty.JettyHttpClient)1 NodeConfig (io.airlift.node.NodeConfig)1 NodeInfo (io.airlift.node.NodeInfo)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 HttpServlet (javax.servlet.http.HttpServlet)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 Test (org.testng.annotations.Test)1