3 Replies Latest reply on Dec 30, 2008 8:52 AM by visumagic

    need drools permissions hello world application

    visumagic

      Hi
      I'm new to drools and trying to implement permissions using drools
      rules. I'm able to understand point by point using seamspace example.
      But I'm not able to run the rule in my helloworld app. here is my sample code


      1)I generated seam application using jboss tools


      rule apple
      when
       check: PermissionCheck(name=="Ale",action == "ale")
      then
      System.out.println("Hello World");
      check.grant();
      end



      2)


      @Name("Ale")
      public class Ale
      {
              @Logger private Log log;
          public void ale()
          {
                log.info("Ale.ale() action called");
          }
      
      }
      



      2)I'm trying to print the permissions on my xhtml page using following expression.
                


      #{s:hasPermission(Ale,'ale')}




      Here I'm trying to validate the permission.
      When ever I call Ale.ale() then rule should  print Hello World but it's not at all going through


      I'm novice at drools rules. I'm searching explanation for here.
      As per my understanding
      hasPermission checks permissions on (target or name)->action (PermissionCheck)
      And I'm not able to understand few things here..
      a) As per my requirement I want to render a component based on ownership and with few conditions. here my mind is empty
      because I'm still at HelloWorld in drools.



      please suggest me ..


      thanks
      raghu

        • 1. Re: need drools permissions hello world application
          visumagic

          After a long investigation I found that , hasPermission is limitted to 3 parameters (name,action,target) - in target I can pass only one arg(not var args)
          Identity:hasPermissions has var args feature but , it's not working.


          I did't find any additional advantages , it's simple to write my permissions api in java/groovy


          Unfortunately I did't found much docs to explain this. For beginners it will be much difficult to understand.


          I hope there will me more features on this area in the next releases of Seam.


          thanks
          raghu 

          • 2. Re: need drools permissions hello world application
            visumagic

            That too I totally confused with seamspace sample application.It's security rules are in draft (most of them are not implemented)


            Useful links:


            http://chiralsoftware.com/seam-security-rules/jboss-rules.seam
            http://shane.bryzak.com/articles/seamsecuritygetsanupgrade
            (only google cached version is available)


            thanks
            raghu

            • 3. Re: need drools permissions hello world application
              visumagic

              Finally I got it..
              i did a mistake ..
              drools got user account into it's working memory , we can directly
              point that.


              Working rule:


              rule UserChitchatCheck
               no-loop
                   activation-group "permissions"
              when
                   
                    u: User()
                    //Chitchat(u2:user)
                    Chitchat(user.id == u.id)
                    check: PermissionCheck(action == "cdelete")
                   // Role(name == "user")
              then
                   //System.out.println("cdelete:"+n);
                   //System.out.println("cdelete:"+u.id+"-"+u2.id);
                    check.grant();
              end     


                   


              I agree, drools is simple if u know :)


              thanks
              raghu