com.mindbright.ssh
Class SSHConsoleClient

java.lang.Object
  extended bycom.mindbright.ssh.SSHClientUserAdaptor
      extended bycom.mindbright.ssh.SSHConsoleClient
All Implemented Interfaces:
SSHClientUser, SSHConsole, SSHConsoleRemote
Direct Known Subclasses:
SSHSCPClient

public class SSHConsoleClient
extends SSHClientUserAdaptor
implements SSHConsole, SSHConsoleRemote


Field Summary
protected  SSHClient client
           
static int DEFAULT_COPY_BUFFER_SZ
           
protected  OutputStreamPipe inBottom
           
protected  InputStreamPipe inTop
           
protected  SSHClientUser proxyUser
           
protected  java.lang.String sshHost
           
protected  com.mindbright.ssh.SSHConsoleClient.TerminalOutStream stdin
           
protected  java.io.OutputStream stdout
           
 
Fields inherited from class com.mindbright.ssh.SSHClientUserAdaptor
interactor, sshPort
 
Constructor Summary
SSHConsoleClient(java.lang.String sshHost, int port, SSHAuthenticator authenticator, SSHInteractor interactor)
           
SSHConsoleClient(java.lang.String sshHost, int port, SSHAuthenticator authenticator, SSHInteractor interactor, int bufferSize)
           
 
Method Summary
 void changeStdOut(java.io.OutputStream out)
          Changes the output stream where stdout is written to in the underlying session channel.
 void close()
          Closes the session channel.
 void close(boolean waitforcloseconfirm)
          Closes the session channel.
 boolean command(java.lang.String command)
          Runs single command on server.
 java.net.Socket getProxyConnection()
           
 java.io.OutputStream getStdIn()
          Gets the stdin stream of the underlying session channel.
 java.io.InputStream getStdOut()
          Gets the stdout stream of the underlying session channel.
 TerminalWindow getTerminal()
           
 void print(java.lang.String str)
           
 void println(java.lang.String str)
           
 void serverConnect(SSHChannelController controller, SSHCipher sndCipher)
           
 void serverDisconnect(java.lang.String reason)
           
 void setClientUser(SSHClientUser proxyUser)
           
 boolean shell()
          Starts an interactive shell on the server, note that no PTY is allocated.
 void stderrWriteString(byte[] str)
           
 void stdoutWriteString(byte[] str)
           
 boolean wantPTY()
           
 
Methods inherited from class com.mindbright.ssh.SSHClientUserAdaptor
getAliveInterval, getCompressionLevel, getDisplay, getInteractor, getMaxPacketSz, getSrvHost, getSrvPort, wantX11Forward
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_COPY_BUFFER_SZ

public static final int DEFAULT_COPY_BUFFER_SZ
See Also:
Constant Field Values

client

protected SSHClient client

proxyUser

protected SSHClientUser proxyUser

sshHost

protected java.lang.String sshHost

inTop

protected InputStreamPipe inTop

inBottom

protected OutputStreamPipe inBottom

stdout

protected java.io.OutputStream stdout

stdin

protected com.mindbright.ssh.SSHConsoleClient.TerminalOutStream stdin
Constructor Detail

SSHConsoleClient

public SSHConsoleClient(java.lang.String sshHost,
                        int port,
                        SSHAuthenticator authenticator,
                        SSHInteractor interactor)
                 throws java.io.IOException

SSHConsoleClient

public SSHConsoleClient(java.lang.String sshHost,
                        int port,
                        SSHAuthenticator authenticator,
                        SSHInteractor interactor,
                        int bufferSize)
                 throws java.io.IOException
Method Detail

command

public boolean command(java.lang.String command)
Description copied from interface: SSHConsoleRemote
Runs single command on server.

Specified by:
command in interface SSHConsoleRemote
Parameters:
command - command line to run
Returns:
a boolean indicating success or failure

shell

public boolean shell()
Description copied from interface: SSHConsoleRemote
Starts an interactive shell on the server, note that no PTY is allocated.

Specified by:
shell in interface SSHConsoleRemote
Returns:
a boolean indicating success or failure

close

public void close()
Description copied from interface: SSHConsoleRemote
Closes the session channel. That is cancels a command/shell in progress if it hasn't already exited.

Specified by:
close in interface SSHConsoleRemote

close

public void close(boolean waitforcloseconfirm)
Description copied from interface: SSHConsoleRemote
Closes the session channel. If waitforcloseconfirm is true it waits for the remote end to acknowledge the close.

Specified by:
close in interface SSHConsoleRemote

changeStdOut

public void changeStdOut(java.io.OutputStream out)
Description copied from interface: SSHConsoleRemote
Changes the output stream where stdout is written to in the underlying session channel.

Specified by:
changeStdOut in interface SSHConsoleRemote
Parameters:
out - new stdout stream

getStdIn

public java.io.OutputStream getStdIn()
Description copied from interface: SSHConsoleRemote
Gets the stdin stream of the underlying session channel. Note, this is an output stream since one wants to write to stdin.

Specified by:
getStdIn in interface SSHConsoleRemote
Returns:
the input stream of stdout stream

getStdOut

public java.io.InputStream getStdOut()
Description copied from interface: SSHConsoleRemote
Gets the stdout stream of the underlying session channel. Note, this is an input stream since one wants to read from stdout.

Specified by:
getStdOut in interface SSHConsoleRemote
Returns:
the input stream of stdout stream

setClientUser

public void setClientUser(SSHClientUser proxyUser)

stdoutWriteString

public void stdoutWriteString(byte[] str)
Specified by:
stdoutWriteString in interface SSHConsole

stderrWriteString

public void stderrWriteString(byte[] str)
Specified by:
stderrWriteString in interface SSHConsole

getTerminal

public TerminalWindow getTerminal()
Specified by:
getTerminal in interface SSHConsole

print

public void print(java.lang.String str)
Specified by:
print in interface SSHConsole

println

public void println(java.lang.String str)
Specified by:
println in interface SSHConsole

serverConnect

public void serverConnect(SSHChannelController controller,
                          SSHCipher sndCipher)
Specified by:
serverConnect in interface SSHConsole

serverDisconnect

public void serverDisconnect(java.lang.String reason)
Specified by:
serverDisconnect in interface SSHConsole

wantPTY

public boolean wantPTY()
Specified by:
wantPTY in interface SSHClientUser
Overrides:
wantPTY in class SSHClientUserAdaptor

getProxyConnection

public java.net.Socket getProxyConnection()
                                   throws java.io.IOException
Specified by:
getProxyConnection in interface SSHClientUser
Overrides:
getProxyConnection in class SSHClientUserAdaptor
Throws:
java.io.IOException