com.mindbright.ssh2
Interface SSH2ConnectionEventHandler

All Known Implementing Classes:
SSH2ConnectionEventAdapter

public interface SSH2ConnectionEventHandler

This interface is an event callback interface used to monitor the connection layer of an ssh2 connection. It is used with the class SSH2Connection to get info on the progress and status of all forwards and resulting channels through the connection.

All callback methods which indicates channel open confirmation or channel open failure uses the naming convention that when it begins with "local" (e.g. localDirectConnect) it is coupled to a channel originating locally and conversly when it begins with "remote" (e.g. remoteForwardedConnect) it is coupled to a channel originating remotely. The naming of the channel types in the connection protocol specification is used to identify whether a channel is a local forward or a remote forward. This means that local forwards are called "direct" and remote forwards are called "forwarded". This naming can be somewhat confusing for example the method localForwardedConnect might be the one might expect to be called when a local forward channel is confirmed to be open, instead the call is localDirectConnect. The reason for this is to have a symmetrical naming for all callbacks which are valid on both client and server side, hence check each callback and see if it applies to youe need (i.e. client or server).

See Also:
SSH2Connection, SSH2ConnectionEventAdapter, SSH2Listener, SSH2Channel

Method Summary
 void channelAdded(SSH2Connection connection, SSH2Channel channel)
          Called when a new channel is added (i.e.
 void channelClosed(SSH2Connection connection, SSH2Channel channel)
          Called when a channel is closed (i.e.
 void channelConnect(java.lang.Object originator, SSH2Channel channel, java.net.Socket fwdSocket)
          Called when a channel is connected to a Socket.
 void channelDeleted(SSH2Connection connection, SSH2Channel channel)
          Called when a channel is deleted (i.e.
 boolean listenerAccept(SSH2Listener listener, java.net.Socket fwdSocket)
          Called when a listener accepts a new connection (i.e.
 void localChannelOpenFailure(SSH2Connection connection, SSH2Channel channel, int reasonCode, java.lang.String reasonText, java.lang.String languageTag)
          Called on either side when a locally originating channel gets a channel open failure indication from peer.
 void localDirectConnect(SSH2Connection connection, SSH2Listener listener, SSH2Channel channel)
          Called on the client side when a local forward channel is confirmed to be open.
 void localForwardedConnect(SSH2Connection connection, SSH2Listener listener, SSH2Channel channel)
          Called on the server side when a remote forward channel is confirmed to be open.
 void localSessionConnect(SSH2Connection connection, SSH2Channel channel)
          Called on the client side when a session channel is confirmed to be open.
 void localX11Connect(SSH2Connection connection, SSH2Listener listener, SSH2Channel channel)
          Called on the server side when an X11 channel is confirmed to be open.
 void remoteChannelOpenFailure(SSH2Connection connection, java.lang.String channelType, java.lang.String targetAddr, int targetPort, java.lang.String originAddr, int originPort, SSH2Exception cause)
          Called on either side when there is a problem opening a remotely originating channel resulting in a channel open failure indication beeing sent back to peer.
 void remoteDirectConnect(SSH2Connection connection, SSH2Channel channel)
          Called on the client side when a remote direct channel has been confirmed to be open.
 void remoteForwardedConnect(SSH2Connection connection, java.lang.String remoteAddr, int remotePort, SSH2Channel channel)
          Called on the client side when a remote forward channel has been confirmed to be open.
 void remoteSessionConnect(SSH2Connection connection, java.lang.String remoteAddr, int remotePort, SSH2Channel channel)
          Called on the client side when a remote session channel has been confirmed to be open.
 void remoteX11Connect(SSH2Connection connection, SSH2Channel channel)
          Called on the client side when a remote X11 channel has been confirmed to be open.
 void setSocketOptions(int channelType, java.net.Socket s)
          Called to set socket options on newly connected port forward channels
 

Method Detail

channelAdded

public void channelAdded(SSH2Connection connection,
                         SSH2Channel channel)
Called when a new channel is added (i.e. a new channel has been opened through a port forward).

Parameters:
connection - the connection layer responsible
channel - the channel which was added

channelDeleted

public void channelDeleted(SSH2Connection connection,
                           SSH2Channel channel)
Called when a channel is deleted (i.e. a channel has been finally removed).

Parameters:
connection - the connection layer responsible
channel - the channel which was deleted

channelConnect

public void channelConnect(java.lang.Object originator,
                           SSH2Channel channel,
                           java.net.Socket fwdSocket)
Called when a channel is connected to a Socket.

Parameters:
originator - the responsible listener/connector
channel - the created channel
fwdSocket - the socket which is connected to

channelClosed

public void channelClosed(SSH2Connection connection,
                          SSH2Channel channel)
Called when a channel is closed (i.e. the channel has been closed and will be flushed and then removed).

Parameters:
connection - the connection layer responsible
channel - the channel which was deleted

listenerAccept

public boolean listenerAccept(SSH2Listener listener,
                              java.net.Socket fwdSocket)
Called when a listener accepts a new connection (i.e. a local forward is opened). This callback indicates if a connection should be handled or not by returning true or false.

Parameters:
listener - the responsible listener
fwdSocket - the socket which resulted
Returns:
boolean indicating wether to process connection or not.

localForwardedConnect

public void localForwardedConnect(SSH2Connection connection,
                                  SSH2Listener listener,
                                  SSH2Channel channel)
Called on the server side when a remote forward channel is confirmed to be open.

Parameters:
connection - the connection layer responsible
listener - the responsible listener
channel - the channel which was opened

localDirectConnect

public void localDirectConnect(SSH2Connection connection,
                               SSH2Listener listener,
                               SSH2Channel channel)
Called on the client side when a local forward channel is confirmed to be open.

Parameters:
connection - the connection layer responsible
listener - the responsible listener
channel - the channel which was opened

localSessionConnect

public void localSessionConnect(SSH2Connection connection,
                                SSH2Channel channel)
Called on the client side when a session channel is confirmed to be open.

Parameters:
connection - the connection layer responsible
channel - the channel which was opened

localX11Connect

public void localX11Connect(SSH2Connection connection,
                            SSH2Listener listener,
                            SSH2Channel channel)
Called on the server side when an X11 channel is confirmed to be open.

Parameters:
connection - the connection layer responsible
listener - the responsible listener
channel - the channel which was opened

localChannelOpenFailure

public void localChannelOpenFailure(SSH2Connection connection,
                                    SSH2Channel channel,
                                    int reasonCode,
                                    java.lang.String reasonText,
                                    java.lang.String languageTag)
Called on either side when a locally originating channel gets a channel open failure indication from peer. See the class SSH2 for reason codes.

Parameters:
connection - the connection layer responsible
channel - the channel which was opened
reasonCode - the reason code
reasonText -
languageTag -
See Also:
SSH2

remoteForwardedConnect

public void remoteForwardedConnect(SSH2Connection connection,
                                   java.lang.String remoteAddr,
                                   int remotePort,
                                   SSH2Channel channel)
Called on the client side when a remote forward channel has been confirmed to be open.

Parameters:
connection - the connection layer responsible
remoteAddr -
remotePort -
channel - the channel which was opened

remoteDirectConnect

public void remoteDirectConnect(SSH2Connection connection,
                                SSH2Channel channel)
Called on the client side when a remote direct channel has been confirmed to be open.

Parameters:
connection - the connection layer responsible
channel - the channel which was opened

remoteSessionConnect

public void remoteSessionConnect(SSH2Connection connection,
                                 java.lang.String remoteAddr,
                                 int remotePort,
                                 SSH2Channel channel)
Called on the client side when a remote session channel has been confirmed to be open.

Parameters:
connection - the connection layer responsible
remoteAddr -
remotePort -
channel - the channel which was opened

remoteX11Connect

public void remoteX11Connect(SSH2Connection connection,
                             SSH2Channel channel)
Called on the client side when a remote X11 channel has been confirmed to be open.

Parameters:
connection - the connection layer responsible
channel - the channel which was opened

remoteChannelOpenFailure

public void remoteChannelOpenFailure(SSH2Connection connection,
                                     java.lang.String channelType,
                                     java.lang.String targetAddr,
                                     int targetPort,
                                     java.lang.String originAddr,
                                     int originPort,
                                     SSH2Exception cause)
Called on either side when there is a problem opening a remotely originating channel resulting in a channel open failure indication beeing sent back to peer. The exception which was the cause of the problem is provided aswell as the type of channel and relevant addresses and ports.

Parameters:
connection - the connection layer responsible
channelType - the type of channel
targetAddr - the address which should have been connected to
targetPort - the port which should have been connected to
originAddr - the address where the channel originated (depends on type)
originPort - the port where the channel originated (depends on type)
cause - the exception which was the cause of the problem

setSocketOptions

public void setSocketOptions(int channelType,
                             java.net.Socket s)
Called to set socket options on newly connected port forward channels

Parameters:
channelType - the type of the channel
s - socket to manipulate