X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fnetconf-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fclient%2FTlsClientChannelInitializer.java;h=dc6598dd2a3deb159f963e51b1f26eeaad1bb984;hb=50aba4430f250f89dcd59a480cef5980475a70cd;hp=64d567f5aaac8893edee78673a98f5cfa7335180;hpb=57bfa6dd35ae51496e2c1aecd2ef7755b5203cba;p=netconf.git diff --git a/netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/TlsClientChannelInitializer.java b/netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/TlsClientChannelInitializer.java index 64d567f5aa..dc6598dd2a 100644 --- a/netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/TlsClientChannelInitializer.java +++ b/netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/TlsClientChannelInitializer.java @@ -11,25 +11,21 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.util.concurrent.Promise; -import org.opendaylight.netconf.nettyutil.AbstractChannelInitializer; -public final class TlsClientChannelInitializer extends AbstractChannelInitializer { +public final class TlsClientChannelInitializer extends AbstractClientChannelInitializer { public static final String CHANNEL_ACTIVE_SENTRY = "channelActiveSentry"; private final SslHandlerFactory sslHandlerFactory; - private final NetconfClientSessionNegotiatorFactory negotiatorFactory; - private final NetconfClientSessionListener sessionListener; public TlsClientChannelInitializer(final SslHandlerFactory sslHandlerFactory, final NetconfClientSessionNegotiatorFactory negotiatorFactory, final NetconfClientSessionListener sessionListener) { + super(negotiatorFactory, sessionListener); this.sslHandlerFactory = sslHandlerFactory; - this.negotiatorFactory = negotiatorFactory; - this.sessionListener = sessionListener; } @Override - public void initialize(Channel ch, Promise promise) { + public void initialize(final Channel ch, final Promise promise) { // When ssl handshake fails due to the certificate mismatch, the connection will try again, // then we have a chance to create a new SslHandler using the latest certificates with the // help of the sentry. We will replace the sentry with the new SslHandler once the channel @@ -38,12 +34,6 @@ public final class TlsClientChannelInitializer extends AbstractChannelInitialize super.initialize(ch, promise); } - @Override - protected void initializeSessionNegotiator(Channel ch, Promise promise) { - ch.pipeline().addAfter(NETCONF_MESSAGE_DECODER, AbstractChannelInitializer.NETCONF_SESSION_NEGOTIATOR, - negotiatorFactory.getSessionNegotiator(() -> sessionListener, ch, promise)); - } - private static final class ChannelActiveSentry extends ChannelInboundHandlerAdapter { private final SslHandlerFactory sslHandlerFactory; @@ -52,9 +42,9 @@ public final class TlsClientChannelInitializer extends AbstractChannelInitialize } @Override - public void channelActive(ChannelHandlerContext ctx) { - ctx.pipeline().replace(this, "sslHandler", sslHandlerFactory.createSslHandler()) - .fireChannelActive(); + public void channelActive(final ChannelHandlerContext ctx) { + final var sslHandler = sslHandlerFactory.createSslHandler(); + ctx.pipeline().replace(this, "sslHandler", sslHandler).fireChannelActive(); } } }