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());
}
Aggregations