com.mindbright.ssh2
Class SSH2TerminalAdapterImpl

java.lang.Object
  extended bycom.mindbright.terminal.TerminalInputChaff
      extended bycom.mindbright.ssh2.SSH2TerminalAdapterImpl
All Implemented Interfaces:
java.lang.Runnable, SSH2ChannelCloseListener, SSH2TerminalAdapter, TerminalInputListener

public class SSH2TerminalAdapterImpl
extends TerminalInputChaff
implements SSH2TerminalAdapter, SSH2ChannelCloseListener

Adapter class which interfaces between terminal windows and ssh2.


Constructor Summary
SSH2TerminalAdapterImpl(TerminalWindow terminal)
          Constructor.
 
Method Summary
 void attach(SSH2SessionChannel session)
          Attach the terminal to a session
 void closed(SSH2Channel channel)
          Called when the channel is closed.
 void detach()
          Detach from the session
 TerminalWindow getTerminal()
          Get the actual terminal window.
 void sendBreak()
          This function should be called by the actual terminal window whenever the user wants to send break.
 void sendBytes(byte[] b)
          Send a number of bytes.
protected  void sendFakeChar()
          Send a fake character.
protected  void sendTypedChar(int c)
          Send an actually typed character.
 void signalWindowChanged(int rows, int cols, int vpixels, int hpixels)
          This function should be called by the actual terminal window whenever it is resized.
 void startChaff()
          Starts sending chaff.
 void stopChaff()
          Stop sending chaff.
 
Methods inherited from class com.mindbright.terminal.TerminalInputChaff
dispenseChaff, isChaffActive, run, signalTermTypeChanged, typedChar, typedChar
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SSH2TerminalAdapterImpl

public SSH2TerminalAdapterImpl(TerminalWindow terminal)
Constructor.

Parameters:
terminal - Terminal window to use.
Method Detail

getTerminal

public TerminalWindow getTerminal()
Description copied from interface: SSH2TerminalAdapter
Get the actual terminal window.

Specified by:
getTerminal in interface SSH2TerminalAdapter
Returns:
The terminal interface.

attach

public void attach(SSH2SessionChannel session)
Description copied from interface: SSH2TerminalAdapter
Attach the terminal to a session

Specified by:
attach in interface SSH2TerminalAdapter
Parameters:
session - The session to attach to.

detach

public void detach()
Description copied from interface: SSH2TerminalAdapter
Detach from the session

Specified by:
detach in interface SSH2TerminalAdapter

startChaff

public void startChaff()
Description copied from interface: SSH2TerminalAdapter
Starts sending chaff. While chaffing is in operation the terminal sends packets at a constant rate. This hides the timing of the actual keypresses made by the user. It is mostly useful while passwords are enterd.

Specified by:
startChaff in interface SSH2TerminalAdapter
Overrides:
startChaff in class TerminalInputChaff

stopChaff

public void stopChaff()
Description copied from interface: SSH2TerminalAdapter
Stop sending chaff.

Specified by:
stopChaff in interface SSH2TerminalAdapter
Overrides:
stopChaff in class TerminalInputChaff

closed

public void closed(SSH2Channel channel)
Description copied from interface: SSH2ChannelCloseListener
Called when the channel is closed.

Specified by:
closed in interface SSH2ChannelCloseListener
Parameters:
channel - The channel which is closed

sendTypedChar

protected void sendTypedChar(int c)
Send an actually typed character.

Specified by:
sendTypedChar in class TerminalInputChaff
Parameters:
c - The typed character to send.

sendFakeChar

protected void sendFakeChar()
Send a fake character. Sends a packet which is the same size as a real keypress packet but it contains no data.

Specified by:
sendFakeChar in class TerminalInputChaff

sendBytes

public void sendBytes(byte[] b)
Send a number of bytes.

Specified by:
sendBytes in interface TerminalInputListener
Parameters:
b - Array of bytes to send.

signalWindowChanged

public void signalWindowChanged(int rows,
                                int cols,
                                int vpixels,
                                int hpixels)
This function should be called by the actual terminal window whenever it is resized.

Specified by:
signalWindowChanged in interface TerminalInputListener
Parameters:
rows - new number of rows
cols - new number of columns
vpixels - new number of vertical pixels
hpixels - new number of horizontal pixels

sendBreak

public void sendBreak()
This function should be called by the actual terminal window whenever the user wants to send break. A break length of 500ms is used, since most devices will recognize a break of that length.

Specified by:
sendBreak in interface TerminalInputListener
Overrides:
sendBreak in class TerminalInputChaff