IP*Works!

ipworks
Class Rcp

java.lang.Object
  |
  +--ipworks.Rcp

public class Rcp
extends java.lang.Object

The RCP control implements the popular UNIX Remote Copy Protocol, used to transfer files between systems.

Using the control is as simple as specifying a LocalFile , a RemoteFile and RemoteHost , and calling the GetFile or the PutFile method. Alternatively you can set the Action to either 'Get File' or 'Put File' to achieve the same results.

The Remote Copy Protocol is implemented over either RSHELL or REXEC. The control allows you to choose which protocol to use via the Protocol property.


Field Summary
static int fwNone
           
static int fwSOCKS4
           
static int fwSOCKS5
           
static int fwTunnel
           
static int protRexec
           
static int protRshell
           
static int rcpGetFile
           
static int rcpIdle
           
static int rcpPutFile
           
 
Constructor Summary
Rcp()
           
 
Method Summary
 void addRcpEventListener(RcpEventListener l)
           
 void fireConnected(int statusCode, java.lang.String description)
          Fired immediately after a connection completes (or fails).
 void fireDisconnected(int statusCode, java.lang.String description)
          Fired when a connection is closed.
 void fireError(int errorCode, java.lang.String description)
          Information about errors during data delivery.
 void fireProgress(int percentDone)
          Fired whenever data is being transferred between the localhost and RemoteHost .
 int getAction()
          An action code for the control.
 void getFile()
          Get File.
 java.lang.String getFileMode()
          The file mode for the RemoteFile .
 byte[] getFirewallData()
          Used to send other data to firewall.
 java.lang.String getFirewallHost()
          Name or IP address of firewall (optional).
 java.lang.String getFirewallPassword()
          A password if authentication is to be used connecting through the firewall.
 int getFirewallPort()
          Port of the firewall to connect to.
 int getFirewallType()
          Determines the type of firewall to connect through.
 java.lang.String getFirewallUser()
          A user name if authentication is to be used connecting through a firewall.
 java.lang.String getLocalFile()
          The file on the local host.
 java.lang.String getLocalHost()
          The name of the local host or user-assigned IP interface through which connections are initiated or accepted.
 int getLocalPort()
          The TCP port in the local host where the component binds.
 java.lang.String getPassword()
          The password associated with User .
 int getProtocol()
          Sets the protocol to use for the transfer.
 java.lang.String getRemoteFile()
          The file on the remote host.
 java.lang.String getRemoteHost()
          The remote host to connect to.
 int getRemotePort()
          The port for the service (REXEC or RSHELL).
 int getStderrPort()
          The local port where the remote systems sends the stderr stream.
 int getTimeout()
          A timeout for the component.
 java.lang.String getUser()
          The identification of the remote user for a transfer.
 void interrupt()
          Interrupt the Action in progress (if any).
 boolean isEnableStderr()
          Enables or disables secondary (stderr) stream.
 void putFile()
          Put File A connection is made and a request is sent to copy LocalFile to the file specified by RemoteFile .
 void removeRcpEventListener(RcpEventListener l)
           
 void setAction(int action)
          An action code for the control.
 void setEnableStderr(boolean enableStderr)
          Enables or disables secondary (stderr) stream.
 void setFileMode(java.lang.String fileMode)
          The file mode for the RemoteFile .
 void setFirewallData(byte[] firewallData)
          Used to send other data to firewall.
 void setFirewallHost(java.lang.String firewallHost)
          Name or IP address of firewall (optional).
 void setFirewallPassword(java.lang.String firewallPassword)
          A password if authentication is to be used connecting through the firewall.
 void setFirewallPort(int firewallPort)
          Port of the firewall to connect to.
 void setFirewallType(int firewallType)
          Determines the type of firewall to connect through.
 void setFirewallUser(java.lang.String firewallUser)
          A user name if authentication is to be used connecting through a firewall.
 void setLocalFile(java.lang.String localFile)
          The file on the local host.
 void setLocalHost(java.lang.String localHost)
          The name of the local host or user-assigned IP interface through which connections are initiated or accepted.
 void setLocalPort(int localPort)
          The TCP port in the local host where the component binds.
 void setPassword(java.lang.String password)
          The password associated with User .
 void setProtocol(int protocol)
          Sets the protocol to use for the transfer.
 void setRemoteFile(java.lang.String remoteFile)
          The file on the remote host.
 void setRemoteHost(java.lang.String remoteHost)
          The remote host to connect to.
 void setRemotePort(int remotePort)
          The port for the service (REXEC or RSHELL).
 void setStderrPort(int stderrPort)
          The local port where the remote systems sends the stderr stream.
 void setTimeout(int timeout)
          A timeout for the component.
 void setUser(java.lang.String user)
          The identification of the remote user for a transfer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rcpIdle

public static final int rcpIdle

rcpGetFile

public static final int rcpGetFile

rcpPutFile

public static final int rcpPutFile

fwNone

public static final int fwNone

fwTunnel

public static final int fwTunnel

fwSOCKS4

public static final int fwSOCKS4

fwSOCKS5

public static final int fwSOCKS5

protRexec

public static final int protRexec

protRshell

public static final int protRshell
Constructor Detail

Rcp

public Rcp()
Method Detail

getAction

public int getAction()
An action code for the control. The following are the possible values for the Action property and the corresponding descriptions:
rcpIdle (0)
Default action. It can also be used to interrupt the current operation.
rcpGetFile (1)
A connection is made with the RemoteHost using the specified Protocol , User , and Password , and a request is sent to read the file specified by RemoteFile .
rcpPutFile (2)
A connection is made and a request is sent to copy LocalFile to the file specified by RemoteFile .

After a request has been successfully sent, the control returns to 'Idle'.


setAction

public void setAction(int action)
               throws IPWorksException
An action code for the control. The following are the possible values for the Action property and the corresponding descriptions:
rcpIdle (0)
Default action. It can also be used to interrupt the current operation.
rcpGetFile (1)
A connection is made with the RemoteHost using the specified Protocol , User , and Password , and a request is sent to read the file specified by RemoteFile .
rcpPutFile (2)
A connection is made and a request is sent to copy LocalFile to the file specified by RemoteFile .

After a request has been successfully sent, the control returns to 'Idle'.


isEnableStderr

public boolean isEnableStderr()
Enables or disables secondary (stderr) stream. Some systems (most notably certain versions of Linux) do not support the secondary stderr stream of rexec/rshell. For these systems, you must turn EnableStderr off. Any stderr output will then be provided through stdout.


setEnableStderr

public void setEnableStderr(boolean enableStderr)
                     throws IPWorksException
Enables or disables secondary (stderr) stream. Some systems (most notably certain versions of Linux) do not support the secondary stderr stream of rexec/rshell. For these systems, you must turn EnableStderr off. Any stderr output will then be provided through stdout.


getFileMode

public java.lang.String getFileMode()
The file mode for the RemoteFile . The FileMode property is used together with the rcpPutFile Action . The default mode is "0600".


setFileMode

public void setFileMode(java.lang.String fileMode)
                 throws IPWorksException
The file mode for the RemoteFile . The FileMode property is used together with the rcpPutFile Action . The default mode is "0600".


getFirewallData

public byte[] getFirewallData()
Used to send other data to firewall. When the firewall is a tunneling proxy, use this property to to send custom (additional) headers to the firewall (e.g. headers for custom authentication schemes).


setFirewallData

public void setFirewallData(byte[] firewallData)
                     throws IPWorksException
Used to send other data to firewall. When the firewall is a tunneling proxy, use this property to to send custom (additional) headers to the firewall (e.g. headers for custom authentication schemes).


getFirewallHost

public java.lang.String getFirewallHost()
Name or IP address of firewall (optional). If a FirewallHost is given, requested connections will be authenticated through the specified firewall when connecting.

If the FirewallHost property is set to a Domain Name, a DNS request is initiated and upon successful termination of the request, the FirewallHost property is set to the corresponding address. If the search is not successful, an error is returned.


setFirewallHost

public void setFirewallHost(java.lang.String firewallHost)
                     throws IPWorksException
Name or IP address of firewall (optional). If a FirewallHost is given, requested connections will be authenticated through the specified firewall when connecting.

If the FirewallHost property is set to a Domain Name, a DNS request is initiated and upon successful termination of the request, the FirewallHost property is set to the corresponding address. If the search is not successful, an error is returned.


getFirewallPassword

public java.lang.String getFirewallPassword()
A password if authentication is to be used connecting through the firewall. if FirewallHost is specified, the FirewallUser and FirewallPassword properties are used to connect and authenticate to the given firewall. If the authentication fails, a trappable error is fired.


setFirewallPassword

public void setFirewallPassword(java.lang.String firewallPassword)
                         throws IPWorksException
A password if authentication is to be used connecting through the firewall. if FirewallHost is specified, the FirewallUser and FirewallPassword properties are used to connect and authenticate to the given firewall. If the authentication fails, a trappable error is fired.


getFirewallPort

public int getFirewallPort()
Port of the firewall to connect to. The TCP port for the FirewallHost . See the description of the FirewallHost property for details.

Note that the FirewallPort is set automatically when FirewallType is set to a valid value. See the description of the FirewallType property for details.


setFirewallPort

public void setFirewallPort(int firewallPort)
                     throws IPWorksException
Port of the firewall to connect to. The TCP port for the FirewallHost . See the description of the FirewallHost property for details.

Note that the FirewallPort is set automatically when FirewallType is set to a valid value. See the description of the FirewallType property for details.


getFirewallType

public int getFirewallType()
Determines the type of firewall to connect through. The applicable values are the following:
fwNone (0)
No firewall (default setting).
fwTunnel (1)
Connect through a tunneling proxy. FirewallPort is set to 80.
fwSOCKS4 (2)
Connect through a SOCKS4 Proxy. FirewallPort is set to 1080.
fwSOCKS5 (3)
Connect through a SOCKS5 Proxy. FirewallPort is set to 1080.


setFirewallType

public void setFirewallType(int firewallType)
                     throws IPWorksException
Determines the type of firewall to connect through. The applicable values are the following:
fwNone (0)
No firewall (default setting).
fwTunnel (1)
Connect through a tunneling proxy. FirewallPort is set to 80.
fwSOCKS4 (2)
Connect through a SOCKS4 Proxy. FirewallPort is set to 1080.
fwSOCKS5 (3)
Connect through a SOCKS5 Proxy. FirewallPort is set to 1080.


getFirewallUser

public java.lang.String getFirewallUser()
A user name if authentication is to be used connecting through a firewall. if FirewallHost is specified, the FirewallUser and FirewallPassword properties are used to connect and authenticate to the given firewall. If the authentication fails, a trappable error is fired.


setFirewallUser

public void setFirewallUser(java.lang.String firewallUser)
                     throws IPWorksException
A user name if authentication is to be used connecting through a firewall. if FirewallHost is specified, the FirewallUser and FirewallPassword properties are used to connect and authenticate to the given firewall. If the authentication fails, a trappable error is fired.


getLocalFile

public java.lang.String getLocalFile()
The file on the local host. If Action is rcpGetFile and the file already exists, it is overwritten. If Action is rcpPutFile , LocalFile must point to a valid file, or an error will be returned.


setLocalFile

public void setLocalFile(java.lang.String localFile)
                  throws IPWorksException
The file on the local host. If Action is rcpGetFile and the file already exists, it is overwritten. If Action is rcpPutFile , LocalFile must point to a valid file, or an error will be returned.


getLocalHost

public java.lang.String getLocalHost()
The name of the local host or user-assigned IP interface through which connections are initiated or accepted. The LocalHost property contains the name of the local host as obtained by the gethostname() Winsock call, or if the user has assigned an IP address, the value of that address.

In multihomed hosts (machines with more than one IP interface) setting LocalHost to the value of an interface will make the control initiate connections (or accept in the case of server controls) only through that interface.

If the control is connected, the LocalHost property shows the IP address of the interface through which the connection is made in internet dotted format (aaa.bbb.ccc.ddd). In most cases, this is the address of the local host, except for multihomed hosts (machines with more than one IP interface).

NOTE: LocalHost is not persistent. You must always set it in code, and never in the property window.


setLocalHost

public void setLocalHost(java.lang.String localHost)
                  throws IPWorksException
The name of the local host or user-assigned IP interface through which connections are initiated or accepted. The LocalHost property contains the name of the local host as obtained by the gethostname() Winsock call, or if the user has assigned an IP address, the value of that address.

In multihomed hosts (machines with more than one IP interface) setting LocalHost to the value of an interface will make the control initiate connections (or accept in the case of server controls) only through that interface.

If the control is connected, the LocalHost property shows the IP address of the interface through which the connection is made in internet dotted format (aaa.bbb.ccc.ddd). In most cases, this is the address of the local host, except for multihomed hosts (machines with more than one IP interface).

NOTE: LocalHost is not persistent. You must always set it in code, and never in the property window.


getLocalPort

public int getLocalPort()
The TCP port in the local host where the component binds. The LocalPort property must be set before a connection is attempted. It instructs the control to bind to a specific port (or communication endpoint) in the local machine.

Setting it to 0 (default) enables the control to choose a port at random. The chosen port will be shown by the LocalPort property after the connection is established.

LocalPort cannot be changed once a connection is made. Any attempt to set the LocalPort property when a connection is active will generate an error.

USe this property with caution. If you supply a value, it must be an available port on the system, or an error will be returned. Furthermore, the control always attempts to bind to a secure (sub 1000) port when the value of LocalPort is the default (0). If you supply your own value, make sure the remote system is configured to allow that particular value.


setLocalPort

public void setLocalPort(int localPort)
                  throws IPWorksException
The TCP port in the local host where the component binds. The LocalPort property must be set before a connection is attempted. It instructs the control to bind to a specific port (or communication endpoint) in the local machine.

Setting it to 0 (default) enables the control to choose a port at random. The chosen port will be shown by the LocalPort property after the connection is established.

LocalPort cannot be changed once a connection is made. Any attempt to set the LocalPort property when a connection is active will generate an error.

USe this property with caution. If you supply a value, it must be an available port on the system, or an error will be returned. Furthermore, the control always attempts to bind to a secure (sub 1000) port when the value of LocalPort is the default (0). If you supply your own value, make sure the remote system is configured to allow that particular value.


getPassword

public java.lang.String getPassword()
The password associated with User . This property needs to be set to the password that the RemoteHost has associated with the User . This property is needed only if the Protocol used is REXEC.


setPassword

public void setPassword(java.lang.String password)
                 throws IPWorksException
The password associated with User . This property needs to be set to the password that the RemoteHost has associated with the User . This property is needed only if the Protocol used is REXEC.


getProtocol

public int getProtocol()
Sets the protocol to use for the transfer. The Protocol property determines the protocol mechanism used to communicate with the remote host. It has two possible values:
protRexec (0)
The control uses the REXEC protocol is used for data transfer.
protRshell (1)
The control uses the RSHELL protocol is used for data transfer.
The default value is protRexec . ( protRshell is not genereally recommended because of potential security issues.)


setProtocol

public void setProtocol(int protocol)
                 throws IPWorksException
Sets the protocol to use for the transfer. The Protocol property determines the protocol mechanism used to communicate with the remote host. It has two possible values:
protRexec (0)
The control uses the REXEC protocol is used for data transfer.
protRshell (1)
The control uses the RSHELL protocol is used for data transfer.
The default value is protRexec . ( protRshell is not genereally recommended because of potential security issues.)


getRemoteFile

public java.lang.String getRemoteFile()
The file on the remote host. When the Action is 'Get File', this must be a valid file on the RemoteHost .


setRemoteFile

public void setRemoteFile(java.lang.String remoteFile)
                   throws IPWorksException
The file on the remote host. When the Action is 'Get File', this must be a valid file on the RemoteHost .


getRemoteHost

public java.lang.String getRemoteHost()
The remote host to connect to. Set this property to a valid Internet address of a computer that is running REXEC or RSHELL services. If the computer is not running the service that the Protocol property is set to, then the connection will fail.


setRemoteHost

public void setRemoteHost(java.lang.String remoteHost)
                   throws IPWorksException
The remote host to connect to. Set this property to a valid Internet address of a computer that is running REXEC or RSHELL services. If the computer is not running the service that the Protocol property is set to, then the connection will fail.


getRemotePort

public int getRemotePort()
The port for the service (REXEC or RSHELL). The value of RemotePort is set automatically to 512 for REXEC or 514 for RSHELL every time the Protocol property is set. Please refer to the description of the Protocol property for more information.


setRemotePort

public void setRemotePort(int remotePort)
                   throws IPWorksException
The port for the service (REXEC or RSHELL). The value of RemotePort is set automatically to 512 for REXEC or 514 for RSHELL every time the Protocol property is set. Please refer to the description of the Protocol property for more information.


getStderrPort

public int getStderrPort()
The local port where the remote systems sends the stderr stream. The default value is 0, which instructs the control to use a random port. Use this property with caution. If you supply a value, it must be an available port on the system, or an error will be returned.

Some systems do not support secondary stderr streams. Please refer to the EnableStderr property for more information.


setStderrPort

public void setStderrPort(int stderrPort)
                   throws IPWorksException
The local port where the remote systems sends the stderr stream. The default value is 0, which instructs the control to use a random port. Use this property with caution. If you supply a value, it must be an available port on the system, or an error will be returned.

Some systems do not support secondary stderr streams. Please refer to the EnableStderr property for more information.


getTimeout

public int getTimeout()
A timeout for the component. If the Timeout property is set to 0 (default value) all actions will run uninterrupted until succesful completion, or an error condition is encountered.

If Timeout is set to a positive value, and any action does not complete within Timeout seconds, the action is aborted, and a 'Timeout' error is fired..

The control will use DoEvents to enter an efficient wait loop during any potential waiting period, making sure that all system events are processed immediately as they arrive. This ensures that the host application does not "freeze" and always remains responsive.


setTimeout

public void setTimeout(int timeout)
                throws IPWorksException
A timeout for the component. If the Timeout property is set to 0 (default value) all actions will run uninterrupted until succesful completion, or an error condition is encountered.

If Timeout is set to a positive value, and any action does not complete within Timeout seconds, the action is aborted, and a 'Timeout' error is fired..

The control will use DoEvents to enter an efficient wait loop during any potential waiting period, making sure that all system events are processed immediately as they arrive. This ensures that the host application does not "freeze" and always remains responsive.


getUser

public java.lang.String getUser()
The identification of the remote user for a transfer. This identification is necessary for use with the protocols REXEC and RSHELL.


setUser

public void setUser(java.lang.String user)
             throws IPWorksException
The identification of the remote user for a transfer. This identification is necessary for use with the protocols REXEC and RSHELL.


fireConnected

public void fireConnected(int statusCode,
                          java.lang.String description)
Fired immediately after a connection completes (or fails). (Called internally to dispatch the event.)
See Also:
RcpConnectedEvent

fireDisconnected

public void fireDisconnected(int statusCode,
                             java.lang.String description)
Fired when a connection is closed. (Called internally to dispatch the event.)
See Also:
RcpDisconnectedEvent

fireError

public void fireError(int errorCode,
                      java.lang.String description)
Information about errors during data delivery. (Called internally to dispatch the event.)
See Also:
RcpErrorEvent

fireProgress

public void fireProgress(int percentDone)
Fired whenever data is being transferred between the localhost and RemoteHost . (Called internally to dispatch the event.)
See Also:
RcpProgressEvent

getFile

public void getFile()
             throws IPWorksException
Get File. A connection is made with the RemoteHost using the specified Protocol , User , and Password , and a request is sent to read the file specified by RemoteFile .

Calling this method is equivalent to setting the Action property to rcpGetFile .


interrupt

public void interrupt()
               throws IPWorksException
Interrupt the Action in progress (if any). Calling this method is equivalent to setting the Action property to Idle (0) .


putFile

public void putFile()
             throws IPWorksException
Put File A connection is made and a request is sent to copy LocalFile to the file specified by RemoteFile .

Calling this method is equivalent to setting the Action property to rcpPutFile .


addRcpEventListener

public void addRcpEventListener(RcpEventListener l)
                         throws java.util.TooManyListenersException

removeRcpEventListener

public void removeRcpEventListener(RcpEventListener l)

IP*Works!

Copyright (c) 2001 /n software inc. - All rights reserved.