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

com.nulabinc.zxcvbn.matchers.MatchFactory Maven / Gradle / Ivy

Go to download

This is a java port of zxcvbn, which is a JavaScript password strength generator.

There is a newer version: 1.9.0
Show newest version
package com.nulabinc.zxcvbn.matchers;

import com.nulabinc.zxcvbn.Pattern;

import java.util.List;
import java.util.Map;

public class MatchFactory {

    private MatchFactory() { }

    public static Match createBruteforceMatch(int i, int j, CharSequence token) {
        return new Match.Builder(Pattern.Bruteforce, i, j, token).build();
    }


    public static Match createDictionaryMatch(int i, int j, CharSequence token, CharSequence matchedWord, int rank, String dictionaryName) {
        return new Match.Builder(Pattern.Dictionary, i, j, token)
                .matchedWord(matchedWord)
                .rank(rank)
                .dictionaryName(dictionaryName)
                .reversed(false)
                .l33t(false)
                .build();
    }

    public static Match createReversedDictionaryMatch(int i, int j, CharSequence token, CharSequence matchedWord, int rank, String dictionaryName) {
        return new Match.Builder(Pattern.Dictionary, i, j, token)
                .matchedWord(matchedWord)
                .rank(rank)
                .dictionaryName(dictionaryName)
                .reversed(true)
                .l33t(false)
                .build();
    }

    public static Match createDictionaryL33tMatch(int i, int j, CharSequence token, CharSequence matchedWord, int rank, String dictionaryName, boolean reversed, Map sub, String subDisplay) {
        return new Match.Builder(Pattern.Dictionary, i, j, token)
                .matchedWord(matchedWord)
                .rank(rank)
                .dictionaryName(dictionaryName)
                .reversed(reversed)
                .sub(sub)
                .subDisplay(subDisplay)
                .l33t(true)
                .build();
    }

    public static Match createSpatialMatch(int i, int j, CharSequence token, String graph, int turns, int shiftedCount) {
        return new Match.Builder(Pattern.Spatial, i, j, token)
                .graph(graph)
                .turns(turns)
                .shiftedCount(shiftedCount)
                .build();
    }

    public static Match createRepeatMatch(int i, int j, CharSequence token, CharSequence baseToken, double baseGuesses, List baseMatches, int repeatCount) {
        return new Match.Builder(Pattern.Repeat, i, j, token)
                .baseToken(baseToken)
                .baseGuesses(baseGuesses)
                .baseMatches(baseMatches)
                .repeatCount(repeatCount)
                .build();
    }

    public static Match createSequenceMatch(int i, int j, CharSequence token, String sequenceName, int sequenceSpace, boolean ascending) {
        return new Match.Builder(Pattern.Sequence, i, j, token)
                .sequenceName(sequenceName)
                .sequenceSpace(sequenceSpace)
                .ascending(ascending)
                .build();
    }

    public static Match createRegexMatch(int i, int j, CharSequence token, String regexName, java.util.regex.Matcher regexMatch) {
        return new Match.Builder(Pattern.Regex, i, j, token)
                .regexName(regexName)
                .regexMatch(regexMatch)
                .build();
    }

    public static Match createDateMatch(int i, int j, CharSequence token, String separator, int year, int month, int day) {
        return new Match.Builder(Pattern.Date, i, j, token)
                .separator(separator)
                .year(year)
                .month(month)
                .day(day)
                .build();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy