Search in sources :

Example 1 with IllegalRegexRule

use of org.passay.IllegalRegexRule in project dataverse by IQSS.

the class PasswordValidatorServiceBean method repeatingDigitsRule.

private IllegalRegexRule repeatingDigitsRule(int numConsecutiveDigitsAllowed) {
    int complainAboutThisManyConsecutiveDigits = numConsecutiveDigitsAllowed;
    if (numConsecutiveDigitsAllowed != Integer.MAX_VALUE) {
        // The check above is to avoid overflowing the int. MAX_VALUE is how we disable the setting.
        complainAboutThisManyConsecutiveDigits = numConsecutiveDigitsAllowed + 1;
    }
    Pattern pattern = Pattern.compile("\\d{" + complainAboutThisManyConsecutiveDigits + "}");
    return new IllegalRegexRule(pattern.pattern());
}
Also used : Pattern(java.util.regex.Pattern) IllegalRegexRule(org.passay.IllegalRegexRule)

Aggregations

Pattern (java.util.regex.Pattern)1 IllegalRegexRule (org.passay.IllegalRegexRule)1