1 package com.atlassian.user.impl.osuser.security.authentication;
2
3 import com.atlassian.user.EntityException;
4 import com.atlassian.user.repository.RepositoryIdentifier;
5 import com.atlassian.user.security.authentication.Authenticator;
6 import com.opensymphony.user.provider.CredentialsProvider;
7
8 import java.util.Iterator;
9 import java.util.List;
10
11
12
13
14
15 public class OSUListOfCredentialProvidersAuthenticator implements Authenticator
16 {
17 private final RepositoryIdentifier repository;
18 private final List credentialProviders;
19
20 public OSUListOfCredentialProvidersAuthenticator(RepositoryIdentifier repository, List credentialProviders)
21 {
22 this.repository = repository;
23 this.credentialProviders = credentialProviders;
24 }
25
26 public boolean authenticate(String username, String password) throws EntityException
27 {
28 Iterator iter = credentialProviders.iterator();
29 while (iter.hasNext())
30 {
31 CredentialsProvider provider = (CredentialsProvider) iter.next();
32 if (provider.handles(username))
33 return provider.authenticate(username, password);
34 }
35
36 return false;
37 }
38
39 public RepositoryIdentifier getRepository()
40 {
41 return repository;
42 }
43 }