1 Reply Latest reply on Nov 2, 2011 1:48 PM by nathandennis

    Programmatic login in Seam 3 per JEE6

    numerico

      If anyone ever needs to programmatically login a user using Seam 3, this is how I got it to work:


      import org.jboss.seam.security.Credentials;
      import org.picketlink.idm.impl.api.PasswordCredential;
      import org.jboss.seam.security.Identity;


      /in my class:/


      @Inject private Identity id;


      @Inject private Credentials credentials;


      /in my method:/


      credentials.setUsername(user.getName());


      credentials.setCredential(new PasswordCredential(confirmado.getPassword()));


      id.login(); //this will call my custom authenticate() method



      There are many posts on how to achieve this in Seam 2 just setting the user and pass, but couldn't find none about the same topic using JEE6, though it turned out to be pretty obvious.


      These classes are those of a default Seam 3 installation on JBoss AS 6.0.0


      Numerico.
      Chile