- introduced netconf ssh wrapper bundle
[controller.git] / opendaylight / netconf / netconf-ssh / src / main / java / org / opendaylight / controller / netconf / ssh / handler / SSHChannelInboundHandler.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.netconf.ssh.handler;
9
10 import ch.ethz.ssh2.ServerSession;
11 import io.netty.buffer.ByteBuf;
12 import io.netty.channel.ChannelHandlerContext;
13 import io.netty.channel.SimpleChannelInboundHandler;
14
15 public class SSHChannelInboundHandler extends SimpleChannelInboundHandler {
16
17     private ServerSession serverSession;
18
19     public SSHChannelInboundHandler(ServerSession serverSession) {
20         this.serverSession = serverSession;
21     }
22
23     @Override
24     protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
25         this.serverSession.getStdin().write( ((ByteBuf)msg).readBytes(((ByteBuf)msg).readableBytes()).array());
26     }
27 }