com.mindbright.ssh
Class SSHInteractiveClient

java.lang.Object
  extended by com.mindbright.ssh.SSH
      extended by com.mindbright.ssh.SSHClient
          extended by com.mindbright.ssh.SSHInteractiveClient
All Implemented Interfaces:
MindTermApp, SSHInteractor, SSH2Interactor, TerminalInputListener, java.lang.Runnable

public final class SSHInteractiveClient
extends SSHClient
implements java.lang.Runnable, SSHInteractor, SSH2Interactor, MindTermApp, TerminalInputListener


Nested Class Summary
 
Nested classes/interfaces inherited from class com.mindbright.ssh.SSHClient
SSHClient.AuthFailException, SSHClient.ExitMonitor, SSHClient.LocalForward, SSHClient.RemoteForward
 
Field Summary
 java.lang.String customStartMessage
           
 boolean exitOnLogout
           
 boolean isSSH2
           
 boolean quiet
           
 SSH2Transport transport
           
 boolean wantHelpInfo
           
 
Fields inherited from class com.mindbright.ssh.SSHClient
activateTunnels, authenticator, commandLine, console, controller, exitStatus, firstFTPPort, gracefulExit, havePORTFtp, interactor, isConnected, isOpened, keepAliveThread, localAddr, localForwards, myThread, rand, refCount, remoteForwards, serverAddr, serverRealAddr, srvVersionMajor, srvVersionMinor, srvVersionStr, sshIn, sshOut, sshSocket, user
 
Fields inherited from class com.mindbright.ssh.SSH
AUTH_CRYPTOCARD, AUTH_DEFAULT, AUTH_GSSAPI, AUTH_HOSTBASED, AUTH_KBDINTERACT, AUTH_KERBEROS, AUTH_NOTSUPPORTED, AUTH_PASSWORD, AUTH_PUBLICKEY, AUTH_RHOSTS, AUTH_RHOSTS_RSA, AUTH_SDI, AUTH_TIS, authTypeDesc, CIPHER_3DES, CIPHER_ANY, CIPHER_BLOWFISH, CIPHER_DEFAULT, CIPHER_DES, CIPHER_IDEA, CIPHER_INVALID, CIPHER_NONE, CIPHER_NOTSUPPORTED, CIPHER_RC4, CIPHER_RESERVED, CIPHER_TSS, cipherClasses, cipherType, CMSG_ACM_ACCESS_DENIED, CMSG_ACM_NEW_PIN, CMSG_ACM_NEW_PIN_ACCEPTED, CMSG_ACM_NEW_PIN_REJECTED, CMSG_ACM_NEW_PIN_REQUIRED, CMSG_ACM_NEXT_CODE, CMSG_ACM_NEXT_CODE_REQUIRED, CMSG_ACM_OK, CMSG_AGENT_REQUEST_FORWARDING, CMSG_AUTH_PASSWORD, CMSG_AUTH_RHOSTS, CMSG_AUTH_RHOSTS_RSA, CMSG_AUTH_RSA, CMSG_AUTH_RSA_RESPONSE, CMSG_AUTH_SDI, CMSG_AUTH_TIS, CMSG_AUTH_TIS_RESPONSE, CMSG_EOF, CMSG_EXEC_CMD, CMSG_EXEC_SHELL, CMSG_EXIT_CONFIRMATION, CMSG_MAX_PACKET_SIZE, CMSG_PORT_FORWARD_REQUEST, CMSG_REQUEST_COMPRESSION, CMSG_REQUEST_PTY, CMSG_SESSION_KEY, CMSG_STDIN_DATA, CMSG_USER, CMSG_WINDOW_SIZE, CMSG_X11_REQUEST_FORWARDING, CONNECT_CHAN_NUM, CVS_DATE, DEBUG, DEBUGMORE, DEBUGPKG, DEFAULTPORT, HOST_KEY_LENGTH, IDX_CIPHER_CLASS, IDX_CIPHER_NAME, isAnSSHClient, KNOWN_HOSTS_FILE, LISTEN_CHAN_NUM, MAIN_CHAN_NUM, MSG_ANY, MSG_CHANNEL_CLOSE, MSG_CHANNEL_CLOSE_CONFIRMATION, MSG_CHANNEL_DATA, MSG_CHANNEL_INPUT_EOF, MSG_CHANNEL_OPEN_CONFIRMATION, MSG_CHANNEL_OPEN_FAILURE, MSG_CHANNEL_OUTPUT_CLOSED, MSG_DEBUG, MSG_DISCONNECT, MSG_IGNORE, MSG_NONE, MSG_PORT_OPEN, PASS_KERBEROS_TGT, protocolFlags, PROTOFLAG_HOST_IN_FWD_OPEN, PROTOFLAG_SCREEN_NUMBER, PROXY_HTTP, PROXY_NONE, PROXY_NOTSUPPORTED, PROXY_SOCKS4, PROXY_SOCKS5_DNS, PROXY_SOCKS5_IP, randomSeed, rcvCipher, rcvComp, secureRandom, SERVER_KEY_LENGTH, SESSION_KEY_LENGTH, sessionId, sessionKey, SMSG_AGENT_OPEN, SMSG_AUTH_RSA_CHALLENGE, SMSG_AUTH_TIS_CHALLENGE, SMSG_EXITSTATUS, SMSG_FAILURE, SMSG_PUBLIC_KEY, SMSG_STDERR_DATA, SMSG_STDOUT_DATA, SMSG_SUCCESS, SMSG_X11_OPEN, sndCipher, sndComp, SRV_HOSTKEY_CHANGED, SRV_HOSTKEY_KNOWN, SRV_HOSTKEY_NEW, srvCookie, srvHostKey, srvServerKey, SSH_VER_MAJOR, SSH_VER_MINOR, supportedAuthTypes, supportedCiphers, TTY_OP_END, TTY_OP_ISPEED, TTY_OP_OSPEED, UNKNOWN_CHAN_NUM, VER_MINDTERM, VER_MINDTUNL
 
Constructor Summary
SSHInteractiveClient(boolean quiet, boolean exitOnLogout, SSHPropertyHandler propsHandler)
           
SSHInteractiveClient(SSHInteractiveClient clone)
           
 
Method Summary
 void addAuthModules(SSH2Authenticator authenticator, java.lang.String methods)
           
 void addRemotePortForward(java.lang.String remoteHost, int remotePort, java.lang.String localHost, int localPort, java.lang.String plugin)
           
 void alert(java.lang.String msg)
           
 boolean askConfirmation(java.lang.String message, boolean defAnswer)
           
 boolean askConfirmation(java.lang.String message, boolean preferDialog, boolean defAnswer)
           
 void closeTunnelFromList(int listIdx)
           
 void connected(SSHClient client)
           
 void delLocalPortForward(java.lang.String localHost, int port)
           
 void delRemotePortForward(java.lang.String remoteHost, int port)
           
 void disconnected(SSHClient client, boolean graceful)
           
 void doSingleCommand(java.lang.String commandLine)
           
 boolean fingerprintMatch(SSH2Signature serverHostKey)
           
 void forcedDisconnect()
           
 java.applet.AppletContext getAppletContext()
           
 java.lang.String getAppName()
           
 SSH2Connection getConnection()
           
 long getConnectTimeout()
           
 SSHConsoleRemote getConsoleRemote()
           
 long getHelloTimeout()
           
 java.lang.String getHost()
           
 SSH2Interactor getInteractor()
           
 Logo getLogo()
           
 java.awt.Frame getParentFrame()
           
 int getPort()
           
 java.util.Properties getProperties()
           
 java.lang.String getProperty(java.lang.String name)
           
 SSHPropertyHandler getPropertyHandler()
           
 RandomSeed getRandomSeed()
           
 TerminalWin getTerminalWin()
           
 SSH2Transport getTransport()
           
 java.lang.String getUserName()
           
 java.lang.String getVersionId(boolean client)
           
static byte[] getX11Cookie()
          Get the local MIT_MAGIC_COOKIE to use for X11 connections.
 void hideLogo()
           
 boolean installLogo()
           
 boolean isApplet()
           
 boolean isDumb()
           
 boolean isVerbose()
           
 boolean licenseDialog(java.lang.String license)
           
 java.lang.String[] listTunnels()
           
 void newShell()
           
 void open(SSHClient client)
           
 java.lang.String promptLine(java.lang.String prompt, boolean echo)
          Prompt for a single string.
 java.lang.String promptLine(java.lang.String prompt, java.lang.String defaultVal)
           
 int promptList(java.lang.String name, java.lang.String instruction, java.lang.String[] choices)
          This function is only used by AppGate internal code so there is no need to actually implement it in any other code.
 java.lang.String[] promptMulti(java.lang.String[] prompts, boolean[] echos)
          Prompt for multiple strings.
 java.lang.String[] promptMultiFull(java.lang.String name, java.lang.String instruction, java.lang.String[] prompts, boolean[] echos)
          Prompt for multiple strings.
 java.lang.String promptPassword(java.lang.String prompt)
           
 void propsStateChanged(SSHPropertyHandler props)
           
 boolean quietPrompts()
           
 java.io.ByteArrayOutputStream readResource(java.lang.String name)
           
 void report(java.lang.String msg)
           
 void requestLocalPortForward(java.lang.String localHost, int localPort, java.lang.String remoteHost, int remotePort, java.lang.String plugin)
           
 void run()
           
 void sendBreak()
          Called when the user sends a break to the terminal
 void sendBytes(byte[] b)
          May be called when the user pastes data.
 void sendBytesDirect(byte[] b)
          Send some bytes directly to the host.
 void sessionStarted(SSHClient client)
           
 void setMenus(SSHMenuHandler menus)
           
 void setParent(java.awt.Frame parent)
           
 void setProperty(java.lang.String name, java.lang.String value)
           
 void showLogo()
           
 void signalTermTypeChanged(java.lang.String newTermType)
          Called when the terminal type has changed.
 void signalWindowChanged(int rows, int cols, int vpixels, int hpixels)
          Called when the size of the terminal window has changed.
 void splashScreen()
           
 void startNewSession(SSHClient client)
           
 void typedChar(byte[] b)
          Called when the user types a character
 void typedChar(char c)
          Called when the user types a character
 void updateMenus()
           
 void updateTitle()
           
 
Methods inherited from class com.mindbright.ssh.SSHClient
addLocalPortForward, addLocalPortForward, addRef, boot, bootSSH, bootSSH, clearAllForwards, delRef, delRemotePortForward, disconnect, doSingleCommand, getConsole, getExitStatus, getLocalAddr, getServerAddr, getServerRealAddr, getServerVersion, isConnected, isOpened, setConsole, setExitStatus, setLocalAddr, setServerRealAddr, startExitMonitor, startExitMonitor, waitForExit
 
Methods inherited from class com.mindbright.ssh.SSH
getAltAuthName, getAuthName, getAuthType, getAuthTypes, getCipherName, getCipherType, getProxyType, getProxyTypes, getSupportedCipher, haveSecureRandom, initCipher, initClientCipher, initSeedGenerator, initServerCipher, isAuthTypeSupported, isProtocolFlagSet, log, logDebug, logExtra, logIgnore, msgTypeString, randomSeed, secureRandom
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.mindbright.application.MindTermApp
isConnected
 

Field Detail

isSSH2

public boolean isSSH2

transport

public SSH2Transport transport

wantHelpInfo

public boolean wantHelpInfo

customStartMessage

public java.lang.String customStartMessage

quiet

public boolean quiet

exitOnLogout

public boolean exitOnLogout
Constructor Detail

SSHInteractiveClient

public SSHInteractiveClient(boolean quiet,
                            boolean exitOnLogout,
                            SSHPropertyHandler propsHandler)

SSHInteractiveClient

public SSHInteractiveClient(SSHInteractiveClient clone)
Method Detail

setMenus

public void setMenus(SSHMenuHandler menus)

setParent

public void setParent(java.awt.Frame parent)

getPropertyHandler

public SSHPropertyHandler getPropertyHandler()

updateMenus

public void updateMenus()

splashScreen

public void splashScreen()

installLogo

public boolean installLogo()

readResource

public java.io.ByteArrayOutputStream readResource(java.lang.String name)

doSingleCommand

public void doSingleCommand(java.lang.String commandLine)
                     throws java.lang.Exception
Throws:
java.lang.Exception

run

public void run()
Specified by:
run in interface java.lang.Runnable

getConnectTimeout

public long getConnectTimeout()
Overrides:
getConnectTimeout in class SSHClient

getHelloTimeout

public long getHelloTimeout()
Overrides:
getHelloTimeout in class SSHClient

isDumb

public boolean isDumb()

getTerminalWin

public TerminalWin getTerminalWin()

showLogo

public void showLogo()

hideLogo

public void hideLogo()

getLogo

public Logo getLogo()

updateTitle

public void updateTitle()

promptLine

public java.lang.String promptLine(java.lang.String prompt,
                                   boolean echo)
                            throws SSH2UserCancelException
Description copied from interface: SSH2Interactor
Prompt for a single string.

Specified by:
promptLine in interface SSH2Interactor
Parameters:
prompt - The prompt string to show
echo - True if the text the user enters should be echoed.
Returns:
The text entered by the user.
Throws:
SSH2UserCancelException

promptMulti

public java.lang.String[] promptMulti(java.lang.String[] prompts,
                                      boolean[] echos)
                               throws SSH2UserCancelException
Description copied from interface: SSH2Interactor
Prompt for multiple strings. The expectation here is that the client will put up a dialog where the user sees multiple prompts and input fields.

Specified by:
promptMulti in interface SSH2Interactor
Parameters:
prompts - List of prompts to show
echos - List of boolean values which indicates if the text entered for the corresponding prompt should be echoed.
Returns:
An array of strings which contains on element for each prompt, in the same order. The elements should contain the text the user entered.
Throws:
SSH2UserCancelException

promptMultiFull

public java.lang.String[] promptMultiFull(java.lang.String name,
                                          java.lang.String instruction,
                                          java.lang.String[] prompts,
                                          boolean[] echos)
                                   throws SSH2UserCancelException
Description copied from interface: SSH2Interactor
Prompt for multiple strings. The expectation here is that the client will put up a dialog where the user sees multiple prompts and input fields. This version of the call includes more elements which should be shown in the dialog.

Specified by:
promptMultiFull in interface SSH2Interactor
Parameters:
name - Suggested title of the dialog
instruction - Instructions to show to user in the dialog
prompts - List of prompts to show
echos - List of boolean values which indicates if the text entered for the corresponding prompt should be echoed.
Returns:
An array of strings which contains on element for each prompt, in the same order. The elements should contain the text the user entered.
Throws:
SSH2UserCancelException

promptList

public int promptList(java.lang.String name,
                      java.lang.String instruction,
                      java.lang.String[] choices)
               throws SSH2UserCancelException
Description copied from interface: SSH2Interactor
This function is only used by AppGate internal code so there is no need to actually implement it in any other code.

It is used to let the user select one element in a list.

Specified by:
promptList in interface SSH2Interactor
Parameters:
name - Suggested title of dialog
instruction - Instructions to show to user
choices - Array of possible choices
Returns:
index of selected list item
Throws:
SSH2UserCancelException

propsStateChanged

public void propsStateChanged(SSHPropertyHandler props)
Specified by:
propsStateChanged in interface SSHInteractor

startNewSession

public void startNewSession(SSHClient client)
Specified by:
startNewSession in interface SSHInteractor

sessionStarted

public void sessionStarted(SSHClient client)
Specified by:
sessionStarted in interface SSHInteractor

quietPrompts

public boolean quietPrompts()
Specified by:
quietPrompts in interface SSHInteractor

isVerbose

public boolean isVerbose()
Specified by:
isVerbose in interface SSHInteractor

promptLine

public java.lang.String promptLine(java.lang.String prompt,
                                   java.lang.String defaultVal)
                            throws java.io.IOException
Specified by:
promptLine in interface SSHInteractor
Throws:
java.io.IOException

promptPassword

public java.lang.String promptPassword(java.lang.String prompt)
                                throws java.io.IOException
Specified by:
promptPassword in interface SSHInteractor
Throws:
java.io.IOException

askConfirmation

public boolean askConfirmation(java.lang.String message,
                               boolean defAnswer)
Specified by:
askConfirmation in interface SSHInteractor

askConfirmation

public boolean askConfirmation(java.lang.String message,
                               boolean preferDialog,
                               boolean defAnswer)
                        throws java.io.IOException
Throws:
java.io.IOException

licenseDialog

public boolean licenseDialog(java.lang.String license)
Specified by:
licenseDialog in interface SSHInteractor

connected

public void connected(SSHClient client)
Specified by:
connected in interface SSHInteractor

open

public void open(SSHClient client)
Specified by:
open in interface SSHInteractor

disconnected

public void disconnected(SSHClient client,
                         boolean graceful)
Specified by:
disconnected in interface SSHInteractor

report

public void report(java.lang.String msg)
Specified by:
report in interface SSHInteractor

getInteractor

public SSH2Interactor getInteractor()
Specified by:
getInteractor in interface MindTermApp

alert

public void alert(java.lang.String msg)
Specified by:
alert in interface MindTermApp
Specified by:
alert in interface SSHInteractor

forcedDisconnect

public void forcedDisconnect()
Overrides:
forcedDisconnect in class SSHClient

requestLocalPortForward

public void requestLocalPortForward(java.lang.String localHost,
                                    int localPort,
                                    java.lang.String remoteHost,
                                    int remotePort,
                                    java.lang.String plugin)
                             throws java.io.IOException
Throws:
java.io.IOException

addRemotePortForward

public void addRemotePortForward(java.lang.String remoteHost,
                                 int remotePort,
                                 java.lang.String localHost,
                                 int localPort,
                                 java.lang.String plugin)
Overrides:
addRemotePortForward in class SSHClient

delLocalPortForward

public void delLocalPortForward(java.lang.String localHost,
                                int port)
Overrides:
delLocalPortForward in class SSHClient

delRemotePortForward

public void delRemotePortForward(java.lang.String remoteHost,
                                 int port)
Overrides:
delRemotePortForward in class SSHClient

fingerprintMatch

public boolean fingerprintMatch(SSH2Signature serverHostKey)

typedChar

public void typedChar(char c)
Description copied from interface: TerminalInputListener
Called when the user types a character

Specified by:
typedChar in interface TerminalInputListener
Parameters:
c - typed character

typedChar

public void typedChar(byte[] b)
Description copied from interface: TerminalInputListener
Called when the user types a character

Specified by:
typedChar in interface TerminalInputListener
Parameters:
b - byte code representation fo the character encoded in the current encoding.

sendBytes

public void sendBytes(byte[] b)
Description copied from interface: TerminalInputListener
May be called when the user pastes data. It may also be called by some external entity whishing to simulate multiple key presses.

Specified by:
sendBytes in interface TerminalInputListener
Parameters:
b - array of bytes representing characters to input

sendBytesDirect

public void sendBytesDirect(byte[] b)
Description copied from interface: TerminalInputListener
Send some bytes directly to the host. This does not echo the characters and bypasses any line buffering. This is typically used when replying to some query from the host.

Specified by:
sendBytesDirect in interface TerminalInputListener
Parameters:
b - array of bytes representing characters to send

sendBreak

public void sendBreak()
Description copied from interface: TerminalInputListener
Called when the user sends a break to the terminal

Specified by:
sendBreak in interface TerminalInputListener

signalWindowChanged

public void signalWindowChanged(int rows,
                                int cols,
                                int vpixels,
                                int hpixels)
Description copied from interface: TerminalInputListener
Called when the size of the terminal window has changed.

Specified by:
signalWindowChanged in interface TerminalInputListener
Parameters:
rows - new number of rows
cols - new number of columns
vpixels - new number of vertical pixels
hpixels - new number of horizontal pixels

signalTermTypeChanged

public void signalTermTypeChanged(java.lang.String newTermType)
Description copied from interface: TerminalInputListener
Called when the terminal type has changed. That is when the user has changed which terminal type this terminal window should emulate.

Specified by:
signalTermTypeChanged in interface TerminalInputListener
Parameters:
newTermType - new terminal type to emulate

addAuthModules

public void addAuthModules(SSH2Authenticator authenticator,
                           java.lang.String methods)

newShell

public void newShell()

getVersionId

public java.lang.String getVersionId(boolean client)
Overrides:
getVersionId in class SSH

closeTunnelFromList

public void closeTunnelFromList(int listIdx)

listTunnels

public java.lang.String[] listTunnels()

getHost

public java.lang.String getHost()
Specified by:
getHost in interface MindTermApp

getPort

public int getPort()
Specified by:
getPort in interface MindTermApp

getProperties

public java.util.Properties getProperties()
Specified by:
getProperties in interface MindTermApp

getProperty

public java.lang.String getProperty(java.lang.String name)
Specified by:
getProperty in interface MindTermApp

setProperty

public void setProperty(java.lang.String name,
                        java.lang.String value)
Specified by:
setProperty in interface MindTermApp

getUserName

public java.lang.String getUserName()
Specified by:
getUserName in interface MindTermApp

getParentFrame

public java.awt.Frame getParentFrame()
Specified by:
getParentFrame in interface MindTermApp

getAppName

public java.lang.String getAppName()
Specified by:
getAppName in interface MindTermApp

getRandomSeed

public RandomSeed getRandomSeed()
Specified by:
getRandomSeed in interface MindTermApp

isApplet

public boolean isApplet()
Specified by:
isApplet in interface MindTermApp

getAppletContext

public java.applet.AppletContext getAppletContext()
Specified by:
getAppletContext in interface MindTermApp

getTransport

public SSH2Transport getTransport()
Specified by:
getTransport in interface MindTermApp

getConnection

public SSH2Connection getConnection()
Specified by:
getConnection in interface MindTermApp

getConsoleRemote

public SSHConsoleRemote getConsoleRemote()
Specified by:
getConsoleRemote in interface MindTermApp

getX11Cookie

public static byte[] getX11Cookie()
Get the local MIT_MAGIC_COOKIE to use for X11 connections. This procedure uses xauth to get the cookie for $DISPLAY if possible.

Returns:
byte-buffer containing cookie or null