org.opensaml.util.storage
Class ReplayCache

java.lang.Object
  extended by org.opensaml.util.storage.ReplayCache

public class ReplayCache
extends Object

Class that uses an underlying StorageService to track information associated with messages in order to detect message replays. This class is thread-safe and uses a basic reentrant lock to avoid corruption of the underlying store, as well as to prevent race conditions with respect to replay checking.


Constructor Summary
ReplayCache(StorageService<String,ReplayCacheEntry> storageService, long duration)
          Constructor.
ReplayCache(StorageService<String,ReplayCacheEntry> storageService, String storageParition, long duration)
          Constructor.
 
Method Summary
protected  void addMessageID(String messageId, org.joda.time.DateTime expiration)
          Accquires a write lock and adds the message state to the underlying storage service.
 boolean isReplay(String issuerId, String messageId)
          Checks if the message has been replayed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplayCache

public ReplayCache(StorageService<String,ReplayCacheEntry> storageService,
                   long duration)
Constructor.

Parameters:
storageService - the StorageService which serves as the backing store for the cache
duration - default length of time that message state is valid

ReplayCache

public ReplayCache(StorageService<String,ReplayCacheEntry> storageService,
                   String storageParition,
                   long duration)
Constructor.

Parameters:
storageService - the StorageService which serves as the backing store for the cache
storageParition - name of storage service partition to use
duration - default length of time that message state is valid
Method Detail

isReplay

public boolean isReplay(String issuerId,
                        String messageId)
Checks if the message has been replayed. If the message has not been seen before then it is added to the list of seen of messages for the default duration.

Parameters:
issuerId - unique ID of the message issuer
messageId - unique ID of the message
Returns:
true if the given message ID has been seen before

addMessageID

protected void addMessageID(String messageId,
                            org.joda.time.DateTime expiration)
Accquires a write lock and adds the message state to the underlying storage service.

Parameters:
messageId - unique ID of the message
expiration - time the message state expires


Copyright © 2006-2013 Internet2. All Rights Reserved.