import org.apache.sshd.common.io.IoOutputStream;
import org.apache.sshd.server.Environment;
import org.apache.sshd.server.ExitCallback;
-import org.apache.sshd.server.SessionAware;
+import org.apache.sshd.server.channel.ChannelSession;
import org.apache.sshd.server.command.AsyncCommand;
import org.apache.sshd.server.command.Command;
import org.apache.sshd.server.session.ServerSession;
* <p>
* Command is Apache Mina SSH terminology for objects handling ssh data.
*/
-public class RemoteNetconfCommand implements AsyncCommand, SessionAware {
+public class RemoteNetconfCommand implements AsyncCommand {
private static final Logger LOG = LoggerFactory.getLogger(RemoteNetconfCommand.class);
}
@Override
- public void start(final Environment env) {
+ public void start(final ChannelSession channel, final Environment env) {
+ final ServerSession session = channel.getServerSession();
+ final SocketAddress remoteAddress = session.getIoSession().getRemoteAddress();
+ final String hostName;
+ final String port;
+ if (remoteAddress instanceof InetSocketAddress) {
+ hostName = ((InetSocketAddress) remoteAddress).getAddress().getHostAddress();
+ port = Integer.toString(((InetSocketAddress) remoteAddress).getPort());
+ } else {
+ hostName = "";
+ port = "";
+ }
+ netconfHelloMessageAdditionalHeader = new NetconfHelloMessageAdditionalHeader(session.getUsername(), hostName,
+ port, "ssh", "client");
+
LOG.trace("Establishing internal connection to netconf server for client: {}", getClientAddress());
final Bootstrap clientBootstrap = new Bootstrap();
}
@Override
- public void destroy() {
+ public void destroy(final ChannelSession channel) {
LOG.trace("Releasing internal connection to netconf server for client: {} on channel: {}",
getClientAddress(), clientChannel);
return netconfHelloMessageAdditionalHeader.getAddress();
}
- @Override
- public void setSession(final ServerSession session) {
- final SocketAddress remoteAddress = session.getIoSession().getRemoteAddress();
- String hostName = "";
- String port = "";
- if (remoteAddress instanceof InetSocketAddress) {
- hostName = ((InetSocketAddress) remoteAddress).getAddress().getHostAddress();
- port = Integer.toString(((InetSocketAddress) remoteAddress).getPort());
- }
- netconfHelloMessageAdditionalHeader = new NetconfHelloMessageAdditionalHeader(
- session.getUsername(), hostName, port, "ssh", "client");
- }
-
public static class NetconfCommandFactory implements NamedFactory<Command> {
public static final String NETCONF = "netconf";
return new RemoteNetconfCommand(clientBootstrap, localAddress);
}
}
-
}