TestAuthenticator.java

  1. package org.itracker.services.authentication;

  2. import org.itracker.model.User;
  3. import org.itracker.services.UserService;
  4. import org.itracker.services.exceptions.AuthenticatorException;


  5. /**
  6.  * An authenticator that always returns the admin user.
  7.  * Mainly for testing
  8.  *
  9.  * @author Ricardo Trindade (ricardo.trindade@emation.pt)
  10.  */
  11. public class TestAuthenticator extends DefaultAuthenticator {

  12.     /**
  13.      * @see org.itracker.ejb.authentication.AbstractPluggableAuthenticator#checkLogin(java.lang.String,
  14.      *      java.lang.Object, int, int)
  15.      */
  16.     public User checkLogin(String login, Object authentication, int authType, int reqSource)
  17.             throws AuthenticatorException {

  18.         UserService userService = getUserService();
  19.         return (userService.getUserByLogin("admin"));

  20.     }

  21.     /*
  22.      * (non-Javadoc)
  23.      *
  24.      * @see org.itracker.ejb.authentication.AbstractPluggableAuthenticator#allowProfileUpdates(org.itracker.model.deprecatedmodels.User,
  25.      *      java.lang.Object, int, int)
  26.      */
  27.     public boolean allowProfileUpdates(User user, Object authentication, int authType, int reqSource)
  28.             throws AuthenticatorException {
  29.         return true;
  30.     }

  31.     /*
  32.      * (non-Javadoc)
  33.      *
  34.      * @see org.itracker.ejb.authentication.AbstractPluggableAuthenticator#allowPasswordUpdates(org.itracker.model.deprecatedmodels.User,
  35.      *      java.lang.Object, int, int)
  36.      */
  37.     public boolean allowPasswordUpdates(User user, Object authentication, int authType, int reqSource)
  38.             throws AuthenticatorException {
  39.         return false;
  40.     }

  41. }