@Override public UserInformation login( final String username, final String password, final boolean rememberMe) throws LoginException { final Collection<UserService> services = this.userServiceTracker.getTracked().values(); if (services == null || services.isEmpty()) { throw new LoginException("No login service available"); } for (final UserService service : services) { try { // pass on to the next user service final UserInformation user = service.checkCredentials(username, password, rememberMe); if (user != null) { // got a login return user; } } catch (final Exception e) { if (ExceptionHelper.getRootCause(e) instanceof LoginException) { // this failure is ok throw e; } // this one it not and so we continue afterwards logger.warn("UserService failed", e); } } // end of the service list, nobody knowns this user throw new LoginException("Login error!", "Invalid username or password."); }
@Override public boolean hasUserBase() { final Collection<UserService> services = this.userServiceTracker.getTracked().values(); for (final UserService service : services) { if (service.hasUserBase()) { return true; } } return false; }
@Override public UserInformation refresh(final UserInformation user) { final Collection<UserService> services = this.userServiceTracker.getTracked().values(); if (services == null || services.isEmpty()) { return user; } for (final UserService service : services) { final UserInformation refreshedUser = service.refresh(user); if (refreshedUser != null) { return refreshedUser; } } return user; }