Package adams.scripting.connection
Class SSHConnection
-
- All Implemented Interfaces:
CleanUpHandler,Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,SSHSessionProvider,OptionHandler,PasswordSupporter,QuickInfoSupporter,SizeOfHandler,Connection,Serializable,Comparable<Connection>
public class SSHConnection extends AbstractSSHConnectionWithPortForwarding
Uses an SSH tunnel to connect to the remote scripting engine.
Inspired by: www.beanizer.org- Version:
- $Revision$
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class adams.scripting.connection.AbstractSSHConnection
AbstractSSHConnection.TrustAll
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanm_ForwardXwhether to forward X11.protected intm_Waitthe time in msec to wait before disconnecting the session again.protected Stringm_XHostthe xhost to use.protected intm_XPortthe xport to use.-
Fields inherited from class adams.scripting.connection.AbstractSSHConnectionWithPortForwarding
m_AssignedPort, m_LocalPort, m_ScriptingPort
-
Fields inherited from class adams.scripting.connection.AbstractSSHConnection
m_AuthenticationType, m_Host, m_KnownHosts, m_Password, m_Port, m_PrivateKeyFile, m_PrivateKeyPassphrase, m_Session, m_StrictHostKeyChecking, m_User
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description SSHConnection()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected com.jcraft.jsch.SessioncreateSession(String host, int port)Creates a newSessionobject, but does not connect or establish the tunnel.voiddefineOptions()Adds options to the internal list of options.protected StringdoSend(RemoteCommand cmd, RemoteCommandProcessor processor, boolean request)Sends the command to the specified sscripting engine.StringforwardXTipText()Returns the tip text for this property.booleangetForwardX()Returns whether X11 is forwarded.intgetWait()Returns the period in msec to wait before disconnecting the session.StringgetXHost()Returns the xhost to connect to.intgetXPort()Returns the xport to connect to.StringglobalInfo()Returns a string describing the object.voidsetForwardX(boolean value)Sets whether to forward X11.voidsetWait(int value)Sets the period in msec to wait before disconnecting the session.voidsetXHost(String value)Sets the xhost to connect to.voidsetXPort(int value)Sets the xport to connect to.StringwaitTipText()Returns the tip text for this property.StringXHostTipText()Returns the tip text for this property.StringXPortTipText()Returns the tip text for this property.-
Methods inherited from class adams.scripting.connection.AbstractSSHConnectionWithPortForwarding
cleanUp, getLocalPort, getScriptingPort, localPortTipText, newSession, scriptingPortTipText, setLocalPort, setScriptingPort
-
Methods inherited from class adams.scripting.connection.AbstractSSHConnection
authenticationTypeTipText, doSendRequest, doSendResponse, getAuthenticationType, getHost, getKnownHosts, getPassword, getPort, getPrivateKeyFile, getPrivateKeyPassphrase, getQuickInfo, getSession, getStrictHostKeyChecking, getUser, hostTipText, knownHostsTipText, newSession, passwordTipText, portTipText, privateKeyFileTipText, privateKeyPassphraseTipText, reset, send, setAuthenticationType, setHost, setKnownHosts, setPassword, setPort, setPrivateKeyFile, setPrivateKeyPassphrase, setStrictHostKeyChecking, setUser, strictHostKeyCheckingTipText, userTipText
-
Methods inherited from class adams.scripting.connection.AbstractConnection
checkRequest, checkResponse, compareTo, equals, sendRequest, sendResponse, toString
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.Destroyable
destroy
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
-
-
-
Field Detail
-
m_ForwardX
protected boolean m_ForwardX
whether to forward X11.
-
m_XHost
protected String m_XHost
the xhost to use.
-
m_XPort
protected int m_XPort
the xport to use.
-
m_Wait
protected int m_Wait
the time in msec to wait before disconnecting the session again.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractSSHConnectionWithPortForwarding
-
setForwardX
public void setForwardX(boolean value)
Sets whether to forward X11.- Parameters:
value- if true then X11 is forwarded
-
getForwardX
public boolean getForwardX()
Returns whether X11 is forwarded.- Returns:
- true if X11 is forwarded
-
forwardXTipText
public String forwardXTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setXHost
public void setXHost(String value)
Sets the xhost to connect to.- Parameters:
value- the host name/ip
-
getXHost
public String getXHost()
Returns the xhost to connect to.- Returns:
- the host name/ip
-
XHostTipText
public String XHostTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setXPort
public void setXPort(int value)
Sets the xport to connect to.- Parameters:
value- the port
-
getXPort
public int getXPort()
Returns the xport to connect to.- Returns:
- the port
-
XPortTipText
public String XPortTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setWait
public void setWait(int value)
Sets the period in msec to wait before disconnecting the session.- Parameters:
value- the waiting period
-
getWait
public int getWait()
Returns the period in msec to wait before disconnecting the session.- Returns:
- the waiting period
-
waitTipText
public String waitTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
createSession
protected com.jcraft.jsch.Session createSession(String host, int port) throws Exception
Creates a newSessionobject, but does not connect or establish the tunnel.- Overrides:
createSessionin classAbstractSSHConnection- Returns:
- the Session object
- Throws:
Exception
-
doSend
protected String doSend(RemoteCommand cmd, RemoteCommandProcessor processor, boolean request)
Sends the command to the specified sscripting engine.- Specified by:
doSendin classAbstractSSHConnection- Parameters:
cmd- the command to sendprocessor- the processor for formatting/parsingrequest- whether Request or Response- Returns:
- null if successfully sent, otherwise error message
-
-