@Inject @InstanceProviderList private List<Instance<AuthProvider>> providers;
public void tryToLogin() {
Principal principal = null;
Iterator<Instance<AuthProvider>> iterator = providers.iterator();
AuthenticateFailedEvent event = new AuthenticateFailedEvent();
//for while, if one provider returns Principal, is ok.
while(iterator.hasNext() && principal==null){
try {
AuthProvider provider = iterator.next().get();
logger.debug("trying to login using {}", provider);
principal = provider.authenticate(httpRequest.getParameter("login"),httpRequest.getParameter("password"));
} catch (Exception e) {
event.add(e);
}
}
if(principal != null){
logger.debug("Login successful, firing the AuthenticatedEvent event");