ostore.mac
Class MacHandler

java.lang.Object
  |
  +--ostore.mac.MacHandler
All Implemented Interfaces:
EventHandlerIF, ProfilableIF
Direct Known Subclasses:
HMACDHHandler, StubHandler

public abstract class MacHandler
extends Object
implements EventHandlerIF, ProfilableIF

MacHandler. Responsible for checking message authenticity and initializing 'first contact' with another OceanStore instance. The result being

(1) a MAC relationship established between both parties,

(2) a GUID exchange, and

(3) the source of your machine's GUID.

Additional details are implementation specific.

Note:There is to be only one MacHandler per instance of sandstorm.


Inner Class Summary
 class MacHandler.GuidNotEstablished
          Thrown when a request for action (such as authenticate(ostore.util.QuickSerializable, ostore.util.QSByteArray, ostore.util.SecureHash) or doMAC(ostore.util.QuickSerializable, ostore.util.SecureHash)) is called on a guid that doesn't have an established connection yet.
 class MacHandler.HandshakeFailed
          Announcement that after multiple retries, we were still unable to successfully establish a connection with the guid.
 class MacHandler.KeyEstablished
          Announcement that we have established a connection with the guid and are ready to call authenticate(ostore.util.QuickSerializable, ostore.util.QSByteArray, ostore.util.SecureHash) and doMAC(ostore.util.QuickSerializable, ostore.util.SecureHash) on that guid.
 
Field Summary
static boolean DEBUG
           
 
Constructor Summary
MacHandler()
           
 
Method Summary
abstract  boolean authenticate(QuickSerializable user_data, QSByteArray mac, SecureHash guid)
           
abstract  void destroy()
           
abstract  QSByteArray doMAC(QuickSerializable user_data, SecureHash guid)
          Computes the MAC code for the this message
abstract  void establish(SecureHash guid)
          Establish a connection between the guid and this instance of sandstorm

Once a connection is established, the MacHandler will broadcast a MacHandler.KeyEstablished announcement.
abstract  void handleEvent(QueueElementIF item)
           
 void handleEvents(QueueElementIF[] item)
           
abstract  String idString()
          Id String
abstract  void init(ConfigDataIF config)
           
abstract  SecureHash myGuid()
          My GUID
abstract  int profileSize()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final boolean DEBUG
Constructor Detail

MacHandler

public MacHandler()
Method Detail

handleEvent

public abstract void handleEvent(QueueElementIF item)
                          throws EventHandlerException
Specified by:
handleEvent in interface EventHandlerIF

handleEvents

public void handleEvents(QueueElementIF[] item)
                  throws EventHandlerException
Specified by:
handleEvents in interface EventHandlerIF

idString

public abstract String idString()
Id String

myGuid

public abstract SecureHash myGuid()
My GUID

establish

public abstract void establish(SecureHash guid)
Establish a connection between the guid and this instance of sandstorm

Once a connection is established, the MacHandler will broadcast a MacHandler.KeyEstablished announcement. If a connection is pending this will be ignored. If a connection to this guid is already established, a MacHandler.KeyEstablished will be broadcasted.

authenticate

public abstract boolean authenticate(QuickSerializable user_data,
                                     QSByteArray mac,
                                     SecureHash guid)
                              throws MacHandler.GuidNotEstablished
Returns:
true iff this message is authentic, i.e. verified by the internal MAC

doMAC

public abstract QSByteArray doMAC(QuickSerializable user_data,
                                  SecureHash guid)
                           throws MacHandler.GuidNotEstablished
Computes the MAC code for the this message
Returns:
true iff the MAC was computed successfully.

init

public abstract void init(ConfigDataIF config)
                   throws Exception
Specified by:
init in interface EventHandlerIF

destroy

public abstract void destroy()
                      throws Exception
Specified by:
destroy in interface EventHandlerIF

profileSize

public abstract int profileSize()
Specified by:
profileSize in interface ProfilableIF