Home / Class/ StartTlsServerHandler Class — netty Architecture

StartTlsServerHandler Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  a505be0e_4066_b29c_d557_d32c407f4d58["StartTlsServerHandler"]
  22dc6292_176b_7a59_4a97_0becd5db6cd4["SocketStartTlsTest.java"]
  a505be0e_4066_b29c_d557_d32c407f4d58 -->|defined in| 22dc6292_176b_7a59_4a97_0becd5db6cd4
  f445b76e_9f4e_9833_8699_3f5becec96e9["StartTlsServerHandler()"]
  a505be0e_4066_b29c_d557_d32c407f4d58 -->|method| f445b76e_9f4e_9833_8699_3f5becec96e9
  5f6a3312_f1ab_e2da_d187_5e0539beac36["channelActive()"]
  a505be0e_4066_b29c_d557_d32c407f4d58 -->|method| 5f6a3312_f1ab_e2da_d187_5e0539beac36
  09d53f4b_3bda_cc79_0ab9_9fcc6bc8ca79["channelRead0()"]
  a505be0e_4066_b29c_d557_d32c407f4d58 -->|method| 09d53f4b_3bda_cc79_0ab9_9fcc6bc8ca79
  78e8cfa4_2fc5_fd26_957d_3535cbba6e42["channelReadComplete()"]
  a505be0e_4066_b29c_d557_d32c407f4d58 -->|method| 78e8cfa4_2fc5_fd26_957d_3535cbba6e42
  4facaa50_e7d2_bf72_8db4_c3370155818e["exceptionCaught()"]
  a505be0e_4066_b29c_d557_d32c407f4d58 -->|method| 4facaa50_e7d2_bf72_8db4_c3370155818e

Relationship Graph

Source Code

testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketStartTlsTest.java lines 297–346

    private static class StartTlsServerHandler extends SimpleChannelInboundHandler<String> {
        private final SslHandler sslHandler;
        private final boolean autoRead;
        volatile Channel channel;
        final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();

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

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

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

            assertEquals("EncryptedRequest", msg);
            ctx.writeAndFlush("EncryptedResponse\n");
        }

        @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 server side", cause);
            }

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

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free