|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.openuat.authentication.AuthenticationEventSender
org.openuat.authentication.DHWithVerification
org.openuat.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 a String 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 (String) represents the remote canonical host name 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 keepConnected 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 RemoteConnection object as its second entry when keepConnected has been set to true. The authentication failure and progress events to not go to these lengths and will return either a String object or an Integer object as the remote parameter, depending on the current stage of the Relate protocol when the event occurs.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.openuat.authentication.DHWithVerification |
|---|
DHWithVerification.HostAuthenticationEventHandler, DHWithVerification.StartVerificationHandler |
| Field Summary | |
|---|---|
static int |
KeyAgreementProtocolTimeout
Allow the (incoming) key agreement to take at maximum this amout of ms. |
static int |
TcpPort
|
| Fields inherited from class org.openuat.authentication.DHWithVerification |
|---|
instanceId, keyManager, server, useJSSE |
| Fields inherited from class org.openuat.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(boolean failHard,
RemoteConnection remote,
java.lang.Object optionalVerificationId,
java.lang.Exception e,
java.lang.String message)
Called by the base class when the whole authentication protocol failed. |
protected void |
protocolProgressHook(RemoteConnection remote,
int cur,
int max,
java.lang.String message)
Called by the base class when the whole authentication protocol shows progress. |
protected void |
protocolStartedHook(RemoteConnection remote)
This hook will be called when the whole authentication protocol has been started. |
protected void |
protocolSucceededHook(RemoteConnection remote,
java.lang.Object optionalVerificationId,
java.lang.String optionalParameterFromRemote,
byte[] sharedSessionKey)
Called by the base class when the whole authentication protocol succeeded. |
protected void |
resetHook(RemoteConnection remote)
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 |
startVerificationAsync(byte[] sharedAuthenticationKey,
java.lang.String param,
RemoteConnection toRemote)
Called by the base class when shared keys have been established and should be verified now. |
| Methods inherited from class org.openuat.authentication.DHWithVerification |
|---|
authenticationFailed, isIdle, reset, startAuthentication, startListening, stopListening, verificationFailure, verificationSuccess |
| Methods inherited from class org.openuat.authentication.AuthenticationEventSender |
|---|
addAuthenticationProgressHandler, raiseAuthenticationFailureEvent, raiseAuthenticationProgressEvent, raiseAuthenticationStartedEvent, raiseAuthenticationSuccessEvent, removeAuthenticationProgressHandler, setAuthenticationProgressHandlers |
| 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
public static final int KeyAgreementProtocolTimeout
| 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.openuat.authentication.AuthenticationProgressHandler),
DongleProtocolHandler.handleDongleCommunication(byte[], byte[], org.openuat.authentication.InterlockProtocol, org.openuat.authentication.InterlockProtocol)protected void resetHook(RemoteConnection remote)
resetHook in class DHWithVerification
protected void protocolSucceededHook(RemoteConnection remote,
java.lang.Object optionalVerificationId,
java.lang.String optionalParameterFromRemote,
byte[] sharedSessionKey)
protocolSucceededHook in class DHWithVerificationremote - The remote host with which the key exchange succeeded. If
it has not been requested that the connection should stay
open (keepConnectedOnSuccess==true), then this will be closed
immediately after the hook method returns.optionalVerificationId - If the key verification step yielded any
ID or reference that can be referred to, then this will be set.
It is directly forwarded through from the call to
verificationSuccess.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.
protected void protocolFailedHook(boolean failHard,
RemoteConnection remote,
java.lang.Object optionalVerificationId,
java.lang.Exception e,
java.lang.String message)
protocolFailedHook in class DHWithVerificationfailHard - If true, then the protocol has failed hard, meaning that
there can be no retry without another key agreement
protocol run. Key material will be wiped after this
hook returns.
If false, only a soft failure occurred, meaning that
the connection will be closed, but key material will
not be wiped yet. Retrying key verification (i.e.
authenticating the key agreement) will be possible.remote - The remote host with which the key exchange failed. If
it has not been requested that the connection should stay
open (keepConnectedOnFailure==true), then this will be closed
immediately after the hook method returns.optionalVerificationId - If the key verification step yielded any
ID or reference that can be referred to, then this will be set.
It is directly forwarded through from the call to
verificationSuccess or verificationFailed. If the protocol
already failed during key agreement (or the derived class did
not set the parameter), then this will be null.e - If not null, the exception describing the failure.message - If not null, the message describing the failure.
protected void protocolProgressHook(RemoteConnection remote,
int cur,
int max,
java.lang.String message)
protocolProgressHook in class DHWithVerificationremote - The remote host with which the key exchange progressed.cur - @see AuthenticationProgressHandler#AuthenticationProgressmax - @see AuthenticationProgressHandler#AuthenticationProgressmessage - @see AuthenticationProgressHandler#AuthenticationProgressprotected void protocolStartedHook(RemoteConnection remote)
DHWithVerification
protocolStartedHook in class DHWithVerificationremote - The remote host with which the key exchange started.
protected void startVerificationAsync(byte[] sharedAuthenticationKey,
java.lang.String param,
RemoteConnection toRemote)
startVerificationAsync in class DHWithVerificationsharedAuthenticationKey - This key should be verified to be equal on
both sides.param - Optional parameters sent by the remote host during the key agreement
phase.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 | ||||||||