Package com.ibm.di.protocols.rxa
Class ConnectionImpl
- java.lang.Object
-
- com.ibm.di.protocols.rxa.ConnectionImpl
-
- All Implemented Interfaces:
Connection
- Direct Known Subclasses:
AS400Connection,RexecConnection,RSHConnection,SSHConnection,WinConnection
public abstract class ConnectionImpl extends java.lang.Object implements Connection
This class encapsulates the RXA library's Connection related objects
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAS400_PROXYString for the Proxy parameter to be used if required for AS400 connectionstatic java.lang.StringAS400_RUNPROGString for the Secondary mechanism parameter for executing AS400 Programsstatic java.lang.StringAS400_SSLString for the Enable or disable SSL parameter over an AS400 connectionprotected java.lang.Stringas400ProxyThis parameter defines an AS400 proxy server if so requiredprotected booleanas400RunProgAn optional Remote CLFC parameter that defines the type of command execution to use for an AS400 (i5/OS) connectionprotected booleanas400SSLThis parameter governs whether an SSL connection is enforced on the AS400 (i5/OS) connectionprotected java.lang.StringcmdArgsCharEncodeThe character encoding to use for AS400 command line argumentsstatic java.lang.StringCOMMAND_RETURN_CODEString for Command Return Code Parameterstatic java.lang.StringCOMMAND_STD_ERRORString for Command Error Parameterstatic java.lang.StringCOMMAND_STD_OUTPUTString for Command Output Parameterprotected static java.lang.StringEMPTYSTRINGEmpty Stringstatic java.lang.StringHANDLE_TEXT_FILEString for the Parameter to handle as text fileprotected java.lang.StringhostNameThe hostname (address) of the target machine.static java.lang.StringHOSTNAMEString for Hostname parameter of Remote Machine (target)protected intinitial_timeoutAn optional Remote CLFC parameter that defines a timeout period for the initial connection to the target system.static java.lang.StringINITIAL_TIMEOUTString for the Timeout parameter of the connectionprotected java.lang.StringkeystoreFull path to the file containing the keystorestatic java.lang.StringKEYSTOREString for the keystore parameter to be used when connecting to the remote machine using the SSH protocolprotected LogProxylpUsed for loggingprotected java.lang.StringparentDirToStdinParent directory to the folder containing the stdin destination folderprotected byte[]passphraseThe passphrase that protects your private key, in the keystore specified by the Keystore Path parameter abovestatic java.lang.StringPASSPHRASEString for the passphrase parameter for the keystoreprotected byte[]passwordThe password for the user (specified as Remote User) on the target machine.static java.lang.StringPASSWORDString for the User password parameter to authenticate to the targetstatic java.lang.StringPATHString for the file path on the targetprotected intportThe port to use to connect to the target machinestatic java.lang.StringPORTString for the port parameter to be used when establishing connection with targetprotected java.lang.StringrandomDirPath to random directory createdstatic java.lang.StringRECURSIVE_SEARCHString for the Timeout parameter of the connectionprotected AttributertnCodeAttrThe return code from the executed command indicating the success of the requested operationstatic java.lang.StringSOURCEPATHString for the Source file pathprotected AttributestdErrorAttrThe standard error from the executed commandprotected AttributestdOutputAttrThe standard output from the executed commandprotected inttimeoutThe desired CPU timeout period in millisecondsstatic java.lang.StringTIMEOUTString for the Timeout duration parameter for executing the command (ms)protected java.lang.StringuserNameThe name of a user with Administrative privileges on the target machinestatic java.lang.StringUSERNAMEString for the username paremeter to be used when connecting to target
-
Constructor Summary
Constructors Constructor Description ConnectionImpl(LogProxy log)ConnectionImpl Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract com.ibm.tivoli.remoteaccess.RemoteAccessbeginSession()Begin a session with the target machinevoidcreateDir(java.lang.String dir)Create a directory on the target machinejava.lang.StringcreateRandomDir(java.lang.String p)Create a random directory on the target machinevoidendSession()End the session with the target machinejava.lang.StringgetHost()Get the hostname of the target for the connectionchargetOSSeparator()Return the character that the target uses to separate path informationcom.ibm.tivoli.remoteaccess.RemoteAccessgetRXAProtocol()Return the RXA Connection Objectabstract java.lang.StringgetType()Return this connection typejava.lang.StringgetUser()Get the username being used in the connectionvoidinitializeProps(java.util.Properties p)Initialize the properties of the connectionbooleanisExists(java.lang.String path)Returns true/false to check a given file exists or notjava.util.ArrayList<java.lang.String>list(java.lang.String path)Retrieves the list of filesvoidreceiveFile(java.lang.String remotepath, java.lang.String localpath)Receives the specified file from the target machine to a specified destination on the local machinevoidremoveDir(java.lang.String dir)Remove a directory on the target machineEntryrunCommand(java.lang.String c)Run the specified command on the target machinevoidsetCmdArgsCharEncode(java.lang.String enc)Sets encoding for the command arguments before executing the actual commandvoidsetHost(java.lang.String s)Set the hostname of the target with which to connectvoidsetRXAProtocol(com.ibm.tivoli.remoteaccess.RemoteAccess remote)Set the RXA connection object for this connectionvoidsetUser(java.lang.String u)Set the username to be used when connecting to the targetvoidtransferFile(java.lang.String localPath, java.lang.String remotePath)Transfer the specified file from the local machine to a specified destination on the remote target
-
-
-
Field Detail
-
hostName
protected java.lang.String hostName
The hostname (address) of the target machine. This is a required parameter
-
userName
protected java.lang.String userName
The name of a user with Administrative privileges on the target machine
-
password
protected byte[] password
The password for the user (specified as Remote User) on the target machine. This parameter may be optional in the case of SSH connections using a keystore, as well as for RSH connections
-
passphrase
protected byte[] passphrase
The passphrase that protects your private key, in the keystore specified by the Keystore Path parameter above
-
cmdArgsCharEncode
protected java.lang.String cmdArgsCharEncode
The character encoding to use for AS400 command line arguments
-
keystore
protected java.lang.String keystore
Full path to the file containing the keystore
-
timeout
protected int timeout
The desired CPU timeout period in milliseconds
-
port
protected int port
The port to use to connect to the target machine
-
as400SSL
protected boolean as400SSL
This parameter governs whether an SSL connection is enforced on the AS400 (i5/OS) connection
-
as400Proxy
protected java.lang.String as400Proxy
This parameter defines an AS400 proxy server if so required
-
as400RunProg
protected boolean as400RunProg
An optional Remote CLFC parameter that defines the type of command execution to use for an AS400 (i5/OS) connection
-
initial_timeout
protected int initial_timeout
An optional Remote CLFC parameter that defines a timeout period for the initial connection to the target system. This has no effect on AS400 targets
-
COMMAND_RETURN_CODE
public static final java.lang.String COMMAND_RETURN_CODE
String for Command Return Code Parameter- See Also:
- Constant Field Values
-
COMMAND_STD_OUTPUT
public static final java.lang.String COMMAND_STD_OUTPUT
String for Command Output Parameter- See Also:
- Constant Field Values
-
COMMAND_STD_ERROR
public static final java.lang.String COMMAND_STD_ERROR
String for Command Error Parameter- See Also:
- Constant Field Values
-
HOSTNAME
public static final java.lang.String HOSTNAME
String for Hostname parameter of Remote Machine (target)- See Also:
- Constant Field Values
-
USERNAME
public static final java.lang.String USERNAME
String for the username paremeter to be used when connecting to target- See Also:
- Constant Field Values
-
PORT
public static final java.lang.String PORT
String for the port parameter to be used when establishing connection with target- See Also:
- Constant Field Values
-
PASSWORD
public static final java.lang.String PASSWORD
String for the User password parameter to authenticate to the target- See Also:
- Constant Field Values
-
PATH
public static final java.lang.String PATH
String for the file path on the target- See Also:
- Constant Field Values
-
SOURCEPATH
public static final java.lang.String SOURCEPATH
String for the Source file path- See Also:
- Constant Field Values
-
TIMEOUT
public static final java.lang.String TIMEOUT
String for the Timeout duration parameter for executing the command (ms)- See Also:
- Constant Field Values
-
KEYSTORE
public static final java.lang.String KEYSTORE
String for the keystore parameter to be used when connecting to the remote machine using the SSH protocol- See Also:
- Constant Field Values
-
PASSPHRASE
public static final java.lang.String PASSPHRASE
String for the passphrase parameter for the keystore- See Also:
- Constant Field Values
-
AS400_SSL
public static final java.lang.String AS400_SSL
String for the Enable or disable SSL parameter over an AS400 connection- See Also:
- Constant Field Values
-
AS400_PROXY
public static final java.lang.String AS400_PROXY
String for the Proxy parameter to be used if required for AS400 connection- See Also:
- Constant Field Values
-
AS400_RUNPROG
public static final java.lang.String AS400_RUNPROG
String for the Secondary mechanism parameter for executing AS400 Programs- See Also:
- Constant Field Values
-
HANDLE_TEXT_FILE
public static final java.lang.String HANDLE_TEXT_FILE
String for the Parameter to handle as text file- See Also:
- Constant Field Values
-
INITIAL_TIMEOUT
public static final java.lang.String INITIAL_TIMEOUT
String for the Timeout parameter of the connection- See Also:
- Constant Field Values
-
RECURSIVE_SEARCH
public static final java.lang.String RECURSIVE_SEARCH
String for the Timeout parameter of the connection- See Also:
- Constant Field Values
-
rtnCodeAttr
protected Attribute rtnCodeAttr
The return code from the executed command indicating the success of the requested operation
-
stdErrorAttr
protected Attribute stdErrorAttr
The standard error from the executed command
-
stdOutputAttr
protected Attribute stdOutputAttr
The standard output from the executed command
-
lp
protected LogProxy lp
Used for logging
-
parentDirToStdin
protected java.lang.String parentDirToStdin
Parent directory to the folder containing the stdin destination folder
-
randomDir
protected java.lang.String randomDir
Path to random directory created
-
EMPTYSTRING
protected static final java.lang.String EMPTYSTRING
Empty String- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ConnectionImpl
public ConnectionImpl(LogProxy log)
ConnectionImpl Constructor- Parameters:
log- LogProxy for logging
-
-
Method Detail
-
initializeProps
public void initializeProps(java.util.Properties p)
Initialize the properties of the connection- Specified by:
initializePropsin interfaceConnection- Parameters:
p- Properties object containing the configurable connection attributes
-
beginSession
public abstract com.ibm.tivoli.remoteaccess.RemoteAccess beginSession() throws RemoteConnectExceptionBegin a session with the target machine- Specified by:
beginSessionin interfaceConnection- Returns:
- RemoteAccess The RXA connection object connecting to the target
- Throws:
RemoteConnectException
-
getType
public abstract java.lang.String getType()
Return this connection type- Specified by:
getTypein interfaceConnection- Returns:
- String The connection protocol used for this connection. One of: WIN, REXEC, RSH, SSH
-
endSession
public void endSession()
End the session with the target machine- Specified by:
endSessionin interfaceConnection
-
runCommand
public Entry runCommand(java.lang.String c) throws GeneralCLFCException
Run the specified command on the target machine- Specified by:
runCommandin interfaceConnection- Parameters:
c- String containing the command to be executed- Returns:
- Entry containing the results from executing the command. It contains three attributes: command.out, command.error and command.returnCode.
- Throws:
GeneralCLFCException
-
createRandomDir
public java.lang.String createRandomDir(java.lang.String p) throws RemoteConnectException, GeneralCLFCExceptionCreate a random directory on the target machine- Specified by:
createRandomDirin interfaceConnection- Parameters:
p- The path to the parent directory where the random directory is to be created- Returns:
- String specifying the path to the random directory that was created
- Throws:
GeneralCLFCExceptionRemoteConnectException
-
createDir
public void createDir(java.lang.String dir) throws GeneralCLFCExceptionCreate a directory on the target machine- Specified by:
createDirin interfaceConnection- Parameters:
dir- Path of the folder to be created- Throws:
GeneralCLFCException- if the folder cannot be successfully created on the target
-
removeDir
public void removeDir(java.lang.String dir) throws GeneralCLFCExceptionRemove a directory on the target machine- Specified by:
removeDirin interfaceConnection- Parameters:
dir- The path to the folder to be deleted- Throws:
GeneralCLFCException- if the folder cannot be successfully removed from the target
-
transferFile
public void transferFile(java.lang.String localPath, java.lang.String remotePath) throws GeneralCLFCExceptionTransfer the specified file from the local machine to a specified destination on the remote target- Specified by:
transferFilein interfaceConnection- Parameters:
localPath- Path to the source file on the local machineremotePath- Path to where the file is to be stored on the remote machine- Throws:
GeneralCLFCException- if the transfer fails
-
receiveFile
public void receiveFile(java.lang.String remotepath, java.lang.String localpath) throws GeneralCLFCExceptionReceives the specified file from the target machine to a specified destination on the local machine- Specified by:
receiveFilein interfaceConnection- Parameters:
localPath- Path to the source file on the remote machineremotePath- Path to where the file is to be stored on local machine- Throws:
GeneralCLFCException- if the transfer fails
-
isExists
public boolean isExists(java.lang.String path) throws GeneralCLFCExceptionReturns true/false to check a given file exists or not- Specified by:
isExistsin interfaceConnection- Parameters:
path- path on the file- Returns:
- true if the given file exists on the remote machine otherwise false
- Throws:
GeneralCLFCException
-
list
public java.util.ArrayList<java.lang.String> list(java.lang.String path) throws GeneralCLFCExceptionRetrieves the list of files- Specified by:
listin interfaceConnection- Parameters:
path- path on the remote machine- Throws:
GeneralCLFCException
-
getOSSeparator
public char getOSSeparator() throws RemoteConnectExceptionReturn the character that the target uses to separate path information- Specified by:
getOSSeparatorin interfaceConnection- Returns:
- char separator
- Throws:
RemoteConnectException
-
getRXAProtocol
public com.ibm.tivoli.remoteaccess.RemoteAccess getRXAProtocol()
Return the RXA Connection Object- Specified by:
getRXAProtocolin interfaceConnection- Returns:
- RemoteAccess connection object accessing the target
-
setHost
public void setHost(java.lang.String s)
Set the hostname of the target with which to connect- Specified by:
setHostin interfaceConnection- Parameters:
s- The hostname of the target
-
getHost
public java.lang.String getHost()
Get the hostname of the target for the connection- Specified by:
getHostin interfaceConnection- Returns:
- String hostname
-
setUser
public void setUser(java.lang.String u)
Set the username to be used when connecting to the target- Specified by:
setUserin interfaceConnection- Parameters:
u- Username
-
getUser
public java.lang.String getUser()
Get the username being used in the connection- Specified by:
getUserin interfaceConnection- Returns:
- String username
-
setRXAProtocol
public void setRXAProtocol(com.ibm.tivoli.remoteaccess.RemoteAccess remote)
Set the RXA connection object for this connection- Parameters:
remote- The protocol-specific connection object
-
setCmdArgsCharEncode
public void setCmdArgsCharEncode(java.lang.String enc)
Sets encoding for the command arguments before executing the actual command- Specified by:
setCmdArgsCharEncodein interfaceConnection- Parameters:
enc- encoding to be used
-
-