[jboss-user] [JBoss Seam] - Re: Exception for authorization attempt

shane.bryzak@jboss.com do-not-reply at jboss.com
Mon Feb 5 06:43:38 EST 2007


Yes, the authentication method changed.  You now need to provide a method that takes no parameters (instead of the three it expected before) but still returns a boolean.  The parameters were removed in favor of directly manipulating the identity instead - here's the example from the docs:


  | @Name("authenticator")
  | public class Authenticator {
  |    @In EntityManager entityManager;
  |    public boolean authenticate() {
  |       try
  |       {
  |          User user = (User) entityManager.createQuery(
  |             "from User where username = :username and password = :password")
  |             .setParameter("username", Identity.instance().getUsername())
  |             .setParameter("password", Identity.instance().getPassword())
  |             .getSingleResult();
  | 
  |          if (user.getRoles() != null)
  |          {
  |             for (UserRole mr : user.getRoles())
  |                Identity.instance().addRole(mr.getName());
  |          }
  | 
  |          return true;
  |       }
  |       catch (NoResultException ex)
  |       {
  |          FacesMessages.instance().add("Invalid username/password");
  |          return false;
  |       }
  |    }
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4011279#4011279

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4011279



More information about the jboss-user mailing list