DummyAuthenticator.java :  » Web-Framework » JAT » com » jat » business » authentication » Java Open Source

Java Open Source » Web Framework » JAT 
JAT » com » jat » business » authentication » DummyAuthenticator.java
package com.jat.business.authentication;

import com.jat.business.BusinessException;
import com.jat.business.BusinessObjectProperties;
import com.jat.business.JatUser;

/**
 * <p>Title: JAT</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004 -2005 Stefano Fratini (stefano.fratini@gmail.com)</p>
 * <p>Distributed under the terms of the GNU Lesser General Public License, v2.1 or later</p>
 * @author stf
 * @version 1.2
 * @since 1.0
 */

public class DummyAuthenticator implements Authenticator {

  public JatUser authenticate(String username, String password) throws AuthenticationException {
  DefaultUser user = null;
  try {
    user = new DefaultUser("DUMMY", username, password);
  } catch(BusinessException ex) {
    throw new AuthenticationException(ex.getMessage());
  }
  //if (username.indexOf("st")<0) throw new AuthenticationException("User does not exist");
  if(password.length()<3)
    throw new AuthenticationException("Wrong username and/or password");
  user.putField(JatUser.LAST_NAME, "Satriani");
  user.putField(JatUser.FIRST_NAME, "Joe");
  user.putField(JatUser.PROFILE, "DUMMY");
  return user;
  }

  /** @link dependency
   * @stereotype instantiate*/
  /*# DefaultUser lnkDefaultUser; */
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.