X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Futil%2Fhandler%2Fssh%2FSshHandler.java;fp=opendaylight%2Fnetconf%2Fnetconf-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Futil%2Fhandler%2Fssh%2FSshHandler.java;h=0000000000000000000000000000000000000000;hp=49d5a05ae22a6939f992c4637f123f550fb3a4e7;hb=c3108b4e80ec9f6ee6c8cf96df3009bb91dc8bc0;hpb=04a788d2df5303c60cdbcff02254291f411566bd diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/SshHandler.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/SshHandler.java deleted file mode 100644 index 49d5a05ae2..0000000000 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/SshHandler.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.netconf.util.handler.ssh; - -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelFutureListener; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelOutboundHandlerAdapter; -import io.netty.channel.ChannelPromise; - -import java.io.IOException; -import java.net.SocketAddress; - -import org.opendaylight.controller.netconf.util.handler.ssh.authentication.AuthenticationHandler; -import org.opendaylight.controller.netconf.util.handler.ssh.client.Invoker; -import org.opendaylight.controller.netconf.util.handler.ssh.client.SshClient; -import org.opendaylight.controller.netconf.util.handler.ssh.client.SshClientAdapter; -import org.opendaylight.controller.netconf.util.handler.ssh.virtualsocket.VirtualSocket; - -/** - * Netty SSH handler class. Acts as interface between Netty and SSH library. All standard Netty message handling - * stops at instance of this class. All downstream events are handed of to wrapped {@link org.opendaylight.controller.netconf.util.handler.ssh.client.SshClientAdapter}; - */ -public class SshHandler extends ChannelOutboundHandlerAdapter { - private static final String SOCKET = "socket"; - - private final VirtualSocket virtualSocket = new VirtualSocket(); - private final SshClientAdapter sshClientAdapter; - - public SshHandler(AuthenticationHandler authenticationHandler, Invoker invoker) throws IOException { - SshClient sshClient = new SshClient(virtualSocket, authenticationHandler); - this.sshClientAdapter = new SshClientAdapter(sshClient, invoker); - } - - @Override - public void handlerAdded(ChannelHandlerContext ctx){ - if (ctx.channel().pipeline().get(SOCKET) == null) { - ctx.channel().pipeline().addFirst(SOCKET, virtualSocket); - } - } - - @Override - public void handlerRemoved(ChannelHandlerContext ctx) { - if (ctx.channel().pipeline().get(SOCKET) != null) { - ctx.channel().pipeline().remove(SOCKET); - } - } - - @Override - public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws IOException { - this.sshClientAdapter.write((ByteBuf) msg); - } - - @Override - public void connect(final ChannelHandlerContext ctx, - SocketAddress remoteAddress, - SocketAddress localAddress, - ChannelPromise promise) { - ctx.connect(remoteAddress, localAddress, promise); - - promise.addListener(new ChannelFutureListener() { - public void operationComplete(ChannelFuture channelFuture) { - sshClientAdapter.start(ctx); - }} - ); - } - - @Override - public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) { - sshClientAdapter.stop(promise); - } -}