use of org.motechproject.security.validator.PasswordValidator in project motech by motech.
the class PasswordValidatorManager method getValidator.
/**
* Retrieves a validator by the name it was registered with. The service property with the kye org.motechproject.security.validator_name
* is treated as the name of the validator.
* @param name the name of the validator
* @return the validator, or null if it is missing
*/
public PasswordValidator getValidator(String name) {
try {
Collection<ServiceReference<PasswordValidator>> refs = bundleContext.getServiceReferences(PasswordValidator.class, null);
for (ServiceReference<PasswordValidator> ref : refs) {
PasswordValidator validator = bundleContext.getService(ref);
if (StringUtils.equalsIgnoreCase(name, validator.getName())) {
return validator;
}
}
LOGGER.warn("Validator with name {} not found", name);
return null;
} catch (InvalidSyntaxException e) {
throw new IllegalStateException("Unable to create a service filter expression", e);
}
}
Aggregations