examples
Class BasicClient

java.lang.Object
  extended byjava.awt.event.WindowAdapter
      extended byexamples.BasicClient
All Implemented Interfaces:
java.util.EventListener, java.lang.Runnable, TerminalMenuListener, java.awt.event.WindowFocusListener, java.awt.event.WindowListener, java.awt.event.WindowStateListener

public final class BasicClient
extends java.awt.event.WindowAdapter
implements TerminalMenuListener, java.lang.Runnable

Ssh2 client which opens a terminal window and asks the user where to connect to.

Usage: java -cp examples.jar examples.BasicClient [props_file_name]

Username and password as well as server can be stored in the properties file.

It can also read portforwards from properties. Create properties named 'localN' or 'remoteN' where N is an integer 0-31. The contents of the properties is in the following format:

   [/plugin/][local_host:]local_port:remote_host:remote_port
 
This client understands the ftp and sniff plugins.

See Also:
SSH2FTPProxyFilter, SSH2StreamSniffer

Constructor Summary
BasicClient(java.util.Properties props)
          Simple constructor where all required properties have good default values so no properties have to be provided.
 
Method Summary
 void close(TerminalMenuHandler origMenu)
          Called when the user has selected close in the menu
 void doClose()
          Close the connection to the server (if any) in a controlled way.
 int getExitStatus()
          Get the exit status from the SSH2ConsoleRemote instance
static void main(java.lang.String[] argv)
          Run the application
static java.lang.Object[] parseForwardSpec(java.lang.String spec, java.lang.String listenAddr)
          Parse a portforward specification string
 void run()
          Actually runs the client.
 void update()
          Called when the menu is updated
 void windowClosing(java.awt.event.WindowEvent e)
          Overide corresponding function in java.awt.event.WindowAdapter
 
Methods inherited from class java.awt.event.WindowAdapter
windowActivated, windowClosed, windowDeactivated, windowDeiconified, windowGainedFocus, windowIconified, windowLostFocus, windowOpened, windowStateChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicClient

public BasicClient(java.util.Properties props)
Simple constructor where all required properties have good default values so no properties have to be provided. However the properties is the only way to change the encryption algorithms etc in this client.

Parameters:
props - SSH2 protocol properties.
Method Detail

run

public void run()
Actually runs the client. This gets called from the main function.

Specified by:
run in interface java.lang.Runnable

getExitStatus

public int getExitStatus()
Get the exit status from the SSH2ConsoleRemote instance

Returns:
the exit status

parseForwardSpec

public static java.lang.Object[] parseForwardSpec(java.lang.String spec,
                                                  java.lang.String listenAddr)
                                           throws java.lang.IllegalArgumentException
Parse a portforward specification string

Throws:
java.lang.IllegalArgumentException

doClose

public void doClose()
Close the connection to the server (if any) in a controlled way.


windowClosing

public void windowClosing(java.awt.event.WindowEvent e)
Overide corresponding function in java.awt.event.WindowAdapter

Specified by:
windowClosing in interface java.awt.event.WindowListener

close

public void close(TerminalMenuHandler origMenu)
Description copied from interface: TerminalMenuListener
Called when the user has selected close in the menu

Specified by:
close in interface TerminalMenuListener
Parameters:
origMenu - the menu where close was selected

update

public void update()
Description copied from interface: TerminalMenuListener
Called when the menu is updated

Specified by:
update in interface TerminalMenuListener

main

public static void main(java.lang.String[] argv)
Run the application