[seam-commits] Seam SVN: r10102 - trunk/src/main/org/jboss/seam/security/permission.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon Mar 2 05:27:17 EST 2009
Author: shane.bryzak at jboss.com
Date: 2009-03-02 05:27:17 -0500 (Mon, 02 Mar 2009)
New Revision: 10102
Modified:
trunk/src/main/org/jboss/seam/security/permission/PermissionCheck.java
trunk/src/main/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java
Log:
support for multi-target permission checks
Modified: trunk/src/main/org/jboss/seam/security/permission/PermissionCheck.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/PermissionCheck.java 2009-03-01 19:15:15 UTC (rev 10101)
+++ trunk/src/main/org/jboss/seam/security/permission/PermissionCheck.java 2009-03-02 10:27:17 UTC (rev 10102)
@@ -1,5 +1,8 @@
package org.jboss.seam.security.permission;
+import java.util.HashSet;
+import java.util.Set;
+
/**
* Used to assert permission requirements into a WorkingMemory when evaluating
* a @Restrict expression. The consequence of the rule is responsible for
@@ -16,6 +19,7 @@
private String action;
private boolean granted;
+ private Set<String> requirements;
public PermissionCheck(Object target, String action)
{
@@ -44,6 +48,16 @@
{
return action;
}
+
+ public void require(String requirement)
+ {
+ if (requirements == null)
+ {
+ requirements = new HashSet<String>();
+ }
+
+ requirements.add(requirement);
+ }
public void grant()
{
@@ -59,4 +73,14 @@
{
return granted;
}
+
+ public boolean hasRequirements()
+ {
+ return requirements != null && requirements.size() > 0;
+ }
+
+ public Set<String> getRequirements()
+ {
+ return requirements;
+ }
}
Modified: trunk/src/main/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java 2009-03-01 19:15:15 UTC (rev 10101)
+++ trunk/src/main/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java 2009-03-02 10:27:17 UTC (rev 10102)
@@ -164,6 +164,22 @@
try
{
+ handles.add( securityContext.insert(check));
+
+ // Check if there are any additional requirements
+ securityContext.fireAllRules();
+ if (check.hasRequirements())
+ {
+ for (String requirement : check.getRequirements())
+ {
+ Object value = Contexts.lookupInStatefulContexts(requirement);
+ if (value != null)
+ {
+ handles.add (securityContext.insert(value));
+ }
+ }
+ }
+
synchronizeContext();
handles.add( securityContext.insert(roleCheck));
More information about the seam-commits
mailing list