diff --git a/src/main/java/me/gosimple/nbvcxz/matching/DateMatcher.java b/src/main/java/me/gosimple/nbvcxz/matching/DateMatcher.java index 3906008..77dd0b9 100644 --- a/src/main/java/me/gosimple/nbvcxz/matching/DateMatcher.java +++ b/src/main/java/me/gosimple/nbvcxz/matching/DateMatcher.java @@ -226,7 +226,7 @@ private static ValidDateSplit isDateValid(String day, String month, String year) } } - public List match(final Configuration configuration, final String password, String... userInput) + public List match(final Configuration configuration, final String password, final String... userInput) { List dateMatches = new ArrayList<>(); diff --git a/src/main/java/me/gosimple/nbvcxz/matching/DictionaryMatcher.java b/src/main/java/me/gosimple/nbvcxz/matching/DictionaryMatcher.java index 3ef275e..40e2581 100644 --- a/src/main/java/me/gosimple/nbvcxz/matching/DictionaryMatcher.java +++ b/src/main/java/me/gosimple/nbvcxz/matching/DictionaryMatcher.java @@ -262,7 +262,7 @@ else if (m == 0) return -1; } - public List match(final Configuration configuration, final String password, String... userInput) + public List match(final Configuration configuration, final String password, final String... userInput) { DictionaryBuilder userInputBuilder = new DictionaryBuilder() .setDictionaryName("userInput") diff --git a/src/main/java/me/gosimple/nbvcxz/matching/LeakMatcher.java b/src/main/java/me/gosimple/nbvcxz/matching/LeakMatcher.java new file mode 100644 index 0000000..0f0def0 --- /dev/null +++ b/src/main/java/me/gosimple/nbvcxz/matching/LeakMatcher.java @@ -0,0 +1,86 @@ +package me.gosimple.nbvcxz.matching; + +import me.gosimple.nbvcxz.matching.match.LeakMatch; +import me.gosimple.nbvcxz.matching.match.Match; +import me.gosimple.nbvcxz.resources.Configuration; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +/** + * Look for the password by querying the Leak API + * + * @author Adam Brusselback + */ +public final class LeakMatcher implements PasswordMatcher +{ + public List match(final Configuration configuration, final String password, final String... userInput) + { + ArrayList result = new ArrayList<>(); + + if (!configuration.getLeakApiEnabled()) + return result; + + String hashedPassword = hashPassword(password); + String prefix = hashedPassword.substring(0, 5); + String suffix = hashedPassword.substring(5).toUpperCase(); + String url = configuration.getLeakApiEndpoint() + prefix; + + try { + HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); + connection.setRequestMethod("GET"); + connection.setRequestProperty("User-Agent", "HIBP-Java-API"); + + int responseCode = connection.getResponseCode(); + if (responseCode == 200) { + BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String inputLine; + HashMap response = new HashMap<>(); + while ((inputLine = in.readLine()) != null) { + String[] line = inputLine.split(":"); + response.put(line[0], Integer.valueOf(line[1])); + } + in.close(); + + if (response.containsKey(suffix)) { + LeakMatch match = new LeakMatch(password, configuration, response.get(suffix), 0, password.length()); + result.add(match); + return result; + } else { + return result; + } + } else { + System.out.println("Error with request, response code: " + responseCode); + return result; + } + } catch (IOException e) { + System.out.println("Unable to run LeakMatcher"); + e.printStackTrace(); + } + return null; + } + + private static String hashPassword(String password) { + try { + MessageDigest md = MessageDigest.getInstance("SHA-1"); + byte[] digest = md.digest(password.getBytes()); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < digest.length; i++) { + sb.append(Integer.toString((digest[i] & 0xff) + 0x100, 16).substring(1)); + } + return sb.toString(); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + return null; + } + } +} diff --git a/src/main/java/me/gosimple/nbvcxz/matching/RepeatMatcher.java b/src/main/java/me/gosimple/nbvcxz/matching/RepeatMatcher.java index 1521135..d9169f4 100644 --- a/src/main/java/me/gosimple/nbvcxz/matching/RepeatMatcher.java +++ b/src/main/java/me/gosimple/nbvcxz/matching/RepeatMatcher.java @@ -18,7 +18,7 @@ */ public final class RepeatMatcher implements PasswordMatcher { - public List match(final Configuration configuration, final String password, String... userInput) + public List match(final Configuration configuration, final String password, final String... userInput) { List matches = new ArrayList<>(); diff --git a/src/main/java/me/gosimple/nbvcxz/matching/SeparatorMatcher.java b/src/main/java/me/gosimple/nbvcxz/matching/SeparatorMatcher.java index c938867..62626f2 100644 --- a/src/main/java/me/gosimple/nbvcxz/matching/SeparatorMatcher.java +++ b/src/main/java/me/gosimple/nbvcxz/matching/SeparatorMatcher.java @@ -21,7 +21,7 @@ public final class SeparatorMatcher implements PasswordMatcher private static final Pattern NON_ALPHA_NUMERIC = Pattern.compile("[^a-zA-Z\\d]"); - public List match(final Configuration configuration, final String password, String... userInput) + public List match(final Configuration configuration, final String password, final String... userInput) { Matcher matcher = NON_ALPHA_NUMERIC.matcher(password); diff --git a/src/main/java/me/gosimple/nbvcxz/matching/SequenceMatcher.java b/src/main/java/me/gosimple/nbvcxz/matching/SequenceMatcher.java index de8fa7d..7a96fa2 100644 --- a/src/main/java/me/gosimple/nbvcxz/matching/SequenceMatcher.java +++ b/src/main/java/me/gosimple/nbvcxz/matching/SequenceMatcher.java @@ -14,7 +14,7 @@ */ public final class SequenceMatcher implements PasswordMatcher { - public List match(final Configuration configuration, final String password, String... userInput) + public List match(final Configuration configuration, final String password, final String... userInput) { List matches = new ArrayList<>(); char[] characters = password.toCharArray(); diff --git a/src/main/java/me/gosimple/nbvcxz/matching/SpacialMatcher.java b/src/main/java/me/gosimple/nbvcxz/matching/SpacialMatcher.java index abb6d6c..4049fcc 100644 --- a/src/main/java/me/gosimple/nbvcxz/matching/SpacialMatcher.java +++ b/src/main/java/me/gosimple/nbvcxz/matching/SpacialMatcher.java @@ -21,7 +21,7 @@ */ public final class SpacialMatcher implements PasswordMatcher { - public List match(final Configuration configuration, final String password, String... userInput) + public List match(final Configuration configuration, final String password, final String... userInput) { List matches = new ArrayList<>(); Map> neighbors = new HashMap<>(); diff --git a/src/main/java/me/gosimple/nbvcxz/matching/YearMatcher.java b/src/main/java/me/gosimple/nbvcxz/matching/YearMatcher.java index 88cad0c..00b51e1 100644 --- a/src/main/java/me/gosimple/nbvcxz/matching/YearMatcher.java +++ b/src/main/java/me/gosimple/nbvcxz/matching/YearMatcher.java @@ -16,7 +16,7 @@ */ public final class YearMatcher implements PasswordMatcher { - public List match(final Configuration configuration, final String password, String... userInput) + public List match(final Configuration configuration, final String password, final String... userInput) { Pattern pattern = configuration.getYearPattern(); Matcher matcher = pattern.matcher(password); diff --git a/src/main/java/me/gosimple/nbvcxz/matching/match/LeakMatch.java b/src/main/java/me/gosimple/nbvcxz/matching/match/LeakMatch.java new file mode 100644 index 0000000..c8e9361 --- /dev/null +++ b/src/main/java/me/gosimple/nbvcxz/matching/match/LeakMatch.java @@ -0,0 +1,44 @@ +package me.gosimple.nbvcxz.matching.match; + +import me.gosimple.nbvcxz.resources.Configuration; + +import java.util.ResourceBundle; + +/** + * @author Adam Brusselback + */ +public final class LeakMatch extends BaseMatch +{ + private int count; + public LeakMatch(String match, Configuration configuration, int count, int start_index, int end_index) + { + super(match, configuration, start_index, end_index); + + this.count = count; + + super.setEntropy(getEntropy()); + } + + private double getEntropy() + { + return 0d; + } + + public int getCount() + { + return count; + } + + public String getDetails() + { + ResourceBundle mainResource = configuration.getMainResource(); + StringBuilder detailBuilder = new StringBuilder(); + detailBuilder.append(super.getDetails()); + detailBuilder.append("\n"); + detailBuilder.append(mainResource.getString("main.match.count")).append(" ").append(getCount()); + detailBuilder.append("\n"); + return detailBuilder.toString(); + } + + +} diff --git a/src/main/java/me/gosimple/nbvcxz/resources/Configuration.java b/src/main/java/me/gosimple/nbvcxz/resources/Configuration.java index 9d72043..65b3b8d 100644 --- a/src/main/java/me/gosimple/nbvcxz/resources/Configuration.java +++ b/src/main/java/me/gosimple/nbvcxz/resources/Configuration.java @@ -31,6 +31,8 @@ public class Configuration private final ResourceBundle mainResource; private final ResourceBundle feedbackResource; private final long combinationAlgorithmTimeout; + private final String leakApiEndpoint; + private final boolean leakApiEnabled; /** * @param passwordMatchers The list of {@link PasswordMatcher}s which will be used for matching @@ -44,7 +46,7 @@ public class Configuration * @param distanceCalc Enable or disable levenshtein distance calculation for dictionary matches * @param combinationAlgorithmTimeout Timeout for the findBestMatches algorithm */ - public Configuration(List passwordMatchers, Map guessTypes, List dictionaries, List adjacencyGraphs, Map leetTable, Pattern yearPattern, Double minimumEntropy, Integer maxLength, Locale locale, boolean distanceCalc, long combinationAlgorithmTimeout) + public Configuration(List passwordMatchers, Map guessTypes, List dictionaries, List adjacencyGraphs, Map leetTable, Pattern yearPattern, Double minimumEntropy, Integer maxLength, Locale locale, boolean distanceCalc, long combinationAlgorithmTimeout, String leakApiEndpoint, boolean leakApiEnabled) { this.passwordMatchers = passwordMatchers; this.guessTypes = guessTypes; @@ -59,6 +61,8 @@ public Configuration(List passwordMatchers, Map g this.mainResource = ResourceBundle.getBundle("main", locale); this.feedbackResource = ResourceBundle.getBundle("feedback", locale); this.combinationAlgorithmTimeout = combinationAlgorithmTimeout; + this.leakApiEndpoint = leakApiEndpoint; + this.leakApiEnabled = leakApiEnabled; } /** @@ -148,6 +152,20 @@ public long getCombinationAlgorithmTimeout() return combinationAlgorithmTimeout; } + /** + * @return The endpoint for the Leak API, used by the LeakMatcher + */ + public String getLeakApiEndpoint() { + return leakApiEndpoint; + } + + /** + * @return The API key used for the Leak API Endpoint + */ + public boolean getLeakApiEnabled() { + return leakApiEnabled; + } + /** * @return Return the resource bundle which contains the text for everything but feedback */ diff --git a/src/main/java/me/gosimple/nbvcxz/resources/ConfigurationBuilder.java b/src/main/java/me/gosimple/nbvcxz/resources/ConfigurationBuilder.java index 2181bf0..0de0b01 100644 --- a/src/main/java/me/gosimple/nbvcxz/resources/ConfigurationBuilder.java +++ b/src/main/java/me/gosimple/nbvcxz/resources/ConfigurationBuilder.java @@ -1,14 +1,7 @@ package me.gosimple.nbvcxz.resources; import me.gosimple.nbvcxz.Nbvcxz; -import me.gosimple.nbvcxz.matching.DateMatcher; -import me.gosimple.nbvcxz.matching.DictionaryMatcher; -import me.gosimple.nbvcxz.matching.PasswordMatcher; -import me.gosimple.nbvcxz.matching.RepeatMatcher; -import me.gosimple.nbvcxz.matching.SeparatorMatcher; -import me.gosimple.nbvcxz.matching.SequenceMatcher; -import me.gosimple.nbvcxz.matching.SpacialMatcher; -import me.gosimple.nbvcxz.matching.YearMatcher; +import me.gosimple.nbvcxz.matching.*; import me.gosimple.nbvcxz.matching.match.Match; import java.math.BigDecimal; @@ -44,6 +37,7 @@ public class ConfigurationBuilder defaultPasswordMatchers.add(new SpacialMatcher()); defaultPasswordMatchers.add(new DictionaryMatcher()); defaultPasswordMatchers.add(new SeparatorMatcher()); + defaultPasswordMatchers.add(new LeakMatcher()); defaultDictionaries.add(new Dictionary("passwords", DictionaryUtil.loadRankedDictionary(DictionaryUtil.passwords), false)); defaultDictionaries.add(new Dictionary("male_names", DictionaryUtil.loadRankedDictionary(DictionaryUtil.male_names), false)); @@ -92,6 +86,8 @@ public class ConfigurationBuilder private Boolean distanceCalc; private Long combinationAlgorithmTimeout; private Long crackingHardwareCost; + private String leakApiEndpoint; + private Boolean leakApiEnabled; /** * @return Includes all standard password matchers included with Nbvcxz. @@ -236,6 +232,22 @@ public static long getDefaultCrackingHardwareCost() return 20000; } + /** + * @return The default Leak API Endpoint, HIBP(v3) by default + */ + public static String getDefaultLeakApiEndpoint() + { + return "https://api.pwnedpasswords.com/range/"; + } + + /** + * @return true, the leak API is enabled by default + */ + public static boolean getDefaultLeakApiEnabled() + { + return true; + } + /** * {@link PasswordMatcher} are what look for different patterns within the password and create an associated {@link Match} object. *
@@ -418,6 +430,27 @@ public ConfigurationBuilder setCrackingHardwareCost(final Long crackingHardwareC return this; } + /** + * Sets the Leak API Endpoint to be used by the LeakMatcher. + * By default, this is the HIBP(v3) api. You can point it to any compatible API endpoint. + * @param leakApiEndpoint the API endpoint URL + * @return Builder + */ + public ConfigurationBuilder setLeakApiEndpoint(final String leakApiEndpoint) { + this.leakApiEndpoint = leakApiEndpoint; + return this; + } + + /** + * Enables the LeakMatcher using the configured LeakApiEndpoint + * @param leakApiEnabled the key used to authenticate to the Leak API + * @return Builder + */ + public ConfigurationBuilder setLeakApiEnabled(final boolean leakApiEnabled) { + this.leakApiEnabled = leakApiEnabled; + return this; + } + /** * Creates the {@link Configuration} object using all values set in this builder, or default values if unset. * @@ -473,7 +506,15 @@ public Configuration createConfiguration() { combinationAlgorithmTimeout = getDefaultCombinationAlgorithmTimeout(); } - return new Configuration(passwordMatchers, guessTypes, dictionaries, adjacencyGraphs, leetTable, yearPattern, minimumEntropy, maxLength, locale, distanceCalc, combinationAlgorithmTimeout); + if (leakApiEndpoint == null) + { + leakApiEndpoint = getDefaultLeakApiEndpoint(); + } + if (leakApiEnabled == null) + { + leakApiEnabled = getDefaultLeakApiEnabled(); + } + return new Configuration(passwordMatchers, guessTypes, dictionaries, adjacencyGraphs, leetTable, yearPattern, minimumEntropy, maxLength, locale, distanceCalc, combinationAlgorithmTimeout, leakApiEndpoint, leakApiEnabled); } diff --git a/src/main/resources/main.properties b/src/main/resources/main.properties index 047c43a..e26b7c0 100644 --- a/src/main/resources/main.properties +++ b/src/main/resources/main.properties @@ -38,6 +38,7 @@ main.match.year=Year: main.match.month=Month: main.match.day=Day: main.match.separator=Separator: +main.match.count=Leak Count: main.estimate.greaterCenturies=infinite (>100000 centuries) main.estimate.centuries=centuries main.estimate.years=years diff --git a/src/test/java/me/gosimple/nbvcxz/NbvcxzTest.java b/src/test/java/me/gosimple/nbvcxz/NbvcxzTest.java index 28d9bf3..0291f41 100644 --- a/src/test/java/me/gosimple/nbvcxz/NbvcxzTest.java +++ b/src/test/java/me/gosimple/nbvcxz/NbvcxzTest.java @@ -32,6 +32,7 @@ public void testExcludeDictionary() Configuration configuration = new ConfigurationBuilder() .setDictionaries(dictionaryList) + .setLeakApiEnabled(false) .createConfiguration(); final Nbvcxz nbvcxz = new Nbvcxz(configuration); @@ -71,7 +72,7 @@ public void testConcurrency() List matchers = ConfigurationBuilder.getDefaultPasswordMatchers(); PasswordMatcher testMatcher = new PasswordMatcher() { @Override - public List match(Configuration configuration, String password) { + public List match(Configuration configuration, String password, String... userInput) { return new ArrayList<>(); } }; @@ -85,6 +86,7 @@ public void testMaxLength() { Configuration configuration = new ConfigurationBuilder() .setMaxLength(50) + .setLeakApiEnabled(false) .createConfiguration(); final Nbvcxz nbvcxz = new Nbvcxz(configuration); @@ -115,7 +117,8 @@ public void testMaxLength() @Test public void testEstimate() { - final Nbvcxz nbvcxz = new Nbvcxz(); + final Configuration configuration = new ConfigurationBuilder().setLeakApiEnabled(false).createConfiguration(); + final Nbvcxz nbvcxz = new Nbvcxz(configuration); final List tests = new ArrayList<>(); tests.add(new EntropyTest(nbvcxz,"correcthorsebatterystaple",16.60965490131509D)); @@ -157,7 +160,8 @@ public void testEstimate() @Test public void testEstimateConcurrently() { - final Nbvcxz nbvcxz = new Nbvcxz(); + final Configuration configuration = new ConfigurationBuilder().setLeakApiEnabled(false).createConfiguration(); + final Nbvcxz nbvcxz = new Nbvcxz(configuration); final ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(4); @@ -220,7 +224,7 @@ private class EntropyTest implements Runnable private Result result; private String[] userInput; - public EntropyTest(Nbvcxz nbvcxz, String password, Double expectedEntropy, String... userInput) { + public EntropyTest(Nbvcxz nbvcxz, String password, Double expectedEntropy, final String... userInput) { this.nbvcxz = nbvcxz; this.password = password; this.expectedEntropy = expectedEntropy; diff --git a/src/test/java/me/gosimple/nbvcxz/matching/DateMatcherTest.java b/src/test/java/me/gosimple/nbvcxz/matching/DateMatcherTest.java index a5a3f8c..20baaf7 100644 --- a/src/test/java/me/gosimple/nbvcxz/matching/DateMatcherTest.java +++ b/src/test/java/me/gosimple/nbvcxz/matching/DateMatcherTest.java @@ -13,7 +13,7 @@ */ public class DateMatcherTest { - final Configuration configuration = new ConfigurationBuilder().createConfiguration(); + final Configuration configuration = new ConfigurationBuilder().setLeakApiEnabled(false).createConfiguration(); /** * Test of match method, of class DateMatcher. diff --git a/src/test/java/me/gosimple/nbvcxz/matching/DictionaryMatcherTest.java b/src/test/java/me/gosimple/nbvcxz/matching/DictionaryMatcherTest.java index 3127994..a9af915 100644 --- a/src/test/java/me/gosimple/nbvcxz/matching/DictionaryMatcherTest.java +++ b/src/test/java/me/gosimple/nbvcxz/matching/DictionaryMatcherTest.java @@ -29,7 +29,7 @@ public DictionaryMatcherTest() } } - this.configuration = new ConfigurationBuilder().setDictionaries(dictionaries).createConfiguration(); + this.configuration = new ConfigurationBuilder().setLeakApiEnabled(false).setDictionaries(dictionaries).createConfiguration(); } diff --git a/src/test/java/me/gosimple/nbvcxz/matching/RepeatMatcherTest.java b/src/test/java/me/gosimple/nbvcxz/matching/RepeatMatcherTest.java index ff4f079..6cd08ff 100644 --- a/src/test/java/me/gosimple/nbvcxz/matching/RepeatMatcherTest.java +++ b/src/test/java/me/gosimple/nbvcxz/matching/RepeatMatcherTest.java @@ -13,7 +13,7 @@ */ public class RepeatMatcherTest { - final Configuration configuration = new ConfigurationBuilder().createConfiguration(); + final Configuration configuration = new ConfigurationBuilder().setLeakApiEnabled(false).createConfiguration(); /** * Test of match method, of class RepeatMatcher. diff --git a/src/test/java/me/gosimple/nbvcxz/matching/SequenceMatcherTest.java b/src/test/java/me/gosimple/nbvcxz/matching/SequenceMatcherTest.java index c13b531..9cc47ca 100644 --- a/src/test/java/me/gosimple/nbvcxz/matching/SequenceMatcherTest.java +++ b/src/test/java/me/gosimple/nbvcxz/matching/SequenceMatcherTest.java @@ -12,7 +12,7 @@ */ public class SequenceMatcherTest { - final Configuration configuration = new ConfigurationBuilder().createConfiguration(); + final Configuration configuration = new ConfigurationBuilder().setLeakApiEnabled(false).createConfiguration(); /** * Test of match method, of class DateMatcher. diff --git a/src/test/java/me/gosimple/nbvcxz/matching/SpacialMatcherTest.java b/src/test/java/me/gosimple/nbvcxz/matching/SpacialMatcherTest.java index 6930d6f..c4434fe 100644 --- a/src/test/java/me/gosimple/nbvcxz/matching/SpacialMatcherTest.java +++ b/src/test/java/me/gosimple/nbvcxz/matching/SpacialMatcherTest.java @@ -14,7 +14,7 @@ public class SpacialMatcherTest { - final Configuration configuration = new ConfigurationBuilder().createConfiguration(); + final Configuration configuration = new ConfigurationBuilder().setLeakApiEnabled(false).createConfiguration(); /** * Test of match method, of class DateMatcher. diff --git a/src/test/java/me/gosimple/nbvcxz/matching/YearMatcherTest.java b/src/test/java/me/gosimple/nbvcxz/matching/YearMatcherTest.java index 4fc3329..8eb151c 100644 --- a/src/test/java/me/gosimple/nbvcxz/matching/YearMatcherTest.java +++ b/src/test/java/me/gosimple/nbvcxz/matching/YearMatcherTest.java @@ -12,7 +12,7 @@ */ public class YearMatcherTest { - final Configuration configuration = new ConfigurationBuilder().createConfiguration(); + final Configuration configuration = new ConfigurationBuilder().setLeakApiEnabled(false).createConfiguration(); /** * Test of match method, of class DateMatcher. diff --git a/src/test/java/me/gosimple/nbvcxz/matching/match/BaseMatchTest.java b/src/test/java/me/gosimple/nbvcxz/matching/match/BaseMatchTest.java index d78c732..523b082 100644 --- a/src/test/java/me/gosimple/nbvcxz/matching/match/BaseMatchTest.java +++ b/src/test/java/me/gosimple/nbvcxz/matching/match/BaseMatchTest.java @@ -86,7 +86,7 @@ public class BaseMatchImpl extends BaseMatch public BaseMatchImpl(String s) { - super(s, new ConfigurationBuilder().createConfiguration(), 0, s == null ? 0 : s.length() - 1); + super(s, new ConfigurationBuilder().setLeakApiEnabled(false).createConfiguration(), 0, s == null ? 0 : s.length() - 1); } } diff --git a/src/test/java/me/gosimple/nbvcxz/matching/match/DateMatchTest.java b/src/test/java/me/gosimple/nbvcxz/matching/match/DateMatchTest.java index 5eba3f8..7da47c4 100644 --- a/src/test/java/me/gosimple/nbvcxz/matching/match/DateMatchTest.java +++ b/src/test/java/me/gosimple/nbvcxz/matching/match/DateMatchTest.java @@ -25,7 +25,7 @@ public DateMatchTest() public void testCalculateEntropy() { System.out.println("Test of guessEntropy method, of class DateMatch"); - Configuration configuration = new ConfigurationBuilder().createConfiguration(); + Configuration configuration = new ConfigurationBuilder().setLeakApiEnabled(false).createConfiguration(); HashMap expectedMatches = new HashMap<>(); expectedMatches.put(new DateMatch("0090", configuration, 0, 0, 1990, null, 0, 3), 15.550386066531285); diff --git a/src/test/java/me/gosimple/nbvcxz/matching/match/DictionaryMatchTest.java b/src/test/java/me/gosimple/nbvcxz/matching/match/DictionaryMatchTest.java index 50b6939..99e44aa 100644 --- a/src/test/java/me/gosimple/nbvcxz/matching/match/DictionaryMatchTest.java +++ b/src/test/java/me/gosimple/nbvcxz/matching/match/DictionaryMatchTest.java @@ -22,7 +22,7 @@ public void testCalculateEntropy() { System.out.println("Test of guessEntropy method, of class DictionaryMatch"); - Configuration configuration = new ConfigurationBuilder().createConfiguration(); + Configuration configuration = new ConfigurationBuilder().setLeakApiEnabled(false).createConfiguration(); ArrayList sub = new ArrayList<>(); double entropy; diff --git a/src/test/java/me/gosimple/nbvcxz/matching/match/RepeatMatchTest.java b/src/test/java/me/gosimple/nbvcxz/matching/match/RepeatMatchTest.java index 9028ab0..9767a17 100644 --- a/src/test/java/me/gosimple/nbvcxz/matching/match/RepeatMatchTest.java +++ b/src/test/java/me/gosimple/nbvcxz/matching/match/RepeatMatchTest.java @@ -72,7 +72,7 @@ public void testCalculateEntropy() repeatMap.put("6p6p6p6p6p6p6p6p6p6p6p6p6p6p6p6p6p6p", "6p"); // Test the fixture - Configuration configuration = new ConfigurationBuilder().createConfiguration(); + Configuration configuration = new ConfigurationBuilder().setLeakApiEnabled(false).createConfiguration(); for (Map.Entry entry : entropyMap.entrySet()) { String password = entry.getKey(); diff --git a/src/test/java/me/gosimple/nbvcxz/matching/match/SequenceMatchTest.java b/src/test/java/me/gosimple/nbvcxz/matching/match/SequenceMatchTest.java index 4990ec5..8becd26 100644 --- a/src/test/java/me/gosimple/nbvcxz/matching/match/SequenceMatchTest.java +++ b/src/test/java/me/gosimple/nbvcxz/matching/match/SequenceMatchTest.java @@ -57,7 +57,7 @@ public void testCalculateEntropy() private void testHelper(HashMap fixture) { - Configuration configuration = new ConfigurationBuilder().createConfiguration(); + Configuration configuration = new ConfigurationBuilder().setLeakApiEnabled(false).createConfiguration(); for (Map.Entry entry : fixture.entrySet()) { String password = entry.getKey(); diff --git a/src/test/java/me/gosimple/nbvcxz/matching/match/SpacialMatchTest.java b/src/test/java/me/gosimple/nbvcxz/matching/match/SpacialMatchTest.java index 3053cfa..feaccfe 100644 --- a/src/test/java/me/gosimple/nbvcxz/matching/match/SpacialMatchTest.java +++ b/src/test/java/me/gosimple/nbvcxz/matching/match/SpacialMatchTest.java @@ -15,7 +15,7 @@ */ public class SpacialMatchTest { - final Configuration configuration = new ConfigurationBuilder().createConfiguration(); + final Configuration configuration = new ConfigurationBuilder().setLeakApiEnabled(false).createConfiguration(); /** * Test of guessEntropy method, of class SpacialMatch. diff --git a/src/test/java/me/gosimple/nbvcxz/matching/match/YearMatchTest.java b/src/test/java/me/gosimple/nbvcxz/matching/match/YearMatchTest.java index 35c9b28..0657f52 100644 --- a/src/test/java/me/gosimple/nbvcxz/matching/match/YearMatchTest.java +++ b/src/test/java/me/gosimple/nbvcxz/matching/match/YearMatchTest.java @@ -41,7 +41,7 @@ public void testCalculateEntropy() { String password = entry.getKey(); double expected = entry.getValue(); - double computed = new YearMatch(password, new ConfigurationBuilder().createConfiguration(), 0, password.length() - 1).calculateEntropy(); + double computed = new YearMatch(password, new ConfigurationBuilder().setLeakApiEnabled(false).createConfiguration(), 0, password.length() - 1).calculateEntropy(); Assert.assertEquals(password, expected, computed, 0.000000000000001); } } diff --git a/src/test/java/me/gosimple/nbvcxz/scoring/ScoreTest.java b/src/test/java/me/gosimple/nbvcxz/scoring/ScoreTest.java index fcc73fc..64df4e0 100644 --- a/src/test/java/me/gosimple/nbvcxz/scoring/ScoreTest.java +++ b/src/test/java/me/gosimple/nbvcxz/scoring/ScoreTest.java @@ -25,7 +25,7 @@ public void testBasicScore() String password; Result result; - Configuration configuration = new ConfigurationBuilder().createConfiguration(); + Configuration configuration = new ConfigurationBuilder().setLeakApiEnabled(false).createConfiguration(); final Nbvcxz nbvcxz = new Nbvcxz(configuration); try diff --git a/src/test/java/me/gosimple/nbvcxz/scoring/TimeEstimateTest.java b/src/test/java/me/gosimple/nbvcxz/scoring/TimeEstimateTest.java index b2d8148..a98839a 100644 --- a/src/test/java/me/gosimple/nbvcxz/scoring/TimeEstimateTest.java +++ b/src/test/java/me/gosimple/nbvcxz/scoring/TimeEstimateTest.java @@ -47,7 +47,7 @@ public void testCalculateEntropy() guessTypes.put("ONLINE_UNTHROTTLED", 100L); guessTypes.put("ONLINE_THROTTLED", 2L); - Configuration configuration = new ConfigurationBuilder().setGuessTypes(guessTypes).createConfiguration(); + Configuration configuration = new ConfigurationBuilder().setLeakApiEnabled(false).setGuessTypes(guessTypes).createConfiguration(); final Nbvcxz nbvcxz = new Nbvcxz(configuration); try