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.util.handler.ssh.client;
11 import ch.ethz.ssh2.Session;
12 import ch.ethz.ssh2.StreamGobbler;
14 import java.io.IOException;
15 import java.io.InputStream;
16 import java.io.OutputStream;
19 * Wrapper class for proprietary SSH sessions implementations
21 public class SshSession {
22 final Session session;
24 public SshSession(Session session) {
25 this.session = session;
28 public void execCommand(String cmd) throws IOException {
29 session.execCommand(cmd);
32 public void execCommand(String cmd, String charsetName) throws IOException {
33 session.execCommand(cmd, charsetName);
36 public void startShell() throws IOException {
40 public void startSubSystem(String name) throws IOException {
41 session.startSubSystem(name);
44 public int getState() {
45 return session.getState();
48 public InputStream getStdout() {
49 return new StreamGobbler(session.getStdout());
52 public InputStream getStderr() {
53 return session.getStderr();
56 public OutputStream getStdin() {
57 return session.getStdin();
60 public int waitUntilDataAvailable(long timeout) throws IOException {
61 return session.waitUntilDataAvailable(timeout);
64 public int waitForCondition(int condition_set, long timeout) {
65 return session.waitForCondition(condition_set, timeout);
68 public Integer getExitStatus() {
69 return session.getExitStatus();
72 public String getExitSignal() {
73 return session.getExitSignal();