Package org.forgerock.openam.blacklist
Class BloomFilterBlacklist<T extends Blacklistable>
- java.lang.Object
-
- org.forgerock.openam.blacklist.BloomFilterBlacklist<T>
-
- Type Parameters:
T- The blacklist type.
- All Implemented Interfaces:
Blacklist<T>
public final class BloomFilterBlacklist<T extends Blacklistable> extends Object implements Blacklist<T>
A entry blacklist decorator implementation that uses a bloom filter to reduce the number of checks that need to be performed against the underlying blacklist implementation. The advantage of a bloom filter is that it can store very large blacklists (millions of entries) in memory, but with some possibility of false positives.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBloomFilterBlacklist.BlacklistEntryMinimal information about an entry required for blacklisting in the bloom filter.-
Nested classes/interfaces inherited from interface org.forgerock.openam.blacklist.Blacklist
Blacklist.Listener
-
-
Constructor Summary
Constructors Constructor Description BloomFilterBlacklist(Blacklist<T> delegate, long purgeDelayMs)Creates the bloom filter entry blacklist using the given delegate blacklist to confirm membership, and the given service configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidblacklist(T entry)Blacklists the given entry until its expiry time.booleanisBlacklisted(T entry)Determines whether the entry has previously been blacklisted.voidsubscribe(Blacklist.Listener listener)Subscribe for notifications when entries are blacklisted.
-
-
-
Constructor Detail
-
BloomFilterBlacklist
public BloomFilterBlacklist(Blacklist<T> delegate, long purgeDelayMs)
Creates the bloom filter entry blacklist using the given delegate blacklist to confirm membership, and the given service configuration. If the bloom filter does not contain a given entry, then we know for definite that it is not blacklisted. Otherwise, we delegate to the given entry blacklist to check if it actually is blacklisted or not, to eliminate false positives.In order to ensure that the bloom filter is kept in-sync with the definitive blacklist (to avoid false negatives), this implementation will subscribe to blacklist notifications from the delegate.
- Parameters:
delegate- the definitive blacklist.purgeDelayMs- The purge delay in milli seconds.
-
-
Method Detail
-
blacklist
public void blacklist(T entry) throws BlacklistException
Description copied from interface:BlacklistBlacklists the given entry until its expiry time.- Specified by:
blacklistin interfaceBlacklist<T extends Blacklistable>- Parameters:
entry- The blacklist entry.- Throws:
BlacklistException- if the entry cannot be blacklisted for any reason.
-
isBlacklisted
public boolean isBlacklisted(T entry) throws BlacklistException
Description copied from interface:BlacklistDetermines whether the entry has previously been blacklisted. Note: entries are only blacklisted until they expire, so afalseresult does not mean the entry is valid. Further checks should be made to establish entry validity.- Specified by:
isBlacklistedin interfaceBlacklist<T extends Blacklistable>- Parameters:
entry- The entry to check for blacklisting.- Returns:
trueif the entry is currently blacklisted, orfalseif the entry is not blacklisted or has expired (and therefore been removed from the blacklist).- Throws:
BlacklistException- if an error occurs when checking the blacklist.
-
subscribe
public void subscribe(Blacklist.Listener listener)
Description copied from interface:BlacklistSubscribe for notifications when entries are blacklisted. Depending on the implementation, this may include only entries blacklisted in the local machine, or also notifications for entries blacklisted on other nodes in the cluster.- Specified by:
subscribein interfaceBlacklist<T extends Blacklistable>- Parameters:
listener- the event listener to call when entries are blacklisted.
-
-