SSH Factory

com.jscape.inet.ipclientssh
Class IpClientSsh

java.lang.Object
  extended bycom.jscape.inet.ipclient.IpClient
      extended bycom.jscape.inet.ipclientssh.IpClientSsh

public class IpClientSsh
extends IpClient

Implements basic functionality of a TCP/IP client connection tunnelling data through a secure SSH connection.

Example usage:

 

// connection information for SSH server String sshHostname = "10.0.0.1"; String sshUsername = "jsmith"; String sshPassword = "secret"; try { // create new SshParameters instance SshParameters sshParams = new SshParameters(sshHostname,sshUsername,sshPassword);

// create new IpClient instance with SSH parameters, hostname, port and timeout arguments IpClientSsh client = new IpClientSsh(sshParams,"10.0.0.1",53,5000);

// establish connection with server client.connect();

// obtain OutputStream for sending data to server OutputStream out = client.getOutputStream();

// obtain InputStream for reading data from server InputStream in = client.getInputStream();

// disconnect from server client.disconnect();

} catch(IpClientException ipe) { ipe.printStackTrace(); }


Constructor Summary
IpClientSsh(SshParameters sshParameters, java.lang.String hostname, int port)
          Creates a new IpClientSsh instance.
IpClientSsh(SshParameters sshParameters, java.lang.String hostname, int port, int timeout)
          Creates a new IpClientSsh instance.
IpClientSsh(SshParameters sshParameters, java.lang.String hostname, int port, int timeout, com.jscape.inet.ssh.SshConfiguration config)
           
 
Method Summary
 void connect()
          Establishes connection with SSH server, performs authentication and creates tunnel to hostname and port provided in constructor.
 void disconnect()
          Closes tunnel between SSH server and host and closes connection to SSH server.
 java.net.Socket getSocket()
          Gets Socket established after invoking the IpClient#connect method.
 
Methods inherited from class com.jscape.inet.ipclient.IpClient
addIpClientListener, getInputStream, getOutputStream, removeIpClientListener, setInputStream, setOutputStream, setSocket
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IpClientSsh

public IpClientSsh(SshParameters sshParameters,
                   java.lang.String hostname,
                   int port)
Creates a new IpClientSsh instance.

Parameters:
hostname - the hostname of server to connect to
port - the port of server to connect to
sshParameters - the SSH parameters used in establishing secure connection

IpClientSsh

public IpClientSsh(SshParameters sshParameters,
                   java.lang.String hostname,
                   int port,
                   int timeout)
Creates a new IpClientSsh instance.

Parameters:
hostname - the hostname of server to connect to
port - the port of server to connect to
timeout - the timeout period to wait before connection to server is established
sshParameters - the SSH parameters used in establishing secure connection

IpClientSsh

public IpClientSsh(SshParameters sshParameters,
                   java.lang.String hostname,
                   int port,
                   int timeout,
                   com.jscape.inet.ssh.SshConfiguration config)
Parameters:
sshParameters -
hostname -
port -
timeout -
config -
Method Detail

connect

public void connect()
             throws IpClientException
Establishes connection with SSH server, performs authentication and creates tunnel to hostname and port provided in constructor.

Overrides:
connect in class IpClient
Throws:
IpClientException - if an error occurs while establishing connection

disconnect

public void disconnect()
                throws IpClientException
Closes tunnel between SSH server and host and closes connection to SSH server.

Overrides:
disconnect in class IpClient
Throws:
IpClientException - if an I/O related error occurs

getSocket

public java.net.Socket getSocket()
Gets Socket established after invoking the IpClient#connect method.

Overrides:
getSocket in class IpClient
Returns:
a Socket
See Also:
connect()

SSH Factory

Copyright JSCAPE 2004 All Rights Reserved