2 * Copyright (c) 2013 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
9 package org.opendaylight.controller.netconf.nettyutil.handler.ssh.client;
11 import ch.ethz.ssh2.Session;
12 import ch.ethz.ssh2.channel.Channel;
13 import java.io.Closeable;
14 import java.io.IOException;
15 import java.io.InputStream;
16 import java.io.OutputStream;
19 * Wrapper class for proprietary SSH sessions implementations
21 class SshSession implements Closeable {
22 private final Session session;
24 public SshSession(final Session session) {
25 this.session = session;
28 public void startSubSystem(final String name) throws IOException {
29 session.startSubSystem(name);
32 public InputStream getStdout() {
33 return session.getStdout();
36 // FIXME according to http://www.ganymed.ethz.ch/ssh2/FAQ.html#blocking you should read data from both stdout and stderr to prevent window filling up (since stdout and stderr share a window)
37 // FIXME stdErr is not used anywhere
38 public InputStream getStderr() {
39 return session.getStderr();
42 public OutputStream getStdin() {
43 return session.getStdin();
48 if (session.getState() == Channel.STATE_OPEN || session.getState() == Channel.STATE_OPENING) {