JBoss Portal SVN: r12356 - in modules/authorization/trunk/PAP/src: test/java/org/jboss/security/authz/pap/hierarchial and 1 other directory.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2008-12-05 18:20:26 -0500 (Fri, 05 Dec 2008)
New Revision: 12356
Modified:
modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/hierarchial/HierarchialPolicy.java
modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/hierarchial/TestHierarchialPolicy.java
Log:
code backup
Modified: modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/hierarchial/HierarchialPolicy.java
===================================================================
--- modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/hierarchial/HierarchialPolicy.java 2008-12-05 22:02:03 UTC (rev 12355)
+++ modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/hierarchial/HierarchialPolicy.java 2008-12-05 23:20:26 UTC (rev 12356)
@@ -281,9 +281,9 @@
return condition;
}
- //---------More Developer Friendly API-------------------------------------------------------------------------------------------------------------------------
+ //---------A Developer Friendly API for generating Hierarchial Policies-------------------------------------------------------------------------------------------------------------------------
/**
- * Specifies that this Hierarchial Policy should be applied the specified unique Resource Uri
+ * Specifies that this Hierarchial Policy should be applied the specified Resource identified by the Unique Resource Uri
*
* @param resourceUri Unique identifier for the Resource being protected by this Hierarchial Policy
*/
@@ -300,14 +300,23 @@
}
/**
- * Specifies a Policy Rule that must be applied to the specified "action" such that the specified "role" should be allowed
- * to execute this "action" on the Resource protected by this Policy instance
+ * Specifies a Policy Rule that must be applied to the specified "Action" such that the specified "Role" should be allowed
+ * to execute this "Action" on the Resource protected by this Policy instance
*
* @param action Action for which this Rule applies
* @param role the Role that is permitted to execute this Action
*/
public void setPermitCriteria(String action, String role)
{
+ if(action == null || action.trim().length()==0)
+ {
+ throw new IllegalArgumentException("Action cannot be Empty");
+ }
+ if(role == null || role.trim().length()==0)
+ {
+ throw new IllegalArgumentException("Role cannot be Empty");
+ }
+
Rule permitRule = new Rule();
Target ruleTarget = new Target();
@@ -326,14 +335,55 @@
}
/**
- * Specifies a Policy Rule that must be applied to the specified "action" such that the Authenticated User will be permitted to
- * execute it if he/she belongs to any of the specified "roles"
+ * Specifies a Policy Rule that must be applied to the specified "Action" such that the specified "Role" should *NOT* be allowed
+ * to execute this "Action" on the Resource protected by this Policy instance
*
* @param action Action for which this Rule applies
+ * @param role the Role that is *NOT* permitted to execute this Action
+ */
+ public void setDenyCriteria(String action, String role)
+ {
+ if(action == null || action.trim().length()==0)
+ {
+ throw new IllegalArgumentException("Action cannot be Empty");
+ }
+ if(role == null || role.trim().length()==0)
+ {
+ throw new IllegalArgumentException("Role cannot be Empty");
+ }
+
+ Rule permitRule = new Rule();
+ Target ruleTarget = new Target();
+
+ permitRule.setRuleId(action);
+ permitRule.setEffect(Effect.DENY);
+ permitRule.setTarget(ruleTarget);
+
+ //Create an Action Match Function
+ ruleTarget.addActionMatch(ExpressionBuilder.getInstance().createActionExpression(action));
+
+ //Create a Subject Match Function
+ ruleTarget.addSubjectMatch(ExpressionBuilder.getInstance().createBelongsToRoleExpression(role));
+
+ //Add the Rule to the Policy
+ this.rules.add(permitRule);
+ }
+
+ /**
+ * Specifies a Policy Rule that must be applied to the specified "Action" such that the Authenticated User will be permitted to
+ * execute it if he/she belongs to any of the specified "Roles"
+ *
+ * @param action Action for which this Rule applies
* @param roles a list of permitted roles for this Action
- */
+ */
public void setPermitCriteria(String action, String[] roles)
{
+ if(action == null || action.trim().length()==0)
+ {
+ throw new IllegalArgumentException("Action cannot be Empty");
+ }
+
+
Rule permitRule = new Rule();
Target ruleTarget = new Target();
@@ -345,12 +395,83 @@
ruleTarget.addActionMatch(ExpressionBuilder.getInstance().createActionExpression(action));
//Create a Subject Match Function
- for(int i=0; i<roles.length; i++)
+ if(roles != null)
{
- ruleTarget.addSubjectMatch(ExpressionBuilder.getInstance().createBelongsToRoleExpression(roles[i]));
+ for(int i=0; i<roles.length; i++)
+ {
+ ruleTarget.addSubjectMatch(ExpressionBuilder.getInstance().createBelongsToRoleExpression(roles[i]));
+ }
}
//Add the Rule to the Policy
this.rules.add(permitRule);
}
+
+ /**
+ * Specifies a Policy Rule that must be applied to the specified "Action" such that the Authenticated User will *NOT* be permitted to
+ * execute it if he/she belongs to any of the specified "Roles"
+ *
+ * @param action Action for which this Rule applies
+ * @param roles a list of roles that must *NOT* be allowed to execute for this Action
+ */
+ public void setDenyCriteria(String action, String[] roles)
+ {
+ if(action == null || action.trim().length()==0)
+ {
+ throw new IllegalArgumentException("Action cannot be Empty");
+ }
+
+
+ Rule permitRule = new Rule();
+ Target ruleTarget = new Target();
+
+ permitRule.setRuleId(action);
+ permitRule.setEffect(Effect.DENY);
+ permitRule.setTarget(ruleTarget);
+
+ //Create an Action Match Function
+ ruleTarget.addActionMatch(ExpressionBuilder.getInstance().createActionExpression(action));
+
+ //Create a Subject Match Function
+ if(roles != null)
+ {
+ for(int i=0; i<roles.length; i++)
+ {
+ ruleTarget.addSubjectMatch(ExpressionBuilder.getInstance().createBelongsToRoleExpression(roles[i]));
+ }
+ }
+
+ //Add the Rule to the Policy
+ this.rules.add(permitRule);
+ }
+
+ public void setPermitCriteria(String action, DroolsRuleExpression ruleExpression)
+ {
+ if(action == null || action.trim().length()==0)
+ {
+ throw new IllegalArgumentException("Action cannot be Empty");
+ }
+ if(ruleExpression == null)
+ {
+ throw new IllegalArgumentException("RuleExpression cannot be Empty");
+ }
+
+ //TODO: compile the Rule that is being added, and add it to the Drools Rule Repository
+
+ Rule permitRule = new Rule();
+ Target ruleTarget = new Target();
+
+ permitRule.setRuleId(action);
+ permitRule.setEffect(Effect.PERMIT);
+ permitRule.setTarget(ruleTarget);
+
+ //Create an Action Match Function
+ ruleTarget.addActionMatch(ExpressionBuilder.getInstance().createActionExpression(action));
+
+ //Create a pointer to the new Rule
+ permitRule.setExpression(ruleExpression);
+
+ //Add the Rule to the Policy
+ this.rules.add(permitRule);
+ }
}
Modified: modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/hierarchial/TestHierarchialPolicy.java
===================================================================
--- modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/hierarchial/TestHierarchialPolicy.java 2008-12-05 22:02:03 UTC (rev 12355)
+++ modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/hierarchial/TestHierarchialPolicy.java 2008-12-05 23:20:26 UTC (rev 12356)
@@ -22,14 +22,11 @@
******************************************************************************/
package org.jboss.security.authz.pap.hierarchial;
-import java.util.Set;
-import java.util.HashSet;
-
import junit.framework.TestCase;
import org.apache.log4j.Logger;
-import org.jboss.security.authz.model.*;
+import org.jboss.security.authz.model.DroolsRuleExpression;
/**
@@ -48,9 +45,7 @@
{
}
- /**
- *
- */
+
public void testSimplePolicy() throws Exception
{
//Populate the HierarchialPolicy
@@ -78,4 +73,49 @@
log.info(xacmlPolicy);
log.info("--------------------------------------------------------------------");
}
+
+ public void testSimpleDeny() throws Exception
+ {
+ //Populate the HierarchialPolicy
+ HierarchialPolicy policy = new HierarchialPolicy("simpleHierarchialPolicy");
+ policy.setResourceCriteria("http://www.redhat.com/protected/index.html");
+ policy.setDenyCriteria("Write", "developer");
+
+ String xacmlPolicy = policy.generateXACMLPolicy();
+
+ log.info("--------------------------------------------------------------------");
+ log.info(xacmlPolicy);
+ log.info("--------------------------------------------------------------------");
+ }
+
+ public void testMultiRoleDenyPolicy() throws Exception
+ {
+ //Populate the HierarchialPolicy
+ HierarchialPolicy policy = new HierarchialPolicy("simpleHierarchialPolicy");
+ policy.setResourceCriteria("http://www.redhat.com/protected/index.html");
+ policy.setDenyCriteria("Write", new String[]{"developer", "designer", "sysadmin"});
+
+ String xacmlPolicy = policy.generateXACMLPolicy();
+
+ log.info("--------------------------------------------------------------------");
+ log.info(xacmlPolicy);
+ log.info("--------------------------------------------------------------------");
+ }
+
+ public void testSimplePolicyWithDroolsExpression() throws Exception
+ {
+ //Populate the HierarchialPolicy
+ HierarchialPolicy policy = new HierarchialPolicy("simpleHierarchialPolicy");
+ policy.setResourceCriteria("http://www.redhat.com/protected/index.html");
+
+ DroolsRuleExpression expression = new DroolsRuleExpression();
+ expression.setFunctionId("WriteRule");
+ policy.setPermitCriteria("Write", expression);
+
+ String xacmlPolicy = policy.generateXACMLPolicy();
+
+ log.info("--------------------------------------------------------------------");
+ log.info(xacmlPolicy);
+ log.info("--------------------------------------------------------------------");
+ }
}
17 years, 5 months
JBoss Portal SVN: r12355 - in modules/authorization/trunk: PAP/src/test/java/org/jboss/security/authz/pap/hierarchial and 1 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2008-12-05 17:02:03 -0500 (Fri, 05 Dec 2008)
New Revision: 12355
Modified:
modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/hierarchial/HierarchialPolicy.java
modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/hierarchial/TestHierarchialPolicy.java
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/ExpressionBuilder.java
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Policy.java
Log:
code backup
Modified: modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/hierarchial/HierarchialPolicy.java
===================================================================
--- modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/hierarchial/HierarchialPolicy.java 2008-12-05 20:51:00 UTC (rev 12354)
+++ modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/hierarchial/HierarchialPolicy.java 2008-12-05 22:02:03 UTC (rev 12355)
@@ -29,6 +29,7 @@
import javax.xml.bind.JAXBElement;
+import org.jboss.security.authz.model.ExpressionBuilder;
import org.jboss.security.authz.model.Policy;
import org.jboss.security.authz.model.Rule;
import org.jboss.security.authz.model.Target;
@@ -42,6 +43,7 @@
import org.jboss.security.authz.xacml.PolicyUtil;
import org.jboss.security.xacml.core.model.policy.ActionMatchType;
+import org.jboss.security.xacml.core.model.policy.SubjectMatchType;
import org.jboss.security.xacml.core.model.policy.ApplyType;
import org.jboss.security.xacml.core.model.policy.VariableReferenceType;
import org.jboss.security.xacml.core.model.policy.EffectType;
@@ -51,11 +53,14 @@
import org.jboss.security.xacml.core.model.policy.ResourceType;
import org.jboss.security.xacml.core.model.policy.ActionsType;
import org.jboss.security.xacml.core.model.policy.ActionType;
+import org.jboss.security.xacml.core.model.policy.SubjectsType;
+import org.jboss.security.xacml.core.model.policy.SubjectType;
import org.jboss.security.xacml.core.model.policy.RuleType;
import org.jboss.security.xacml.core.model.policy.TargetType;
import org.jboss.security.xacml.core.model.policy.ConditionType;
import org.jboss.security.xacml.core.model.policy.ObjectFactory;
import org.jboss.security.xacml.core.model.policy.AttributeValueType;
+import org.jboss.security.xacml.core.model.policy.SubjectAttributeDesignatorType;
import org.jboss.security.xacml.factories.PolicyAttributeFactory;
/**
@@ -68,6 +73,15 @@
*/
public class HierarchialPolicy extends Policy
{
+ /**
+ *
+ * @param policyUri
+ */
+ public HierarchialPolicy(String policyUri)
+ {
+ super(policyUri);
+ }
+
public HierarchialPolicy(String policyUri, Target target, Set<Rule> rules) throws PolicyException
{
super(policyUri, target, rules);
@@ -140,11 +154,20 @@
if(rule.getTarget() != null)
{
List<AttributeExpression> actionMatches = rule.getTarget().getActionMatches();
+ List<AttributeExpression> subjectMatches = rule.getTarget().getSubjectMatches();
+ TargetType ruleTarget = new TargetType();
+
if(actionMatches != null && !actionMatches.isEmpty())
+ {
+ ruleTarget.setActions(this.generateRuleActions(actionMatches));
+ }
+
+ if(subjectMatches != null && !subjectMatches.isEmpty())
{
- TargetType ruleTarget = this.generateRuleActions(actionMatches);
- ruleType.setTarget(ruleTarget);
+ ruleTarget.setSubjects(this.generateRuleSubjects(subjectMatches));
}
+
+ ruleType.setTarget(ruleTarget);
}
//Process the Rule Expression/Condition
@@ -174,11 +197,10 @@
}
}
- private TargetType generateRuleActions(List<AttributeExpression> actionMatches)
+ private ActionsType generateRuleActions(List<AttributeExpression> actionMatches)
{
- TargetType target = new TargetType();
+ ActionsType actions = new ActionsType();
- ActionsType actions = new ActionsType();
for(AttributeExpression action: actionMatches)
{
ActionType actionType = new ActionType();
@@ -190,10 +212,27 @@
actions.getAction().add(actionType);
}
- target.setActions(actions);
- return target;
+ return actions;
}
+ private SubjectsType generateRuleSubjects(List<AttributeExpression> subjectMatches)
+ {
+ SubjectsType subjects = new SubjectsType();
+
+ for(AttributeExpression subject: subjectMatches)
+ {
+ SubjectType subjectType = new SubjectType();
+ SubjectMatchType match = new SubjectMatchType();
+ match.setMatchId(subject.getFunctionId());
+ match.setAttributeValue(PolicyAttributeFactory.createStringAttributeType(subject.getAttribute().getValue()));
+ match.setSubjectAttributeDesignator((SubjectAttributeDesignatorType)AttributeDesignatorUtil.getAttributeDesignator(subject.getAttribute()));
+ subjectType.getSubjectMatch().add(match);
+ subjects.getSubject().add(subjectType);
+ }
+
+ return subjects;
+ }
+
/**
*
* @param expression
@@ -242,4 +281,76 @@
return condition;
}
+ //---------More Developer Friendly API-------------------------------------------------------------------------------------------------------------------------
+ /**
+ * Specifies that this Hierarchial Policy should be applied the specified unique Resource Uri
+ *
+ * @param resourceUri Unique identifier for the Resource being protected by this Hierarchial Policy
+ */
+ public void setResourceCriteria(String resourceUri)
+ {
+ if(resourceUri == null || resourceUri.trim().length() == 0)
+ {
+ throw new IllegalArgumentException("Resource Criteria cannot be Empty");
+ }
+
+ Target target = new Target();
+ target.addResourceMatch(ExpressionBuilder.getInstance().createResourceIdExpression(resourceUri));
+ this.target = target;
+ }
+
+ /**
+ * Specifies a Policy Rule that must be applied to the specified "action" such that the specified "role" should be allowed
+ * to execute this "action" on the Resource protected by this Policy instance
+ *
+ * @param action Action for which this Rule applies
+ * @param role the Role that is permitted to execute this Action
+ */
+ public void setPermitCriteria(String action, String role)
+ {
+ Rule permitRule = new Rule();
+ Target ruleTarget = new Target();
+
+ permitRule.setRuleId(action);
+ permitRule.setEffect(Effect.PERMIT);
+ permitRule.setTarget(ruleTarget);
+
+ //Create an Action Match Function
+ ruleTarget.addActionMatch(ExpressionBuilder.getInstance().createActionExpression(action));
+
+ //Create a Subject Match Function
+ ruleTarget.addSubjectMatch(ExpressionBuilder.getInstance().createBelongsToRoleExpression(role));
+
+ //Add the Rule to the Policy
+ this.rules.add(permitRule);
+ }
+
+ /**
+ * Specifies a Policy Rule that must be applied to the specified "action" such that the Authenticated User will be permitted to
+ * execute it if he/she belongs to any of the specified "roles"
+ *
+ * @param action Action for which this Rule applies
+ * @param roles a list of permitted roles for this Action
+ */
+ public void setPermitCriteria(String action, String[] roles)
+ {
+ Rule permitRule = new Rule();
+ Target ruleTarget = new Target();
+
+ permitRule.setRuleId(action);
+ permitRule.setEffect(Effect.PERMIT);
+ permitRule.setTarget(ruleTarget);
+
+ //Create an Action Match Function
+ ruleTarget.addActionMatch(ExpressionBuilder.getInstance().createActionExpression(action));
+
+ //Create a Subject Match Function
+ for(int i=0; i<roles.length; i++)
+ {
+ ruleTarget.addSubjectMatch(ExpressionBuilder.getInstance().createBelongsToRoleExpression(roles[i]));
+ }
+
+ //Add the Rule to the Policy
+ this.rules.add(permitRule);
+ }
}
Modified: modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/hierarchial/TestHierarchialPolicy.java
===================================================================
--- modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/hierarchial/TestHierarchialPolicy.java 2008-12-05 20:51:00 UTC (rev 12354)
+++ modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/hierarchial/TestHierarchialPolicy.java 2008-12-05 22:02:03 UTC (rev 12355)
@@ -52,40 +52,30 @@
*
*/
public void testSimplePolicy() throws Exception
- {
- //SetUp the Policy Target
- Target target = new Target();
- for(int i=0; i<1; i++)
- {
- target.addResourceMatch(ExpressionBuilder.getInstance().createResourceIdExpression("http://www.redhat.com/protected/index.html?tier="+i));
- }
-
- //SetUp the Policy Rules
- Set<Rule> rules = new HashSet<Rule>();
- Rule writeRule = new Rule();
+ {
+ //Populate the HierarchialPolicy
+ HierarchialPolicy policy = new HierarchialPolicy("simpleHierarchialPolicy");
+ policy.setResourceCriteria("http://www.redhat.com/protected/index.html");
+ policy.setPermitCriteria("Write", "developer");
- writeRule.setRuleId("write");
- writeRule.setEffect(Effect.PERMIT);
+ String xacmlPolicy = policy.generateXACMLPolicy();
- Target ruleTarget = new Target();
-
- for(int i=0; i<5; i++)
- {
- ruleTarget.addActionMatch(ExpressionBuilder.getInstance().createActionExpression("WRITE:/"+i));
- }
- writeRule.setTarget(ruleTarget);
-
- writeRule.setExpression(ExpressionBuilder.getInstance().createRoleExpression("developer"));
-
- rules.add(writeRule);
-
+ log.info("--------------------------------------------------------------------");
+ log.info(xacmlPolicy);
+ log.info("--------------------------------------------------------------------");
+ }
+
+ public void testMultiRolePolicy() throws Exception
+ {
//Populate the HierarchialPolicy
- HierarchialPolicy policy = new HierarchialPolicy("simpleHierarchialPolicy", target, rules);
+ HierarchialPolicy policy = new HierarchialPolicy("simpleHierarchialPolicy");
+ policy.setResourceCriteria("http://www.redhat.com/protected/index.html");
+ policy.setPermitCriteria("Write", new String[]{"developer", "designer", "sysadmin"});
String xacmlPolicy = policy.generateXACMLPolicy();
log.info("--------------------------------------------------------------------");
log.info(xacmlPolicy);
- log.info("--------------------------------------------------------------------");
+ log.info("--------------------------------------------------------------------");
}
}
Modified: modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/ExpressionBuilder.java
===================================================================
--- modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/ExpressionBuilder.java 2008-12-05 20:51:00 UTC (rev 12354)
+++ modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/ExpressionBuilder.java 2008-12-05 22:02:03 UTC (rev 12355)
@@ -155,18 +155,18 @@
* @param role Role of the Authenticated User
* @return an expression that will be used within the Policy Definition
*/
- public AttributeExpression createRoleExpression(String role)
+ public AttributeExpression createBelongsToRoleExpression(String role)
{
AttributeExpression expression = new AttributeExpression();
- expression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
+ expression.setFunctionId(XACMLConstants.FUNCTION_STRING_IS_IN);
Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_ROLE,
XMLSchemaConstants.DATATYPE_STRING, role);
expression.setAttribute(attribute);
return expression;
- }
+ }
//---------Environment Expressions------------------------------------------------------------------------------------------------------------------------------
//---------Custom Expressions-----------------------------------------------------------------------------------------------------------------------------------
/**
Modified: modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Policy.java
===================================================================
--- modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Policy.java 2008-12-05 20:51:00 UTC (rev 12354)
+++ modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Policy.java 2008-12-05 22:02:03 UTC (rev 12355)
@@ -23,6 +23,7 @@
package org.jboss.security.authz.model;
import java.util.Set;
+import java.util.HashSet;
/**
@@ -37,7 +38,22 @@
protected Target target = null;
protected Set<Rule> rules = null;
+ /**
+ *
+ * @param policyUri
+ */
+ public Policy(String policyUri)
+ {
+ if(policyUri == null)
+ {
+ throw new IllegalArgumentException("PolicyUri cannot be Null");
+ }
+
+ this.policyUri = policyUri;
+ this.rules = new HashSet<Rule>();
+ }
+
/**
*
*
@@ -90,6 +106,10 @@
public void setRules(Set<Rule> rules)
{
+ if(rules == null)
+ {
+ rules = new HashSet<Rule>();
+ }
this.rules = rules;
}
17 years, 5 months
JBoss Portal SVN: r12354 - docs/enterprise/trunk/Installation_Guide.
by portal-commits@lists.jboss.org
Author: prabhat.jha(a)jboss.com
Date: 2008-12-05 15:51:00 -0500 (Fri, 05 Dec 2008)
New Revision: 12354
Modified:
docs/enterprise/trunk/Installation_Guide/Installation_Guide.pdf
Log:
latest pdf
Modified: docs/enterprise/trunk/Installation_Guide/Installation_Guide.pdf
===================================================================
(Binary files differ)
17 years, 5 months
JBoss Portal SVN: r12353 - docs/enterprise/trunk/Installation_Guide/en-US.
by portal-commits@lists.jboss.org
Author: prabhat.jha(a)jboss.com
Date: 2008-12-05 15:08:22 -0500 (Fri, 05 Dec 2008)
New Revision: 12353
Modified:
docs/enterprise/trunk/Installation_Guide/en-US/Installation.xml
Log:
oops
Modified: docs/enterprise/trunk/Installation_Guide/en-US/Installation.xml
===================================================================
--- docs/enterprise/trunk/Installation_Guide/en-US/Installation.xml 2008-12-05 18:35:42 UTC (rev 12352)
+++ docs/enterprise/trunk/Installation_Guide/en-US/Installation.xml 2008-12-05 20:08:22 UTC (rev 12353)
@@ -18,7 +18,7 @@
<para>
To install from a zip file, simply unzip the downloaded file to a directory of your choice. You can unzip the platform on any operating system that supports the zip format. Four types of server configurations will be included in your installation - minimal, default, production and all.
- The Getting Started Guide of &JBEAP; explains in detail the different server configuration file sets.
+ The Getting Started Guide of &JBEAP; as well as http://www.jboss.org/community/docs/DOC-12942 explain in detail the different server configuration file sets.
<itemizedlist>
<listitem>
@@ -50,7 +50,7 @@
</listitem>
<listitem>
<para>
- <literal>default</literal> server configuration has non clustered Portal bits <literal>jboss-portal.sar</literal> in
+ <literal>default</literal> server configuration has non-clustered Portal bits <literal>jboss-portal.sar</literal> in
<literal>deploy</literal> folder.
</para>
</listitem>
@@ -62,7 +62,7 @@
</listitem>
<listitem>
<para>
- <literal>production</literal> server configuration has clustered Portal bits <literal>jboss-portal.sar</literal> and this is
+ <literal>production</literal> server configuration has clustered Portal bits <literal>jboss-portal-ha.sar</literal> and this is
the sever that gets started by default. This server configuration has several optimizations such as logging, memory size etc.
If you do not need clustered portal version and want to use this optimized server configuration, you simply need to copy the directory
<literal>jboss-portal.sar</literal> from <literal>default/deploy</literal> to <literal>production/deploy</literal>. Don't forget to
@@ -70,6 +70,7 @@
</para>
</listitem>
</itemizedlist>
+ </para>
</section>
</chapter>
17 years, 5 months
JBoss Portal SVN: r12352 - in branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core: model/portal/command/action and 1 other directory.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-12-05 13:35:42 -0500 (Fri, 05 Dec 2008)
New Revision: 12352
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerResponseFactory.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java
Log:
JBPORTAL-2248: Action URL retained by client
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerResponseFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerResponseFactory.java 2008-12-05 18:10:22 UTC (rev 12351)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerResponseFactory.java 2008-12-05 18:35:42 UTC (rev 12352)
@@ -36,9 +36,11 @@
import org.jboss.portal.core.model.instance.command.response.PortletInstanceActionResponse;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.command.response.PortletWindowActionResponse;
+import org.jboss.portal.core.model.portal.navstate.PageNavigationalState;
import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.info.ParameterInfo;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
import org.jboss.portal.portlet.invocation.response.ContentResponse;
@@ -48,6 +50,8 @@
import java.util.HashMap;
import java.util.Map;
+import javax.xml.namespace.QName;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
@@ -67,7 +71,7 @@
}
}
- public static ControllerResponse createActionResponse(PortalObjectId targetId, PortletInvocationResponse response)
+ public static ControllerResponse createActionResponse(PortalObjectId targetId, PortletInvocationResponse response, org.jboss.portal.portlet.info.PortletInfo portletInfo, PageNavigationalState pns)
{
if (response instanceof UpdateNavigationalStateResponse)
{
@@ -82,10 +86,30 @@
ParametersStateString state = (ParametersStateString)renderResult.getNavigationalState();
Map<String, String[]> parameters = new HashMap<String, String[]>(state.getParameters());
+
+ if (pns != null)
+ {
+
+ //
+ for (ParameterInfo parameterInfo : portletInfo.getNavigation().getPublicParameters())
+ {
+ String key = parameterInfo.getId();
+
+ //
+ String[] values = pns.getParameter(parameterInfo.getName());
+
+ //
+ if (values != null)
+ {
+ parameters.put(key, values);
+ }
+ }
+ }
+
+ parameters.putAll(renderResult.getPublicNavigationalStateUpdates());
- parameters.putAll(renderResult.getPublicNavigationalStateUpdates());
-
return new PortletWindowActionResponse(targetId, windowState, mode, ParametersStateString.create(parameters));
+// return new PortletWindowActionResponse(targetId, windowState, mode, renderResult.getNavigationalState());
}
else
{
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java 2008-12-05 18:10:22 UTC (rev 12351)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java 2008-12-05 18:35:42 UTC (rev 12352)
@@ -25,6 +25,7 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.NoSuchResourceException;
@@ -38,6 +39,8 @@
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.command.response.UpdatePageResponse;
+import org.jboss.portal.core.model.portal.navstate.PageNavigationalState;
+import org.jboss.portal.core.navstate.NavigationalStateContext;
import org.jboss.portal.identity.User;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.StateString;
@@ -181,8 +184,24 @@
PortletResponse portletResponse = (PortletResponse)cr;
+ if (cr instanceof PageUpdateResponse)
+ {
+ //
+ PageUpdateResponse pageUpdate = (PageUpdateResponse)cr;
+
+ //
+ ControllerPageNavigationalState pageNavigationalState = (ControllerPageNavigationalState)pageUpdate.getPageNavigationalState();
+
+ // Flush all NS
+ pageNavigationalState.flushUpdates();
+ }
+ // Populate the parameters
+ NavigationalStateContext ctx = (NavigationalStateContext)cpcc.getControllerContext().getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
+
+ PageNavigationalState pns = ctx.getPageNavigationalState(page.getId().toString());
+
//
- return ControllerResponseFactory.createActionResponse(targetId, portletResponse.getResponse());
+ return ControllerResponseFactory.createActionResponse(targetId, portletResponse.getResponse(), portletInfo, pns);
}
catch (PortletInvokerException e)
{
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java 2008-12-05 18:10:22 UTC (rev 12351)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java 2008-12-05 18:35:42 UTC (rev 12352)
@@ -24,6 +24,9 @@
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.command.response.UpdatePageResponse;
+import org.jboss.portal.core.model.portal.navstate.PageNavigationalState;
+import org.jboss.portal.core.navstate.NavigationalStateContext;
+import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.command.info.CommandInfo;
@@ -174,9 +177,14 @@
//
ResourceResponse resourceResponse = (ResourceResponse)cr;
+
+ // Populate the parameters
+ NavigationalStateContext ctx = (NavigationalStateContext)cpcc.getControllerContext().getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
+
+ PageNavigationalState pns = ctx.getPageNavigationalState(page.getId().toString());
//
- return ControllerResponseFactory.createActionResponse(targetId, resourceResponse.getResponse());
+ return ControllerResponseFactory.createActionResponse(targetId, resourceResponse.getResponse(), portletInfo, pns);
}
catch (PortletInvokerException e)
{
17 years, 5 months
JBoss Portal SVN: r12351 - docs/enterprise/trunk/Installation_Guide/en-US.
by portal-commits@lists.jboss.org
Author: prabhat.jha(a)jboss.com
Date: 2008-12-05 13:10:22 -0500 (Fri, 05 Dec 2008)
New Revision: 12351
Modified:
docs/enterprise/trunk/Installation_Guide/en-US/Getting_Started.xml
docs/enterprise/trunk/Installation_Guide/en-US/Installation.xml
docs/enterprise/trunk/Installation_Guide/en-US/Introduction.xml
Log:
Modified: docs/enterprise/trunk/Installation_Guide/en-US/Getting_Started.xml
===================================================================
--- docs/enterprise/trunk/Installation_Guide/en-US/Getting_Started.xml 2008-12-05 15:34:38 UTC (rev 12350)
+++ docs/enterprise/trunk/Installation_Guide/en-US/Getting_Started.xml 2008-12-05 18:10:22 UTC (rev 12351)
@@ -7,7 +7,7 @@
<section id="Getting_Started-Pre_Requisites">
<title>Pre-Requisites</title>
<para>
- You must have adequate disk space<!--TODO how much --> to install JDK and &JBEPP; while also allowing enough space for your applications. Before installing &JBEPP; you must have a working installation of Java. Since JBoss is 100% pure Java you can have it working on any Operating System / Platform that supports Java. However, there are a few Operating System-specific issues that you should be aware of. Refer to <ulink url="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossOperatingSystemSpecificIssues"></ulink> for more information.
+ You must have adequate disk space<!--TODO how much --> to install JDK and &JBEPP; while also allowing enough space for your applications. Before installing &JBEPP; you must have a working installation of Java. Since JBoss is 100% pure Java you can have it working on any Operating System / Platform that supports Java. However, there are a few Operating System-specific issues that you should be aware of. Refer to <ulink url="http://www.jboss.org/community/docs/DOC-10687"></ulink> for more information.
</para>
<section id="Pre_Requisites-Hardware_and_Operating_System_Requirements">
<title>Hardware and Operating System Requirements</title>
Modified: docs/enterprise/trunk/Installation_Guide/en-US/Installation.xml
===================================================================
--- docs/enterprise/trunk/Installation_Guide/en-US/Installation.xml 2008-12-05 15:34:38 UTC (rev 12350)
+++ docs/enterprise/trunk/Installation_Guide/en-US/Installation.xml 2008-12-05 18:10:22 UTC (rev 12351)
@@ -17,7 +17,8 @@
<title>Installing</title>
<para>
- To install from a zip file, simply unzip the downloaded file to a directory of your choice. You can unzip the platform on any operating system that supports the zip format. Four types of server configurations will be included in your installation - minimal, default, production and all. The Getting Started Guide explains in detail the different server configuration file sets.
+ To install from a zip file, simply unzip the downloaded file to a directory of your choice. You can unzip the platform on any operating system that supports the zip format. Four types of server configurations will be included in your installation - minimal, default, production and all.
+ The Getting Started Guide of &JBEAP; explains in detail the different server configuration file sets.
<itemizedlist>
<listitem>
@@ -33,7 +34,42 @@
</para>
</listitem>
</itemizedlist>
- </para>
+ </para>
</section>
+
+ <section id="server-config-differences">
+ <title>Choosing a server configuration</title>
+ <para>
+ The important differences as far as Portal is concerned are:
+
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>minimal</literal> server configuration has no Portal bits. It's there for the sake of consistency with &JBEAP;
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>default</literal> server configuration has non clustered Portal bits <literal>jboss-portal.sar</literal> in
+ <literal>deploy</literal> folder.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>all</literal> server configuration has clustered Portal bits <literal>jboss-portal-ha.sar</literal> in
+ <literal>deploy</literal> folder.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>production</literal> server configuration has clustered Portal bits <literal>jboss-portal.sar</literal> and this is
+ the sever that gets started by default. This server configuration has several optimizations such as logging, memory size etc.
+ If you do not need clustered portal version and want to use this optimized server configuration, you simply need to copy the directory
+ <literal>jboss-portal.sar</literal> from <literal>default/deploy</literal> to <literal>production/deploy</literal>. Don't forget to
+ remove <literal>jboss-portal-ha.sar</literal> though.
+ </para>
+ </listitem>
+ </itemizedlist>
+ </section>
</chapter>
Modified: docs/enterprise/trunk/Installation_Guide/en-US/Introduction.xml
===================================================================
--- docs/enterprise/trunk/Installation_Guide/en-US/Introduction.xml 2008-12-05 15:34:38 UTC (rev 12350)
+++ docs/enterprise/trunk/Installation_Guide/en-US/Introduction.xml 2008-12-05 18:10:22 UTC (rev 12351)
@@ -39,7 +39,7 @@
<section id="introduction-Feedback">
<title>Feedback</title>
<para>
- If you spot a typo in this guide, or if you have thought of a way to make this manual better, we would love to hear from you! Submit a report in <ulink url="http://jira.jboss.com/jira/browse/JBPAPP">JIRA</ulink> against the Product: JBoss Enterprise Application Platform, Version: <replaceable><version></replaceable>, Component: <emphasis>Doc</emphasis>. If you have a suggestion for improving the documentation, try to be as specific as possible. If you have found an error, include the section number and some of the surrounding text so we can find it easily.
+ If you spot a typo in this guide, or if you have thought of a way to make this manual better, we would love to hear from you! Submit a report in <ulink url="http://jira.jboss.com/jira/browse/JBEPP">JIRA</ulink> against the Version: <replaceable><version></replaceable>, Component: <emphasis>Doc</emphasis>. If you have a suggestion for improving the documentation, try to be as specific as possible. If you have found an error, include the section number and some of the surrounding text so we can find it easily.
</para>
</section>
17 years, 5 months
JBoss Portal SVN: r12350 - branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium.
by portal-commits@lists.jboss.org
Author: vrockai
Date: 2008-12-05 10:34:38 -0500 (Fri, 05 Dec 2008)
New Revision: 12350
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSelenium.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java
Log:
turning off screenshots
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2008-12-05 05:54:40 UTC (rev 12349)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2008-12-05 15:34:38 UTC (rev 12350)
@@ -34,7 +34,7 @@
@BeforeClass
public void setupChromeForLogin() throws Exception {
String browser = System.getProperty("browser");
- selenium = new JBossSelenium("127.0.0.1", 44444, browser, "http://localhost:8080/portal/");
+ selenium = new DefaultSelenium("127.0.0.1", 44444, browser, "http://localhost:8080/portal/");
JBossSeleniumTestListener.selenium = selenium;
selenium.start();
selenium.setTimeout(PAGE_LOAD);
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSelenium.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSelenium.java 2008-12-05 05:54:40 UTC (rev 12349)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSelenium.java 2008-12-05 15:34:38 UTC (rev 12350)
@@ -19,34 +19,43 @@
@Override
public void click(String locator) {
try {
- super.click(locator);
- }
- catch (SeleniumException e){
-
- String name = "E_";
- Pattern methodname = Pattern.compile("^org.jboss.portal.test.selenium\\S+test\\S+\\(\\S+\\)");
- for(int i=0;i<e.getStackTrace().length;i++){
- String input = e.getStackTrace()[i].toString();
- Matcher match = methodname.matcher(input);
- if (match.matches()){
- input = input.replace("org.jboss.portal.test.selenium","");
- input = input.replaceAll("\\(.*\\)","");
- name += input;
+ try {
+ super.click(locator);
+ }
+ catch (SeleniumException e){
+
+ String name = "E_";
+ Pattern methodname = Pattern.compile("^org.jboss.portal.test.selenium\\S+test\\S+\\(\\S+\\)");
+ for(int i=0;i<e.getStackTrace().length;i++){
+ String input = e.getStackTrace()[i].toString();
+ Matcher match = methodname.matcher(input);
+ if (match.matches()){
+ input = input.replace("org.jboss.portal.test.selenium","");
+ input = input.replaceAll("\\(.*\\)","");
+ name += input;
+ }
}
+ name += "."+count;
+ try {
+ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(name+".html")));
+ out.println(getHtmlSource());
+ out.close();
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+ try {
+ windowMaximize();
+ captureScreenshot(name + ".jpg");
+ } catch (SeleniumException e2) {
+ e2.printStackTrace();
+ }
+ count++;
+
+ throw new SeleniumException(e);
}
- name += "."+count;
- try {
- PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(name+".html")));
- out.println(getHtmlSource());
- out.close();
- } catch (IOException e1) {
- e1.printStackTrace();
- }
- windowMaximize();
- captureScreenshot(name +".jpg");
- count++;
-
- throw new SeleniumException(e);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
}
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java 2008-12-05 05:54:40 UTC (rev 12349)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java 2008-12-05 15:34:38 UTC (rev 12350)
@@ -15,6 +15,7 @@
import org.testng.TestListenerAdapter;
import com.thoughtworks.selenium.Selenium;
+import com.thoughtworks.selenium.SeleniumException;
public class JBossSeleniumTestListener extends TestListenerAdapter {//extends ITestListener {
@@ -31,8 +32,14 @@
} catch (IOException e1) {
e1.printStackTrace();
}
+ /*
+ try {
selenium.windowMaximize();
selenium.captureScreenshot(name + ".jpg");
+ } catch (SeleniumException e2) {
+ e2.printStackTrace();
+ }
+ */
count++;
}
17 years, 5 months
JBoss Portal SVN: r12349 - in modules/authorization/trunk: PAP/src/main/java/org/jboss/security/authz/pap/hierarchial and 7 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2008-12-05 00:54:40 -0500 (Fri, 05 Dec 2008)
New Revision: 12349
Added:
modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/plugin/DroolsRuleManager.java
modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/plugin/TestDroolsRuleManager.java
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/ExpressionBuilder.java
Removed:
modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/service/DroolsRuleManager.java
modules/authorization/trunk/PAP/src/main/resources/rules/
modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/service/TestDroolsRuleManager.java
Modified:
modules/authorization/trunk/PAP/pom.xml
modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/hierarchial/HierarchialPolicy.java
modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/plugin/DroolsFunction.java
modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/hierarchial/TestHierarchialPolicy.java
modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/plugin/TestDroolsFunction.java
modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/plugin/TestDroolsRules.java
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Action.java
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/PolicyException.java
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Resource.java
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Subject.java
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Target.java
Log:
code backup
Modified: modules/authorization/trunk/PAP/pom.xml
===================================================================
--- modules/authorization/trunk/PAP/pom.xml 2008-12-04 23:14:45 UTC (rev 12348)
+++ modules/authorization/trunk/PAP/pom.xml 2008-12-05 05:54:40 UTC (rev 12349)
@@ -69,8 +69,8 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.3.1</version>
<configuration>
- <includes>
- <include>**/TestDroolsRuleManager.java</include>
+ <includes>
+ <include>**/TestHierarchialPolicy.java</include>
</includes>
</configuration>
</plugin>
Modified: modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/hierarchial/HierarchialPolicy.java
===================================================================
--- modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/hierarchial/HierarchialPolicy.java 2008-12-04 23:14:45 UTC (rev 12348)
+++ modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/hierarchial/HierarchialPolicy.java 2008-12-05 05:54:40 UTC (rev 12349)
@@ -68,9 +68,16 @@
*/
public class HierarchialPolicy extends Policy
{
- public HierarchialPolicy(String policyUri, Target target, Set<Rule> rules)
+ public HierarchialPolicy(String policyUri, Target target, Set<Rule> rules) throws PolicyException
{
- super(policyUri, target, rules);
+ super(policyUri, target, rules);
+
+ //Validate the state of the data
+ //Make sure there is only one ResourceMatch specified
+ if(target.getResourceMatches() == null || target.getResourceMatches().size()>1)
+ {
+ throw new PolicyException("The HierarchialPolicy type requires there is exactly one match specified for a Resource inside the Policy definition");
+ }
}
@Override
@@ -97,21 +104,20 @@
{
ResourcesType resourcesType = new ResourcesType();
targetType.setResources(resourcesType);
- for(AttributeExpression resourceMatch: resourceMatches)
- {
- ResourceType resourceType = new ResourceType();
- ResourceMatchType rmt = new ResourceMatchType();
-
- rmt.setMatchId(resourceMatch.getFunctionId());
-
- rmt.setResourceAttributeDesignator(AttributeDesignatorUtil.getAttributeDesignator(resourceMatch.getAttribute()));
-
- rmt.setAttributeValue(PolicyAttributeFactory
- .createStringAttributeType(resourceMatch.getAttribute().getValue()));
-
- resourceType.getResourceMatch().add(rmt);
- resourcesType.getResource().add(resourceType);
- }
+
+ AttributeExpression resourceMatch = resourceMatches.get(0);
+ ResourceType resourceType = new ResourceType();
+ ResourceMatchType rmt = new ResourceMatchType();
+
+ rmt.setMatchId(resourceMatch.getFunctionId());
+
+ rmt.setResourceAttributeDesignator(AttributeDesignatorUtil.getAttributeDesignator(resourceMatch.getAttribute()));
+
+ rmt.setAttributeValue(PolicyAttributeFactory
+ .createStringAttributeType(resourceMatch.getAttribute().getValue()));
+
+ resourceType.getResourceMatch().add(rmt);
+ resourcesType.getResource().add(resourceType);
}
//Process the Policy Rules
Modified: modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/plugin/DroolsFunction.java
===================================================================
--- modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/plugin/DroolsFunction.java 2008-12-04 23:14:45 UTC (rev 12348)
+++ modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/plugin/DroolsFunction.java 2008-12-05 05:54:40 UTC (rev 12349)
@@ -22,16 +22,11 @@
******************************************************************************/
package org.jboss.security.authz.pap.plugin;
-import java.io.InputStreamReader;
-import java.io.Reader;
import java.util.List;
import java.util.ArrayList;
import org.drools.RuleBase;
-import org.drools.RuleBaseFactory;
import org.drools.WorkingMemory;
-import org.drools.rule.Package;
-import org.drools.compiler.PackageBuilder;
import org.jboss.security.xacml.sunxacml.EvaluationCtx;
import org.jboss.security.xacml.sunxacml.cond.EvaluationResult;
@@ -50,8 +45,6 @@
{
public static final String NAME = FUNCTION_NS + "drools:rule";
- private RuleBase rules = null;
-
/**
*
* @param functionName
@@ -69,16 +62,7 @@
0, //FunctionId
BooleanAttribute.identifier, //returnType
false //returns a Bag of values
- );
-
- try
- {
- this.rules = this.readStaticRules();
- }
- catch(Exception e)
- {
- throw new RuntimeException(e);
- }
+ );
}
@@ -110,15 +94,8 @@
{
EvaluationResult result = null;
try
- {
- //Mock Code
- WorkingMemory workingMemory = this.rules.newStatefulSession();
-
- //Insert Security related Facts into the Rule Engine
-
- workingMemory.fireAllRules();
+ {
-
/**
* TODO: start a Drools context and evaluate the specified Rule against the data presented in the EvaluationContext
*/
@@ -132,39 +109,5 @@
result = new EvaluationResult(status);
}
return result;
- }
- //--------------------------------------------------------------------------------------------------------------------------------------------------------------
- /**
- * Used when using Rule Deployment in a static manner from the classpath
- *
- * With this approach, the Policy Condition Rules are supplied during server startup. Rule Modifications require a server re-start
- */
- private RuleBase readStaticRules() throws Exception
- {
- //read in the source
- Reader source = new InputStreamReader(this.getClass().getResourceAsStream("/rules/security.drl"));
-
- //optionally read in the DSL (if you are using it).
- //Reader dsl = new InputStreamReader( DroolsTest.class.getResourceAsStream( "/mylang.dsl" ) );
-
- //Use package builder to build up a rule package.
- //An alternative lower level class called "DrlParser" can also be used...
-
- PackageBuilder builder = new PackageBuilder();
-
- //this wil parse and compile in one step
- //NOTE: There are 2 methods here, the one argument one is for normal DRL.
- builder.addPackageFromDrl(source);
-
- //Use the following instead of above if you are using a DSL:
- //builder.addPackageFromDrl( source, dsl );
-
- //get the compiled package (which is serializable)
- Package pkg = builder.getPackage();
-
- //add the package to a rulebase (deploy the rule package).
- RuleBase ruleBase = RuleBaseFactory.newRuleBase();
- ruleBase.addPackage(pkg);
- return ruleBase;
- }
+ }
}
Copied: modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/plugin/DroolsRuleManager.java (from rev 12334, modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/service/DroolsRuleManager.java)
===================================================================
--- modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/plugin/DroolsRuleManager.java (rev 0)
+++ modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/plugin/DroolsRuleManager.java 2008-12-05 05:54:40 UTC (rev 12349)
@@ -0,0 +1,203 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.security.authz.pap.plugin;
+
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.ByteArrayInputStream;
+import java.util.Map;
+import java.util.HashMap;
+
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+import org.drools.compiler.PackageBuilder;
+
+import org.jboss.security.authz.model.DroolsRuleExpression;
+
+/**
+ * This service provides management for Drools based authorization Rules/Logic used by the Drools Function extension of the XACML Engine
+ *
+ * TODO: Add Database Persistence to the State of this Manager
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public final class DroolsRuleManager
+{
+ private static String rulePkg =
+ "package security\n"+
+ "import org.jboss.security.authz.model.*;\n"+
+ "import org.jboss.security.xacml.interfaces.XACMLConstants;\n";
+
+ private RuleBase activeRuleBase = null;
+ private Map<String, String> drls = null;
+
+ public DroolsRuleManager()
+ {
+ }
+
+ public void start()
+ {
+ try
+ {
+ this.drls = new HashMap<String, String>();
+ this.reloadActiveRuleBase();
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void stop()
+ {
+ this.activeRuleBase = null;
+ this.drls = null;
+ }
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------
+ RuleBase getActiveRuleBase()
+ {
+ return this.activeRuleBase;
+ }
+
+ void addRule(DroolsRuleExpression rule)
+ {
+ try
+ {
+ if(rule.getRuleReference() == null || rule.getRuleReference().trim().length() == 0)
+ {
+ throw new IllegalArgumentException("Rule Reference is missing");
+ }
+ if(rule.getWhen() == null || rule.getWhen().trim().length() == 0)
+ {
+ throw new IllegalArgumentException("LHS value is missing");
+ }
+
+
+ this.drls.put(rule.getRuleReference(), rule.getWhen());
+ this.reloadActiveRuleBase();
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ DroolsRuleExpression readRule(String ruleReference)
+ {
+ try
+ {
+ if(ruleReference == null || ruleReference.trim().length() == 0)
+ {
+ throw new IllegalArgumentException("Rule Reference is missing");
+ }
+
+ DroolsRuleExpression rule = null;
+
+ String when = this.drls.get(ruleReference);
+
+ rule = new DroolsRuleExpression();
+ rule.setRuleReference(ruleReference);
+ rule.setWhen(when);
+
+ return rule;
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ void updateRule(DroolsRuleExpression rule)
+ {
+ try
+ {
+ if(rule.getRuleReference() == null || rule.getRuleReference().trim().length() == 0)
+ {
+ throw new IllegalArgumentException("Rule Reference is missing");
+ }
+ if(rule.getWhen() == null || rule.getWhen().trim().length() == 0)
+ {
+ throw new IllegalArgumentException("LHS value is missing");
+ }
+
+ this.drls.put(rule.getRuleReference(), rule.getWhen());
+ this.reloadActiveRuleBase();
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ void removeRule(String ruleReference)
+ {
+ try
+ {
+ if(ruleReference == null || ruleReference.trim().length() == 0)
+ {
+ throw new IllegalArgumentException("Rule Reference is missing");
+ }
+
+ this.drls.remove(ruleReference);
+ this.reloadActiveRuleBase();
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ //-----------------------------------------------------------------------------------------------------------------------------------------------------------
+ private synchronized void reloadActiveRuleBase() throws Exception
+ {
+ StringBuilder buffer = new StringBuilder();
+
+ buffer.append(DroolsRuleManager.rulePkg+"\n");
+
+ for(String drl: this.drls.values())
+ {
+ buffer.append(drl+"\n");
+ }
+
+ Reader source = new InputStreamReader(new ByteArrayInputStream(buffer.toString().getBytes()));
+ try
+ {
+ PackageBuilder packageBuilder = new PackageBuilder();
+ packageBuilder.addPackageFromDrl(source);
+
+ if(this.activeRuleBase == null)
+ {
+ this.activeRuleBase = RuleBaseFactory.newRuleBase();
+ }
+
+ //Perform the reloading of the RuleBase with the updated Rules
+ this.activeRuleBase.lock();
+ this.activeRuleBase.addPackage(packageBuilder.getPackage());
+ this.activeRuleBase.unlock();
+ }
+ finally
+ {
+ source.close();
+ }
+ }
+}
Deleted: modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/service/DroolsRuleManager.java
===================================================================
--- modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/service/DroolsRuleManager.java 2008-12-04 23:14:45 UTC (rev 12348)
+++ modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/service/DroolsRuleManager.java 2008-12-05 05:54:40 UTC (rev 12349)
@@ -1,178 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.security.authz.pap.service;
-
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.ByteArrayInputStream;
-import java.util.Map;
-import java.util.HashMap;
-
-import org.drools.RuleBase;
-import org.drools.RuleBaseFactory;
-import org.drools.compiler.PackageBuilder;
-
-import org.jboss.security.authz.model.DroolsRuleExpression;
-
-/**
- * This service provides management for Drools based authorization Rules/Logic used by the Drools Function extension of the XACML Engine
- *
- * TODO: Add Database Persistence to the State of this Manager
- *
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- *
- */
-public class DroolsRuleManager
-{
- private static String rulePkg =
- "package security\n"+
- "import org.jboss.security.authz.model.*;\n"+
- "import org.jboss.security.xacml.interfaces.XACMLConstants;\n";
-
- private RuleBase activeRuleBase = null;
- private Map<String, String> drls = null;
-
- public DroolsRuleManager()
- {
- }
-
- public void start()
- {
- try
- {
- this.drls = new HashMap<String, String>();
- this.reloadActiveRuleBase();
- }
- catch(Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public void stop()
- {
- this.activeRuleBase = null;
- this.drls = null;
- }
- //---------------------------------------------------------------------------------------------------------------------------------------------------------
- public RuleBase getActiveRuleBase()
- {
- return this.activeRuleBase;
- }
-
- public void addRule(DroolsRuleExpression rule) throws Exception
- {
- if(rule.getRuleReference() == null || rule.getRuleReference().trim().length() == 0)
- {
- throw new IllegalArgumentException("Rule Reference is missing");
- }
- if(rule.getWhen() == null || rule.getWhen().trim().length() == 0)
- {
- throw new IllegalArgumentException("LHS value is missing");
- }
-
-
- this.drls.put(rule.getRuleReference(), rule.getWhen());
- this.reloadActiveRuleBase();
- }
-
- public DroolsRuleExpression readRule(String ruleReference) throws Exception
- {
- if(ruleReference == null || ruleReference.trim().length() == 0)
- {
- throw new IllegalArgumentException("Rule Reference is missing");
- }
-
- DroolsRuleExpression rule = null;
-
- String when = this.drls.get(ruleReference);
-
- rule = new DroolsRuleExpression();
- rule.setRuleReference(ruleReference);
- rule.setWhen(when);
-
- return rule;
- }
-
- public void updateRule(DroolsRuleExpression rule) throws Exception
- {
- if(rule.getRuleReference() == null || rule.getRuleReference().trim().length() == 0)
- {
- throw new IllegalArgumentException("Rule Reference is missing");
- }
- if(rule.getWhen() == null || rule.getWhen().trim().length() == 0)
- {
- throw new IllegalArgumentException("LHS value is missing");
- }
-
- this.drls.put(rule.getRuleReference(), rule.getWhen());
- this.reloadActiveRuleBase();
- }
-
- public void removeRule(String ruleReference) throws Exception
- {
- if(ruleReference == null || ruleReference.trim().length() == 0)
- {
- throw new IllegalArgumentException("Rule Reference is missing");
- }
-
- this.drls.remove(ruleReference);
- this.reloadActiveRuleBase();
- }
- //-----------------------------------------------------------------------------------------------------------------------------------------------------------
- private synchronized void reloadActiveRuleBase() throws Exception
- {
- StringBuilder buffer = new StringBuilder();
-
- buffer.append(DroolsRuleManager.rulePkg+"\n");
-
- for(String drl: this.drls.values())
- {
- buffer.append(drl+"\n");
- }
-
-
- ByteArrayInputStream bis = new ByteArrayInputStream(buffer.toString().getBytes());
- try
- {
- Reader source = new InputStreamReader(bis);
-
- PackageBuilder packageBuilder = new PackageBuilder();
- packageBuilder.addPackageFromDrl(source);
-
- if(this.activeRuleBase == null)
- {
- this.activeRuleBase = RuleBaseFactory.newRuleBase();
- }
-
- //Perform the reloading of the RuleBase with the updated Rules
- this.activeRuleBase.lock();
- this.activeRuleBase.addPackage(packageBuilder.getPackage());
- this.activeRuleBase.unlock();
- }
- finally
- {
- bis.close();
- }
- }
-}
Modified: modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/hierarchial/TestHierarchialPolicy.java
===================================================================
--- modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/hierarchial/TestHierarchialPolicy.java 2008-12-04 23:14:45 UTC (rev 12348)
+++ modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/hierarchial/TestHierarchialPolicy.java 2008-12-05 05:54:40 UTC (rev 12349)
@@ -29,9 +29,6 @@
import org.apache.log4j.Logger;
-import org.jboss.security.xacml.interfaces.XACMLConstants;
-import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
-
import org.jboss.security.authz.model.*;
@@ -58,14 +55,9 @@
{
//SetUp the Policy Target
Target target = new Target();
- for(int i=0; i<5; i++)
- {
- AttributeExpression resourceMatch = new AttributeExpression();
- resourceMatch.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
- Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_RESOURCE_ID,
- XMLSchemaConstants.DATATYPE_STRING, "http://www.redhat.com/protected/index.html?tier="+i);
- resourceMatch.setAttribute(attribute);
- target.addResourceMatch(resourceMatch);
+ for(int i=0; i<1; i++)
+ {
+ target.addResourceMatch(ExpressionBuilder.getInstance().createResourceIdExpression("http://www.redhat.com/protected/index.html?tier="+i));
}
//SetUp the Policy Rules
@@ -78,24 +70,13 @@
Target ruleTarget = new Target();
for(int i=0; i<5; i++)
- {
- AttributeExpression actionMatch = new AttributeExpression();
- actionMatch.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
- Attribute actionAttribute = new Attribute(XACMLConstants.ATTRIBUTEID_ACTION_ID,
- XMLSchemaConstants.DATATYPE_STRING, "WRITE:/"+i);
- actionMatch.setAttribute(actionAttribute);
- ruleTarget.addActionMatch(actionMatch);
- }
-
+ {
+ ruleTarget.addActionMatch(ExpressionBuilder.getInstance().createActionExpression("WRITE:/"+i));
+ }
writeRule.setTarget(ruleTarget);
-
- AttributeExpression roleExpression = new AttributeExpression();
- roleExpression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
- Attribute roleAttribute = new Attribute(XACMLConstants.ATTRIBUTEID_ROLE,
- XMLSchemaConstants.DATATYPE_STRING, "developer");
- roleExpression.setAttribute(roleAttribute);
- writeRule.setExpression(roleExpression);
+ writeRule.setExpression(ExpressionBuilder.getInstance().createRoleExpression("developer"));
+
rules.add(writeRule);
//Populate the HierarchialPolicy
Modified: modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/plugin/TestDroolsFunction.java
===================================================================
--- modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/plugin/TestDroolsFunction.java 2008-12-04 23:14:45 UTC (rev 12348)
+++ modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/plugin/TestDroolsFunction.java 2008-12-05 05:54:40 UTC (rev 12349)
@@ -176,7 +176,7 @@
return requestContext;
}
- private Policy getSimplePolicy()
+ private Policy getSimplePolicy() throws Exception
{
//SetUp the Policy Target
Target target = new Target();
Copied: modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/plugin/TestDroolsRuleManager.java (from rev 12334, modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/service/TestDroolsRuleManager.java)
===================================================================
--- modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/plugin/TestDroolsRuleManager.java (rev 0)
+++ modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/plugin/TestDroolsRuleManager.java 2008-12-05 05:54:40 UTC (rev 12349)
@@ -0,0 +1,135 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.security.authz.pap.plugin;
+
+
+import junit.framework.TestCase;
+
+import org.drools.WorkingMemory;
+import org.drools.StatefulSession;
+
+import org.jboss.security.xacml.interfaces.XACMLConstants;
+import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
+import org.jboss.security.authz.model.*;
+import org.jboss.security.authz.pap.plugin.DroolsRuleManager;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class TestDroolsRuleManager extends TestCase
+{
+ private static final String rule1 =
+ "rule \"Rule1\"\n"+
+ "when\n"+
+ "$subject: Subject()\n"+
+ "String(toString == \"Rule1\")\n"+
+ "Subject(category == XACMLConstants.ATTRIBUTEID_ACCESS_SUBJECT)\n"+
+ "Attribute(uri == XACMLConstants.ATTRIBUTEID_ROLE && value == \"developer\") from $subject.attributes\n"+
+ "then\n"+
+ "System.out.println(\"Rule1 successfully fired\");\n"+
+ "end\n";
+
+ private static final String rule2 =
+ "rule \"Rule2\"\n"+
+ "when\n"+
+ "$subject: Subject()\n"+
+ "String(toString == \"Rule2\")\n"+
+ "Subject(category == XACMLConstants.ATTRIBUTEID_ACCESS_SUBJECT)\n"+
+ "Attribute(uri == XACMLConstants.ATTRIBUTEID_ROLE && value == \"developer\") from $subject.attributes\n"+
+ "then\n"+
+ "System.out.println(\"Rule2 successfully fired\");\n"+
+ "end\n";
+
+
+ private DroolsRuleManager ruleManager = null;
+
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ this.ruleManager = new DroolsRuleManager();
+ this.ruleManager.start();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ this.ruleManager = null;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------------------------------------
+ public void testAddRule() throws Exception
+ {
+ DroolsRuleExpression expression = new DroolsRuleExpression();
+ expression.setRuleReference("Rule2");
+ expression.setWhen(TestDroolsRuleManager.rule2);
+ this.ruleManager.addRule(expression);
+
+ WorkingMemory workingMemory = ruleManager.getActiveRuleBase().newStatefulSession();
+ workingMemory.insert("Rule2");
+ workingMemory.insert(this.getSubject());
+
+ //Fire
+ System.out.println("Firing Rule2........");
+ workingMemory.fireAllRules();
+ ((StatefulSession)workingMemory).dispose();
+
+ expression.setRuleReference("Rule1");
+ expression.setWhen(TestDroolsRuleManager.rule1);
+ this.ruleManager.addRule(expression);
+
+ workingMemory = ruleManager.getActiveRuleBase().newStatefulSession();
+ workingMemory.insert("Rule1");
+ workingMemory.insert(this.getSubject());
+
+ //Fire
+ System.out.println("Firing Rule1........");
+ workingMemory.fireAllRules();
+ ((StatefulSession)workingMemory).dispose();
+
+ workingMemory = ruleManager.getActiveRuleBase().newStatefulSession();
+ workingMemory.insert("Rule2");
+ workingMemory.insert(this.getSubject());
+
+ //Fire
+ System.out.println("Firing Rule2........");
+ workingMemory.fireAllRules();
+ ((StatefulSession)workingMemory).dispose();
+ }
+ //-----------------------------------------------------------------------------------------------------------------------------------------------------------
+ private Subject getSubject()
+ {
+ Subject subject = new Subject();
+
+ subject.setCategory(XACMLConstants.ATTRIBUTEID_ACCESS_SUBJECT);
+
+ //Create a Role Attribute
+ Attribute attribute = new Attribute();
+ attribute.setUri(XACMLConstants.ATTRIBUTEID_ROLE);
+ attribute.setDatatType(XMLSchemaConstants.DATATYPE_STRING);
+ attribute.setValue("developer");
+ subject.addAttribute(attribute);
+
+ return subject;
+ }
+}
Modified: modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/plugin/TestDroolsRules.java
===================================================================
--- modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/plugin/TestDroolsRules.java 2008-12-04 23:14:45 UTC (rev 12348)
+++ modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/plugin/TestDroolsRules.java 2008-12-05 05:54:40 UTC (rev 12349)
@@ -31,7 +31,6 @@
import org.jboss.security.xacml.interfaces.XACMLConstants;
import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
import org.jboss.security.authz.model.*;
-import org.jboss.security.authz.pap.service.DroolsRuleManager;
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
Deleted: modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/service/TestDroolsRuleManager.java
===================================================================
--- modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/service/TestDroolsRuleManager.java 2008-12-04 23:14:45 UTC (rev 12348)
+++ modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/service/TestDroolsRuleManager.java 2008-12-05 05:54:40 UTC (rev 12349)
@@ -1,134 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.security.authz.pap.service;
-
-
-import junit.framework.TestCase;
-
-import org.drools.WorkingMemory;
-import org.drools.StatefulSession;
-
-import org.jboss.security.xacml.interfaces.XACMLConstants;
-import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
-import org.jboss.security.authz.model.*;
-import org.jboss.security.authz.pap.service.DroolsRuleManager;
-
-/**
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- *
- */
-public class TestDroolsRuleManager extends TestCase
-{
- private static final String rule2 =
- "rule \"Rule2\"\n"+
- "when\n"+
- "$subject: Subject()\n"+
- "String(toString == \"Rule2\")\n"+
- "Subject(category == XACMLConstants.ATTRIBUTEID_ACCESS_SUBJECT)\n"+
- "Attribute(uri == XACMLConstants.ATTRIBUTEID_ROLE && value == \"developer\") from $subject.attributes\n"+
- "then\n"+
- "System.out.println(\"Rule2 successfully fired\");\n"+
- "end\n";
-
- private static final String rule1 =
- "rule \"Rule1\"\n"+
- "when\n"+
- "$subject: Subject()\n"+
- "String(toString == \"Rule1\")\n"+
- "Subject(category == XACMLConstants.ATTRIBUTEID_ACCESS_SUBJECT)\n"+
- "Attribute(uri == XACMLConstants.ATTRIBUTEID_ROLE && value == \"developer\") from $subject.attributes\n"+
- "then\n"+
- "System.out.println(\"Rule1 successfully fired\");\n"+
- "end\n";
-
- private DroolsRuleManager ruleManager = null;
-
-
- @Override
- protected void setUp() throws Exception
- {
- this.ruleManager = new DroolsRuleManager();
- this.ruleManager.start();
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- this.ruleManager = null;
- }
- //------------------------------------------------------------------------------------------------------------------------------------------------------------
- public void testAddRule() throws Exception
- {
- DroolsRuleExpression expression = new DroolsRuleExpression();
- expression.setRuleReference("Rule2");
- expression.setWhen(TestDroolsRuleManager.rule2);
- this.ruleManager.addRule(expression);
-
- WorkingMemory workingMemory = ruleManager.getActiveRuleBase().newStatefulSession();
- workingMemory.insert("Rule2");
- workingMemory.insert(this.getSubject());
-
- //Fire
- System.out.println("Firing Rule2........");
- workingMemory.fireAllRules();
- ((StatefulSession)workingMemory).dispose();
-
- expression.setRuleReference("Rule1");
- expression.setWhen(TestDroolsRuleManager.rule1);
- this.ruleManager.addRule(expression);
-
- workingMemory = ruleManager.getActiveRuleBase().newStatefulSession();
- workingMemory.insert("Rule1");
- workingMemory.insert(this.getSubject());
-
- //Fire
- System.out.println("Firing Rule1........");
- workingMemory.fireAllRules();
- ((StatefulSession)workingMemory).dispose();
-
- workingMemory = ruleManager.getActiveRuleBase().newStatefulSession();
- workingMemory.insert("Rule2");
- workingMemory.insert(this.getSubject());
-
- //Fire
- System.out.println("Firing Rule2........");
- workingMemory.fireAllRules();
- ((StatefulSession)workingMemory).dispose();
- }
- //-----------------------------------------------------------------------------------------------------------------------------------------------------------
- private Subject getSubject()
- {
- Subject subject = new Subject();
-
- subject.setCategory(XACMLConstants.ATTRIBUTEID_ACCESS_SUBJECT);
-
- //Create a Role Attribute
- Attribute attribute = new Attribute();
- attribute.setUri(XACMLConstants.ATTRIBUTEID_ROLE);
- attribute.setDatatType(XMLSchemaConstants.DATATYPE_STRING);
- attribute.setValue("developer");
- subject.addAttribute(attribute);
-
- return subject;
- }
-}
Modified: modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Action.java
===================================================================
--- modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Action.java 2008-12-04 23:14:45 UTC (rev 12348)
+++ modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Action.java 2008-12-05 05:54:40 UTC (rev 12349)
@@ -62,5 +62,5 @@
public void setAttributes(Set<Attribute> attributes)
{
this.attributes = attributes;
- }
+ }
}
Added: modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/ExpressionBuilder.java
===================================================================
--- modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/ExpressionBuilder.java (rev 0)
+++ modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/ExpressionBuilder.java 2008-12-05 05:54:40 UTC (rev 12349)
@@ -0,0 +1,192 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.security.authz.model;
+
+import org.jboss.security.xacml.interfaces.XACMLConstants;
+import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
+
+/**
+ * ExpressionBuilder provides easy to use operations for generating commonly used Expressions that must be represented within a Policy
+ *
+ * The purpose of this class is to provide a user friendly API for Developers to create these commonly used Expressions without having to deal with
+ * low-level XACML related concepts/API
+ *
+ * This API will grow as more and more different types of Expressions are added to the System as part of the core API
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class ExpressionBuilder
+{
+ private static ExpressionBuilder singleton = null;
+
+ private ExpressionBuilder()
+ {
+
+ }
+
+ public static ExpressionBuilder getInstance()
+ {
+ if(ExpressionBuilder.singleton == null)
+ {
+ ExpressionBuilder.singleton = new ExpressionBuilder();
+ }
+ return ExpressionBuilder.singleton;
+ }
+ //--------Resource expressions-----------------------------------------------------------------------------------------------------------------------------
+ /**
+ * Creates an expression for matching a unique Resource via its unique Id
+ *
+ * @param resourceId Unique Id of a Resource in the system that a policy should be applied to
+ * @return an expression that will be used within the Policy Definition
+ */
+ public AttributeExpression createResourceIdExpression(String resourceId)
+ {
+ AttributeExpression expression = new AttributeExpression();
+
+ expression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
+
+ Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_RESOURCE_ID,
+ XMLSchemaConstants.DATATYPE_STRING, resourceId);
+ expression.setAttribute(attribute);
+
+ return expression;
+ }
+
+ /**
+ * Creates an expression for matching a Resource Location
+ *
+ * @param resourceLocation the Location of a Resource in the system that a policy should be applied to
+ * @return an expression that will be used within the Policy Definition
+ */
+ public AttributeExpression createResourceLocationExpression(String resourceLocation)
+ {
+ AttributeExpression expression = new AttributeExpression();
+
+ expression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
+
+ Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_RESOURCE_LOCATION,
+ XMLSchemaConstants.DATATYPE_STRING, resourceLocation);
+ expression.setAttribute(attribute);
+
+ return expression;
+ }
+
+ /**
+ * Creates an expression for matching a File stored on the machine
+ *
+ * @param fileName Name of the file
+ * @return an expression that will be used within the Policy Definition
+ */
+ public AttributeExpression createFileNameExpression(String fileName)
+ {
+ AttributeExpression expression = new AttributeExpression();
+
+ expression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
+
+ Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_SIMPLE_FILE_NAME,
+ XMLSchemaConstants.DATATYPE_STRING, fileName);
+ expression.setAttribute(attribute);
+
+ return expression;
+ }
+ //---------Action Expressions---------------------------------------------------------------------------------------------------------------------------------
+ /**
+ * Creates an expression for matching an Action
+ *
+ * @param action signifies the Action that is to be protected on the resoource in question
+ * @return an expression that will be used within the Policy Definition
+ */
+ public AttributeExpression createActionExpression(String action)
+ {
+ AttributeExpression expression = new AttributeExpression();
+
+ expression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
+
+ Attribute actionAttribute = new Attribute(XACMLConstants.ATTRIBUTEID_ACTION_ID,
+ XMLSchemaConstants.DATATYPE_STRING, action);
+ expression.setAttribute(actionAttribute);
+
+ return expression;
+ }
+ //---------Subject Expressions----------------------------------------------------------------------------------------------------------------------------------
+ /**
+ * Creates an expression for matching an the Identity of the Authenticated User
+ *
+ * @param subjectId Identity of the Authenticated User
+ * @return an expression that will be used within the Policy Definition
+ */
+ public AttributeExpression createIdentityExpression(String identity)
+ {
+ AttributeExpression expression = new AttributeExpression();
+
+ expression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
+
+ Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_SUBJECT_ID,
+ XMLSchemaConstants.DATATYPE_STRING, identity);
+ expression.setAttribute(attribute);
+
+ return expression;
+ }
+
+ /**
+ * Creates an expression for matching the Role of the Authenticated User
+ *
+ * @param role Role of the Authenticated User
+ * @return an expression that will be used within the Policy Definition
+ */
+ public AttributeExpression createRoleExpression(String role)
+ {
+ AttributeExpression expression = new AttributeExpression();
+
+ expression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
+
+ Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_ROLE,
+ XMLSchemaConstants.DATATYPE_STRING, role);
+ expression.setAttribute(attribute);
+
+ return expression;
+ }
+ //---------Environment Expressions------------------------------------------------------------------------------------------------------------------------------
+ //---------Custom Expressions-----------------------------------------------------------------------------------------------------------------------------------
+ /**
+ * A generic method used to produce an Expression related to the type of Attribute designated by the Attribute Uri specified
+ * The function used within the Expression is a String equals
+ *
+ * @param attributeUri designates the type of Attribute in question
+ * @param attributeValue the Value of the Attribute for matching
+ * @return an expression that will be used within the Policy Definition
+ */
+ public AttributeExpression createCustomExpression(String attributeUri, String attributeValue)
+ {
+ AttributeExpression expression = new AttributeExpression();
+
+ expression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
+
+ Attribute attribute = new Attribute(attributeUri,
+ XMLSchemaConstants.DATATYPE_STRING, attributeValue);
+ expression.setAttribute(attribute);
+
+ return expression;
+ }
+}
Modified: modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/PolicyException.java
===================================================================
--- modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/PolicyException.java 2008-12-04 23:14:45 UTC (rev 12348)
+++ modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/PolicyException.java 2008-12-05 05:54:40 UTC (rev 12349)
@@ -28,7 +28,6 @@
*/
public class PolicyException extends Exception
{
-
public PolicyException()
{
super();
Modified: modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Resource.java
===================================================================
--- modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Resource.java 2008-12-04 23:14:45 UTC (rev 12348)
+++ modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Resource.java 2008-12-05 05:54:40 UTC (rev 12349)
@@ -24,6 +24,7 @@
import java.util.Set;
+
/**
* Represents the protected Resource of the system upon which various Actions can be performed
*
@@ -62,5 +63,5 @@
public void setAttributes(Set<Attribute> attributes)
{
this.attributes = attributes;
- }
+ }
}
Modified: modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Subject.java
===================================================================
--- modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Subject.java 2008-12-04 23:14:45 UTC (rev 12348)
+++ modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Subject.java 2008-12-05 05:54:40 UTC (rev 12349)
@@ -100,7 +100,5 @@
}
this.attributes.add(attribute);
- }
-
-
+ }
}
Modified: modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Target.java
===================================================================
--- modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Target.java 2008-12-04 23:14:45 UTC (rev 12348)
+++ modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Target.java 2008-12-05 05:54:40 UTC (rev 12349)
@@ -42,7 +42,15 @@
public Target()
{
+ this.resources = new ArrayList<Resource>();
+ this.actions = new ArrayList<Action>();
+ this.subjects = new ArrayList<Subject>();
+ this.environments = new ArrayList<Environment>();
+ this.resourceMatches = new ArrayList<AttributeExpression>();
+ this.actionMatches = new ArrayList<AttributeExpression>();
+ this.subjectMatches = new ArrayList<AttributeExpression>();
+ this.environmentMatches = new ArrayList<AttributeExpression>();
}
public List<Action> getActions()
@@ -52,6 +60,10 @@
public void setActions(List<Action> actions)
{
+ if(actions == null)
+ {
+ actions = new ArrayList<Action>();
+ }
this.actions = actions;
}
@@ -62,6 +74,10 @@
public void setEnvironments(List<Environment> environments)
{
+ if(environments == null)
+ {
+ environments = new ArrayList<Environment>();
+ }
this.environments = environments;
}
@@ -72,6 +88,10 @@
public void setResources(List<Resource> resources)
{
+ if(resources == null)
+ {
+ resources = new ArrayList<Resource>();
+ }
this.resources = resources;
}
@@ -82,6 +102,10 @@
public void setSubjects(List<Subject> subjects)
{
+ if(subjects == null)
+ {
+ subjects = new ArrayList<Subject>();
+ }
this.subjects = subjects;
}
@@ -92,6 +116,10 @@
public void setActionMatches(List<AttributeExpression> actionMatches)
{
+ if(actionMatches == null)
+ {
+ actionMatches = new ArrayList<AttributeExpression>();
+ }
this.actionMatches = actionMatches;
}
@@ -102,6 +130,10 @@
public void setEnvironmentMatches(List<AttributeExpression> environmentMatches)
{
+ if(environmentMatches == null)
+ {
+ environmentMatches = new ArrayList<AttributeExpression>();
+ }
this.environmentMatches = environmentMatches;
}
@@ -112,6 +144,10 @@
public void setResourceMatches(List<AttributeExpression> resourceMatches)
{
+ if(resourceMatches == null)
+ {
+ resourceMatches = new ArrayList<AttributeExpression>();
+ }
this.resourceMatches = resourceMatches;
}
@@ -122,24 +158,50 @@
public void setSubjectMatches(List<AttributeExpression> subjectMatches)
{
+ if(subjectMatches == null)
+ {
+ subjectMatches = new ArrayList<AttributeExpression>();
+ }
this.subjectMatches = subjectMatches;
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------
+ public void addResource(Resource resource)
+ {
+ this.resources.add(resource);
+ }
+
+ public void addSubject(Subject subject)
+ {
+ this.subjects.add(subject);
+ }
+
+ public void addAction(Action action)
+ {
+ this.actions.add(action);
+ }
+
+ public void addEnvironment(Environment environment)
+ {
+ this.environments.add(environment);
+ }
+
public void addResourceMatch(AttributeExpression resourceMatch)
- {
- if(this.resourceMatches == null)
- {
- this.resourceMatches = new ArrayList<AttributeExpression>();
- }
+ {
this.resourceMatches.add(resourceMatch);
}
public void addActionMatch(AttributeExpression actionMatch)
- {
- if(this.actionMatches == null)
- {
- this.actionMatches = new ArrayList<AttributeExpression>();
- }
+ {
this.actionMatches.add(actionMatch);
}
+
+ public void addSubjectMatch(AttributeExpression subjectMatch)
+ {
+ this.subjectMatches.add(subjectMatch);
+ }
+
+ public void addEnvironmentMatch(AttributeExpression envMatch)
+ {
+ this.environmentMatches.add(envMatch);
+ }
}
17 years, 5 months
JBoss Portal SVN: r12348 - branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-12-04 18:14:45 -0500 (Thu, 04 Dec 2008)
New Revision: 12348
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerResponseFactory.java
Log:
JBPORTAL-2248: Action URL retained by client
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerResponseFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerResponseFactory.java 2008-12-04 20:09:47 UTC (rev 12347)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerResponseFactory.java 2008-12-04 23:14:45 UTC (rev 12348)
@@ -37,6 +37,7 @@
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.command.response.PortletWindowActionResponse;
import org.jboss.portal.portlet.NoSuchPortletException;
+import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
@@ -44,6 +45,8 @@
import java.io.ByteArrayInputStream;
import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -76,8 +79,13 @@
//
WindowState windowState = renderResult.getWindowState();
- //
- return new PortletWindowActionResponse(targetId, windowState, mode, renderResult.getNavigationalState());
+ ParametersStateString state = (ParametersStateString)renderResult.getNavigationalState();
+
+ Map<String, String[]> parameters = new HashMap<String, String[]>(state.getParameters());
+
+ parameters.putAll(renderResult.getPublicNavigationalStateUpdates());
+
+ return new PortletWindowActionResponse(targetId, windowState, mode, ParametersStateString.create(parameters));
}
else
{
17 years, 5 months