adams.flow.standalone
Class SSHConnection

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.core.option.AbstractOptionHandler
          extended by adams.flow.core.AbstractActor
              extended by adams.flow.standalone.AbstractStandalone
                  extended by adams.flow.standalone.SSHConnection
All Implemented Interfaces:
AdditionalInformationHandler, CleanUpHandler, Debuggable, DebugOutputHandler, Destroyable, OptionHandler, QuickInfoSupporter, ShallowCopySupporter<AbstractActor>, SizeOfHandler, Stoppable, TechnicalInformationHandler, VariableChangeListener, Actor, ErrorHandler, Serializable, Comparable

public class SSHConnection
extends AbstractStandalone
implements TechnicalInformationHandler

Provides access to a remote host via SSH.

For more information see:

(2011). JSch - JSch is a pure Java implementation of SSH2..

Valid options are:

-D <int> (property: debugLevel)
    The greater the number the more additional info the scheme may output to 
    the console (0 = off).
    default: 0
    minimum: 0
 
-name <java.lang.String> (property: name)
    The name of the actor.
    default: SSHConnection
 
-annotation <adams.core.base.BaseText> (property: annotations)
    The annotations to attach to this actor.
    default: 
 
-skip (property: skip)
    If set to true, transformation is skipped and the input token is just forwarded 
    as it is.
 
-stop-flow-on-error (property: stopFlowOnError)
    If set to true, the flow gets stopped in case this actor encounters an error;
     useful for critical actors.
 
-host <java.lang.String> (property: host)
    The host (name/IP address) to connect to.
    default: 
 
-port <int> (property: port)
    The port to connect to.
    default: 22
    minimum: 1
    maximum: 65535
 
-user <java.lang.String> (property: user)
    The SSH user to use for connecting.
    default: fracpete
 
-password <adams.core.base.BasePassword> (property: password)
    The password of the SSH user to use for connecting.
    default: {}
 
-known-hosts <adams.core.io.PlaceholderFile> (property: knownHosts)
    The file storing the known hosts.
    default: ${HOME}/.ssh/known_hosts
 
-forward-x (property: forwardX)
    If set to true, then X is forwarded.
 
-x-host <java.lang.String> (property: XHost)
    The xhost (name/IP address) to connect to.
    default: 
 
-x-port <java.lang.String> (property: XPort)
    The xport to connect to.
    default: 0:0
 

Version:
$Revision: 5867 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Field Summary
protected  boolean m_ForwardX
          whether to forward X11.
protected  String m_Host
          the SSH host.
protected  PlaceholderFile m_KnownHosts
          the file with known hosts.
protected  BasePassword m_Password
          the SSH password to use.
protected  int m_Port
          the SSH port.
protected  com.jcraft.jsch.Session m_Session
          the SSH session.
protected  String m_User
          the SSH user to use.
protected  String m_XHost
          the xhost to use.
protected  String m_XPort
          the xport to use.
 
Fields inherited from class adams.flow.core.AbstractActor
m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_Executing, m_FullName, m_Headless, m_Name, m_Parent, m_Root, m_Self, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
 
Fields inherited from class adams.core.option.AbstractOptionHandler
m_DebugLevel, m_OptionManager
 
Fields inherited from interface adams.flow.core.Actor
FILE_EXTENSION, FILE_EXTENSION_GZ
 
Constructor Summary
SSHConnection()
           
 
Method Summary
static int checkAck(InputStream in)
          Checks the stream (scp).
 void defineOptions()
          Adds options to the internal list of options.
protected  void disconnect()
          Disconnects the SSH session, if necessary.
protected  String doExecute()
          Executes the flow item.
 String forwardXTipText()
          Returns the tip text for this property.
 boolean getForwardX()
          Returns whether X11 is forwarded.
 String getHost()
          Returns the host to connect to.
 PlaceholderFile getKnownHosts()
          Returns the file with the known hosts.
 BasePassword getPassword()
          Returns the SSH password to use.
 int getPort()
          Returns the port to connect to.
 String getQuickInfo()
          Returns a quick info about the actor, which will be displayed in the GUI.
 com.jcraft.jsch.Session getSession()
          Returns the SSH session.
 TechnicalInformation getTechnicalInformation()
          Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.
 String getUser()
          Returns the SSH user name to use.
 String getXHost()
          Returns the xhost to connect to.
 String getXPort()
          Returns the xport to connect to.
 String globalInfo()
          Returns a string describing the object.
 String hostTipText()
          Returns the tip text for this property.
 String knownHostsTipText()
          Returns the tip text for this property.
 String passwordTipText()
          Returns the tip text for this property.
 String portTipText()
          Returns the tip text for this property.
protected  void reset()
          Resets the actor.
 void setForwardX(boolean value)
          Sets whether to forward X11.
 void setHost(String value)
          Sets the host to connect to.
 void setKnownHosts(PlaceholderFile value)
          Sets the file with the known hosts.
 void setPassword(BasePassword value)
          Sets the SSH password to use.
 void setPort(int value)
          Sets the port to connect to.
 void setUser(String value)
          Sets the SSH user to use.
 void setXHost(String value)
          Sets the xhost to connect to.
 void setXPort(String value)
          Sets the xport to connect to.
 String userTipText()
          Returns the tip text for this property.
 void wrapUp()
          Cleans up after the execution has finished.
 String XHostTipText()
          Returns the tip text for this property.
 String XPortTipText()
          Returns the tip text for this property.
 
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, backupState, canInspectOptions, canPerformSetUpCheck, cleanUp, compareTo, debug, destroy, equals, execute, findVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFullName, getName, getNextSibling, getParent, getPreviousSibling, getRoot, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, initialize, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, postExecute, preExecute, pruneBackup, pruneBackup, restoreState, setAnnotations, setErrorHandler, setHeadless, setName, setParent, setSkip, setStopFlowOnError, setUp, setVariables, shallowCopy, shallowCopy, sizeOf, skipTipText, stopExecution, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
 
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, debug, debugLevelTipText, finishInit, getDebugLevel, getOptionManager, isDebugOn, newOptionManager, setDebugLevel, toCommandLine, toString
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager
 

Field Detail

m_Host

protected String m_Host
the SSH host.


m_Port

protected int m_Port
the SSH port.


m_User

protected String m_User
the SSH user to use.


m_Password

protected BasePassword m_Password
the SSH password to use.


m_KnownHosts

protected PlaceholderFile m_KnownHosts
the file with known hosts.


m_ForwardX

protected boolean m_ForwardX
whether to forward X11.


m_XHost

protected String m_XHost
the xhost to use.


m_XPort

protected String m_XPort
the xport to use.


m_Session

protected com.jcraft.jsch.Session m_Session
the SSH session.

Constructor Detail

SSHConnection

public SSHConnection()
Method Detail

globalInfo

public String globalInfo()
Returns a string describing the object.

Specified by:
globalInfo in class AbstractOptionHandler
Returns:
a description suitable for displaying in the gui

getTechnicalInformation

public TechnicalInformation getTechnicalInformation()
Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.

Specified by:
getTechnicalInformation in interface TechnicalInformationHandler
Returns:
the technical information about this class

defineOptions

public void defineOptions()
Adds options to the internal list of options.

Specified by:
defineOptions in interface OptionHandler
Overrides:
defineOptions in class AbstractActor

reset

protected void reset()
Resets the actor.

Overrides:
reset in class AbstractActor

getQuickInfo

public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.

Specified by:
getQuickInfo in interface QuickInfoSupporter
Specified by:
getQuickInfo in interface Actor
Overrides:
getQuickInfo in class AbstractActor
Returns:
null if no info available, otherwise short string

setHost

public void setHost(String value)
Sets the host to connect to.

Parameters:
value - the host name/ip

getHost

public String getHost()
Returns the host to connect to.

Returns:
the host name/ip

hostTipText

public String hostTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setPort

public void setPort(int value)
Sets the port to connect to.

Parameters:
value - the port

getPort

public int getPort()
Returns the port to connect to.

Returns:
the port

portTipText

public String portTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setUser

public void setUser(String value)
Sets the SSH user to use.

Parameters:
value - the user name

getUser

public String getUser()
Returns the SSH user name to use.

Returns:
the user name

userTipText

public String userTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setPassword

public void setPassword(BasePassword value)
Sets the SSH password to use.

Parameters:
value - the password

getPassword

public BasePassword getPassword()
Returns the SSH password to use.

Returns:
the password

passwordTipText

public String passwordTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setKnownHosts

public void setKnownHosts(PlaceholderFile value)
Sets the file with the known hosts.

Parameters:
value - the file

getKnownHosts

public PlaceholderFile getKnownHosts()
Returns the file with the known hosts.

Returns:
the file

knownHostsTipText

public String knownHostsTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

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(String value)
Sets the xport to connect to.

Parameters:
value - the port

getXPort

public String 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.

getSession

public com.jcraft.jsch.Session getSession()
Returns the SSH session.

Returns:
the SSH session, null if not connected

doExecute

protected String doExecute()
Executes the flow item.

Specified by:
doExecute in class AbstractActor
Returns:
null if ok, otherwise error message

disconnect

protected void disconnect()
Disconnects the SSH session, if necessary.


wrapUp

public void wrapUp()
Cleans up after the execution has finished.

Specified by:
wrapUp in interface Actor
Overrides:
wrapUp in class AbstractActor

checkAck

public static int checkAck(InputStream in)
                    throws IOException
Checks the stream (scp).

Parameters:
in - the stream to use
Returns:
0 = success, 1 = error, 2 = fatal error, -1 = end of stream
Throws:
IOException


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.