Skip to content
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
44 lines (37 sloc) 1.25 KB
package org.kovacstelekes;
import static org.kovacstelekes.AuthenticationResult.FAILED;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
public class AuthenticationService {
private final static Logger LOGGER = LoggerFactory
private List<AuthenticationProvider> providers;
public void setProviders(List<AuthenticationProvider> providers) {
this.providers = providers;
* Asks all providers to attempt authentication.
* @param userId
* the user ID
* @param password
* the password
* @return true if authenticated, false if not
public AuthenticationResult authenticate(String userId, String password) {
AuthenticationResult result = FAILED;
for (AuthenticationProvider provider : providers) {
result = provider.authenticate(userId, password);
if (result.isFinal()) {
}"Result of authenticating {}: {}", userId, result);
return result;
You can’t perform that action at this time.