@Test public void sslHandlerReplaced() throws Exception { final SslHandler sslHandler = Mockito.mock(SslHandler.class); OptionalSslHandler handler = new OptionalSslHandler(sslContext) { @Override protected SslHandler newSslHandler(ChannelHandlerContext context, SslContext sslContext) { return sslHandler; } @Override protected String newSslHandlerName() { return SSL_HANDLER_NAME; } }; final ByteBuf payload = Unpooled.wrappedBuffer(new byte[] { 22, 3, 1, 0, 5 }); try { handler.decode(context, payload, null); verify(pipeline).replace(handler, SSL_HANDLER_NAME, sslHandler); } finally { payload.release(); } }
@Override protected void decode(ChannelHandlerContext context, ByteBuf in, List<Object> out) throws Exception { if (in.readableBytes() < SslUtils.SSL_RECORD_HEADER_LENGTH) { return; } if (SslHandler.isEncrypted(in)) { handleSsl(context); } else { handleNonSsl(context); } }
OptionalSslHandler extends ByteToMessageDecoder { @Override protected void decode(ChannelHandlerContext context, ByteBuf in, List<Object> out) throws Exception { if (in.readableBytes() < SslUtils.SSL_RECORD_HEADER_LENGTH) { return; } if (SslHandler.isEncrypted(in)) { handleSsl(context); } else { handleNonSsl(context); } } }
OptionalSslHandler extends ByteToMessageDecoder { @Override protected void decode(ChannelHandlerContext context, ByteBuf in, List<Object> out) throws Exception { if (in.readableBytes() < SslUtils.SSL_RECORD_HEADER_LENGTH) { return; } if (SslHandler.isEncrypted(in)) { handleSsl(context); } else { handleNonSsl(context); } } OptionalSslHandler(SslContext sslContext); }
OptionalSslHandler extends ByteToMessageDecoder { @Override protected void decode(ChannelHandlerContext context, ByteBuf in, List<Object> out) throws Exception { if (in.readableBytes() < SslUtils.SSL_RECORD_HEADER_LENGTH) { return; } if (SslHandler.isEncrypted(in)) { handleSsl(context); } else { handleNonSsl(context); } } OptionalSslHandler(SslContext sslContext);  }
OptionalSslHandler extends ByteToMessageDecoder { @Override protected void decode(ChannelHandlerContext context, ByteBuf in, List<Object> out) throws Exception { if (in.readableBytes() < SslUtils.SSL_RECORD_HEADER_LENGTH) { return; } if (SslHandler.isEncrypted(in)) { handleSsl(context); } else { handleNonSsl(context); } } OptionalSslHandler(SslContext sslContext);   }