package net.vinant.idp4java.base;
import java.util.List;
import java.util.Vector;
import net.vinant.idp4java.openid4javaImpl.User;
import org.apache.commons.lang.StringUtils;
public class InMemoryAuthenticationHandler extends BaseAuthenticationHandler {
private static List<User> users = new Vector();
public InMemoryAuthenticationHandler(BaseServiceProxy proxy) {
super(proxy);
}
@Override
public IUser authenticate(String username, String password) {
if(!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)){
for(User u : users){
if(u.getUserName()!=null && u.getPassword()!=null &&
StringUtils.equalsIgnoreCase(u.getUserName(), username)
&& StringUtils.equals(u.getPassword(), password))
return u;
}
}
return null;
}
@Override
public void init() {
User u1 = new User("Joe", "Doe", "joe.dow@gmail.com", "test", "test");
users.add(u1);
u1 = new User("Joe2", "Doe2", "joe.dow2@gmail.com", "user", "pass");
users.add(u1);
}
}