All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.gosimple.nbvcxz.matching.YearMatcher Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 1.5.1
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy