1 Reply Latest reply on Nov 10, 2010 3:21 AM by poschd

    IdentityManager not found in components.xml

    poschd

      Hi everyone,


      I am struggling to set up authentication using the Identity Management API. It seems to be a straight forward task, but I have failed. When I try to login, the following excpetion occurs:


      WARN  [org.jboss.seam.security.jaas.SeamLoginModule] (http-localhost%2F127.0.0.1-8080-1) Error invoking login method



      I haven't management to get more information... (Any suggestions?) Anyway, what catched my eye were two warnings in components.xml from Eclipse, stating that neither IdentityManager nor JpaIdentityStore could be resolved:



      • "org.jboss.seam.security.IdentityManager" cannot be resolved to a type

      • "org.jboss.seam.security.JpaIdentityStore" cannot be resolved to a type



      I think there's something wrong with capitalization, isn't it? Shouldn't it be "identityManager" and "jpaIdentityManager", respectively? Can this be a bug? Or is there an error elsewhere in my code?


      I'd be happy for any suggestions. Thanks a lot!


      Best Regards,


      Daniel


      By the way, I'm using Seam 2.2.CR2 and JBoss 5.1.


      components.xml:


      <!-- .... -->
      <security:identity-manager identity-store="#{jpaIdentityStore}" /> <!-- "org.jboss.seam.security.IdentityManager" cannot be resolved to a type -->
      <security:jpa-identity-store user-class="my.simple.entity.User" role-class="my.simple.entity.Role" /> <!-- "org.jboss.seam.security.JpaIdentityStore" cannot be resolved to a type -->
      <!-- .... -->



      login.xhtml:


      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
           xmlns:s="http://jboss.com/products/seam/taglib"
           xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml">
      
           <ui:define name="body">
                <h:form id="loginForm">
                     <rich:panel>
                          <f:facet name="header">Login</f:facet>
      
                          <p>Please login here</p>
      
                          <div class="dialog"><h:panelGrid columns="2" rowClasses="prop"
                               columnClasses="name,value">
                               <h:outputLabel for="username">Username</h:outputLabel>
                               <h:inputText id="username" value="#{credentials.username}" />
                               <h:outputLabel for="password">Password</h:outputLabel>
                               <h:inputSecret id="password" value="#{credentials.password}" />
                               <h:outputLabel for="rememberMe">Remember me</h:outputLabel>
                               <h:selectBooleanCheckbox id="rememberMe"
                                    value="#{identity.rememberMe}" />
                          </h:panelGrid></div>
                     </rich:panel>
      
                     <div class="actionButtons">
                          <h:commandButton id="submit" value="Login" action="#{identity.login}" />
                     </div>
                </h:form>
           </ui:define>
      </ui:composition>



      User.java:



      @Entity
      @Table(name = "user", schema = "security")
      public class User implements java.io.Serializable {
           private static final long serialVersionUID = -6955525812822596985L;
      
           private int id;
           private String username;
           private String password;
           private String firstname;
           private String lastname;
           private Boolean enabled;
           private Set<Role> roles = new HashSet<Role>(0);
      
           public User() {
           }
      
           public User(int id, String username, String password) {
                this.id = id;
                this.username = username;
                this.password = password;
           }
      
           public User(Integer id, String username, String password, String firstname,
                     String lastname, Boolean enabled, Set<Role> roles) {
                this.id = id;
                this.username = username;
                this.password = password;
                this.firstname = firstname;
                this.lastname = lastname;
                this.enabled = enabled;
                this.roles = roles;
           }
      
           @Id
           @GeneratedValue(strategy = GenerationType.SEQUENCE)
           @Column(name = "id", unique = true, nullable = false)
           public int getId() {
                return this.id;
           }
      
           public void setId(int id) {
                this.id = id;
           }
      
           @UserPrincipal
           @Column(name = "username", nullable = false, length = 32)
           public String getUsername() {
                return this.username;
           }
      
           public void setUsername(String username) {
                this.username = username;
           }
      
           @UserPassword(hash = "md5")
           @Column(name = "password", nullable = false)
           public String getPassword() {
                return this.password;
           }
      
           public void setPassword(String password) {
                this.password = password;
           }
      
           @UserFirstName
           @Column(name = "firstname", length = 32)
           public String getFirstname() {
                return this.firstname;
           }
      
           public void setFirstname(String firstname) {
                this.firstname = firstname;
           }
      
           @UserLastName
           @Column(name = "lastname")
           public String getLastname() {
                return this.lastname;
           }
      
           public void setLastname(String lastname) {
                this.lastname = lastname;
           }
      
           @UserEnabled
           @Column(name = "enabled")
           public Boolean getEnabled() {
                return this.enabled;
           }
      
           public void setEnabled(Boolean enabled) {
                this.enabled = enabled;
           }
      
           @UserRoles
           @ManyToMany(fetch = FetchType.LAZY)
           @JoinTable(name = "user_role", schema = "security", joinColumns = { @JoinColumn(name = "user_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "role_id", nullable = false, updatable = false) })
           public Set<Role> getRoles() {
                return this.roles;
           }
      
           public void setRoles(Set<Role> roles) {
                this.roles = roles;
           }
      }




      Role.java:



      @Entity
      @Table(name = "role", schema = "security")
      public class Role implements java.io.Serializable {
           private static final long serialVersionUID = -8291119166266410989L;
      
           private int id;
           private String rolename;
           private Set<User> users = new HashSet<User>(0);
      
           public Role() {
           }
      
           public Role(int id, String rolename) {
                this.id = id;
                this.rolename = rolename;
           }
      
           public Role(int id, String rolename, Set<User> users) {
                this.id = id;
                this.rolename = rolename;
                this.users = users;
           }
      
           @Id
           @GeneratedValue(strategy = GenerationType.SEQUENCE)
           @Column(name = "id", unique = true, nullable = false)
           public int getId() {
                return this.id;
           }
      
           public void setId(int id) {
                this.id = id;
           }
      
           @RoleName
           @Column(name = "rolename", nullable = false, length = 32)
           public String getRolename() {
                return this.rolename;
           }
      
           public void setRolename(String rolename) {
                this.rolename = rolename;
           }
      
           @ManyToMany(fetch = FetchType.LAZY)
           @JoinTable(name = "user_role", schema = "security", joinColumns = { @JoinColumn(name = "role_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "user_id", nullable = false, updatable = false) })
           public Set<User> getUsers() {
                return this.users;
           }
      
           public void setUsers(Set<User> users) {
                this.users = users;
           }
      }