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

me.gosimple.nbvcxz.resources.Configuration 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.resources;

import me.gosimple.nbvcxz.matching.DictionaryMatcher;
import me.gosimple.nbvcxz.matching.PasswordMatcher;
import me.gosimple.nbvcxz.matching.SpacialMatcher;
import me.gosimple.nbvcxz.matching.YearMatcher;

import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.regex.Pattern;

/**
 * Used to set any configurable parameters when estimating password strength.
 *
 * @author Adam Brusselback.
 */
public class Configuration
{
    private final List passwordMatchers;
    private final Map guessTypes;
    private final List dictionaries;
    private final List adjacencyGraphs;
    private final Map leetTable;
    private final Pattern yearPattern;
    private final Double minimumEntropy;
    private final Locale locale;
    private final boolean distanceCalc;
    private final ResourceBundle mainResource;
    private final ResourceBundle feedbackResource;
    private final long combinationAlgorithmTimeout;

    /**
     * @param passwordMatchers            The list of {@link PasswordMatcher}s which will be used for matching
     * @param guessTypes                  Map of types of guesses, and associated guesses/sec
     * @param dictionaries                List of {@link Dictionary} to use for the {@link DictionaryMatcher}
     * @param adjacencyGraphs             List of adjacency graphs to be used by the {@link SpacialMatcher}
     * @param leetTable                   Leet table for use with {@link DictionaryMatcher}
     * @param yearPattern                 Regex {@link Pattern} for use with {@link YearMatcher}
     * @param minimumEntropy              Minimum entropy value passwords should meet
     * @param locale                      Locale for localized text and feedback
     * @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, Locale locale, boolean distanceCalc, long combinationAlgorithmTimeout)
    {
        this.passwordMatchers = passwordMatchers;
        this.guessTypes = guessTypes;
        this.dictionaries = dictionaries;
        this.adjacencyGraphs = adjacencyGraphs;
        this.leetTable = leetTable;
        this.yearPattern = yearPattern;
        this.minimumEntropy = minimumEntropy;
        this.locale = locale;
        this.distanceCalc = distanceCalc;
        this.mainResource = ResourceBundle.getBundle("main", locale);
        this.feedbackResource = ResourceBundle.getBundle("feedback", locale);
        this.combinationAlgorithmTimeout = combinationAlgorithmTimeout;
    }

    /**
     * @return The list of {@link PasswordMatcher}s which will be used for matching
     */
    public List getPasswordMatchers()
    {
        return passwordMatchers;
    }

    /**
     * @return Map of types of guesses, and associated guesses/sec
     */
    public Map getGuessTypes()
    {
        return guessTypes;
    }

    /**
     * @return List of {@link Dictionary} to use for the {@link DictionaryMatcher}
     */
    public List getDictionaries()
    {
        return dictionaries;
    }

    /**
     * @return List of adjacency graphs to be used by the {@link SpacialMatcher}
     */
    public List getAdjacencyGraphs()
    {
        return adjacencyGraphs;
    }

    /**
     * @return Leet table for use with {@link DictionaryMatcher}
     */
    public Map getLeetTable()
    {
        return leetTable;
    }

    /**
     * @return Regex {@link Pattern} for use with {@link YearMatcher}
     */
    public Pattern getYearPattern()
    {
        return yearPattern;
    }

    /**
     * @return Minimum entropy value passwords should meet
     */
    public Double getMinimumEntropy()
    {
        return minimumEntropy;
    }

    /**
     * @return Locale for localized text and feedback
     */
    public Locale getLocale()
    {
        return locale;
    }

    /**
     * @return if dictionary distance calculations are enabled or not
     */
    public boolean isDistanceCalc()
    {
        return distanceCalc;
    }

    /**
     * @return Return the timeout for the findBestMatches algorithm
     */
    public long getCombinationAlgorithmTimeout()
    {
        return combinationAlgorithmTimeout;
    }

    /**
     * @return Return the resource bundle which contains the text for everything but feedback
     */
    public ResourceBundle getMainResource()
    {
        return mainResource;
    }

    /**
     * @return Return the resource bundle which contains the text for feedback
     */
    public ResourceBundle getFeedbackResource()
    {
        return feedbackResource;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy