Package org.passay.dictionary
Class BloomFilterDictionary
java.lang.Object
org.passay.dictionary.BloomFilterDictionary
- All Implemented Interfaces:
Dictionary
Dictionary that is backed by a Bloom Filter.
WARNING bloom filters may return true for a word that is NOT in the dictionary.
This implementation should only be used if false positives can be tolerated.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final com.google.common.hash.BloomFilter<CharSequence>Filter used for searching. -
Constructor Summary
ConstructorsConstructorDescriptionBloomFilterDictionary(com.google.common.hash.BloomFilter<CharSequence> filter) Creates a new dictionary instance from the suppliedBloomFilter. -
Method Summary
Modifier and TypeMethodDescriptioncom.google.common.hash.BloomFilter<CharSequence>Returns the bloom filter used for searching.booleansearch(CharSequence word) WARNING bloom filters may return true for a word that is NOT in the dictionary.longsize()Returns an estimate for the number of words added to the dictionary.toString()
-
Field Details
-
bloomFilter
Filter used for searching.
-
-
Constructor Details
-
BloomFilterDictionary
Creates a new dictionary instance from the suppliedBloomFilter. The fpp (false-positive probability) parameter of the given Bloom filter is a vitally important configuration concern. If it is too high, one risks user frustration due to rejection of valid passwords; if it is too low, one risks excessive storage costs. Finding the proper balance between acceptable user experience and storage costs is worth the time and effort required in testing. The Guava default value of 3% is likely unsuitable for many if not most deployments.- Parameters:
filter- bloom filter used to determine if a word exists.
-
-
Method Details
-
getBloomFilter
Returns the bloom filter used for searching.- Returns:
- bloom filter
-
size
public long size()Returns an estimate for the number of words added to the dictionary. SeeBloomFilter.approximateElementCount().- Specified by:
sizein interfaceDictionary- Returns:
- approximate number of words in the dictionary
-
search
WARNING bloom filters may return true for a word that is NOT in the dictionary. Please make sure you understand how bloom filters work before using this implementation. @see Bloom Filter andBloomFilter.mightContain(Object).- Specified by:
searchin interfaceDictionary- Parameters:
word- to search for- Returns:
- true if the word might be in the bloom filter, false if the word is definitely not in the bloom filter
-
toString
-