2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.client;
10 import io.netty.channel.Channel;
11 import io.netty.util.concurrent.Promise;
12 import org.eclipse.jdt.annotation.Nullable;
13 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
14 import org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandler;
15 import org.opendaylight.netconf.nettyutil.handler.ssh.client.NetconfSshClient;
17 final class SshClientChannelInitializer extends AbstractClientChannelInitializer {
18 private final AuthenticationHandler authenticationHandler;
19 private final @Nullable NetconfSshClient sshClient;
20 private final @Nullable String name;
22 SshClientChannelInitializer(final AuthenticationHandler authHandler,
23 final NetconfClientSessionNegotiatorFactory negotiatorFactory,
24 final NetconfClientSessionListener sessionListener, final @Nullable NetconfSshClient sshClient,
25 final @Nullable String name) {
26 super(negotiatorFactory, sessionListener);
27 authenticationHandler = authHandler;
28 this.sshClient = sshClient;
32 SshClientChannelInitializer(final AuthenticationHandler authHandler,
33 final NetconfClientSessionNegotiatorFactory negotiatorFactory,
34 final NetconfClientSessionListener sessionListener) {
35 this(authHandler, negotiatorFactory, sessionListener, null, null);
39 public void initialize(final Channel ch, final Promise<NetconfClientSession> promise) {
40 // ssh handler has to be the first handler in pipeline
41 var asyncHandler = AsyncSshHandler.createForNetconfSubsystem(authenticationHandler, promise, sshClient, name);
42 ch.pipeline().addFirst(asyncHandler);
43 super.initialize(ch, promise);