0 Replies Latest reply on Jul 2, 2009 1:00 AM by m.schmidt

    Identity.instance().hasPermission doesn't work

    m.schmidt Newbie


      I'm using the default JPA permission store and drools rules to grant admin users all rights.

      But i have problems with Identity.instance().hasPermission when a non-admin tries to perform actions.

      It returns sometimes 'false' although it should return 'true'.

      That's the DB row:

      <id,target,action,recipient,discriminator> = <125,'post:54','viewPost,downloadPost','testuser','user'>

      This view code always works:

      <h:column rendered="#{s:hasPermission(PostViewer.currentPost,'downloadPost')}">

      This Java code works:

      this.post = sessionData.getPost();
      downloadable = Identity.instance().hasPermission(post, "downloadPost");

      This Java code doesn't work:

      Post p = postDAO.findByID(kc.getPost().getId());
      System.out.println("bbbb: " + p.getId()); // prints 'bbbb: 54'
      downloadable = Identity.instance().hasPermission(p, "downloadPost");

      Am I doing something wrong?
      Why does it fail only sometimes?