use of org.gluu.oxtrust.service.AttributeService in project oxTrust by GluuFederation.
the class PasswordValidator method validate.
@Override
public void validate(FacesContext arg0, UIComponent arg1, Object value) throws ValidatorException {
if (attributeService == null) {
attributeService = CdiUtil.bean(AttributeService.class);
}
GluuAttribute attributeByName = attributeService.getAttributeByName(USER_PASSWORD);
AttributeValidation validation = attributeByName.getAttributeValidation();
if (validation != null && validation.getRegexp() != null && !validation.getRegexp().isEmpty()) {
pattern = Pattern.compile(validation.getRegexp());
hasValidation = true;
}
if (hasValidation) {
matcher = pattern.matcher(value.toString());
}
if (hasValidation && !matcher.matches()) {
FacesMessage msg = new FacesMessage(facesMessages.evalResourceAsString("#{msgs['password.validation.invalid']}"));
msg.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ValidatorException(msg);
}
}
Aggregations