Search in sources :

Example 36 with UndertowXnioSsl

use of io.undertow.protocols.ssl.UndertowXnioSsl in project actframework by actframework.

the class UndertowNetwork method setUpClient.

@Override
protected void setUpClient(NetworkHandler client, int port, boolean secure) throws IOException {
    HttpHandler handler = new ActHttpHandler(client);
    ByteBufferPool buffers = new DefaultByteBufferPool(true, 16 * 1024, -1, 4);
    HttpOpenListener openListener = new HttpOpenListener(buffers, serverOptions);
    openListener.setRootHandler(handler);
    ChannelListener<AcceptingChannel<StreamConnection>> acceptListener = ChannelListeners.openListenerAdapter(openListener);
    if (!secure) {
        AcceptingChannel<? extends StreamConnection> server = worker.createStreamConnectionServer(new InetSocketAddress(port), acceptListener, socketOptions);
        server.resumeAccepts();
        channels.add(server);
    } else {
        XnioSsl xnioSsl;
        try {
            SSLContext sslContext = createSSLContext(loadKeyStore("server.keystore"), loadKeyStore("server.truststore"));
            xnioSsl = new UndertowXnioSsl(xnio, OptionMap.create(Options.USE_DIRECT_BUFFERS, true), sslContext);
            AcceptingChannel<SslConnection> sslServer = xnioSsl.createSslConnectionServer(worker, new InetSocketAddress(port), (ChannelListener) acceptListener, socketOptions);
            sslServer.resumeAccepts();
            channels.add(sslServer);
        } catch (Exception e) {
            throw E.unexpected(e);
        }
    }
}
Also used : DefaultByteBufferPool(io.undertow.server.DefaultByteBufferPool) ByteBufferPool(io.undertow.connector.ByteBufferPool) HttpHandler(io.undertow.server.HttpHandler) DefaultByteBufferPool(io.undertow.server.DefaultByteBufferPool) XnioSsl(org.xnio.ssl.XnioSsl) UndertowXnioSsl(io.undertow.protocols.ssl.UndertowXnioSsl) InetSocketAddress(java.net.InetSocketAddress) IOException(java.io.IOException) SslConnection(org.xnio.ssl.SslConnection) HttpOpenListener(io.undertow.server.protocol.http.HttpOpenListener) UndertowXnioSsl(io.undertow.protocols.ssl.UndertowXnioSsl) AcceptingChannel(org.xnio.channels.AcceptingChannel)

Aggregations

UndertowXnioSsl (io.undertow.protocols.ssl.UndertowXnioSsl)36 URI (java.net.URI)21 IOException (java.io.IOException)18 Test (org.junit.Test)17 XnioSsl (org.xnio.ssl.XnioSsl)15 ClientConnection (io.undertow.client.ClientConnection)9 UndertowClient (io.undertow.client.UndertowClient)9 CountDownLatch (java.util.concurrent.CountDownLatch)9 ClientRequest (io.undertow.client.ClientRequest)7 HttpHandler (io.undertow.server.HttpHandler)7 SSLContext (javax.net.ssl.SSLContext)7 InetSocketAddress (java.net.InetSocketAddress)6 HttpServerExchange (io.undertow.server.HttpServerExchange)5 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)5 OptionMap (org.xnio.OptionMap)5 LoadBalancingProxyClient (io.undertow.server.handlers.proxy.LoadBalancingProxyClient)4 HttpOpenListener (io.undertow.server.protocol.http.HttpOpenListener)4 Http2UpgradeHandler (io.undertow.server.protocol.http2.Http2UpgradeHandler)4 StringWriteChannelListener (io.undertow.util.StringWriteChannelListener)4 Undertow (io.undertow.Undertow)3