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 NetconfSshClient sshClient;
21 SshClientChannelInitializer(final AuthenticationHandler authHandler,
22 final NetconfClientSessionNegotiatorFactory negotiatorFactory,
23 final NetconfClientSessionListener sessionListener, @Nullable final NetconfSshClient sshClient) {
24 super(negotiatorFactory, sessionListener);
25 authenticationHandler = authHandler;
26 this.sshClient = sshClient;
29 SshClientChannelInitializer(final AuthenticationHandler authHandler,
30 final NetconfClientSessionNegotiatorFactory negotiatorFactory,
31 final NetconfClientSessionListener sessionListener) {
32 this(authHandler, negotiatorFactory, sessionListener, null);
36 public void initialize(final Channel ch, final Promise<NetconfClientSession> promise) {
37 // ssh handler has to be the first handler in pipeline
38 ch.pipeline().addFirst(AsyncSshHandler.createForNetconfSubsystem(authenticationHandler, promise, sshClient));
39 super.initialize(ch, promise);