com.mindbright.ssh
public final class SSHInteractiveClient extends SSHClient implements java.lang.Runnable, SSHInteractor, SSH2Interactor, MindTermApp, TerminalInputListener, NIOCallback
SSHClient.AuthFailException, SSHClient.ExitMonitor, SSHClient.LocalForward, SSHClient.RemoteForward
Modifier and Type | Field and Description |
---|---|
java.lang.String |
customStartMessage |
boolean |
exitOnLogout |
boolean |
isSSH2 |
boolean |
quiet |
SSH2Transport |
transport |
boolean |
wantHelpInfo |
activateTunnels, commandLine, console, controller, controllerMonitor, exitStatus, firstFTPPort, gracefulExit, havePORTFtp, heartbeat, interactor, isConnected, isOpened, isReading, localAddr, localForwards, rand, refCount, remoteForwards, serverAddr, serverRealAddr, srvVersionMajor, srvVersionMinor, srvVersionStr, sshIn, sshOut, sshSocket, user
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, 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, 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 and Description |
---|
SSHInteractiveClient(boolean quiet,
boolean exitOnLogout,
SSHPropertyHandler propsHandler) |
SSHInteractiveClient(SSHInteractiveClient clone) |
Modifier and Type | Method and Description |
---|---|
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 |
callback(java.lang.Object arg) |
void |
closeTunnelFromList(int listIdx) |
void |
completed(java.nio.ByteBuffer buf)
Called once the network read operation has been completed
|
void |
connected(boolean timeout)
Called once the connection has been established (assuming
interest for this has been registered by calling the
NotifyWhenConnected method of Switchboard ). |
void |
connected(SSHClient client) |
void |
connectionFailed(java.lang.Exception e)
Called if the connection failed (assuming
interest for this has been registered by calling the
NotifyWhenConnected method of Switchboard ). |
void |
delLocalPortForward(java.lang.String localHost,
int port) |
void |
delRemotePortForward(java.lang.String remoteHost,
int port) |
protected void |
disconnect(boolean graceful,
java.lang.Exception e) |
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() |
java.awt.Component |
getDialogParent() |
long |
getHelloTimeout() |
java.lang.String |
getHost() |
SSH2Interactor |
getInteractor() |
long |
getKexTimeout() |
Logo |
getLogo() |
int |
getPort() |
java.util.Properties |
getProperties() |
java.lang.String |
getProperty(java.lang.String name) |
SSHPropertyHandler |
getPropertyHandler() |
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() |
void |
readFailed(java.lang.Exception e)
Called if the read failed
|
static 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 |
setDialogParent(java.awt.Component parent) |
void |
setMenus(SSHMenuHandler menus) |
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 |
startSFTP(boolean startSFTP) |
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() |
void |
waitForCompletion() |
void |
writeFailed()
Called if the write failed
|
addLocalPortForward, addLocalPortForward, addRef, boot, bootSSH, bootSSH, clearAllForwards, delRef, delRemotePortForward, disconnect, doSingleCommand, getConsole, getException, getExitStatus, getLocalAddr, getServerAddr, getServerRealAddr, getServerVersion, isConnected, isOpened, setConsole, setExitStatus, setLocalAddr, setServerRealAddr, shutdown, startExitMonitor, startExitMonitor, waitForExit, waitForExit
getAltAuthName, getAuthName, getAuthType, getAuthTypes, getCipherName, getCipherType, getProxyType, getProxyTypes, getSupportedCipher, initCipher, initClientCipher, initServerCipher, isAuthTypeSupported, isProtocolFlagSet, log, logDebug, logExtra, logIgnore, msgTypeString, secureRandom
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isConnected
public boolean isSSH2
public SSH2Transport transport
public boolean wantHelpInfo
public java.lang.String customStartMessage
public boolean quiet
public boolean exitOnLogout
public SSHInteractiveClient(boolean quiet, boolean exitOnLogout, SSHPropertyHandler propsHandler)
public SSHInteractiveClient(SSHInteractiveClient clone)
public void setMenus(SSHMenuHandler menus)
public void setDialogParent(java.awt.Component parent)
public SSHPropertyHandler getPropertyHandler()
public void updateMenus()
public void splashScreen()
public boolean installLogo()
public static java.io.ByteArrayOutputStream readResource(java.lang.String name)
public void doSingleCommand(java.lang.String commandLine) throws java.lang.Exception
java.lang.Exception
public void startSFTP(boolean startSFTP)
public void run()
run
in interface java.lang.Runnable
public long getConnectTimeout()
getConnectTimeout
in class SSHClient
public long getHelloTimeout()
getHelloTimeout
in class SSHClient
public long getKexTimeout()
public void connected(boolean timeout)
NIOCallback
NotifyWhenConnected
method of Switchboard
).connected
in interface NIOCallback
connected
in class SSHClient
timeout
- true if the connection attempt timed outpublic void connectionFailed(java.lang.Exception e)
NIOCallback
NotifyWhenConnected
method of Switchboard
).connectionFailed
in interface NIOCallback
connectionFailed
in class SSHClient
e
- the exception the connection failed with.public void completed(java.nio.ByteBuffer buf)
NIOCallback
completed
in interface NIOCallback
completed
in class SSHClient
buf
- the buffer provided to the read callpublic void readFailed(java.lang.Exception e)
NIOCallback
readFailed
in interface NIOCallback
readFailed
in class SSHClient
public void writeFailed()
NIOCallback
writeFailed
in interface NIOCallback
writeFailed
in class SSHClient
public boolean isDumb()
public TerminalWin getTerminalWin()
public void showLogo()
public void hideLogo()
public Logo getLogo()
public void updateTitle()
public java.lang.String promptLine(java.lang.String prompt, boolean echo) throws SSH2UserCancelException
SSH2Interactor
promptLine
in interface SSH2Interactor
prompt
- The prompt string to showecho
- True if the text the user enters should be
echoed.SSH2UserCancelException
public java.lang.String[] promptMulti(java.lang.String[] prompts, boolean[] echos) throws SSH2UserCancelException
SSH2Interactor
promptMulti
in interface SSH2Interactor
prompts
- List of prompts to showechos
- List of boolean values which indicates if the
text entered for the corresponding prompt should
be echoed.SSH2UserCancelException
public java.lang.String[] promptMultiFull(java.lang.String name, java.lang.String instruction, java.lang.String[] prompts, boolean[] echos) throws SSH2UserCancelException
SSH2Interactor
promptMultiFull
in interface SSH2Interactor
name
- Suggested title of the dialoginstruction
- Instructions to show to user in the dialogprompts
- List of prompts to showechos
- List of boolean values which indicates if the
text entered for the corresponding prompt should
be echoed.SSH2UserCancelException
public int promptList(java.lang.String name, java.lang.String instruction, java.lang.String[] choices) throws SSH2UserCancelException
SSH2Interactor
It is used to let the user select one element in a list.
promptList
in interface SSH2Interactor
name
- Suggested title of dialoginstruction
- Instructions to show to userchoices
- Array of possible choicesSSH2UserCancelException
public void propsStateChanged(SSHPropertyHandler props)
propsStateChanged
in interface SSHInteractor
public void startNewSession(SSHClient client)
startNewSession
in interface SSHInteractor
public void sessionStarted(SSHClient client)
sessionStarted
in interface SSHInteractor
public boolean quietPrompts()
quietPrompts
in interface SSHInteractor
public boolean isVerbose()
isVerbose
in interface SSHInteractor
public java.lang.String promptLine(java.lang.String prompt, java.lang.String defaultVal) throws java.io.IOException
promptLine
in interface SSHInteractor
java.io.IOException
public java.lang.String promptPassword(java.lang.String prompt) throws java.io.IOException
promptPassword
in interface SSHInteractor
java.io.IOException
public boolean askConfirmation(java.lang.String message, boolean defAnswer)
askConfirmation
in interface SSHInteractor
public boolean askConfirmation(java.lang.String message, boolean preferDialog, boolean defAnswer) throws java.io.IOException
java.io.IOException
public boolean licenseDialog(java.lang.String license)
licenseDialog
in interface SSHInteractor
public void connected(SSHClient client)
connected
in interface SSHInteractor
public void open(SSHClient client)
open
in interface SSHInteractor
public void disconnected(SSHClient client, boolean graceful)
disconnected
in interface SSHInteractor
public void report(java.lang.String msg)
report
in interface SSHInteractor
public SSH2Interactor getInteractor()
getInteractor
in interface MindTermApp
public void alert(java.lang.String msg)
alert
in interface MindTermApp
alert
in interface SSHInteractor
public void forcedDisconnect()
forcedDisconnect
in class SSHClient
public void requestLocalPortForward(java.lang.String localHost, int localPort, java.lang.String remoteHost, int remotePort, java.lang.String plugin) throws java.io.IOException
requestLocalPortForward
in class SSHClient
java.io.IOException
public void addRemotePortForward(java.lang.String remoteHost, int remotePort, java.lang.String localHost, int localPort, java.lang.String plugin)
addRemotePortForward
in class SSHClient
public void delLocalPortForward(java.lang.String localHost, int port)
delLocalPortForward
in class SSHClient
public void delRemotePortForward(java.lang.String remoteHost, int port)
delRemotePortForward
in class SSHClient
public void callback(java.lang.Object arg)
public boolean fingerprintMatch(SSH2Signature serverHostKey)
public void typedChar(char c)
TerminalInputListener
typedChar
in interface TerminalInputListener
c
- typed characterpublic void typedChar(byte[] b)
TerminalInputListener
typedChar
in interface TerminalInputListener
b
- byte code representation fo the character encoded in
the current encoding.public void sendBytes(byte[] b)
TerminalInputListener
sendBytes
in interface TerminalInputListener
b
- array of bytes representing characters to inputpublic void sendBytesDirect(byte[] b)
TerminalInputListener
sendBytesDirect
in interface TerminalInputListener
b
- array of bytes representing characters to sendpublic void sendBreak()
TerminalInputListener
sendBreak
in interface TerminalInputListener
public void signalWindowChanged(int rows, int cols, int vpixels, int hpixels)
TerminalInputListener
signalWindowChanged
in interface TerminalInputListener
rows
- new number of rowscols
- new number of columnsvpixels
- new number of vertical pixelshpixels
- new number of horizontal pixelspublic void signalTermTypeChanged(java.lang.String newTermType)
TerminalInputListener
signalTermTypeChanged
in interface TerminalInputListener
newTermType
- new terminal type to emulatepublic void addAuthModules(SSH2Authenticator authenticator, java.lang.String methods)
public void newShell()
public java.lang.String getVersionId(boolean client)
getVersionId
in class SSH
public void closeTunnelFromList(int listIdx)
public java.lang.String[] listTunnels()
public java.lang.String getHost()
getHost
in interface MindTermApp
public int getPort()
getPort
in interface MindTermApp
public java.util.Properties getProperties()
getProperties
in interface MindTermApp
public java.lang.String getProperty(java.lang.String name)
getProperty
in interface MindTermApp
public void setProperty(java.lang.String name, java.lang.String value)
setProperty
in interface MindTermApp
public java.lang.String getUserName()
getUserName
in interface MindTermApp
public java.awt.Component getDialogParent()
getDialogParent
in interface MindTermApp
public java.lang.String getAppName()
getAppName
in interface MindTermApp
public boolean isApplet()
isApplet
in interface MindTermApp
public java.applet.AppletContext getAppletContext()
getAppletContext
in interface MindTermApp
public SSH2Transport getTransport()
getTransport
in interface MindTermApp
public SSH2Connection getConnection()
getConnection
in interface MindTermApp
public SSHConsoleRemote getConsoleRemote()
getConsoleRemote
in interface MindTermApp
protected void disconnect(boolean graceful, java.lang.Exception e)
disconnect
in class SSHClient
public void waitForCompletion() throws java.lang.Exception
java.lang.Exception
public static byte[] getX11Cookie()