com.limegroup.gnutella.handshaking
Class AuthenticationHandshakeResponder

java.lang.Object
  extended bycom.limegroup.gnutella.handshaking.AuthenticationHandshakeResponder
All Implemented Interfaces:
HandshakeResponder
Direct Known Subclasses:
LeafHandshakeResponder, UltrapeerHandshakeResponder

public abstract class AuthenticationHandshakeResponder
extends java.lang.Object
implements HandshakeResponder

An authentication-capable responder to be used during handshake. This is an abstract class, and provides only authentication capablities.

Concrete subclasses should implement the respondUnAuthenticated() method for the actual handshake (apart from authentication).

The public respond(response, outgoing) method should not be overwritten before taking this statement out.


Field Summary
protected  ConnectionManager _manager
          An instance of connection manager (to reference other stuff held by connection manager)
protected static boolean RECORD_STATS
           
 
Constructor Summary
AuthenticationHandshakeResponder(ConnectionManager manager, java.lang.String host)
          Creates a new instance
 
Method Summary
protected  java.lang.String getRemoteIP()
          Returns the Remote IP
 HandshakeResponse respond(HandshakeResponse response, boolean outgoing)
          Returns the corresponding handshake to be written to the remote host when responding to the connection handshake response just received.
protected abstract  HandshakeResponse respondUnauthenticated(HandshakeResponse response, boolean outgoing)
          Returns the corresponding handshake to be sent to the remote host when responding to the connection handshake response received.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RECORD_STATS

protected static final boolean RECORD_STATS

_manager

protected final ConnectionManager _manager
An instance of connection manager (to reference other stuff held by connection manager)

Constructor Detail

AuthenticationHandshakeResponder

public AuthenticationHandshakeResponder(ConnectionManager manager,
                                        java.lang.String host)
Creates a new instance

Parameters:
manager - Instance of connection manager, managing this connection
host - The host with whom we are handshaking
Method Detail

respond

public HandshakeResponse respond(HandshakeResponse response,
                                 boolean outgoing)
                          throws java.io.IOException
Description copied from interface: HandshakeResponder
Returns the corresponding handshake to be written to the remote host when responding to the connection handshake response just received. Implementations should respond differently to incoming vs. outgoing connections.

Specified by:
respond in interface HandshakeResponder
Parameters:
response - The response received from the host on the other side of teh connection.
outgoing - whether the connection to the remote host is an outgoing connection.
Throws:
java.io.IOException

getRemoteIP

protected java.lang.String getRemoteIP()
Returns the Remote IP


respondUnauthenticated

protected abstract HandshakeResponse respondUnauthenticated(HandshakeResponse response,
                                                            boolean outgoing)
                                                     throws java.io.IOException
Returns the corresponding handshake to be sent to the remote host when responding to the connection handshake response received.

Parameters:
response - The response received from the host on the other side of the connection.
outgoing - whether the connection to the remote host is an outgoing connection.
Returns:
the response to be sent to the remote host
Throws:
java.io.IOException