SSH Factory

com.jscape.inet.ipclientssh
Class IpClientSsh

java.lang.Object
  extended by com.jscape.inet.ipclient.IpClient
      extended by com.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, SshConfiguration config)
          Creates new IpClientSsh instance.
 
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.
 SshHostKeys getHostKeys()
          Returns SSH host keys for further use.
 java.net.Socket getSocket()
          Gets Socket established after invoking the IpClient#connect method.
 
Methods inherited from class com.jscape.inet.ipclient.IpClient
addIpClientListener, clearProxySettings, getConnectTimeout, getInputStream, getOutputStream, getReadTimeout, removeIpClientListener, setConnectTimeout, setInputStream, setOutputStream, setProxyAuthentication, setProxyHost, setProxyType, setReadTimeout, 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,
                   SshConfiguration config)
Creates new IpClientSsh instance.

Parameters:
sshParameters - the SSH parameters used in establishing secure connection
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
config - configuration parameters
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()

getHostKeys

public SshHostKeys getHostKeys()
Returns SSH host keys for further use.

Returns:
SSH host keys or null if keys are not available

SSH Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved