|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.eu.mayrhofer.authentication.AuthenticationEventSender
org.eu.mayrhofer.authentication.DHOverTCPWithVerification
org.eu.mayrhofer.authentication.relate.RelateAuthenticationProtocol
public class RelateAuthenticationProtocol
This is the main class of the relate authentication software: it ties together the host and dongle protocol handlers. Since both handlers work asynchronously in their own threads, this class must also handle the synchronisation between all events coming in from them. It can generate two types of events of its own: as a subclass of AuthenticationEventSender, it sende AuthenticationEvents to all registered AuthenticationProgressHandler. Additionally, when a ProgressEventHandler object is given to the constructor, it will generate the more specific relate events. The authentication success event generated by this protocol will return an object array consisting of an InetAddress object and an Integer object for the remote parameter and either a byte or an object array as the result parameter. For the remote parameter, the first object (InetAddress) represents the remote host address, while the second object (Integer) represents the remote Relate id. The result parameter will contain only the session key as a byte array when keepSocketConnected has been set to false in the constructor, but will contain an Object array with the session key (again as a byte array) as its first entry and the TCP Socket object as its second entry when keepSocketConnected has been set to true. The authentication failure and progress events to not go to these lengths and will return either an InetAddress object or an Integer object as the remote parameter, depending on the current stage of the Relate protocol when the event occurs.
| Field Summary | |
|---|---|
static int |
TcpPort
|
| Fields inherited from class org.eu.mayrhofer.authentication.DHOverTCPWithVerification |
|---|
useJSSE |
| Fields inherited from class org.eu.mayrhofer.authentication.AuthenticationEventSender |
|---|
eventsHandlers |
| Constructor Summary | |
|---|---|
RelateAuthenticationProtocol(java.lang.String serialPort,
uk.ac.lancs.relate.core.MeasurementManager manager,
boolean useJSSE,
boolean keepSocketConnected,
uk.ac.lancs.relate.auth.ProgressEventHandler relateEventHandler)
Initialized the authentication object with the contact data of the remote device to authenticate with. |
|
| Method Summary | |
|---|---|
static void |
main(java.lang.String[] args)
|
protected void |
protocolFailedHook(java.net.InetAddress remote,
java.lang.Object optionalRemoteId,
java.lang.Exception e,
java.lang.String message)
Called by the base class when the whole authentication protocol failed. |
protected void |
protocolProgressHook(java.net.InetAddress remote,
java.lang.Object optionalRemoteId,
int cur,
int max,
java.lang.String message)
Called by the base class when the whole authentication protocol shows progress. |
protected void |
protocolSucceededHook(java.net.InetAddress remote,
java.lang.Object optionalRemoteId,
java.lang.String optionalParameterFromRemote,
byte[] sharedSessionKey,
java.net.Socket toRemote)
Called by the base class when the whole authentication protocol succeeded. |
protected void |
resetHook()
Called by the base class when the object is reset to idle state. |
static void |
setSimulationMode(boolean simulation)
|
boolean |
startAuthentication(java.lang.String remoteHost,
int remoteRelateId,
int rounds)
Starts the spatial authentication protocol in the background. |
protected void |
startVerification(byte[] sharedAuthenticationKey,
java.net.InetAddress remote,
java.lang.String param,
java.net.Socket socketToRemote)
Called by the base class when shared keys have been established and should be verified now. |
| Methods inherited from class org.eu.mayrhofer.authentication.DHOverTCPWithVerification |
|---|
isIdle, isVerifying, startAuthentication, startServer, stopServer, verificationFailure, verificationSuccess |
| 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 |
|---|
public static final int TcpPort
| Constructor Detail |
|---|
public RelateAuthenticationProtocol(java.lang.String serialPort,
uk.ac.lancs.relate.core.MeasurementManager manager,
boolean useJSSE,
boolean keepSocketConnected,
uk.ac.lancs.relate.auth.ProgressEventHandler relateEventHandler)
serialPort - The serial port to which the dongle is connectedmanager - The measurement manager to use. This manager should be registered at the dongle
that is connected to serialPort and should keep a history of the last measurement
received locally from this dongle. It will be used by RelateAuthenticationProtocol
to fetch the reference measurement before starting the spatial authentication
protocol.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.keepSocketConnected - If set to true, the opened client socket soc is passed to the
authentication success event (in the results parameter) for
further re-use of the connection (e.g. passing additional
information about further protocol steps). If set to false, the
socket will be closed when this protocol is done with it. The socket
will always be closed on authentication failures.
If in doubt, set to false;relateEventHandler - If set to an object != null, it will get notified of all events.| Method Detail |
|---|
public boolean startAuthentication(java.lang.String remoteHost,
int remoteRelateId,
int rounds)
throws java.net.UnknownHostException,
java.io.IOException
remoteHost - The hostname/IP address of the remote device to send an authentication request to.remoteRelateId - The relate id of the remote device. This is set by the client only
to enable stricter error checks. Trounds - The number of rounds that should be used for the dongle authentication. This
directly influences the achieved security level, as described in DongleProtocolHandler#handleDongleCommunication.
java.net.UnknownHostException
java.io.IOExceptionAuthenticationEventSender.addAuthenticationProgressHandler(org.eu.mayrhofer.authentication.AuthenticationProgressHandler),
DongleProtocolHandler.handleDongleCommunication(byte[], byte[], int, org.eu.mayrhofer.authentication.InterlockProtocol, org.eu.mayrhofer.authentication.InterlockProtocol)protected void resetHook()
resetHook in class DHOverTCPWithVerification
protected void protocolSucceededHook(java.net.InetAddress remote,
java.lang.Object optionalRemoteId,
java.lang.String optionalParameterFromRemote,
byte[] sharedSessionKey,
java.net.Socket toRemote)
protocolSucceededHook in class DHOverTCPWithVerificationremote - The remote host with which the key exchange succeeded.optionalRemoteId - An optional remote ID, exactly as it has been passed
to verificationSuccess. May be null.optionalParameterFromRemote - If the remote device reported an additional
parameter with its success message, it will
be put into this parameter. May be null.sharedSessionKey - The shared session key (which is different from the
shared authentication key used for verification) that
can now be used for subsequent secure communication.toRemote - If it has been requested that the socket to the remote host
should stay connected, it will be passed in this parameter.
May be null.
protected void protocolFailedHook(java.net.InetAddress remote,
java.lang.Object optionalRemoteId,
java.lang.Exception e,
java.lang.String message)
protocolFailedHook in class DHOverTCPWithVerificationremote - The remote host with which the key exchange succeeded.optionalRemoteId - An optional remote ID, exactly as it has been passed
to verificationSuccess or verificationFailure. May be null.e - If not null, the exception describing the failure.message - If not null, the message describing the failure.
protected void protocolProgressHook(java.net.InetAddress remote,
java.lang.Object optionalRemoteId,
int cur,
int max,
java.lang.String message)
protocolProgressHook in class DHOverTCPWithVerificationremote - The remote host with which the key exchange succeeded.optionalRemoteId - An optional remote ID, exactly as it has been passed
to verificationSuccess or verificationFailure. May be null.cur - @see AuthenticationProgressHandler#AuthenticationProgressmax - @see AuthenticationProgressHandler#AuthenticationProgressmessage - @see AuthenticationProgressHandler#AuthenticationProgress
protected void startVerification(byte[] sharedAuthenticationKey,
java.net.InetAddress remote,
java.lang.String param,
java.net.Socket socketToRemote)
startVerification in class DHOverTCPWithVerificationsharedAuthenticationKey - This key should be verified to be equal on
both sides.remote - The remote host with which the key exchange succeeded.param - Optional parameters sent by the remote host during the key agreement
phase.socketToRemote - This socket is still open and can be used to communicate
with the remote host for verifying the authentication
key. When it is used, care must be taken not to
consume any bytes from the remote end that are not expected
during verification, because the same channel will be
used for exchanging status information about the success
or failure of the whole authentication protocol.public static void setSimulationMode(boolean simulation)
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||