nan.ssh
Class SSHConnection

java.lang.Object
  extended bynan.ssh.SSHConnection

public class SSHConnection
extends java.lang.Object

A class to perform SSH services.

Version:
1.6, 1/4/04
Author:
John David Ratliff

Method Summary
 void close()
          Close the SSH connection.
 void connect(ServerSettings settings)
          Connects to the SSH server.
 void download(java.lang.String directory, java.lang.String filename)
          Downloads a file from the SSH server.
static SSHConnection getInstance()
          Returns the singleton instance of SSHConnection.
 boolean isConnected()
          Asks if we are connected to the SSH server.
 boolean isConnectedTo(java.lang.String hostname, int port)
          Asks if we are connected to a particular server on a particular port.
 boolean openTunnel(ServerSettings settings)
          Opens an SSH tunnel on this connection.
 java.lang.String toString()
          Returns a String representation of this object.
 void upload(java.lang.String directory, java.lang.String filename)
          Uploads a file to the SSH server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstance

public static SSHConnection getInstance()
Returns the singleton instance of SSHConnection.

Returns:
The only SSHConnection.

isConnected

public boolean isConnected()
Asks if we are connected to the SSH server.

Returns:
true if the connection is open; false otherwise.

isConnectedTo

public boolean isConnectedTo(java.lang.String hostname,
                             int port)
Asks if we are connected to a particular server on a particular port.

Parameters:
hostname - The hostname.
port - The port.
Returns:
true if an open connection exists to this server:port; false otherwise.

connect

public void connect(ServerSettings settings)
             throws SSHConnectException
Connects to the SSH server.

Parameters:
settings - The Settings used to connect.
Throws:
SSHConnectException - if the connection fails to establish.

close

public void close()
Close the SSH connection.


openTunnel

public boolean openTunnel(ServerSettings settings)
Opens an SSH tunnel on this connection.

Parameters:
settings - The Settings to use.
Returns:
true if the tunnel was opened; false otherwise.

upload

public void upload(java.lang.String directory,
                   java.lang.String filename)
Uploads a file to the SSH server.

Parameters:
directory - The server's directory.
filename - The filename to upload.

download

public void download(java.lang.String directory,
                     java.lang.String filename)
Downloads a file from the SSH server.

Parameters:
directory - The server's directory.
filename - The filename to download.

toString

public java.lang.String toString()
Returns a String representation of this object.

Returns:
A String representation.