Home / Class/ StartTlsClientHandler Class — netty Architecture

StartTlsClientHandler Class — netty Architecture

Architecture documentation for the StartTlsClientHandler class in SocketStartTlsTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  8d39ef67_652c_2edd_2588_d7b0ba28610d["StartTlsClientHandler"]
  22dc6292_176b_7a59_4a97_0becd5db6cd4["SocketStartTlsTest.java"]
  8d39ef67_652c_2edd_2588_d7b0ba28610d -->|defined in| 22dc6292_176b_7a59_4a97_0becd5db6cd4
  77baa967_f1fa_2868_f119_1ed5e27a4549["StartTlsClientHandler()"]
  8d39ef67_652c_2edd_2588_d7b0ba28610d -->|method| 77baa967_f1fa_2868_f119_1ed5e27a4549
  0c273888_d9cf_2927_8448_3fa86c06c200["channelActive()"]
  8d39ef67_652c_2edd_2588_d7b0ba28610d -->|method| 0c273888_d9cf_2927_8448_3fa86c06c200
  be0658a8_5549_2bf0_6a1a_c07b18c9618d["channelRead0()"]
  8d39ef67_652c_2edd_2588_d7b0ba28610d -->|method| be0658a8_5549_2bf0_6a1a_c07b18c9618d
  9cc94c06_45e6_7fa3_5ba0_42a624b03cba["channelReadComplete()"]
  8d39ef67_652c_2edd_2588_d7b0ba28610d -->|method| 9cc94c06_45e6_7fa3_5ba0_42a624b03cba
  e55e6e8d_48a5_b20f_94a2_0b423edb68cd["exceptionCaught()"]
  8d39ef67_652c_2edd_2588_d7b0ba28610d -->|method| e55e6e8d_48a5_b20f_94a2_0b423edb68cd

Relationship Graph

Source Code

testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketStartTlsTest.java lines 242–295

    private static class StartTlsClientHandler extends SimpleChannelInboundHandler<String> {
        private final SslHandler sslHandler;
        private final boolean autoRead;
        private Future<Channel> handshakeFuture;
        final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();

        StartTlsClientHandler(SSLEngine engine, boolean autoRead) {
            engine.setUseClientMode(true);
            sslHandler = new SslHandler(engine);
            this.autoRead = autoRead;
        }

        @Override
        public void channelActive(ChannelHandlerContext ctx)
                throws Exception {
            if (!autoRead) {
                ctx.read();
            }
            ctx.writeAndFlush("StartTlsRequest\n");
        }

        @Override
        public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
            if ("StartTlsResponse".equals(msg)) {
                ctx.pipeline().addAfter("logger", "ssl", sslHandler);
                handshakeFuture = sslHandler.handshakeFuture();
                ctx.writeAndFlush("EncryptedRequest\n");
                return;
            }

            assertEquals("EncryptedResponse", msg);
            assertNotNull(handshakeFuture);
            assertTrue(handshakeFuture.isSuccess());
            ctx.close();
        }

        @Override
        public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
            if (!autoRead) {
                ctx.read();
            }
        }

        @Override
        public void exceptionCaught(ChannelHandlerContext ctx,
                Throwable cause) throws Exception {
            if (logger.isWarnEnabled()) {
                logger.warn("Unexpected exception from the client side", cause);
            }

            exception.compareAndSet(null, cause);
            ctx.close();
        }
    }

Frequently Asked Questions

What is the StartTlsClientHandler class?
StartTlsClientHandler is a class in the netty codebase, defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketStartTlsTest.java.
Where is StartTlsClientHandler defined?
StartTlsClientHandler is defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketStartTlsTest.java at line 242.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free