com.maverick.ssh
Interface ForwardingRequestListener


public interface ForwardingRequestListener

This interface is required when a request for remote port forwarding is made. The methods enable you to establish a connection to the host and initialize the forwarding channel before it is opened.

Author:
Lee David Painter

Method Summary
 SshTransport createConnection(java.lang.String hostToConnect, int portToConnect)
          Create a connection to the specified host.
 void initializeTunnel(SshTunnel tunnel)
          Called once a connection has been established and a forwarding channel is about to be opened.
 

Method Detail

createConnection

public SshTransport createConnection(java.lang.String hostToConnect,
                                     int portToConnect)
                              throws SshException
Create a connection to the specified host. When requesting remote forwarding you specify the host and port to which incoming connections are bound. This method should create a connection to the host and return an SshTransport implementation.

Parameters:
hostToConnect -
portToConnect -
Returns:
Throws:
SshException
See Also:
SshTransport

initializeTunnel

public void initializeTunnel(SshTunnel tunnel)
Called once a connection has been established and a forwarding channel is about to be opened. Please note that the channel IS NOT open when this method is called and therefore cannot be used to start transfering data. This provides you with the ability to configure the channel, for instance by adding a ChannelEventListener to activate the channel once it has been opened.
 public void initializeTunnel(SshTunnel tunnel) {
    tunnel.addChannelEventListener(new ChannelAdapter() {
         public void channelOpened(SshChannel channel) {

           // Cast the channel into a tunnel
           SshTunnel tunnel = (SshTunnel)channel;

           // Create a pair of IOStreamConnectors to transfer the data
           IOStreamConnector tx = new IOStreamConnector();
 	         tx.connect(tunnel.getInputStream(),
                      tunnel.getTransport().getOutputStream());

           IOStreamConnector rx = new IOStreamConnector();
           tx.connect(tunnel.getTransport().getInputStream(),
                      tunnel.getOutputStream());
       }
 	  });
 }
 

Parameters:
tunnel -


Copyright © 2003 3SP LTD. All Rights Reserved.