[seam-commits] Seam SVN: r8568 - branches/Seam_2_0_FP/src/main/org/jboss/seam/security.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon Aug 4 10:40:13 EDT 2008
Author: manaRH
Date: 2008-08-04 10:40:13 -0400 (Mon, 04 Aug 2008)
New Revision: 8568
Modified:
branches/Seam_2_0_FP/src/main/org/jboss/seam/security/RuleBasedIdentity.java
Log:
Backport of JBSEAM-3064
Modified: branches/Seam_2_0_FP/src/main/org/jboss/seam/security/RuleBasedIdentity.java
===================================================================
--- branches/Seam_2_0_FP/src/main/org/jboss/seam/security/RuleBasedIdentity.java 2008-08-04 14:32:50 UTC (rev 8567)
+++ branches/Seam_2_0_FP/src/main/org/jboss/seam/security/RuleBasedIdentity.java 2008-08-04 14:40:13 UTC (rev 8568)
@@ -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++)
@@ -165,12 +164,15 @@
{
if (securityContext != null)
{
- Iterator<Role> iter = securityContext.iterateObjects(new ClassObjectFilter(Role.class));
-
- while (iter.hasNext())
+ synchronized(securityContext)
{
- Role r = iter.next();
- if (r.getName().equals(role)) return true;
+ Iterator<Role> iter = securityContext.iterateObjects(new ClassObjectFilter(Role.class));
+
+ while (iter.hasNext())
+ {
+ Role r = iter.next();
+ if (r.getName().equals(role)) return true;
+ }
}
}
@@ -222,44 +224,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