5 Replies Latest reply on Feb 17, 2010 11:08 PM by Ben Groeneveld

    JPAPermissionStore.resolvePrincipal fails to resolve if PermissionUser, PermissionRole are different

    Joshua D Novice
      Env: JBoss Seam 2.2.0 JBoss 5.1

      JPAPermissionStore.resolvePrincipal fails to resolve if PermissionUser, PermissionRole are expressed as ManyToOne relationships in the Permission class.

      @Entity
      ...
      public class UserPermission {

      ...
          @ManyToOne(fetch = FetchType.LAZY)
          @JoinColumn(name = "role_id", referencedColumnName = "id")
          @PermissionRole
          private Role role;

          @ManyToOne(fetch = FetchType.LAZY)
          @JoinColumn(name = "user_id", referencedColumnName = "id")
          @PermissionUser
          private User user;
      ...
      }

      JPAPermissionStore:578 (seems to contain the fix as mentioned in https://jira.jboss.org/jira/browse/JBSEAM-3619)

      if (isUser && identityStore.getUserClass().isAssignableFrom(principal.getClass()))
               {
                  return new SimplePrincipal(identityStore.getUserName(principal));
              

      Any ideas on what could cause this issue?


      Debug logs...

          /* select
              p
          from
              com.mycompany.model.UserPermission p
          where
              p.target = :target */ select
                  userpermis0_.id as id26_,
                  userpermis0_.action as action26_,
                  userpermis0_.discriminator as discrimi3_26_,
                  userpermis0_.role_id as role5_26_,
                  userpermis0_.target as target26_,
                  userpermis0_.user_id as user6_26_
              from
                  com_user_role_perm userpermis0_
              where
                  userpermis0_.target=?
      .........

      Caused by: javax.el.ELException: /User.xhtml @123,116 rendered="s:hasPermission('seam.user', 'update')}":
      java.lang.NullPointerException
              at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpressi
      on.java:76)
              at javax.faces.component.UIComponentBase.isRendered(UIComponentBase
      .java:390)
              ... 60 more
      Caused by: java.lang.NullPointerException
              at org.jboss.seam.security.permission.JpaPermissionStore.resolvePri
      ncipal(JpaPermissionStore.java:578)
              at org.jboss.seam.security.permission.JpaPermissionStore.lookupPrin
      cipal(JpaPermissionStore.java:741)
              at org.jboss.seam.security.permission.JpaPermissionStore.listPermis
      sions(JpaPermissionStore.java:674)
              at org.jboss.seam.security.permission.JpaPermissionStore.listPermis
      sions(JpaPermissionStore.java:607)
              at org.jboss.seam.security.permission.PersistentPermissionResolver.
      hasPermission(PersistentPermissionResolver.java:80)
              at org.jboss.seam.security.permission.PermissionMapper.resolvePermi
      ssion(PermissionMapper.java:80)
              at org.jboss.seam.security.Identity.hasPermission(Identity.java:632
      )
              at org.jboss.seam.security.SecurityFunctions.hasPermission(Security
      Functions.java:29)