Search in sources :

Example 1 with MinLengthValidatorDecorator

use of org.motechproject.security.validator.impl.MinLengthValidatorDecorator in project motech by motech.

the class SettingServiceImpl method getPasswordValidator.

@Override
public PasswordValidator getPasswordValidator() {
    MotechSettings motechSettings = configurationService.getPlatformSettings();
    String validatorName = motechSettings.getPasswordValidator();
    PasswordValidator validator = null;
    if (StringUtils.isNotBlank(validatorName)) {
        LOGGER.debug("No password validator configured");
        validator = passwordValidatorManager.getValidator(validatorName);
    }
    if (validator == null) {
        validator = passwordValidatorManager.noneValidator();
    }
    // if min pass length configured, then decorate the validator
    int minPassLength = getMinPasswordLength();
    if (minPassLength > 0) {
        validator = new MinLengthValidatorDecorator(validator, minPassLength);
    }
    return validator;
}
Also used : MinLengthValidatorDecorator(org.motechproject.security.validator.impl.MinLengthValidatorDecorator) MotechSettings(org.motechproject.config.domain.MotechSettings) PasswordValidator(org.motechproject.security.validator.PasswordValidator)

Aggregations

MotechSettings (org.motechproject.config.domain.MotechSettings)1 PasswordValidator (org.motechproject.security.validator.PasswordValidator)1 MinLengthValidatorDecorator (org.motechproject.security.validator.impl.MinLengthValidatorDecorator)1