[seam-commits] Seam SVN: r8321 - branches/Seam_2_0/src/main/org/jboss/seam/security.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue Jun 3 20:17:33 EDT 2008


Author: shane.bryzak at jboss.com
Date: 2008-06-03 20:17:32 -0400 (Tue, 03 Jun 2008)
New Revision: 8321

Modified:
   branches/Seam_2_0/src/main/org/jboss/seam/security/RuleBasedIdentity.java
Log:
JBSEAM-3064

Modified: branches/Seam_2_0/src/main/org/jboss/seam/security/RuleBasedIdentity.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/security/RuleBasedIdentity.java	2008-06-02 12:37:38 UTC (rev 8320)
+++ branches/Seam_2_0/src/main/org/jboss/seam/security/RuleBasedIdentity.java	2008-06-04 00:17:32 UTC (rev 8321)
@@ -117,15 +117,14 @@
       StatefulSession securityContext = getSecurityContext();
       
       if (securityContext == null) return false;      
-      
-      synchronizeContext();
-      
+            
       List<FactHandle> handles = new ArrayList<FactHandle>();
-
       PermissionCheck check = new PermissionCheck(name, action);
       
       synchronized( securityContext )
       {
+         synchronizeContext();         
+         
          handles.add( securityContext.insert(check) );
          
          for (int i = 0; i < arg.length; i++)
@@ -222,44 +221,47 @@
    {
       if (getSecurityContext() != null)
       {
-         for ( Group sg : getSubject().getPrincipals(Group.class) )      
-         {
-            if ( ROLES_GROUP.equals( sg.getName() ) )
+         synchronized(getSecurityContext())
+         {         
+            for ( Group sg : getSubject().getPrincipals(Group.class) )      
             {
-               Enumeration e = sg.members();
-               while (e.hasMoreElements())
+               if ( ROLES_GROUP.equals( sg.getName() ) )
                {
-                  Principal role = (Principal) e.nextElement();
-   
-                  boolean found = false;
-                  Iterator<Role> iter = getSecurityContext().iterateObjects(new ClassObjectFilter(Role.class)); 
-                  while (iter.hasNext()) 
+                  Enumeration e = sg.members();
+                  while (e.hasMoreElements())
                   {
-                     Role r = iter.next();
-                     if (r.getName().equals(role.getName()))
+                     Principal role = (Principal) e.nextElement();
+      
+                     boolean found = false;
+                     Iterator<Role> iter = getSecurityContext().iterateObjects(new ClassObjectFilter(Role.class)); 
+                     while (iter.hasNext()) 
                      {
-                        found = true;
-                        break;
+                        Role r = iter.next();
+                        if (r.getName().equals(role.getName()))
+                        {
+                           found = true;
+                           break;
+                        }
                      }
+                     
+                     if (!found)
+                     {
+                        getSecurityContext().insert(new Role(role.getName()));
+                     }
+                     
                   }
-                  
-                  if (!found)
-                  {
-                     getSecurityContext().insert(new Role(role.getName()));
-                  }
-                  
                }
-            }
-         }    
-         
-         Iterator<Role> iter = getSecurityContext().iterateObjects(new ClassObjectFilter(Role.class)); 
-         while (iter.hasNext()) 
-         {
-            Role r = iter.next();
-            if (!super.hasRole(r.getName()))
+            }    
+            
+            Iterator<Role> iter = getSecurityContext().iterateObjects(new ClassObjectFilter(Role.class)); 
+            while (iter.hasNext()) 
             {
-               FactHandle fh = getSecurityContext().getFactHandle(r);
-               getSecurityContext().retract(fh);
+               Role r = iter.next();
+               if (!super.hasRole(r.getName()))
+               {
+                  FactHandle fh = getSecurityContext().getFactHandle(r);
+                  getSecurityContext().retract(fh);
+               }
             }
          }
       }




More information about the seam-commits mailing list