[seam-commits] Seam SVN: r7165 - trunk/src/main/org/jboss/seam/security.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Mon Jan 21 07:04:34 EST 2008


Author: shane.bryzak at jboss.com
Date: 2008-01-21 07:04:34 -0500 (Mon, 21 Jan 2008)
New Revision: 7165

Modified:
   trunk/src/main/org/jboss/seam/security/RuleBasedIdentity.java
Log:
fixed npe

Modified: trunk/src/main/org/jboss/seam/security/RuleBasedIdentity.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/RuleBasedIdentity.java	2008-01-21 11:45:19 UTC (rev 7164)
+++ trunk/src/main/org/jboss/seam/security/RuleBasedIdentity.java	2008-01-21 12:04:34 UTC (rev 7165)
@@ -222,45 +222,48 @@
     */
    private void synchronizeContext()
    {
-      for ( Group sg : getSubject().getPrincipals(Group.class) )      
+      if (getSecurityContext() != null)
       {
-         if ( ROLES_GROUP.equals( sg.getName() ) )
+         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()) 
                   {
-                     FactHandle fh = getSecurityContext().getFactHandle(r);
-                     found = true;
-                     break;
+                     Role r = iter.next();
+                     if (r.getName().equals(role.getName()))
+                     {
+                        FactHandle fh = getSecurityContext().getFactHandle(r);
+                        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