messageProcessor
Class ReplayDetection

java.lang.Object
  extended by messageProcessor.ReplayDetection

 class ReplayDetection
extends java.lang.Object

Detects whether a message has already been processed, or not. Detection is done using timestamps and hash tables.

This class is thread-safe (but parallel execution won't increase performance).

Author:
Karl-Peter Fuchs

Field Summary
private static NetworkClockController clock
          Reference on component NetworkClock used to validate timestamps.
private  float DB_LOAD_FACTOR
          The load factor for the hash tables replayDatabase1 and replayDatabase2.
private  int INITIAL_DB_CAPACITY
          Number of items the database for replay detection should approximately hold.
private static InternalInformationPortController internalInformationPort
          Reference on InternalInformationPort.
private  long lastDBSwitch
          Point of time, the databases were switched (and one got replaced) lastly.
private static java.util.logging.Logger LOGGER
          Logger used to log and display information.
private  long MAX_DELAY
          Time after which a message is considered as out of date in ms.
private  java.util.Hashtable<java.lang.Integer,byte[]> replayDatabase1
          First replay database.
private  java.util.Hashtable<java.lang.Integer,byte[]> replayDatabase2
          Second replay database.
private  long TOLERANCE
          Maximum divergence between mix' and client's clock in ms.
private  boolean writeToDB1
          Indicates weather to write in the first or second replay database.
 
Constructor Summary
protected ReplayDetection()
          Loads values from property file and initializes hash tables.
 
Method Summary
private  boolean isAlreadyInDB(java.lang.Integer key, byte[] value)
          Detects whether a key is in one of the databases or not.
protected  boolean isReplay(BasicMessage basicMessage)
          Detects whether a message has already been processed, or not.
private  boolean isReplay(java.lang.Integer key, byte[] value, long timestamp)
          Detects whether a message has already been processed, or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

internalInformationPort

private static InternalInformationPortController internalInformationPort
Reference on InternalInformationPort. Used to display and/or log data and read general settings.


LOGGER

private static final java.util.logging.Logger LOGGER
Logger used to log and display information.


clock

private static NetworkClockController clock
Reference on component NetworkClock used to validate timestamps.


INITIAL_DB_CAPACITY

private final int INITIAL_DB_CAPACITY
Number of items the database for replay detection should approximately hold.


DB_LOAD_FACTOR

private final float DB_LOAD_FACTOR
The load factor for the hash tables replayDatabase1 and replayDatabase2.


TOLERANCE

private final long TOLERANCE
Maximum divergence between mix' and client's clock in ms.


MAX_DELAY

private final long MAX_DELAY
Time after which a message is considered as out of date in ms.


replayDatabase1

private java.util.Hashtable<java.lang.Integer,byte[]> replayDatabase1
First replay database.


replayDatabase2

private java.util.Hashtable<java.lang.Integer,byte[]> replayDatabase2
Second replay database.


lastDBSwitch

private long lastDBSwitch
Point of time, the databases were switched (and one got replaced) lastly.


writeToDB1

private boolean writeToDB1
Indicates weather to write in the first or second replay database.

Constructor Detail

ReplayDetection

protected ReplayDetection()
Loads values from property file and initializes hash tables.

Method Detail

isReplay

protected boolean isReplay(BasicMessage basicMessage)
Detects whether a message has already been processed, or not. Detection is done using timestamps and hash tables.

Parameters:
basicMessage - The message to be checked.
Returns:
Indicates whether the bypasses message is a replay or not.

isReplay

private boolean isReplay(java.lang.Integer key,
                         byte[] value,
                         long timestamp)
Detects whether a message has already been processed, or not. Detection is done using timestamps and hash tables.

Parameters:
key - The message's key in the hash table.
value - The message's value in the hash table.
timestamp - The message's timestamp.
Returns:
Indicates whether the bypasses message is a replay or not.

isAlreadyInDB

private boolean isAlreadyInDB(java.lang.Integer key,
                              byte[] value)
Detects whether a key is in one of the databases or not.

Parameters:
key - The key to be checked.
Returns:
Indicates whether the bypasses key is in one of the databases or not