3 Replies Latest reply on Feb 17, 2009 12:16 PM by Pieter Bosman

    Authenticator, Seam Component and JBoss Tools question

    Pieter Bosman Newbie

      Hello all,

      first of all, I'm a newbie in both Seam and JSF/Facelets usage, so it's entirely possible my question a 'stupid' one :)


      I got an entity bean called 'Speler' (roughly translated towards user) which refers to a table containing all my users.

      @Table(name = "speler", catalog = "saga", uniqueConstraints = @UniqueConstraint(columnNames = "login"))
      @Roles ({
           @Role(name="loggedIn", scope=ScopeType.SESSION),
           @Role(name="selectedSpeler", scope=ScopeType.SESSION)
      public class Speler implements java.io.Serializable {
           private Long id;
           private String naam;
           private String paswoord;
           private String login;
           private String voornaam;
           private String role;
      //... Getters and Setters left out ...

      I've left out getters and setters.

      In my Authenticator class, which was generated by JBoss Tools, I've modified the authenticate method to check the login credentials to the ones that exist in the database. This part works.

      public class Authenticator
          @Logger private Log log;
          @In Identity identity;
          @In Credentials credentials;
          @In EntityManager entityManager;
          @In @Out (required=false) Speler loggedIn; 
          public boolean authenticate()
              log.info("authenticating {0}", credentials.getUsername());
              //write your authentication logic here,
              //return true if the authentication was
              //successful, false otherwise
              Speler speler = (Speler) entityManager.
                        createQuery("select s from Speler s where s.login = :login").
                        setParameter("login", credentials.getUsername()).
              if (null!=speler) {
                   if (speler.getPaswoord().equals(credentials.getPassword())) {
                        loggedIn = speler;
                        return true;
              return false;

      Next I tried to add a 'Speler' bean in the Authenticator class that refers to the 'loggedIn' annotated seam component as described in the above code.
      This 'loggedIn' component I then use in my views to show some hello messages, and here is where I somehow loose track of things. My view in no way shows the data that should be in the 'loggedIn' seam Component.

      I call the 'loggedIn' component like this:

                value="Welcome #{loggedIn.voornaam}, You are signed in as: #{loggedIn.role}"
                rendered="#{identity.loggedIn}" />

      And all it renders is Welcome , You are signed in as:

      Am I doing something wrong somewhere?

      all replies appreciated!