@Override public List<Match> execute(String password) { String reversedPassword = new StringBuilder(password).reverse().toString(); List<Match> matches = new ArrayList<>(); for (Match match: new DictionaryMatcher(this.rankedDictionaries).execute(reversedPassword)) { matches.add(MatchFactory.createReversedDictionaryMatch( password.length() - 1 - match.j, password.length() - 1 - match.i, new StringBuilder(match.token).reverse().toString(), match.matchedWord, match.rank, match.dictionaryName)); } return this.sorted(matches); } }
@Override public List<Match> execute(String password) { List<Match> matches = new ArrayList<>(); int len = password.length(); String passwordLower = password.toLowerCase(); for (Map.Entry<String, Map<String, Integer>> rankedDictionaryRef: this.rankedDictionaries.entrySet()) { String dictionaryName = rankedDictionaryRef.getKey(); Map<String, Integer> rankedDict = rankedDictionaryRef.getValue(); for(int i = 0; i < len; i++) { for(int j = i; j < len; j++) { String word = passwordLower.substring(i, j + 1); if (rankedDict.containsKey(word)) { int rank = rankedDict.get(word); String token = password.substring(i, j + 1); matches.add(MatchFactory.createDictionaryMatch(i, j, token, word, rank, dictionaryName)); } } } } return this.sorted(matches); } }
@Override public List<Match> execute(String password) { List<Match> matches = new ArrayList<>(); List<Matcher> matchers = new ArrayList<>(); matchers.add(new DictionaryMatcher(dictionaries)); matchers.add(new ReverseDictionaryMatcher(dictionaries)); matchers.add(new L33tMatcher(dictionaries)); matchers.add(new SpatialMatcher()); matchers.add(new RepeatMatcher()); matchers.add(new SequenceMatcher()); matchers.add(new RegexMatcher()); matchers.add(new DateMatcher()); for (Matcher matcher: matchers) matches.addAll(matcher.execute(password)); return this.sorted(matches); } }
@Override public List<Match> execute(String password) { List<Match> matches = new ArrayList<>(); List<Matcher> matchers = new ArrayList<>(); matchers.add(new DictionaryMatcher(dictionaries)); matchers.add(new ReverseDictionaryMatcher(dictionaries)); matchers.add(new L33tMatcher(dictionaries)); matchers.add(new SpatialMatcher()); matchers.add(new RepeatMatcher()); matchers.add(new SequenceMatcher()); matchers.add(new RegexMatcher()); matchers.add(new DateMatcher()); for (Matcher matcher: matchers) matches.addAll(matcher.execute(password)); return this.sorted(matches); } }
@Override public List<Match> execute(String password) { String reversedPassword = new StringBuilder(password).reverse().toString(); List<Match> matches = new ArrayList<>(); for (Match match: new DictionaryMatcher(this.rankedDictionaries).execute(reversedPassword)) { matches.add(MatchFactory.createReversedDictionaryMatch( password.length() - 1 - match.j, password.length() - 1 - match.i, new StringBuilder(match.token).reverse().toString(), match.matchedWord, match.rank, match.dictionaryName)); } return this.sorted(matches); } }
@Override public List<Match> execute(String password) { List<Match> matches = new ArrayList<>(); int len = password.length(); String passwordLower = password.toLowerCase(); for (Map.Entry<String, Map<String, Integer>> rankedDictionaryRef: this.rankedDictionaries.entrySet()) { String dictionaryName = rankedDictionaryRef.getKey(); Map<String, Integer> rankedDict = rankedDictionaryRef.getValue(); for(int i = 0; i < len; i++) { for(int j = i; j < len; j++) { String word = passwordLower.substring(i, j + 1); if (rankedDict.containsKey(word)) { int rank = rankedDict.get(word); String token = password.substring(i, j + 1); matches.add(MatchFactory.createDictionaryMatch(i, j, token, word, rank, dictionaryName)); } } } } return this.sorted(matches); } }
@Test public void testDictionaryMatching() throws Exception { List<Match> actualMatches = new DictionaryMatcher(dictionaries).execute(password); assertMatches(message, Pattern.Dictionary, expectedMatches, actualMatches); }
if (sub.isEmpty()) break; String subbedPassword = translate(password, sub); for (Match match: new DictionaryMatcher(rankedDictionaries).execute(subbedPassword)) { String token = password.substring(match.i, match.j + 1); if (token.toLowerCase().equals(match.matchedWord)) continue;
if (sub.isEmpty()) break; String subbedPassword = translate(password, sub); for (Match match: new DictionaryMatcher(rankedDictionaries).execute(subbedPassword)) { String token = password.substring(match.i, match.j + 1); if (token.toLowerCase().equals(match.matchedWord)) continue;