@Override public List<Match> execute(String password) { List<Match> matches = new ArrayList<>(); for(Map.Entry<String, String> regexenRef: REGEXEN.entrySet()) { String name = regexenRef.getKey(); java.util.regex.Matcher rxMatch = Pattern.compile(regexenRef.getValue()).matcher(password); while(rxMatch.find()){ String token = rxMatch.group(); matches.add(MatchFactory.createRegexMatch( rxMatch.start(), rxMatch.start() + token.length() - 1, token, name, rxMatch)); } } return this.sorted(matches); } }
private void testRegexMatching(String year) throws Exception { List<Match> actualMatches = new RegexMatcher().execute(year); assertMatches( "matches " + year + " as a recent_year token", Pattern.Regex, new ExpectedMatch[]{new ExpectedMatch(year).regexName("recent_year")}, actualMatches); }
@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) { List<Match> matches = new ArrayList<>(); for(Map.Entry<String, String> regexenRef: REGEXEN.entrySet()) { String name = regexenRef.getKey(); java.util.regex.Matcher rxMatch = Pattern.compile(regexenRef.getValue()).matcher(password); while(rxMatch.find()){ String token = rxMatch.group(); matches.add(MatchFactory.createRegexMatch( rxMatch.start(), rxMatch.start() + token.length() - 1, token, name, rxMatch)); } } return this.sorted(matches); } }