|
|||||||||
| 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.KeyManager
public class KeyManager
This class manages shared secret keys. It assumes that up to two keys are shared with a remote host, an authentication key and a session key for further secure communication. Remote hosts are identified by their RemoteConnection objects, which must implement proper equals() methods. Note that RemoteConnection objects are used primarily for identification purposes, but also for communication with the remote host. A caller may not assume that the RemoteConnection reference can be used to communicate at all times - the respective channel may have been closed. A remote host can, as far as this class is concerned, be in one of the following states:
| Nested Class Summary | |
|---|---|
static interface |
KeyManager.VerificationHandler
This interface must be implemented by classes used for key verification. |
| Field Summary | |
|---|---|
protected java.lang.String |
instanceId
This may be set to distinguish multiple instances running on the same machine. |
static int |
STATE_FAILED
Possible state, indicates that the whole authentication protocol has failed. |
static int |
STATE_IDLE
Possible state, indicates that the authentication has not been started yet. |
static int |
STATE_KEY_AGREEMENT
Possible state, indicates that the host authentication is running. |
static int |
STATE_NONEXISTANT
Possible state, indicates that nothing is known about this host. |
static int |
STATE_SUCCEEDED
Possible state, indicates that the whole authentication protocol has been completed successfully. |
static int |
STATE_VERIFICATION
Possible state, indicates that the key verification is running (and the key agreement has thus implicitly been completed successfully). |
| Fields inherited from class org.openuat.authentication.AuthenticationEventSender |
|---|
eventsHandlers |
| Constructor Summary | |
|---|---|
KeyManager(boolean concurrentVerificationSupported,
java.lang.String instanceId)
Initializes the key manager. |
|
| Method Summary | |
|---|---|
void |
addVerificationHandler(KeyManager.VerificationHandler listener)
Register a listener for verification events. |
void |
dispose()
Wipes all key material by calling wipe(). |
boolean |
fail(RemoteConnection host)
Sets a remote host to STATE_FAILED. |
byte[] |
getAuthenticationKey(RemoteConnection host)
Returns the authentication key for a remote host. |
AuthenticationProgressHandler |
getHostAuthenticationHandler()
Returns an implementation of AuthenticationProgressHandler that should be registered with a HostProtocolHandler so that KeyManager will receive the keys that are agreed to. |
RemoteConnection[] |
getHostsInState(int state)
This method returns all host reference for hosts that are in the requested state. |
java.lang.Object |
getOptionalRemoteReference(RemoteConnection host)
Returns the optional remote reference for a remote host. |
byte[] |
getSessionKey(RemoteConnection host)
Returns the session key for a remote host. |
int |
getState(RemoteConnection host)
Returns the current state of a remote host. |
boolean |
isConcurrentVerificationSupported()
Simply returns the value of concurrentVerificationSupported passed to the constructor. |
boolean |
isIdle()
This method returns true if and only if no remote host is currently in states STATE_KEY_AGREEMENT, STATE_VERIFICATION, or STATE_FAILED. |
boolean |
removeVerificationHandler(KeyManager.VerificationHandler listener)
De-register a listener for verification events. |
boolean |
reset(RemoteConnection host)
Sets a remote host to STATE_IDLE. |
void |
setOptionalRemoteReference(RemoteConnection host,
java.lang.Object optionalRemoteReference)
Returns the optional remote reference for a remote host. |
boolean |
startKeyAgreement(RemoteConnection host)
Sets a remote host to STATE_KEY_AGREEMENT. |
boolean |
succeed(RemoteConnection host)
Sets a remote host to STATE_SUCCEEDED. |
void |
wipe()
Wipes all key material by calling wipe() on each State object. |
| 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 STATE_NONEXISTANT
public static final int STATE_IDLE
public static final int STATE_KEY_AGREEMENT
public static final int STATE_VERIFICATION
public static final int STATE_SUCCEEDED
public static final int STATE_FAILED
protected java.lang.String instanceId
| Constructor Detail |
|---|
public KeyManager(boolean concurrentVerificationSupported,
java.lang.String instanceId)
concurrentVerificationSupported - If set to false, then only one
remote host can be in STATE_VERIFICATION at any time. This can
be used when the sensor hardware used for key verification can
only interact with one remote host at the same time.instanceId - This parameter may be used to distinguish different instances of
this class running on the same machine. It will be used in logging
and error messages. May be set to null.| Method Detail |
|---|
public void addVerificationHandler(KeyManager.VerificationHandler listener)
public boolean removeVerificationHandler(KeyManager.VerificationHandler listener)
public int getState(RemoteConnection host)
public boolean isConcurrentVerificationSupported()
public AuthenticationProgressHandler getHostAuthenticationHandler()
public boolean isIdle()
concurrentVerificationSupportedpublic RemoteConnection[] getHostsInState(int state)
state - One of STATE_NONEXISTANT, STATE_IDLE, STATE_KEY_AGREEMENT,
STATE_VERIFICATION, STATE_SUCCEEDED, STATE_FAILED.
java.lang.IllegalArgumentException - if state < STATE_IDLE or state > STATE_FAILED.public boolean succeed(RemoteConnection host)
host - The host to succeed.
public boolean startKeyAgreement(RemoteConnection host)
host - The host to reset.
public boolean fail(RemoteConnection host)
host - The host to fail.
public boolean reset(RemoteConnection host)
host - The host to reset.
public byte[] getAuthenticationKey(RemoteConnection host)
host - The remote host to retrieve the authentication key for.
public byte[] getSessionKey(RemoteConnection host)
host - The remote host to retrieve the session key for.
public java.lang.Object getOptionalRemoteReference(RemoteConnection host)
host - The remote host to retrieve the optional remote reference.
public void setOptionalRemoteReference(RemoteConnection host,
java.lang.Object optionalRemoteReference)
host - The remote host to retrieve the optional remote reference.public void dispose()
public void wipe()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||