org.eu.mayrhofer.authentication
Class HostProtocolHandler

java.lang.Object
  extended by org.eu.mayrhofer.authentication.AuthenticationEventSender
      extended by org.eu.mayrhofer.authentication.HostProtocolHandler

public class HostProtocolHandler
extends AuthenticationEventSender

This class handles the key agreement protocol between two hosts on the TCP/IP level. It implements both sides of the protocol, allowing to handle incoming connections (i.e. incoming authentication requests) as well as initiating outgoing connections (i.e. outgoing authentication requests). Events are raised upon authentication success, failure and during the progress of an authentication protocol. The authentication success event generated by this protocol will return an InetAddress object for the remote parameter and an Object array as the result parameter. This object array will always have at least 3 objects: two byte arrays representing the session key and the authentication key and a String representing the optional parameter that might have been specified by the client or which might have been passed to the protocol when in client mode. This third object in the object array can be null if no parameter was specified, but it will always be there. An optional fourth object will be included with the array when the keepSocketConnected flag was set. This fourth paramater will then contain the still connected socket object.

Version:
1.0
Author:
Rene Mayrhofer

Field Summary
static int AuthenticationStages
          At the moment, the whole protocol consists of 4 stages.
static java.lang.String Protocol_AuthenticationAcknowledge
           
static java.lang.String Protocol_AuthenticationRequest
           
static java.lang.String Protocol_AuthenticationRequest_Param
          This is an optional field in the authentication request line, where the client can pass parameters to the next authentication protocol.
static java.lang.String Protocol_Hello
          These are the messages of the ASCII authentication protocol.
 
Fields inherited from class org.eu.mayrhofer.authentication.AuthenticationEventSender
eventsHandlers
 
Method Summary
static void startAuthenticationWith(java.lang.String remoteAddress, int remotePort, AuthenticationProgressHandler eventHandler, boolean keepSocketConnected, java.lang.String optionalParameter, boolean useJSSE)
          Outgoing authentication connections are done asynchronously just like the incoming connections.
 
Methods inherited from class org.eu.mayrhofer.authentication.AuthenticationEventSender
addAuthenticationProgressHandler, raiseAuthenticationFailureEvent, raiseAuthenticationProgressEvent, raiseAuthenticationSuccessEvent, removeAuthenticationProgressHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Protocol_Hello

public static final java.lang.String Protocol_Hello
These are the messages of the ASCII authentication protocol.

See Also:
Constant Field Values

Protocol_AuthenticationRequest

public static final java.lang.String Protocol_AuthenticationRequest
See Also:
Protocol_Hello, Constant Field Values

Protocol_AuthenticationRequest_Param

public static final java.lang.String Protocol_AuthenticationRequest_Param
This is an optional field in the authentication request line, where the client can pass parameters to the next authentication protocol.

See Also:
Protocol_AuthenticationRequest, Constant Field Values

Protocol_AuthenticationAcknowledge

public static final java.lang.String Protocol_AuthenticationAcknowledge
See Also:
Protocol_Hello, Constant Field Values

AuthenticationStages

public static final int AuthenticationStages
At the moment, the whole protocol consists of 4 stages.

See Also:
Constant Field Values
Method Detail

startAuthenticationWith

public static void startAuthenticationWith(java.lang.String remoteAddress,
                                           int remotePort,
                                           AuthenticationProgressHandler eventHandler,
                                           boolean keepSocketConnected,
                                           java.lang.String optionalParameter,
                                           boolean useJSSE)
                                    throws java.net.UnknownHostException,
                                           java.io.IOException
Outgoing authentication connections are done asynchronously just like the incoming connections. This method starts a new thread that tries to authenticate with the host given as remote. Callers need to subscribe to the Authentication* events to get notifications of authentication success, failure and progress.

Parameters:
remoteAddress - The remote host to try to connect to.
remotePort - The remote TCP port to try to connect to.
eventHandler - The event handler that should be notified of authentication events. Can be null (in which case no events are sent). If not null, it will be registered with a new HostProtocolHandler object before starting the authentication protocol so that it is guaranteed that all events are posted to the event handler.
keepSocketConnected - When set to true, the socket created in this method is not closed but passed to the authentation success event for further reuse.
optionalParameter - If not null, this string will be passed to the server in the authentication request message. Both the server and the client will then subsequently forward this string in their authentication success message. This parameter must be encoded in 7-bit ASCII and must not contain spaces.
useJSSE - If set to true, the JSSE API with the default JCE provider of the JVM will be used for cryptographic operations. If set to false, an internal copy of the Bouncycastle Lightweight API classes will be used.
Throws:
java.net.UnknownHostException
java.io.IOException


2005-2006, Rene Mayrhofer.