Home / Class/ RenegotiateTest Class — netty Architecture

RenegotiateTest Class — netty Architecture

Architecture documentation for the RenegotiateTest class in RenegotiateTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  55655f2c_c526_e5a8_ad7d_f9fafefc9e46["RenegotiateTest"]
  ea6b68c1_47d5_ffa2_c527_82164be7fee3["RenegotiateTest.java"]
  55655f2c_c526_e5a8_ad7d_f9fafefc9e46 -->|defined in| ea6b68c1_47d5_ffa2_c527_82164be7fee3
  675715b2_cce3_756d_8a7d_41a8984397e2["testRenegotiateServer()"]
  55655f2c_c526_e5a8_ad7d_f9fafefc9e46 -->|method| 675715b2_cce3_756d_8a7d_41a8984397e2
  9ec4ba76_b74b_6790_e938_b993f1eb7943["SslProvider()"]
  55655f2c_c526_e5a8_ad7d_f9fafefc9e46 -->|method| 9ec4ba76_b74b_6790_e938_b993f1eb7943
  32d320f6_095f_bf99_6144_af0f76234506["verifyResult()"]
  55655f2c_c526_e5a8_ad7d_f9fafefc9e46 -->|method| 32d320f6_095f_bf99_6144_af0f76234506

Relationship Graph

Source Code

handler/src/test/java/io/netty/handler/ssl/RenegotiateTest.java lines 41–152

public abstract class RenegotiateTest {

    @Test
    @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
    public void testRenegotiateServer() throws Throwable {
        final AtomicReference<Throwable> error = new AtomicReference<Throwable>();
        final CountDownLatch latch = new CountDownLatch(2);
        SelfSignedCertificate cert = CachedSelfSignedCertificate.getCachedCertificate();
        EventLoopGroup group = new MultiThreadIoEventLoopGroup(LocalIoHandler.newFactory());
        SslProvider sslProvider = serverSslProvider();
        final SslContext context = SslContextBuilder.forServer(cert.key(), cert.cert())
                .sslProvider(sslProvider)
                .protocols(SslProtocols.TLS_v1_2)
                .build();
        try {
            ServerBootstrap sb = new ServerBootstrap();
            sb.group(group).channel(LocalServerChannel.class)
                    .childHandler(new ChannelInitializer<Channel>() {
                        @Override
                        protected void initChannel(Channel ch) throws Exception {
                            SslHandler handler = context.newHandler(ch.alloc());
                            handler.setHandshakeTimeoutMillis(0);
                            ch.pipeline().addLast(handler);
                            ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
                                private boolean renegotiate;

                                @Override
                                public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
                                    ReferenceCountUtil.release(msg);
                                }

                                @Override
                                public void userEventTriggered(
                                        final ChannelHandlerContext ctx, Object evt) throws Exception {
                                    if (!renegotiate && evt instanceof SslHandshakeCompletionEvent) {
                                        SslHandshakeCompletionEvent event = (SslHandshakeCompletionEvent) evt;

                                        if (event.isSuccess()) {
                                            final SslHandler handler = ctx.pipeline().get(SslHandler.class);

                                            renegotiate = true;
                                            handler.renegotiate().addListener(future -> {
                                                if (!future.isSuccess()) {
                                                    error.compareAndSet(null, future.cause());
                                                    ctx.close();
                                                }
                                                latch.countDown();
                                            });
                                        } else {
                                            error.compareAndSet(null, event.cause());
                                            latch.countDown();

                                            ctx.close();
                                        }
                                    }
                                }
                            });
                        }
                    });
            Channel channel = sb.bind(new LocalAddress("RenegotiateTest")).syncUninterruptibly().channel();

            final SslContext clientContext = SslContextBuilder.forClient()
                    .trustManager(InsecureTrustManagerFactory.INSTANCE)
                    .sslProvider(SslProvider.JDK)
                    .protocols(SslProtocols.TLS_v1_2)
                    .build();

            Bootstrap bootstrap = new Bootstrap();
            bootstrap.group(group).channel(LocalChannel.class)
                    .handler(new ChannelInitializer<Channel>() {
                        @Override
                        protected void initChannel(Channel ch) throws Exception {
                            SslHandler handler = clientContext.newHandler(ch.alloc());
                            handler.setHandshakeTimeoutMillis(0);
                            ch.pipeline().addLast(handler);
                            ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
                                @Override
                                public void userEventTriggered(
                                        ChannelHandlerContext ctx, Object evt) throws Exception {
                                    if (evt instanceof SslHandshakeCompletionEvent) {
                                        SslHandshakeCompletionEvent event = (SslHandshakeCompletionEvent) evt;

Frequently Asked Questions

What is the RenegotiateTest class?
RenegotiateTest is a class in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/RenegotiateTest.java.
Where is RenegotiateTest defined?
RenegotiateTest is defined in handler/src/test/java/io/netty/handler/ssl/RenegotiateTest.java at line 41.

Analyze Your Own Codebase

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

Try Supermodel Free