Package net.vinant.idp4java.base

Source Code of net.vinant.idp4java.base.InMemoryAuthenticationHandler

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);   
  }

 
}
TOP

Related Classes of net.vinant.idp4java.base.InMemoryAuthenticationHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.