[seam-commits] Seam SVN: r12377 - in modules/security/trunk/core: src/main/java/org/jboss/seam/security/management/action and 1 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Sat Apr 3 10:39:34 EDT 2010


Author: shane.bryzak at jboss.com
Date: 2010-04-03 10:39:33 -0400 (Sat, 03 Apr 2010)
New Revision: 12377

Modified:
   modules/security/trunk/core/pom.xml
   modules/security/trunk/core/src/main/java/org/jboss/seam/security/management/action/UserSearch.java
   modules/security/trunk/core/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java
Log:
got rule-based permissions working


Modified: modules/security/trunk/core/pom.xml
===================================================================
--- modules/security/trunk/core/pom.xml	2010-04-03 03:32:15 UTC (rev 12376)
+++ modules/security/trunk/core/pom.xml	2010-04-03 14:39:33 UTC (rev 12377)
@@ -43,8 +43,8 @@
       </dependency>
 
       <dependency>
-         <groupId>org.drools</groupId>
-         <artifactId>drools-core</artifactId>
+         <groupId>org.jboss.seam.drools</groupId>
+         <artifactId>seam-drools-core</artifactId>
       </dependency>
        
       <dependency>

Modified: modules/security/trunk/core/src/main/java/org/jboss/seam/security/management/action/UserSearch.java
===================================================================
--- modules/security/trunk/core/src/main/java/org/jboss/seam/security/management/action/UserSearch.java	2010-04-03 03:32:15 UTC (rev 12376)
+++ modules/security/trunk/core/src/main/java/org/jboss/seam/security/management/action/UserSearch.java	2010-04-03 14:39:33 UTC (rev 12377)
@@ -1,24 +1,26 @@
 package org.jboss.seam.security.management.action;
 
 import java.io.Serializable;
+import java.util.List;
 
 import javax.enterprise.context.SessionScoped;
+import javax.inject.Inject;
 import javax.inject.Named;
 
+import org.jboss.seam.security.management.IdentityManager;
+
 @Named
 @SessionScoped
 public class UserSearch implements Serializable
 {
    private static final long serialVersionUID = 8592034786339372510L;
 
-   /*
-   @DataModel
    List<String> users;
    
-   @DataModelSelection
-   String selectedUser;
+   //@DataModelSelection
+   //String selectedUser;
    
-   @Current IdentityManager identityManager;
+   @Inject IdentityManager identityManager;
    
    public void loadUsers()
    {
@@ -41,10 +43,14 @@
       return sb.toString();
    }
    
-   public String getSelectedUser()
+   //public String getSelectedUser()
+   //{
+      //return selectedUser;
+   //}
+   
+   public List<String> getUsers()
    {
-      return selectedUser;
-   }
+      return users;
+   }   
    
-   */
 }
\ No newline at end of file

Modified: modules/security/trunk/core/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java
===================================================================
--- modules/security/trunk/core/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java	2010-04-03 03:32:15 UTC (rev 12376)
+++ modules/security/trunk/core/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java	2010-04-03 14:39:33 UTC (rev 12377)
@@ -14,10 +14,12 @@
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.event.Observes;
 
-import org.drools.FactHandle;
+import org.drools.KnowledgeBase;
 import org.drools.RuleBase;
 import org.drools.StatefulSession;
 import org.drools.ClassObjectFilter;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.rule.FactHandle;
 //import org.jboss.seam.drools.SeamGlobalResolver;
 import org.jboss.seam.security.Identity;
 import org.jboss.seam.security.Role;
@@ -38,9 +40,9 @@
 
    private Logger log = LoggerFactory.getLogger(RuleBasedPermissionResolver.class);
    
-   private StatefulSession securityContext;
+   private StatefulKnowledgeSession securityContext;
    
-   private RuleBase securityRules;
+   private KnowledgeBase securityRules;
    
    @Inject BeanManager manager;
    @Inject Identity identity;
@@ -56,7 +58,7 @@
    {
       if (getSecurityRules() != null)
       {
-         setSecurityContext(getSecurityRules().newStatefulSession(false));
+         setSecurityContext(getSecurityRules().newStatefulKnowledgeSession());
          //getSecurityContext().setGlobalResolver(new SeamGlobalResolver(getSecurityContext().getGlobalResolver()));
       }
    }
@@ -70,7 +72,7 @@
     */
    public boolean hasPermission(Object target, String action)
    {
-      StatefulSession securityContext = getSecurityContext();
+      StatefulKnowledgeSession securityContext = getSecurityContext();
       
       if (securityContext == null) return false;
       
@@ -125,7 +127,7 @@
    
    public boolean checkConditionalRole(String roleName, Object target, String action)
    {
-      StatefulSession securityContext = getSecurityContext();
+      StatefulKnowledgeSession securityContext = getSecurityContext();
       if (securityContext == null) return false;
       
       RoleCheck roleCheck = new RoleCheck(roleName);
@@ -214,11 +216,10 @@
                   Principal role = (Principal) e.nextElement();
    
                   boolean found = false;
-                  Iterator<Role> iter = (Iterator<Role>) getSecurityContext()
-                     .iterateObjects(new ClassObjectFilter(Role.class));
+                  Iterator<?> iter = getSecurityContext().getObjects(new ClassObjectFilter(Role.class)).iterator();
                   while (iter.hasNext())
                   {
-                     Role r = iter.next();
+                     Role r = (Role) iter.next();
                      if (r.getName().equals(role.getName()))
                      {
                         found = true;
@@ -235,11 +236,10 @@
             }
          }
          
-         Iterator<Role> iter = (Iterator<Role>) getSecurityContext()
-            .iterateObjects(new ClassObjectFilter(Role.class));
+         Iterator<?> iter = getSecurityContext().getObjects(new ClassObjectFilter(Role.class)).iterator();
          while (iter.hasNext())
          {
-            Role r = iter.next();
+            Role r = (Role) iter.next();
             if (!identity.hasRole(r.getName()))
             {
                FactHandle fh = getSecurityContext().getFactHandle(r);
@@ -250,23 +250,23 @@
    }
    
    
-   public StatefulSession getSecurityContext()
+   public StatefulKnowledgeSession getSecurityContext()
    {
       return securityContext;
    }
    
-   public void setSecurityContext(StatefulSession securityContext)
+   public void setSecurityContext(StatefulKnowledgeSession securityContext)
    {
       this.securityContext = securityContext;
    }
    
 
-   public RuleBase getSecurityRules()
+   public KnowledgeBase getSecurityRules()
    {
       return securityRules;
    }
 
-   public void setSecurityRules(RuleBase securityRules)
+   public void setSecurityRules(KnowledgeBase securityRules)
    {
       this.securityRules = securityRules;
    }



More information about the seam-commits mailing list