me.gosimple.nbvcxz.matching.YearMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nbvcxz Show documentation
Show all versions of nbvcxz Show documentation
Nbvcxz takes heavy inspiration from the zxcvbn library built by Dropbox, and in a lot of ways is
similar.
I built this library to be heavily extensible for every use case, with sane defaults.
package me.gosimple.nbvcxz.matching;
import me.gosimple.nbvcxz.matching.match.Match;
import me.gosimple.nbvcxz.matching.match.YearMatch;
import me.gosimple.nbvcxz.resources.Configuration;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Look for every part of the password that matches the year pattern.
*
* @author Adam Brusselback
*/
public final class YearMatcher implements PasswordMatcher
{
public List match(final Configuration configuration, final String password)
{
Pattern pattern = configuration.getYearPattern();
Matcher matcher = pattern.matcher(password);
List matches = new ArrayList<>();
while (matcher.find())
{
matches.add(new YearMatch(matcher.group(), configuration, matcher.start(), matcher.end() - 1));
}
return matches;
}
}