JBoss Portal SVN: r12773 - branches/JBoss_Portal_Branch_2_7/core-identity/src/resources/portal-identity-war/jsf/admin.
by portal-commits@lists.jboss.org
Author: prabhat.jha(a)jboss.com
Date: 2009-02-04 13:24:18 -0500 (Wed, 04 Feb 2009)
New Revision: 12773
Modified:
branches/JBoss_Portal_Branch_2_7/core-identity/src/resources/portal-identity-war/jsf/admin/roles.xhtml
Log:
JBPORTAL-2298 make role ui consistent with users ui
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/resources/portal-identity-war/jsf/admin/roles.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/resources/portal-identity-war/jsf/admin/roles.xhtml 2009-02-04 16:46:53 UTC (rev 12772)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/resources/portal-identity-war/jsf/admin/roles.xhtml 2009-02-04 18:24:18 UTC (rev 12773)
@@ -18,6 +18,12 @@
<h:messages style="list-style:none" infoClass="portlet-msg-success" errorClass="portlet-msg-error"
fatalClass="portlet-msg-error" warnClass="portlet-msg-alert"/>
<br/>
+
+<h:form id="create-role-form">
+ <p style="text-align: ldeft;">
+ <h:commandLink id="create-role-link" value="#{bundle.IDENTITY_MANAGEMENT_CREATE_ROLE}" action="createRole" styleClass="actionCreateInstance"/>
+ </p>
+</h:form>
<h:form id="roles-form">
@@ -53,12 +59,8 @@
</h:column>
</h:dataTable>
</h:form>
+ <hr/>
- <hr/>
- <h:form id="create-role-form">
- <p style="text-align: right; padding-right: 5px;">
- <h:commandLink id="create-role-link" value="#{bundle.IDENTITY_MANAGEMENT_CREATE_ROLE}" action="createRole" styleClass="actionCreateInstance"/></p>
- </h:form>
</ui:define>
</ui:composition>
</div>
17 years, 3 months
JBoss Portal SVN: r12772 - in modules/authorization/trunk: common/src/main/java/org/jboss/security/authz/model and 7 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2009-02-04 11:46:53 -0500 (Wed, 04 Feb 2009)
New Revision: 12772
Added:
modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/http/TestHttpResourceRules.java
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestEnterprisePolicyFinderModule.java
Modified:
modules/authorization/trunk/common/pom.xml
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/DroolsRuleExpression.java
modules/authorization/trunk/core-components/pom.xml
modules/authorization/trunk/core-components/src/main/java/org/jboss/security/authz/components/http/HttpResource.java
modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/http/TestHttpResource.java
modules/authorization/trunk/policy-server/pom.xml
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/decision/PolicyDecisionPoint.java
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/DroolsFunction.java
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/DroolsRuleManager.java
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestDroolsFunction.java
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestDroolsRuleManager.java
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestDroolsRules.java
Log:
Integrating Drools based Expressions to specify Policy Rules for the HttpResource core component
Modified: modules/authorization/trunk/common/pom.xml
===================================================================
--- modules/authorization/trunk/common/pom.xml 2009-02-04 14:00:11 UTC (rev 12771)
+++ modules/authorization/trunk/common/pom.xml 2009-02-04 16:46:53 UTC (rev 12772)
@@ -18,7 +18,7 @@
<dependency>
<groupId>org.jboss.security</groupId>
<artifactId>jboss-xacml</artifactId>
- </dependency>
+ </dependency>
</dependencies>
<build>
Modified: modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/DroolsRuleExpression.java
===================================================================
--- modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/DroolsRuleExpression.java 2009-02-04 14:00:11 UTC (rev 12771)
+++ modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/DroolsRuleExpression.java 2009-02-04 16:46:53 UTC (rev 12772)
@@ -30,25 +30,20 @@
*/
public class DroolsRuleExpression extends Expression
{
- private String functionId = null;
- private String ruleReference = null;
- private String when = null;
+ private String functionId;
+ private String ruleReference;
+ private String rule;
public DroolsRuleExpression()
{
-
+ this.functionId = "urn:oasis:names:tc:xacml:2.0:function:jboss-drools:rule";
}
public String getFunctionId()
{
- return functionId;
+ return this.functionId;
}
- public void setFunctionId(String functionId)
- {
- this.functionId = functionId;
- }
-
public String getRuleReference()
{
return ruleReference;
@@ -59,13 +54,13 @@
this.ruleReference = ruleReference;
}
- public String getWhen()
+ public String getRule()
{
- return this.when;
+ return this.rule;
}
- public void setWhen(String when)
+ public void setRule(String rule)
{
- this.when = when;
+ this.rule = rule;
}
}
Modified: modules/authorization/trunk/core-components/pom.xml
===================================================================
--- modules/authorization/trunk/core-components/pom.xml 2009-02-04 14:00:11 UTC (rev 12771)
+++ modules/authorization/trunk/core-components/pom.xml 2009-02-04 16:46:53 UTC (rev 12772)
@@ -24,6 +24,16 @@
<dependency>
<groupId>org.jboss.security</groupId>
<artifactId>jboss-xacml</artifactId>
+ </dependency>
+
+ <!-- Drools -->
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-compiler</artifactId>
</dependency>
</dependencies>
@@ -34,7 +44,8 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.3.1</version>
<configuration>
- <includes>
+ <includes>
+ <include>**/TestHttpResourceRules.java</include>
</includes>
</configuration>
</plugin>
Modified: modules/authorization/trunk/core-components/src/main/java/org/jboss/security/authz/components/http/HttpResource.java
===================================================================
--- modules/authorization/trunk/core-components/src/main/java/org/jboss/security/authz/components/http/HttpResource.java 2009-02-04 14:00:11 UTC (rev 12771)
+++ modules/authorization/trunk/core-components/src/main/java/org/jboss/security/authz/components/http/HttpResource.java 2009-02-04 16:46:53 UTC (rev 12772)
@@ -35,6 +35,7 @@
import org.jboss.security.authz.model.Attribute;
import org.jboss.security.authz.model.Resource;
import org.jboss.security.authz.model.PolicyMetaData;
+import org.jboss.security.authz.model.DroolsRuleExpression;
import org.jboss.security.authz.tools.GeneralTool;
import org.jboss.security.xacml.interfaces.XACMLConstants;
@@ -51,6 +52,34 @@
*/
public class HttpResource
{
+ //make it package-level access so that unit tests can test these rules
+ static final String allowedRolesRule =
+ "rule \"allowedRolesRule\"\n"+
+ "when\n"+
+ "$ruleName: String()\n"+
+ "eval($ruleName.contains(\"httpResource://permittedRoles\"))\n"+
+ "then\n"+
+ "System.out.println(\"AllowedRolesRule successfully fired\");\n"+
+ "end\n";
+
+ static final String deniedRolesRule =
+ "rule \"deniedRolesRule\"\n"+
+ "when\n"+
+ "$ruleName: String()\n"+
+ "eval($ruleName.contains(\"httpResource://deniedRoles\"))\n"+
+ "then\n"+
+ "System.out.println(\"DeniedRolesRule successfully fired\");\n"+
+ "end\n";
+
+ static final String allowedIpsRule =
+ "rule \"allowedIpsRule\"\n"+
+ "when\n"+
+ "$ruleName: String()\n"+
+ "eval($ruleName.contains(\"httpResource://allowedIps\"))\n"+
+ "then\n"+
+ "System.out.println(\"AllowedIpsRule successfully fired\");\n"+
+ "end\n";
+
/**
* The URL that identifies this resource
*/
@@ -173,7 +202,7 @@
*
* @param matchAllParameters 'true' = include matching of all the parameters, 'false' = only url matching, parameters are excluded
*/
- public Target getURLTarget(boolean matchAllParameters)
+ private Target getURLTarget(boolean matchAllParameters)
{
if(this.url == null || this.url.trim().length()==0)
{
@@ -208,7 +237,7 @@
*
* @return the rule
*/
- public Rule getPermittedRolesRule()
+ private Rule getPermittedRolesRule()
{
if(this.allowedRoles == null || this.allowedRoles.isEmpty())
{
@@ -216,18 +245,19 @@
}
Rule permitRule = new Rule();
- Target ruleTarget = new Target();
- permitRule.setRuleId(GeneralTool.generateUniqueId());
+ permitRule.setRuleId("httpResource://permittedRoles/"+GeneralTool.generateUniqueId());
permitRule.setEffect(Effect.PERMIT);
- permitRule.setTarget(ruleTarget);
- //Create a Subject Match Function
+ //Generate a Drools Rule
for(String role: this.allowedRoles)
{
- ruleTarget.addSubjectMatch(ExpressionBuilder.getInstance().createBelongsToRoleExpression(role));
}
+ DroolsRuleExpression expression = new DroolsRuleExpression();
+ expression.setRuleReference(GeneralTool.generateUniqueId());
+ permitRule.setExpression(expression);
+
return permitRule;
}
@@ -236,7 +266,7 @@
*
* @return the role
*/
- public Rule getDeniedRolesRule()
+ private Rule getDeniedRolesRule()
{
if(this.deniedRoles == null || this.deniedRoles.isEmpty())
{
@@ -244,22 +274,22 @@
}
Rule denyRule = new Rule();
- Target ruleTarget = new Target();
- denyRule.setRuleId(GeneralTool.generateUniqueId());
+ denyRule.setRuleId("httpResource://deniedRoles/"+GeneralTool.generateUniqueId());
denyRule.setEffect(Effect.DENY);
- denyRule.setTarget(ruleTarget);
- //Create a Subject Match Function
+ //Generate a Drools Rule
for(String role: this.deniedRoles)
- {
- ruleTarget.addSubjectMatch(ExpressionBuilder.getInstance().createBelongsToRoleExpression(role));
+ {
}
+ DroolsRuleExpression expression = new DroolsRuleExpression();
+ expression.setRuleReference(GeneralTool.generateUniqueId());
+ denyRule.setExpression(expression);
return denyRule;
}
- public Rule getAllowedIpsRule()
+ private Rule getAllowedIpsRule()
{
if(this.allowedIps == null || this.allowedIps.isEmpty())
{
@@ -267,22 +297,23 @@
}
Rule rule = new Rule();
- Target ruleTarget = new Target();
- rule.setRuleId(GeneralTool.generateUniqueId());
+ rule.setRuleId("httpResource://allowedIps/"+GeneralTool.generateUniqueId());
rule.setEffect(Effect.PERMIT);
- rule.setTarget(ruleTarget);
for(String allowedIp: this.allowedIps)
{
- AttributeExpression expression = new AttributeExpression();
+ /*AttributeExpression expression = new AttributeExpression();
expression.setFunctionId(XACMLConstants.FUNCTION_REGEXP_IPADDRESS_MATCH);
Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_IP_ADDRESS,
XMLSchemaConstants.DATATYPE_IPADDRESS, allowedIp);
expression.setAttribute(attribute);
- rule.setExpression(expression);
+ rule.setExpression(expression);*/
}
+ DroolsRuleExpression expression = new DroolsRuleExpression();
+ expression.setRuleReference(GeneralTool.generateUniqueId());
+ rule.setExpression(expression);
return rule;
}
Modified: modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/http/TestHttpResource.java
===================================================================
--- modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/http/TestHttpResource.java 2009-02-04 14:00:11 UTC (rev 12771)
+++ modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/http/TestHttpResource.java 2009-02-04 16:46:53 UTC (rev 12772)
@@ -46,9 +46,7 @@
{
HttpResource httpResource = new HttpResource();
httpResource.setUrl("/portal/admin-tool/modifyLayout");
-
- Target target = httpResource.getURLTarget(false);
-
+
Policy policy = new MockPolicy("testGetURLTargetNoParameters", httpResource.getPolicyMetaData(false));
log.info("------------------------------------------------------------------");
@@ -62,7 +60,6 @@
httpResource.addParameter("test1", "test1://value");
httpResource.addParameter("test2", "test2://value");
- Target target = httpResource.getURLTarget(true);
Policy policy = new MockPolicy("testGetURLTargetWithParameters", httpResource.getPolicyMetaData(true));
@@ -78,12 +75,7 @@
httpResource.addParameter("test2", "test2://value");
httpResource.addAllowedRole("admin");
httpResource.addDeniedRole("anonymous");
-
- Target target = httpResource.getURLTarget(true);
- Set<Rule> rules = new HashSet<Rule>();
- rules.add(httpResource.getPermittedRolesRule());
- rules.add(httpResource.getDeniedRolesRule());
-
+
Policy policy = new MockPolicy("testRoleRules", httpResource.getPolicyMetaData(true));
log.info("------------------------------------------------------------------");
@@ -99,16 +91,10 @@
httpResource.addAllowedRole("admin");
httpResource.addDeniedRole("anonymous");
httpResource.addAllowedIp("192.168.x.x");
-
- Target target = httpResource.getURLTarget(true);
- Set<Rule> rules = new HashSet<Rule>();
- rules.add(httpResource.getPermittedRolesRule());
- rules.add(httpResource.getDeniedRolesRule());
- rules.add(httpResource.getAllowedIpsRule());
-
+
Policy policy = new MockPolicy("testIPRules", httpResource.getPolicyMetaData(true));
log.info("------------------------------------------------------------------");
log.info(policy.generateXACMLPolicy());
- }
+ }
}
Added: modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/http/TestHttpResourceRules.java
===================================================================
--- modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/http/TestHttpResourceRules.java (rev 0)
+++ modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/http/TestHttpResourceRules.java 2009-02-04 16:46:53 UTC (rev 12772)
@@ -0,0 +1,116 @@
+/*
+* 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.components.http;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+
+
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+import org.drools.StatefulSession;
+import org.drools.WorkingMemory;
+import org.drools.compiler.PackageBuilder;
+import org.jboss.security.authz.tools.GeneralTool;
+
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class TestHttpResourceRules extends TestCase
+{
+ private static Logger log = Logger.getLogger(TestHttpResourceRules.class);
+ 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;
+
+ public void setUp() throws Exception
+ {
+ StringBuilder buffer = new StringBuilder();
+
+ buffer.append(rulePkg+"\n");
+ buffer.append(HttpResource.allowedRolesRule+"\n");
+ buffer.append(HttpResource.deniedRolesRule+"\n");
+ buffer.append(HttpResource.allowedIpsRule+"\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();
+ }
+ }
+
+ public void tearDown() throws Exception
+ {
+ this.activeRuleBase = null;
+ }
+
+ public void testAllowedRolesRule() throws Exception
+ {
+ log.info("Executing----------testAllowedRolesRule");
+ WorkingMemory workingMemory = this.activeRuleBase.newStatefulSession();
+ workingMemory.insert("httpResource://permittedRoles/"+GeneralTool.generateUniqueId());
+ workingMemory.fireAllRules();
+ ((StatefulSession)workingMemory).dispose();
+ }
+
+ public void testDeniedRolesRule() throws Exception
+ {
+ log.info("Executing----------testDeniedRolesRule");
+ WorkingMemory workingMemory = this.activeRuleBase.newStatefulSession();
+ workingMemory.insert("httpResource://deniedRoles/"+GeneralTool.generateUniqueId());
+ workingMemory.fireAllRules();
+ ((StatefulSession)workingMemory).dispose();
+ }
+
+ public void testAllowedIpsRule() throws Exception
+ {
+ log.info("Executing----------testAllowedIpsRule");
+ WorkingMemory workingMemory = this.activeRuleBase.newStatefulSession();
+ workingMemory.insert("httpResource://allowedIps/"+GeneralTool.generateUniqueId());
+ workingMemory.fireAllRules();
+ ((StatefulSession)workingMemory).dispose();
+ }
+}
Modified: modules/authorization/trunk/policy-server/pom.xml
===================================================================
--- modules/authorization/trunk/policy-server/pom.xml 2009-02-04 14:00:11 UTC (rev 12771)
+++ modules/authorization/trunk/policy-server/pom.xml 2009-02-04 16:46:53 UTC (rev 12772)
@@ -65,8 +65,8 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.3.1</version>
<configuration>
- <includes>
- <include>**/TestPolicyServer.java</include>
+ <includes>
+ <include>**/TestEnterprisePolicyFinderModule.java</include>
</includes>
</configuration>
</plugin>
Modified: modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/decision/PolicyDecisionPoint.java
===================================================================
--- modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/decision/PolicyDecisionPoint.java 2009-02-04 14:00:11 UTC (rev 12771)
+++ modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/decision/PolicyDecisionPoint.java 2009-02-04 16:46:53 UTC (rev 12772)
@@ -121,4 +121,9 @@
throw new PolicyServerException(e);
}
}
+
+ public PDP getPDP() throws PolicyServerException
+ {
+ return this.policyDecisionPoint;
+ }
}
Modified: modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/DroolsFunction.java
===================================================================
--- modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/DroolsFunction.java 2009-02-04 14:00:11 UTC (rev 12771)
+++ modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/DroolsFunction.java 2009-02-04 16:46:53 UTC (rev 12772)
@@ -43,7 +43,7 @@
*/
public class DroolsFunction extends FunctionBase
{
- public static final String NAME = FUNCTION_NS + "drools:rule";
+ public static final String NAME = "urn:oasis:names:tc:xacml:2.0:function:jboss-drools:rule";
/**
*
Modified: modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/DroolsRuleManager.java
===================================================================
--- modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/DroolsRuleManager.java 2009-02-04 14:00:11 UTC (rev 12771)
+++ modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/DroolsRuleManager.java 2009-02-04 16:46:53 UTC (rev 12772)
@@ -88,13 +88,13 @@
{
throw new IllegalArgumentException("Rule Reference is missing");
}
- if(rule.getWhen() == null || rule.getWhen().trim().length() == 0)
+ if(rule.getRule() == null || rule.getRule().trim().length() == 0)
{
throw new IllegalArgumentException("LHS value is missing");
}
- this.drls.put(rule.getRuleReference(), rule.getWhen());
+ this.drls.put(rule.getRuleReference(), rule.getRule());
this.reloadActiveRuleBase();
}
catch(Exception e)
@@ -118,7 +118,7 @@
rule = new DroolsRuleExpression();
rule.setRuleReference(ruleReference);
- rule.setWhen(when);
+ rule.setRule(when);
return rule;
}
@@ -136,12 +136,12 @@
{
throw new IllegalArgumentException("Rule Reference is missing");
}
- if(rule.getWhen() == null || rule.getWhen().trim().length() == 0)
+ if(rule.getRule() == null || rule.getRule().trim().length() == 0)
{
throw new IllegalArgumentException("LHS value is missing");
}
- this.drls.put(rule.getRuleReference(), rule.getWhen());
+ this.drls.put(rule.getRuleReference(), rule.getRule());
this.reloadActiveRuleBase();
}
catch(Exception e)
Modified: modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestDroolsFunction.java
===================================================================
--- modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestDroolsFunction.java 2009-02-04 14:00:11 UTC (rev 12771)
+++ modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestDroolsFunction.java 2009-02-04 16:46:53 UTC (rev 12772)
@@ -204,8 +204,7 @@
writeRule.setTarget(ruleTarget);
- DroolsRuleExpression ruleExpression = new DroolsRuleExpression();
- ruleExpression.setFunctionId(DroolsFunction.NAME);
+ DroolsRuleExpression ruleExpression = new DroolsRuleExpression();
ruleExpression.setRuleReference("WriteRuleReference");
writeRule.setExpression(ruleExpression);
Modified: modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestDroolsRuleManager.java
===================================================================
--- modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestDroolsRuleManager.java 2009-02-04 14:00:11 UTC (rev 12771)
+++ modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestDroolsRuleManager.java 2009-02-04 16:46:53 UTC (rev 12772)
@@ -82,7 +82,7 @@
{
DroolsRuleExpression expression = new DroolsRuleExpression();
expression.setRuleReference("Rule2");
- expression.setWhen(TestDroolsRuleManager.rule2);
+ expression.setRule(TestDroolsRuleManager.rule2);
this.ruleManager.addRule(expression);
WorkingMemory workingMemory = ruleManager.getActiveRuleBase().newStatefulSession();
@@ -95,7 +95,7 @@
((StatefulSession)workingMemory).dispose();
expression.setRuleReference("Rule1");
- expression.setWhen(TestDroolsRuleManager.rule1);
+ expression.setRule(TestDroolsRuleManager.rule1);
this.ruleManager.addRule(expression);
workingMemory = ruleManager.getActiveRuleBase().newStatefulSession();
Modified: modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestDroolsRules.java
===================================================================
--- modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestDroolsRules.java 2009-02-04 14:00:11 UTC (rev 12771)
+++ modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestDroolsRules.java 2009-02-04 16:46:53 UTC (rev 12772)
@@ -81,7 +81,7 @@
{
DroolsRuleExpression expression = new DroolsRuleExpression();
expression.setRuleReference("Rule2");
- expression.setWhen(TestDroolsRules.rule2);
+ expression.setRule(TestDroolsRules.rule2);
this.ruleManager.addRule(expression);
WorkingMemory workingMemory = ruleManager.getActiveRuleBase().newStatefulSession();
@@ -94,7 +94,7 @@
((StatefulSession)workingMemory).dispose();
expression.setRuleReference("Rule1");
- expression.setWhen(TestDroolsRules.rule1);
+ expression.setRule(TestDroolsRules.rule1);
this.ruleManager.addRule(expression);
workingMemory = ruleManager.getActiveRuleBase().newStatefulSession();
Added: modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestEnterprisePolicyFinderModule.java
===================================================================
--- modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestEnterprisePolicyFinderModule.java (rev 0)
+++ modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestEnterprisePolicyFinderModule.java 2009-02-04 16:46:53 UTC (rev 12772)
@@ -0,0 +1,178 @@
+/*
+* 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.policy.server.plugin;
+
+import java.util.Set;
+import junit.framework.TestCase;
+import org.apache.log4j.Logger;
+
+import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.model.Resource;
+import org.jboss.security.authz.model.Attribute;
+import org.jboss.security.authz.components.http.HttpResource;
+import org.jboss.security.authz.policy.server.PolicyServer;
+import org.jboss.security.authz.policy.server.Server;
+
+import org.jboss.security.xacml.core.model.context.ActionType;
+import org.jboss.security.xacml.core.model.context.AttributeType;
+import org.jboss.security.xacml.core.model.context.AttributeValueType;
+import org.jboss.security.xacml.core.model.context.ObjectFactory;
+import org.jboss.security.xacml.core.model.context.RequestType;
+import org.jboss.security.xacml.core.model.context.ResourceType;
+import org.jboss.security.xacml.core.model.context.SubjectType;
+import org.jboss.security.xacml.factories.RequestResponseContextFactory;
+import org.jboss.security.xacml.interfaces.RequestContext;
+import org.jboss.security.xacml.interfaces.ResponseContext;
+import org.jboss.security.xacml.interfaces.XACMLConstants;
+import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
+
+import org.jboss.security.xacml.sunxacml.PDP;
+import org.jboss.security.xacml.sunxacml.ctx.RequestCtx;
+import org.jboss.security.xacml.sunxacml.ctx.ResponseCtx;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class TestEnterprisePolicyFinderModule extends TestCase
+{
+ private static Logger log = Logger.getLogger(TestEnterprisePolicyFinderModule.class);
+
+ private PolicyServer policyServer;
+
+ public void setUp() throws Exception
+ {
+ Server.bootstrap();
+ this.policyServer = (PolicyServer)Server.lookup("/policy-server/PolicyServer");
+ }
+
+ public void tearDown() throws Exception
+ {
+ }
+
+ public void testNewPolicyEnforcement() throws Exception
+ {
+ HttpResource httpResource = new HttpResource();
+ httpResource.setUrl("/blah/index.html");
+ httpResource.addParameter("param1", "param1Value");
+ httpResource.addParameter("param2", "param2Value");
+ httpResource.addAllowedRole("Admin");
+
+ policyServer.newPolicy(httpResource.getPolicyMetaData(true));
+
+ //Assert Policy State of the Server
+ Policy[] policies = policyServer.readAllPolicies();
+
+ assertTrue("Policy Store must not be empty!!", (policies != null && policies.length == 1));
+ log.info("------------------------------------------------------------------------------");
+ log.info(policies[0].generateXACMLPolicy());
+
+ //Send an Enforcement request that should be allowed
+ this.enforce(this.createPermitRequestContext(httpResource), true);
+
+ //Send an Enforcement request that should be denied
+ this.enforce(this.createPermitRequestContext(httpResource), false);
+ }
+ //----------------------------------------------------------------------------------------------------------------------------------------------------------
+ private void enforce(RequestContext request, boolean mustBePermitted) throws Exception
+ {
+ log.info("-----------------------------------");
+ request.marshall(System.out);
+
+ PDP pdp = this.policyServer.getPolicyDecisionPoint().getPDP();
+
+ ResponseCtx response = pdp.evaluate((RequestCtx)request.get(XACMLConstants.REQUEST_CTX));
+ assertNotNull(response);
+
+ log.info("-----------------------------------");
+ response.encode(System.out);
+
+ ResponseContext responseContext = RequestResponseContextFactory.createResponseContext();
+ responseContext.set(XACMLConstants.RESPONSE_CTX, response);
+ assertNotNull(responseContext);
+ if(mustBePermitted)
+ {
+ assertEquals(responseContext.getDecision(), XACMLConstants.DECISION_PERMIT);
+ }
+ else
+ {
+ assertEquals(responseContext.getDecision(), XACMLConstants.DECISION_DENY);
+ }
+
+ log.info("-----------------------------------");
+ log.info("Decision="+responseContext.getDecision());
+ }
+ private RequestContext createPermitRequestContext(HttpResource httpResource) throws Exception
+ {
+ //Create ObjectFactory
+ ObjectFactory objectFactory = new ObjectFactory();
+
+ //Create RequestContext
+ RequestContext requestContext = RequestResponseContextFactory.createRequestCtx();
+
+ //Create a RequestType
+ RequestType requestType = objectFactory.createRequestType();
+
+
+ //Create Subjects
+ SubjectType subject = objectFactory.createSubjectType();
+ AttributeType subjectAttribute = objectFactory.createAttributeType();
+ subjectAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_ROLE);
+ subjectAttribute.setDataType(XMLSchemaConstants.DATATYPE_STRING);
+ AttributeValueType subjectId = objectFactory.createAttributeValueType();
+ subjectId.getContent().add("Admin");
+ subjectAttribute.getAttributeValue().add(subjectId);
+ subject.getAttribute().add(subjectAttribute);
+ requestType.getSubject().add(subject);
+
+ //Create Resource
+ Resource urlResource = httpResource.getURLResource();
+ ResourceType resource = objectFactory.createResourceType();
+ Set<Attribute> attributes = urlResource.getAttributes();
+ for(Attribute attribute: attributes)
+ {
+ AttributeType resourceAttribute = objectFactory.createAttributeType();
+ resourceAttribute.setAttributeId(attribute.getUri());
+ resourceAttribute.setDataType(attribute.getDatatType());
+ AttributeValueType resourceId = objectFactory.createAttributeValueType();
+ resourceId.getContent().add(attribute.getValue());
+ resourceAttribute.getAttributeValue().add(resourceId);
+ resource.getAttribute().add(resourceAttribute);
+ }
+ requestType.getResource().add(resource);
+
+ //Create Action
+ ActionType action = objectFactory.createActionType();
+ AttributeType actionAttribute = objectFactory.createAttributeType();
+ actionAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_ACTION_ID);
+ actionAttribute.setDataType(XMLSchemaConstants.DATATYPE_STRING);
+ AttributeValueType actionId = objectFactory.createAttributeValueType();
+ actionId.getContent().add("GET");
+ actionAttribute.getAttributeValue().add(actionId);
+ action.getAttribute().add(actionAttribute);
+ requestType.setAction(action);
+
+ //Spit out RequestContext
+ requestContext.setRequest(requestType);
+
+ return requestContext;
+ }
+}
17 years, 3 months
JBoss Portal SVN: r12771 - in branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium: cms and 1 other directory.
by portal-commits@lists.jboss.org
Author: vrockai
Date: 2009-02-04 09:00:11 -0500 (Wed, 04 Feb 2009)
New Revision: 12771
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.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/UserLoginTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java
Log:
identity admin selenium fix
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java 2009-02-04 10:06:14 UTC (rev 12770)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java 2009-02-04 14:00:11 UTC (rev 12771)
@@ -14,7 +14,12 @@
@Test(groups = { "admin_ui" }, enabled = true)
public class IdentityAdminTestCase extends JBossPortalSeleniumTestCase {
+ private static final String SEL_SEARCHUSER_LIMIT = "//select[contains(@id,'search-user-form:limit')]";
private static final String SUB_EDIT_PROF = "//input[contains(@id,'profile-form:submit')]";
+
+ private static final String SUB_PAGIN_LEFT = "//input[contains(@id,'search-user-form1:prev-page')]";
+ private static final String SUB_PAGIN_RIGHT = "//input[contains(@id,'search-user-form1:next-page')]";
+
private static final String SUB_EDIT_USER_EMAIL_CANCEL = "//input[contains(@id,'profile-form:cancel')]";
private static final String INP_EDIT_USER_EMAIL = "//input[contains(@id,'profile-form:email')]";
private static final String SUB_ROLE_SEARCH_USER = "//input[contains(@id,'search-user-form:search') and @type='submit']";
@@ -24,64 +29,65 @@
private static final String INP_EDIT_ROLE_NAME = "//input[contains(@id,'edit-role-link:display-name')]";
private static final String SUB_PASS_CHANGE_SUBMIT = "//input[contains(@name,'change-pwd-form:j_id31')]";
private static final String SUB_PASS_CHANGE_CANCEL = "//input[contains(@id,'change-pwd-form:cancel')]";
- private static final String INPUT_PASS_CHANGE_P2 = "//input[contains(@id,':change-pwd-form:passwordCheck')]";
- private static final String INPUT_PASS_CHANGE_P1 = "//input[contains(@id,':change-pwd-form:password')]";
- private static final String LINK_CHANGE_PASS = "//a[contains(@id,':profile-form:change-pwd-adm-link')]";
- public static final String TABLE_USERLIST = "//table[contains(@id,'search-user-form1:userlist')]";
- public static final String LINK_T_USRLIST_DEL = "//a[contains(@id,''search-user-form1:userlist:{0}:delete-user-link'')]";
- public static final String LINK_T_USRLIST_ROLES = "//a[contains(@id,''search-user-form1:userlist:{0}:assign-role-link'')]";
- public static final String LINK_T_USRLIST_DIS = "//a[contains(@id,''search-user-form1:userlist:{0}:enable-user-link'')]";
- public static final String LINK_T_USRLIST_EDIT = "//a[contains(@id,''search-user-form1:userlist:{0}:rename-link'')]";
-
- public static final String TABLE_ROLELIST = "//table[contains(@id,':_viewRoot:roles-form:userlist')]";
-
- public static final String LINK_T_ROLLIST_DEL = "//a[contains(@id,''roles-form:userlist:{0}:delete-role-link'')]";
- public static final String LINK_T_ROLLIST_MEMBERS = "//a[contains(@id,''roles-form:userlist:{0}:view-role-link'')]";
- public static final String LINK_T_ROLLIST_EDIT = "//a[contains(@id,''roles-form:userlist:{0}:edit-role-link'')]";
-
- public static final String TABLE_ROLEMEMBERS = "//table[contains(@id,'role-members-form:role-data-table')]";
-
- public static final String ID_SUBMIT_CONF_CREATE_USER = "//input[contains(@id,'confirm-form:admin')]";
- public static final String ID_SUBMIT_DELETE_ROLE = "//input[contains(@id,'delete-role-form:confirm')]";
- public static final String ID_SUBMIT_ROLE_CREATE = "//input[contains(@id,':_viewRoot:create-role-form:submit')]";
- public static final String ID_INPUT_ROLEDISNAME = "//input[contains(@id,':_viewRoot:create-role-form:roledisplayname')]";
- public static final String ID_INPUT_ROLENAME = "//input[contains(@id,':_viewRoot:create-role-form:rolename')]";
-
- public static final String ID_BUT_ROLE_CREATE = "//a[contains(@id, ':_viewRoot:create-role-form:create-role-link')]";
- public static final String ID_BUT_SUBMIT_DEL_USER = "//input[contains(@id,'delete-user-form:submit')]";
- public static final String ID_SUBMIT_ASSIGN_ROLE = "//input[contains(@id,'assign-roles-form:submit')]";
- public static final String ID_SUBMIT_USER_ROLE = "//input[contains(@id,'register-role-form:submit')]";
- public static final String ID_SUBMIT_CREATE_USER = "//input[contains(@id,'register-form:submit')]";
- public static final String ID_INPUT_PASSWORD_CHK = "//input[contains(@id,'register-form:passwordCheck')]";
- public static final String ID_INPUT_PASSWORD = "//input[contains(@id,'register-form:password')]";
- public static final String ID_INPUT_USEREMAIL = "//input[contains(@id,'register-form:email')]";
- public static final String ID_INPUT_USERNAME = "//input[contains(@id,'register-form:username')]";
- public static final String ID_SUBMIT_SEARCH_USER = "//input[contains(@id,'search-user-form:search')]";
- public static final String ID_INPUT_SEARCH_USER = "//input[contains(@id,'search-user-form:searchString')]";
- public static final String LINK_SEARCH_USER = "//a[contains(@id,'user-form:search-user-link')]";
- public static final String ID_LINK_USERTAB = "//a[contains(@id,'role-temp-form:manage-users')]";
- public static final String ID_LINK_USERMAIN = "//a[contains(@id,'user-temp-form1:user-adm-link')]";
-
- public static final String ID_LINK_ROLETAB = "//a[contains(@id,'_viewRoot:user-temp-form:role-mgm-link')]";
-
- public static final String ID_LINK_ROLEMAIN = "//a[contains(@id, ':_viewRoot:role-temp-form1:role-admin-link')]";
- public static final String LINK_USERMANG_MAIN = "//a[contains(@id,'user-temp-form1:assign-role-link')]";
- public static final String LINK_USERMANG_MAIN2 = "//a[contains(@id,'user-temp-form1:user-mgm-link')]";
- public static final String ID_LINK_CREATE_USER = "//a[contains(@id,':user-form:create-user-link')]";
+ private static final String INP_PASS_CHANGE_P2 = "//input[contains(@id,':change-pwd-form:passwordCheck')]";
+ private static final String INP_PASS_CHANGE_P1 = "//input[contains(@id,':change-pwd-form:password')]";
+ private static final String LNK_CHANGE_PASS = "//a[contains(@id,':profile-form:change-pwd-adm-link')]";
+ public static final String TBL_USERLIST = "//table[contains(@id,'search-user-form1:userlist')]";
+ public static final String LNK_T_USRLIST_DEL = "//a[contains(@id,''search-user-form1:userlist:{0}:delete-user-link'')]";
+ public static final String LNK_T_USRLIST_ROLES = "//a[contains(@id,''search-user-form1:userlist:{0}:assign-role-link'')]";
+ public static final String LNK_T_USRLIST_DIS = "//a[contains(@id,''search-user-form1:userlist:{0}:enable-user-link'')]";
+ public static final String LNK_T_USRLIST_EDIT = "//a[contains(@id,''search-user-form1:userlist:{0}:rename-link'')]";
- public static final String ID_CHECK_ROLE = "//input[contains(@name,''assign-roles-form:roles'') and @value=''{0}'']";
-
+ public static final String TBL_ROLELIST = "//table[contains(@id,':_viewRoot:roles-form:userlist')]";
+ public static final String LNK_T_ROLLIST_DEL = "//a[contains(@id,''roles-form:userlist:{0}:delete-role-link'')]";
+ public static final String LNK_T_ROLLIST_MEMBERS = "//a[contains(@id,''roles-form:userlist:{0}:view-role-link'')]";
+ public static final String LNK_T_ROLLIST_EDIT = "//a[contains(@id,''roles-form:userlist:{0}:edit-role-link'')]";
+
+ public static final String TBL_ROLEMEMBERS = "//table[contains(@id,'role-members-form:role-data-table')]";
+
+ public static final String SUB_CONF_CREATE_USER = "//input[contains(@id,'confirm-form:admin')]";
+ public static final String SUB_DELETE_ROLE = "//input[contains(@id,'delete-role-form:confirm')]";
+ public static final String SUB_ROLE_CREATE = "//input[contains(@id,':_viewRoot:create-role-form:submit')]";
+ public static final String INP_ROLEDISNAME = "//input[contains(@id,':_viewRoot:create-role-form:roledisplayname')]";
+ public static final String INP_ROLENAME = "//input[contains(@id,':_viewRoot:create-role-form:rolename')]";
+
+ public static final String LNK_ROLE_CREATE = "//a[contains(@id, ':_viewRoot:create-role-form:create-role-link')]";
+ public static final String SUB_DEL_USER = "//input[contains(@id,'delete-user-form:submit')]";
+ public static final String SUB_ASSIGN_ROLE = "//input[contains(@id,'assign-roles-form:submit')]";
+ public static final String SUB_USER_ROLE = "//input[contains(@id,'register-role-form:submit')]";
+ public static final String SUB_CREATE_USER = "//input[contains(@id,'register-form:submit')]";
+ public static final String INP_PASSWORD_CHK = "//input[contains(@id,'register-form:passwordCheck')]";
+ public static final String INP_PASSWORD = "//input[contains(@id,'register-form:password')]";
+ public static final String INP_USEREMAIL = "//input[contains(@id,'register-form:email')]";
+ public static final String INP_USERNAME = "//input[contains(@id,'register-form:username')]";
+ public static final String SUB_SEARCH_USER = "//input[contains(@id,'search-user-form:search')]";
+ public static final String INP_SEARCH_USER = "//input[contains(@id,'search-user-form:searchString')]";
+ public static final String LNK_SEARCH_USER = "//a[contains(@id,'user-form:search-user-link')]";
+ public static final String LNK_USERTAB = "//a[contains(@id,'role-temp-form:manage-users')]";
+ public static final String LNK_USERMAIN = "//a[contains(@id,'user-temp-form1:user-adm-link')]";
+
+ public static final String LNK_ROLETAB = "//a[contains(@id,'_viewRoot:user-temp-form:role-mgm-link')]";
+
+ public static final String LNK_ROLEMAIN = "//a[contains(@id, ':_viewRoot:role-temp-form1:role-admin-link')]";
+ public static final String LNK_USERMANG_MAIN = "//a[contains(@id,'user-temp-form1:assign-role-link')]";
+ public static final String LNK_USERMANG_MAIN2 = "//a[contains(@id,'user-temp-form1:user-mgm-link')]";
+ public static final String LNK_CREATE_USER = "//a[contains(@id,':user-form:create-user-link')]";
+
+ public static final String CHK_ROLE = "//input[contains(@name,''assign-roles-form:roles'') and @value=''{0}'']";
+
+ public static final long SEARCH_TIMEOUT = 5000;
+
private String butDelUsr_id(String userName) {
- String table = TABLE_USERLIST;
+ String table = TBL_USERLIST;
int r = findTableRow(table, userName, 0);
- return MessageFormat.format(LINK_T_USRLIST_DEL, r - 1);
+ return MessageFormat.format(LNK_T_USRLIST_DEL, r - 1);
}
private String butUsrRol_id(String userName) {
- String table = TABLE_USERLIST;
+ String table = TBL_USERLIST;
int r = findTableRow(table, userName, 0);
- return MessageFormat.format(LINK_T_USRLIST_ROLES, r - 1);
+ return MessageFormat.format(LNK_T_USRLIST_ROLES, r - 1);
}
@BeforeMethod(groups = { "log" })
@@ -92,21 +98,20 @@
@AfterMethod(groups = { "log" })
public void logoutAfterTest() {
-
- }
-/*
- // For this mode to be functional, the user which is logged in must be "admin" after each test
- @BeforeClass(groups = { "single" })
- public void loginBefore() {
- login("admin", "admin");
}
- @AfterClass(groups = { "single" })
- public void logoutAfter() {
- logout();
- }
-*/
+ /*
+ * // For this mode to be functional, the user which is logged in must be
+ * "admin" after each test
+ *
+ * @BeforeClass(groups = { "single" }) public void loginBefore() {
+ * login("admin", "admin"); }
+ *
+ * @AfterClass(groups = { "single" }) public void logoutAfter() { logout();
+ * }
+ */
+
@Test(enabled = true, description = "Creation of new user.")
public void testCreateUser() {
createUser("tempUser", "tempPassword", "tempUser(a)redhat.com");
@@ -128,360 +133,358 @@
createRole(role, "tempRoleDisplay");
deleteRole(role);
}
-
+
@Test(enabled = true, description = "Creating and deteling a user.")
public void testDeleteUser() {
createUser("deleteMe", "deleterPass", "disableMe(a)redhat.com");
deleteUser("deleteMe", "disableMe(a)redhat.com");
}
-
+
@Test(enabled = true, description = "Creating and disabling a user.")
public void testDisableUser() {
- createUser("disableMe", "disablePass", "disableMe(a)redhat.com");
-
+ final String userName = "disableMe";
+ final String userPass = "disablePass";
+ final String userMail = "disableMe(a)redhat.com";
+
+ createUser(userName, userPass, userMail);
+
logout();
- login("disableMe", "disablePass");
+ login(userName, userPass);
logout();
- login("admin","admin");
-
- searchUser("disableMe", "disableMe(a)redhat.com");
- int r = findTableRow(TABLE_USERLIST, "disableMe", 0);
-
- selenium.click(MessageFormat.format(LINK_T_USRLIST_DIS, r - 1 ));
-
+ login("admin", "admin");
+
+ searchUser(userName, userMail);
+ int r = findTableRow(TBL_USERLIST, userName, 0);
+
+ selenium.click(MessageFormat.format(LNK_T_USRLIST_DIS, r - 1));
+
logout();
-
- //trying to log in with disabled account
+
+ // trying to log in with disabled account
selenium.open(ADDR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
selenium.click(LINK_LOGIN);
selenium.selectFrame(FRAME_LOGIN_CONTENT);
-
+
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
- selenium.type(INPUT_USERNAME, "disableMe");
- selenium.type(INPUT_PASSWORD, "disablePass");
+
+ selenium.type(INPUT_USERNAME, userName);
+ selenium.type(INPUT_PASSWORD, userPass);
selenium.click(SUBMIT_LOGIN);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Your account is disabled"));
+ Assert.assertTrue(selenium.isTextPresent("Your account is disabled"), "Message telling that account is disabled is other then expected or missing.");
// we should be unable to login with disabled account
// logging as user to end the test correctly
-
- login("admin","admin");
-
- deleteUser("disableMe", "disableMe(a)redhat.com");
+
+ login("admin", "admin");
+
+ deleteUser(userName, userMail);
}
-
- @Test(enabled = true, dependsOnMethods = {"testDisableUser"},description = "Enabling disabled user.")
+
+ @Test(enabled = true, dependsOnMethods = { "testDisableUser" }, description = "Enabling disabled user.")
public void testEnableUser() {
- createUser("enableMe", "enableMe", "enableMe(a)redhat.com");
- searchUser("enableMe", "enableMe(a)redhat.com");
-
- int r = findTableRow(TABLE_USERLIST, "Enable", 5);
- Assert.assertTrue(r<0,"No user should be disabled.");
- r = findTableRow(TABLE_USERLIST, "enableMe", 0);
-
- selenium.click(MessageFormat.format(LINK_T_USRLIST_DIS, r - 1 ));
+ final String userName = "enableMe";
+ final String userPass = "enableMe";
+ final String userMail = "enableMe(a)redhat.com";
+ createUser(userName, userPass, userMail);
+ searchUser(userName, userMail);
+
+ int r = findTableRow(TBL_USERLIST, "Enable", 5);
+ Assert.assertTrue(r < 0, "No user should be disabled.");
+ r = findTableRow(TBL_USERLIST, userName, 0);
+
+ selenium.click(MessageFormat.format(LNK_T_USRLIST_DIS, r - 1));
selenium.waitForPageToLoad(PAGE_LOAD);
-
- searchUser("enableMe", "enableMe(a)redhat.com");
- r = findTableRow(TABLE_USERLIST, "Enable", 5);
- Assert.assertFalse(r<0,"One user should have been disabled.");
- r = findTableRow(TABLE_USERLIST, "enableMe", 0);
- selenium.click(MessageFormat.format(LINK_T_USRLIST_DIS, r - 1 ));
+ searchUser(userName, userMail);
+ r = findTableRow(TBL_USERLIST, "Enable", 5);
+ Assert.assertFalse(r < 0, "One user should have been disabled.");
+
+ r = findTableRow(TBL_USERLIST, userName, 0);
+ selenium.click(MessageFormat.format(LNK_T_USRLIST_DIS, r - 1));
selenium.waitForPageToLoad(PAGE_LOAD);
-
- searchUser("enableMe", "enableMe(a)redhat.com");
- r = findTableRow(TABLE_USERLIST, "Enable", 5);
- Assert.assertTrue(r<0,"No user should be disabled.");
-
- deleteUser("enableMe", "enableMe(a)redhat.com");
+
+ searchUser(userName, userMail);
+ r = findTableRow(TBL_USERLIST, "Enable", 5);
+ Assert.assertTrue(r < 0, "No user should be disabled.");
+
+ deleteUser(userName, userMail);
}
-
+
@Test(enabled = true, description = "Editing a user.")
public void testEditUser() {
- createUser("editMe", "editPass", "editMe(a)redhat.com");
-
+ final String userName = "editMe";
+ final String userPass = "editPass";
+ final String userMail = "editMe(a)redhat.com";
+
+ createUser(userName, userPass, userMail);
+
// canceling the edit form
- searchUser("editMe", "editMe(a)redhat.com");
-
- int r = findTableRow(TABLE_USERLIST, "editMe", 0);
- selenium.click(MessageFormat.format(LINK_T_USRLIST_EDIT, r - 1));
+ searchUser(userName, userMail);
+
+ int r = findTableRow(TBL_USERLIST, userName, 0);
+ selenium.click(MessageFormat.format(LNK_T_USRLIST_EDIT, r - 1));
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.type(INP_EDIT_USER_EMAIL, "editMe2(a)redhat.com");
selenium.click(SUB_EDIT_USER_EMAIL_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("editMe(a)redhat.com"));
-
+ Assert.assertTrue(selenium.isTextPresent(userMail), "User not visible after cancelling editing.");
+
// filling out the edit page
- searchUser("editMe", "editMe(a)redhat.com");
-
- r = findTableRow(TABLE_USERLIST, "editMe", 0);
- selenium.click(MessageFormat.format(LINK_T_USRLIST_EDIT, r - 1));
- selenium.waitForPageToLoad(PAGE_LOAD);
-
+ searchUser(userName, userMail);
+
+ r = findTableRow(TBL_USERLIST, userName, 0);
+ selenium.click(MessageFormat.format(LNK_T_USRLIST_EDIT, r - 1));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
selenium.type(INP_EDIT_USER_EMAIL, "editMe2(a)redhat.com");
/*
- selenium.select("profile-form:timezone", "label=(GMT -12:00 hours) Eniwetok, Kwajalein");
- selenium.select("profile-form:theme", "label=portal.industrial");
- selenium.select("profile-form:locale", "label=Albanian");
- selenium.type("profile-form:givenname", "Edit");
- selenium.type("profile-form:lastname", "Meme");
- selenium.type("profile-form:location", "Editoland");
- selenium.type("profile-form:skype", "editor");
- selenium.type("profile-form:icq", "112113114");
- selenium.type("profile-form:aim", "83838495");
- selenium.type("profile-form:msnm", "u8u8i9o0");
- selenium.type("profile-form:yim", "99384875");
- selenium.type("profile-form:xmmp", "10309128");
- selenium.type("profile-form:homepage", "http://www.edit.com");
- selenium.type("profile-form:occupation", "editor");
- selenium.type("profile-form:interests", "editing");
- selenium.type("profile-form:signature", "----\n\ni like to edit");
- selenium.type("profile-form:extra", "me edit good");
- */
+ * selenium.select("profile-form:timezone",
+ * "label=(GMT -12:00 hours) Eniwetok, Kwajalein");
+ * selenium.select("profile-form:theme", "label=portal.industrial");
+ * selenium.select("profile-form:locale", "label=Albanian");
+ * selenium.type("profile-form:givenname", "Edit");
+ * selenium.type("profile-form:lastname", "Meme");
+ * selenium.type("profile-form:location", "Editoland");
+ * selenium.type("profile-form:skype", "editor");
+ * selenium.type("profile-form:icq", "112113114");
+ * selenium.type("profile-form:aim", "83838495");
+ * selenium.type("profile-form:msnm", "u8u8i9o0");
+ * selenium.type("profile-form:yim", "99384875");
+ * selenium.type("profile-form:xmmp", "10309128");
+ * selenium.type("profile-form:homepage", "http://www.edit.com");
+ * selenium.type("profile-form:occupation", "editor");
+ * selenium.type("profile-form:interests", "editing");
+ * selenium.type("profile-form:signature", "----\n\ni like to edit");
+ * selenium.type("profile-form:extra", "me edit good");
+ */
selenium.click(SUB_EDIT_PROF);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("editMe2(a)redhat.com"));
- Assert.assertTrue(selenium.isTextPresent("Edit"));
-
- deleteUser("editMe", "editMe2(a)redhat.com");
-
+ Assert.assertTrue(selenium.isTextPresent("editMe2(a)redhat.com"), "Edited e-mail adress not visible.");
+
+ deleteUser(userName, "editMe2(a)redhat.com");
+
}
-
+
@Test(enabled = true, description = "Editing a user - changing of password.")
public void testEditUserChangePassword() {
- createUser("changePass", "changePassPass", "changePass(a)redhat.com");
-
+ final String userName = "changePass";
+ final String userPass = "changePassPass";
+ final String userPass2 = "changePass2";
+ final String userMail = "changePass(a)redhat.com";
+
+ createUser(userName, userPass, userMail);
+
logout();
- login("changePass","changePassPass");
+ login(userName, userPass);
logout();
- login("admin","admin");
-
- /*
- * Canceling of change at the first approach
- */
-
- searchUser("changePass", "changePass(a)redhat.com");
-
-
- int r = findTableRow(TABLE_USERLIST, "changePass", 0);
- selenium.click(MessageFormat.format(LINK_T_USRLIST_EDIT, r - 1));
+ login("admin", "admin");
+
+ // Canceling of change at the first approach
+
+ searchUser(userName, userMail);
+
+ int r = findTableRow(TBL_USERLIST, userName, 0);
+ selenium.click(MessageFormat.format(LNK_T_USRLIST_EDIT, r - 1));
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LINK_CHANGE_PASS);
+ selenium.click(LNK_CHANGE_PASS);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.type(INPUT_PASS_CHANGE_P1, "changePass2");
- selenium.type(INPUT_PASS_CHANGE_P2, "changePass2");
+ selenium.type(INP_PASS_CHANGE_P1, userPass2);
+ selenium.type(INP_PASS_CHANGE_P2, userPass2);
selenium.click(SUB_PASS_CHANGE_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
-
- Assert.assertFalse(selenium.isTextPresent("Password has been updated."));
-
+
+ Assert.assertFalse(selenium.isTextPresent("Password has been updated."), "Message telling that password has changed appeared after cancel.");
+
logout();
- login("changePass","changePassPass");
+ login(userName, userPass);
logout();
- login("admin","admin");
-
- /*
- * In the second approach really change the password
- */
-
- searchUser("changePass", "changePass(a)redhat.com");
-
- r = findTableRow(TABLE_USERLIST, "changePass", 0);
- selenium.click(MessageFormat.format(LINK_T_USRLIST_EDIT, r - 1));
+ login("admin", "admin");
+
+ // In the second approach really change the password
+
+ searchUser(userName, userMail);
+
+ r = findTableRow(TBL_USERLIST, userName, 0);
+ selenium.click(MessageFormat.format(LNK_T_USRLIST_EDIT, r - 1));
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LINK_CHANGE_PASS);
+ selenium.click(LNK_CHANGE_PASS);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.type(INPUT_PASS_CHANGE_P1, "changePass2");
- selenium.type(INPUT_PASS_CHANGE_P2, "changePass2");
+ selenium.type(INP_PASS_CHANGE_P1, userPass2);
+ selenium.type(INP_PASS_CHANGE_P2, userPass2);
selenium.click(SUB_PASS_CHANGE_SUBMIT);
selenium.waitForPageToLoad(PAGE_LOAD);
-
- Assert.assertTrue(selenium.isTextPresent("Password has been updated."));
-
+
+ Assert.assertTrue(selenium.isTextPresent("Password has been updated."), "Message telling that password has changed other then expected or missing.");
+
logout();
- login("changePass","changePass2");
+ login(userName, userPass2);
logout();
- login("admin","admin");
-
- deleteUser("changePass","changePass(a)redhat.com");
+ login("admin", "admin");
+
+ deleteUser(userName, userMail);
}
-
+
@Test(enabled = true, description = "Managing members of role.")
public void testRoleMembers() {
- createRole("membersRole", "membersRoleDisplay");
- createUser("newRoleMember" , "newRoleMember", "newRoleMem(a)redhatqa.com");
- assignRole("newRoleMember", "newRoleMem(a)redhatqa.com", "membersRole", "membersRoleDisplay");
-
+ final String roleName = "membersRole";
+ final String roleDisplayName = "membersRoleDisplay";
+ final String userName = "newRoleMember";
+ final String userMail = "newRoleMem(a)redhatqa.com";
+ final String invalidMember = "newRoleNonMember";
+
+ createRole(roleName, roleDisplayName);
+ createUser(userName, userName, userMail);
+ assignRole(userName, userMail, roleName, roleDisplayName);
+
clickUntilMembers();
- clickIfVisible(ID_LINK_ROLETAB);
- clickIfVisible(ID_LINK_ROLEMAIN);
-
- int r = findTableRow(TABLE_ROLELIST, "membersRole", 0);
- selenium.click(MessageFormat.format(LINK_T_ROLLIST_MEMBERS, r-1));
+ clickIfVisible(LNK_ROLETAB);
+ clickIfVisible(LNK_ROLEMAIN);
+
+ int r = findTableRow(TBL_ROLELIST, roleName, 0);
+ selenium.click(MessageFormat.format(LNK_T_ROLLIST_MEMBERS, r - 1));
selenium.waitForPageToLoad(PAGE_LOAD);
-
- //search for the real member of current role
- selenium.type(INP_ROLE_SEARCH_USER, "newRoleMember");
+
+ // search for the real member of current role
+ selenium.type(INP_ROLE_SEARCH_USER, userName);
selenium.click(SUB_ROLE_SEARCH_USER);
waitFor(10000);
-
- r = findTableRow(TABLE_ROLEMEMBERS, "newRoleMember", 0);
- Assert.assertTrue(r>0, "Assigned member not found in the role members table.");
-
- //search for the non-member user of current role
- selenium.type(INP_ROLE_SEARCH_USER, "newRoleNonMember");
+
+ r = findTableRow(TBL_ROLEMEMBERS, userName, 0);
+ Assert.assertTrue(r > 0, "Assigned member not found in the role members table.");
+
+ // search for the non-member user of current role
+ selenium.type(INP_ROLE_SEARCH_USER, invalidMember);
selenium.click(SUB_ROLE_SEARCH_USER);
waitFor(10000);
-
- Assert.assertFalse(selenium.isElementPresent(TABLE_ROLEMEMBERS), "Not assigned member found in the role members table.");
-
- deleteRole("membersRole");
- deleteUser("newRoleMember" , "newRoleMem(a)redhatqa.com");
+
+ Assert.assertFalse(selenium.isElementPresent(TBL_ROLEMEMBERS), "Not assigned member found in the role members table.");
+
+ deleteRole(roleName);
+ deleteUser(userName, userMail);
}
-
+
@Test(enabled = true, description = "Creation of new role.")
public void testRoleEdit() {
-
- createRole("editRole", "editRoleDisplay");
-
+ final String roleName = "editRole";
+ final String roleDisplayName = "editRoleDisplay";
+ final String roleDisplayNameEditet = "editedRoleDisplay";
+
+ createRole(roleName, roleDisplayName);
+
clickUntilMembers();
- clickIfVisible(ID_LINK_ROLETAB);
- clickIfVisible(ID_LINK_ROLEMAIN);
-
- int r = findTableRow(TABLE_ROLELIST, "editRoleDisplay", 1);
- Assert.assertTrue(r>=0,"Renamed display name found in table");
-
- r = findTableRow(TABLE_ROLELIST, "editedRoleDisplay", 1);
- Assert.assertFalse(r>=0,"Not created role display name found in table");
-
- //canceling of renaming of displayname for the first time
- r = findTableRow(TABLE_ROLELIST, "editRole", 0);
-
- selenium.click(MessageFormat.format(LINK_T_ROLLIST_EDIT, r -1));
+ clickIfVisible(LNK_ROLETAB);
+ clickIfVisible(LNK_ROLEMAIN);
+
+ int r = findTableRow(TBL_ROLELIST, roleDisplayName, 1);
+ Assert.assertTrue(r >= 0, "Renamed display name found in table");
+
+ r = findTableRow(TBL_ROLELIST, roleDisplayNameEditet, 1);
+ Assert.assertFalse(r >= 0, "Not created role display name found in table");
+
+ // canceling of renaming of displayname for the first time
+ r = findTableRow(TBL_ROLELIST, roleName, 0);
+
+ selenium.click(MessageFormat.format(LNK_T_ROLLIST_EDIT, r - 1));
selenium.waitForPageToLoad(PAGE_LOAD);
-
- selenium.type(INP_EDIT_ROLE_NAME, "editedRoleDisplay");
+
+ selenium.type(INP_EDIT_ROLE_NAME, roleDisplayNameEditet);
selenium.click(SUB_EDIT_ROLE_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
-
- r = findTableRow(TABLE_ROLELIST, "editRoleDisplay", 1);
- Assert.assertTrue(r>=0,"Renamed display name found in table");
-
- r = findTableRow(TABLE_ROLELIST, "editedRoleDisplay", 1);
- Assert.assertFalse(r>=0,"Not created role display name found in table");
-
+
+ r = findTableRow(TBL_ROLELIST, roleDisplayName, 1);
+ Assert.assertTrue(r >= 0, "Renamed display name found in table");
+
+ r = findTableRow(TBL_ROLELIST, roleDisplayNameEditet, 1);
+ Assert.assertFalse(r >= 0, "Not created role display name found in table");
+
// real renaming
- r = findTableRow(TABLE_ROLELIST, "editRole", 0);
- selenium.click(MessageFormat.format(LINK_T_ROLLIST_EDIT, r-1));
+ r = findTableRow(TBL_ROLELIST, roleName, 0);
+ selenium.click(MessageFormat.format(LNK_T_ROLLIST_EDIT, r - 1));
selenium.waitForPageToLoad(PAGE_LOAD);
-
- selenium.type(INP_EDIT_ROLE_NAME, "editedRoleDisplay");
+
+ selenium.type(INP_EDIT_ROLE_NAME, roleDisplayNameEditet);
selenium.click(SUB_EDIT_ROLE_SUBMIT);
selenium.waitForPageToLoad(PAGE_LOAD);
-
- r = findTableRow(TABLE_ROLELIST, "editRoleDisplay", 1);
- Assert.assertFalse(r>=0,"Renamed display name found in table");
-
- r = findTableRow(TABLE_ROLELIST, "editedRoleDisplay", 1);
- Assert.assertTrue(r>=0,"New role display name not found in table");
-
- deleteRole("editRole");
+
+ r = findTableRow(TBL_ROLELIST, roleDisplayName, 1);
+ Assert.assertFalse(r >= 0, "Renamed display name found in table");
+
+ r = findTableRow(TBL_ROLELIST, roleDisplayNameEditet, 1);
+ Assert.assertTrue(r >= 0, "New role display name not found in table");
+
+ deleteRole(roleName);
}
-
- @Test(enabled= false, description = "Altering the number of rows in user search")
- public void testSearchUserCount() {
-
- for(int i=0; i< 95; i++){
- createUser("man"+i+"us", "man"+i+"pas", "man"+i+"us"+"@redhatqa.com");
- }
-
- searchSimple("man","10");
- Assert.assertEquals(countTableRows(TABLE_USERLIST)-1,10,"Wrong number of row in user table #1.");
-
- searchSimple("man","50");
- Assert.assertEquals(countTableRows(TABLE_USERLIST)-1,50,"Wrong number of row in user table #2.");
+
+ @Test(enabled = true, description = "Altering the number of rows in user search")
+ public void testSearchUserCount() {
+
+ for (int i = 0; i < 95; i++) {
+ createUser("man" + i + "us", "man" + i + "pas", "man" + i + "us" + "@redhatqa.com");
+ }
+
+ searchSimple("man", "10");
+ Assert.assertEquals(countTableRows(TBL_USERLIST) - 1, 10, "Wrong number of row in user table #1.");
+
+ searchSimple("man", "50");
+ Assert.assertEquals(countTableRows(TBL_USERLIST) - 1, 50, "Wrong number of row in user table #2.");
selenium.click("search-user-form1:next-page");
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertEquals(countTableRows(TABLE_USERLIST)-1,45,"Wrong number of row in user table #3.");
+ Assert.assertEquals(countTableRows(TBL_USERLIST) - 1, 45, "Wrong number of row in user table #3.");
selenium.click("search-user-form1:prev-page");
selenium.waitForPageToLoad(PAGE_LOAD);
-
- searchSimple("man","100");
- Assert.assertEquals(countTableRows(TABLE_USERLIST)-1,95,"Wrong number of row in user table #4.");
- /*
- for(int i=0; i< 95; i++){
- deleteUser("man"+i+"us", "man"+i+"us"+"@redhatqa.com");
- }
- */
-
- }
-
- private void searchSimple(String name, String count){
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Members");
- selenium.waitForPageToLoad(PAGE_LOAD);
- clickIfVisible(ID_LINK_USERTAB);
- clickIfVisible(ID_LINK_USERMAIN);
- clickIfVisible(LINK_USERMANG_MAIN);
+ searchSimple("man", "100");
+ Assert.assertEquals(countTableRows(TBL_USERLIST) - 1, 95, "Wrong number of row in user table #4.");
- selenium.click(LINK_SEARCH_USER);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ /*
+ * for(int i=0; i< 95; i++){ deleteUser("man"+i+"us",
+ * "man"+i+"us"+"@redhatqa.com"); }
+ */
- selenium.type(ID_INPUT_SEARCH_USER, name);
- selenium.select("search-user-form:limit", "label="+count);
- selenium.click(ID_SUBMIT_SEARCH_USER);
- //selenium.waitForPageToLoad(PAGE_LOAD);
- waitBlock();
}
-
@Test(enabled = true, dependsOnMethods = { "testCreateUser", "testCreateRole" }, description = "Assigning of the role to the user.")
public void testAssignRole2User() {
String user = "tempUser";
String userMail = "tempUser(a)redhat.com";
String role = "tempRole";
- String roleDisplay = "tempRoleDisplay";
+ final String roleDisplayName = "tempRoleDisplay";
+ final String userPass = "tempPassword";
- createUser(user, "tempPassword", userMail);
- createRole(role, "tempRoleDisplay");
- assignRole(user, userMail, role, roleDisplay);
+ createUser(user, userPass, userMail);
+ createRole(role, roleDisplayName);
+ assignRole(user, userMail, role, roleDisplayName);
- deassignRole(user, userMail, role, roleDisplay);
+ deassignRole(user, userMail, role, roleDisplayName);
deleteRole(role);
deleteUser(user, userMail);
}
- void assignRole(String user, String email, String role, String roleDisplay) {
+ void assignRole(String userName, String userMail, String roleName, String roleDisplayName) {
- searchUser(user, email);
- selenium.click(butUsrRol_id(user));
+ searchUser(userName, userMail);
+ selenium.click(butUsrRol_id(userName));
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent(roleDisplay), "Role display name: " + roleDisplay + " not found on the page.");
+ Assert.assertTrue(selenium.isTextPresent(roleDisplayName), "Role display name: " + roleDisplayName + " not found on the page.");
- final String CHECK_ROLE = MessageFormat.format(ID_CHECK_ROLE, role);
+ final String CHECK_ROLE = MessageFormat.format(CHK_ROLE, roleName);
selenium.click(CHECK_ROLE);
- selenium.click(ID_SUBMIT_ASSIGN_ROLE);
+ selenium.click(SUB_ASSIGN_ROLE);
selenium.waitForPageToLoad(PAGE_LOAD);
- searchUser(user, email);
+ searchUser(userName, userMail);
- selenium.click(butUsrRol_id(user));
+ selenium.click(butUsrRol_id(userName));
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isChecked(CHECK_ROLE), "The role wasn't correctly assigned.");
@@ -496,10 +499,10 @@
Assert.assertTrue(selenium.isTextPresent(roleDisplay), "Role display name: " + roleDisplay + " not found on the page.");
// check the tempRole check box
- final String CHECK_ROLE = MessageFormat.format(ID_CHECK_ROLE, role);
+ final String CHECK_ROLE = MessageFormat.format(CHK_ROLE, role);
selenium.click(CHECK_ROLE);
- selenium.click(ID_SUBMIT_ASSIGN_ROLE);
+ selenium.click(SUB_ASSIGN_ROLE);
selenium.waitForPageToLoad(PAGE_LOAD);
searchUser(user, email);
@@ -510,7 +513,7 @@
}
- void createUser(String username, String password, String email) {
+ void createUser(String userName, String userPass, String userMail) {
selenium.open("/portal/auth/portal/default");
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -520,30 +523,30 @@
selenium.click("link=Members");
selenium.waitForPageToLoad(PAGE_LOAD);
- clickIfVisible(ID_LINK_USERTAB);
- clickIfVisible(ID_LINK_USERMAIN);
- selenium.click(ID_LINK_CREATE_USER);
+ clickIfVisible(LNK_USERTAB);
+ clickIfVisible(LNK_USERMAIN);
+ selenium.click(LNK_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("Username *"), "Label for username input is wrong or missing.");
- selenium.type(ID_INPUT_USERNAME, username);
+ selenium.type(INP_USERNAME, userName);
Assert.assertTrue(selenium.isTextPresent("E-Mail *"), "Label for e-mail input is wrong or missing.");
- selenium.type(ID_INPUT_USEREMAIL, email);
+ selenium.type(INP_USEREMAIL, userMail);
Assert.assertTrue(selenium.isTextPresent("Password *"), "Label for password input is wrong or missing.");
- selenium.type(ID_INPUT_PASSWORD, password);
+ selenium.type(INP_PASSWORD, userPass);
Assert.assertTrue(selenium.isTextPresent("Confirm Password *"), "Label for password confirm input is wrong or missing.");
- selenium.type(ID_INPUT_PASSWORD_CHK, password);
+ selenium.type(INP_PASSWORD_CHK, userPass);
- selenium.click(ID_SUBMIT_CREATE_USER);
+ selenium.click(SUB_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertFalse(selenium.isTextPresent("This username is already taken. tempUser"), "User already exists.");
- selenium.click(ID_SUBMIT_USER_ROLE);
+ selenium.click(SUB_USER_ROLE);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("Confirmation"), "Confirmation screen is missing or corrupted.");
- selenium.click(ID_SUBMIT_CONF_CREATE_USER);
+ selenium.click(SUB_CONF_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("User created"), "User was not created (\"User created\" text missing).");
@@ -558,24 +561,22 @@
selenium.click("link=Members");
selenium.waitForPageToLoad(PAGE_LOAD);
- clickIfVisible(ID_LINK_USERMAIN);
+ clickIfVisible(LNK_USERMAIN);
- selenium.click(ID_LINK_CREATE_USER);
+ selenium.click(LNK_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.type(ID_INPUT_USERNAME, username);
- selenium.type(ID_INPUT_USEREMAIL, email);
- selenium.type(ID_INPUT_PASSWORD, password);
- selenium.type(ID_INPUT_PASSWORD_CHK, password);
- selenium.click(ID_SUBMIT_CREATE_USER);
+ selenium.type(INP_USERNAME, username);
+ selenium.type(INP_USEREMAIL, email);
+ selenium.type(INP_PASSWORD, password);
+ selenium.type(INP_PASSWORD_CHK, password);
+ selenium.click(SUB_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert
- .assertTrue(selenium.isTextPresent("This username is already taken."),
- "No user was overwritten, current username wasn't already taken.");
+ Assert.assertTrue(selenium.isTextPresent("This username is already taken."), "No user was overwritten, current username wasn't already taken.");
}
- void searchUser(String username, String email) {
+ void searchUser(String userName, String userMail) {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=Admin");
@@ -583,21 +584,44 @@
selenium.click("link=Members");
selenium.waitForPageToLoad(PAGE_LOAD);
- clickIfVisible(ID_LINK_USERTAB);
- clickIfVisible(ID_LINK_USERMAIN);
- clickIfVisible(LINK_USERMANG_MAIN);
+ clickIfVisible(LNK_USERTAB);
+ clickIfVisible(LNK_USERMAIN);
+ clickIfVisible(LNK_USERMANG_MAIN);
- selenium.click(LINK_SEARCH_USER);
+ selenium.click(LNK_SEARCH_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.type(ID_INPUT_SEARCH_USER, username);
- selenium.click(ID_SUBMIT_SEARCH_USER);
- //selenium.waitForPageToLoad(PAGE_LOAD);
- waitBlock();
- Assert.assertTrue(selenium.isTextPresent(username), "Username was not found.");
- Assert.assertTrue(selenium.isTextPresent(email), "User email adress was not found.");
+ selenium.type(INP_SEARCH_USER, userName);
+
+ selenium.click(SUB_SEARCH_USER);
+ waitFor(SEARCH_TIMEOUT);
+ if (!selenium.isTextPresent(userName) && !selenium.isTextPresent(userMail))
+ paginate(userName, userMail);
+
+ Assert.assertTrue(selenium.isTextPresent(userName), "Username was not found.");
+ Assert.assertTrue(selenium.isTextPresent(userMail), "User email adress was not found.");
}
+ private void paginate(String userName, String userMail) {
+
+ while (selenium.isElementPresent(SUB_PAGIN_RIGHT)) {
+ selenium.click(SUB_PAGIN_RIGHT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ if (selenium.isTextPresent(userName) && selenium.isTextPresent(userMail))
+ return;
+ }
+
+ while (selenium.isElementPresent(SUB_PAGIN_LEFT)) {
+ selenium.click(SUB_PAGIN_RIGHT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ if (selenium.isTextPresent(userName) && selenium.isTextPresent(userMail))
+ return;
+ }
+
+ }
+
private void deleteUser(String username, String email) {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -606,30 +630,30 @@
selenium.click("link=Members");
selenium.waitForPageToLoad(PAGE_LOAD);
- clickIfVisible(ID_LINK_USERTAB);
+ clickIfVisible(LNK_USERTAB);
// user home page
- clickIfVisible(ID_LINK_USERMAIN);
- clickIfVisible(LINK_USERMANG_MAIN);
- clickIfVisible(LINK_USERMANG_MAIN2);
+ clickIfVisible(LNK_USERMAIN);
+ clickIfVisible(LNK_USERMANG_MAIN);
+ clickIfVisible(LNK_USERMANG_MAIN2);
- selenium.click(LINK_SEARCH_USER);
+ selenium.click(LNK_SEARCH_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.type(ID_INPUT_SEARCH_USER, username);
- selenium.click(ID_SUBMIT_SEARCH_USER);
- //selenium.waitForPageToLoad(PAGE_LOAD);
- waitBlock();
+ selenium.type(INP_SEARCH_USER, username);
+ selenium.click(SUB_SEARCH_USER);
+ // selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(SEARCH_TIMEOUT);
Assert.assertTrue(selenium.isTextPresent(username), "Username was not found.");
Assert.assertTrue(selenium.isTextPresent(email), "User e-mail adress was not found.");
selenium.click(butDelUsr_id(username));
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(ID_BUT_SUBMIT_DEL_USER);
+ selenium.click(SUB_DEL_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("User deleted"), "user was not deleted (\"User deleted\" text missing).");
}
- private void clickUntilMembers(){
+ private void clickUntilMembers() {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=Admin");
@@ -637,7 +661,7 @@
selenium.click("link=Members");
selenium.waitForPageToLoad(PAGE_LOAD);
}
-
+
private void createRole(String roleName, String roleDisplayName) {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -646,19 +670,19 @@
selenium.click("link=Members");
selenium.waitForPageToLoad(PAGE_LOAD);
- clickIfVisible(ID_LINK_ROLETAB);
- clickIfVisible(ID_LINK_ROLEMAIN);
+ clickIfVisible(LNK_ROLETAB);
+ clickIfVisible(LNK_ROLEMAIN);
- Assert.assertTrue(selenium.isElementPresent(ID_BUT_ROLE_CREATE), "Button for role creating has wrong id or doesn't exist.");
- Assert.assertEquals(selenium.getText(ID_BUT_ROLE_CREATE), "Create role", "Button for role creating has wrong label.");
- selenium.click(ID_BUT_ROLE_CREATE);
+ Assert.assertTrue(selenium.isElementPresent(LNK_ROLE_CREATE), "Button for role creating has wrong id or doesn't exist.");
+ Assert.assertEquals(selenium.getText(LNK_ROLE_CREATE), "Create role", "Button for role creating has wrong label.");
+ selenium.click(LNK_ROLE_CREATE);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("Role"), "Label for role name not present or incorrect.");
- selenium.type(ID_INPUT_ROLENAME, roleName);
+ selenium.type(INP_ROLENAME, roleName);
Assert.assertTrue(selenium.isTextPresent("Display name"), "Label for display role name not present or incorrect.");
- selenium.type(ID_INPUT_ROLEDISNAME, roleDisplayName);
- selenium.click(ID_SUBMIT_ROLE_CREATE);
+ selenium.type(INP_ROLEDISNAME, roleDisplayName);
+ selenium.click(SUB_ROLE_CREATE);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent(roleName), "Name of newly created role is missing.");
@@ -673,31 +697,44 @@
selenium.click("link=Members");
selenium.waitForPageToLoad(PAGE_LOAD);
- clickIfVisible(ID_LINK_ROLETAB);
- clickIfVisible(ID_LINK_ROLEMAIN);
+ clickIfVisible(LNK_ROLETAB);
+ clickIfVisible(LNK_ROLEMAIN);
Assert.assertTrue(selenium.isTextPresent(roleName), "Role name is missing");
- int r = findTableRow(TABLE_ROLELIST, roleName, 0);
- selenium.click(MessageFormat.format(LINK_T_ROLLIST_DEL, r-1));
+ int r = findTableRow(TBL_ROLELIST, roleName, 0);
+ selenium.click(MessageFormat.format(LNK_T_ROLLIST_DEL, r - 1));
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Warning! You are about to delete the role '" + roleName+"'"),
+ Assert.assertTrue(selenium.isTextPresent("Warning! You are about to delete the role '" + roleName + "'"),
"Confirmation text for role deletion missing missing.");
- selenium.click(ID_SUBMIT_DELETE_ROLE);
+ selenium.click(SUB_DELETE_ROLE);
selenium.waitForPageToLoad(PAGE_LOAD);
}
-
- protected void waitBlock(){
- try {
- Thread.sleep(2000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
+
+ private void searchSimple(String name, String count) {
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Members");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(LNK_USERTAB);
+ clickIfVisible(LNK_USERMAIN);
+ clickIfVisible(LNK_USERMANG_MAIN);
+
+ selenium.click(LNK_SEARCH_USER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.type(INP_SEARCH_USER, name);
+ selenium.select(SEL_SEARCHUSER_LIMIT, "label=" + count);
+ selenium.click(SUB_SEARCH_USER);
+
+ waitFor(SEARCH_TIMEOUT);
+
}
}
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 2009-02-04 10:06:14 UTC (rev 12770)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSelenium.java 2009-02-04 14:00:11 UTC (rev 12771)
@@ -159,5 +159,14 @@
protected int countTableRows(String tableLocation) {
return Integer.valueOf(getEval("selenium.countTableRows(\"" + tableLocation + "\")"));
}
+
+ protected void waitFor(long time){
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
}
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java 2009-02-04 10:06:14 UTC (rev 12770)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java 2009-02-04 14:00:11 UTC (rev 12771)
@@ -35,6 +35,9 @@
@Test(enabled = true, description = "login as default user 'user' with password 'user'.")
public void testDefaultUserLogin() throws Exception {
+ final String loginName = "user";
+ final String loginPass = "user";
+
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -48,14 +51,14 @@
waitForElement(INP_PASSWORD);
Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM element for username doesn't exist.");
- selenium.type(INP_USERNAME, "user");
+ selenium.type(INP_USERNAME, loginName);
Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM element for password doesn't exist.");
- selenium.type(INP_PASSWORD, "user");
+ selenium.type(INP_PASSWORD, loginPass);
selenium.click(SUB_LOGIN);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Logged in as: user"), "\"Logged in as\" message missing.");
+ Assert.assertTrue(selenium.isTextPresent("Logged in as: "+loginName), "\"Logged in as\" message missing.");
Assert.assertTrue(selenium.isElementPresent(LNK_LOGOUT), "Expected DOM element for login link does not exist.");
Assert.assertEquals(selenium.getText(LNK_LOGOUT), "Logout", "Logout has wrong label.");
@@ -67,6 +70,9 @@
@Test(enabled = true, description = "login as admin user 'admin' with password 'admin'.")
public void testAdminLogin() throws Exception {
+ final String loginName = "admin";
+ final String loginPass = "admin";
+
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
waitForElement(LNK_LOGIN);
@@ -80,9 +86,9 @@
waitForElement(INP_PASSWORD);
Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM element for username doesn't exist.");
- selenium.type(INP_USERNAME, "admin");
+ selenium.type(INP_USERNAME, loginName);
Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM element for password doesn't exist.");
- selenium.type(INP_PASSWORD, "admin");
+ selenium.type(INP_PASSWORD, loginPass);
selenium.click(SUB_LOGIN);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -99,6 +105,9 @@
@Test(enabled = true, description = "canceling of the login form.")
public void testUserLoginCancel() throws Exception {
+ final String loginName = "saki";
+ final String loginPass = "paki";
+
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -114,9 +123,9 @@
waitForElement(INP_PASSWORD);
Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM element for username doesn't exist.");
- selenium.type(INP_USERNAME, "saki");
+ selenium.type(INP_USERNAME, loginName);
Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM element for password doesn't exist.");
- selenium.type(INP_PASSWORD, "paki");
+ selenium.type(INP_PASSWORD, loginPass);
selenium.click(SUB_CANCEL);
selenium.selectFrame(FRM_MAIN);
@@ -129,6 +138,9 @@
@Test(enabled = true, description = "login as 'us2er' which does not exist.")
public void testFalseNameLogin() throws Exception {
+ final String loginName = "us2er";
+ final String loginPass = "user";
+
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -142,9 +154,9 @@
waitForElement(INP_PASSWORD);
Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM element for username doesn't exist.");
- selenium.type(INP_USERNAME, "us2er");
+ selenium.type(INP_USERNAME, loginName);
Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM element for password doesn't exist.");
- selenium.type(INP_PASSWORD, "user");
+ selenium.type(INP_PASSWORD, loginPass);
selenium.click(SUB_LOGIN);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -154,6 +166,9 @@
@Test(enabled = true, description = "login as 'user' with wrong password 'us2er'.")
public void testFalsePasswordLogin() throws Exception {
+ final String loginName = "user";
+ final String loginPass = "us2er";
+
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -167,9 +182,9 @@
waitForElement(INP_PASSWORD);
Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM element for username doesn't exist.");
- selenium.type(INP_USERNAME, "user");
+ selenium.type(INP_USERNAME, loginName);
Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM element for password doesn't exist.");
- selenium.type(INP_PASSWORD, "us2er");
+ selenium.type(INP_PASSWORD, loginPass);
selenium.click(SUB_LOGIN);
selenium.waitForPageToLoad(PAGE_LOAD);
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java 2009-02-04 10:06:14 UTC (rev 12770)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java 2009-02-04 14:00:11 UTC (rev 12771)
@@ -10,7 +10,7 @@
import org.testng.annotations.Test;
/**
- * @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
+ * @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
@Test(groups = { "cms_secure" }, enabled = true, description = "Setting permissions on the default portlet.")
@@ -81,15 +81,15 @@
selenium.click(LNK_MEMBERS);
selenium.waitForPageToLoad(PAGE_LOAD);
- clickIfVisible(IdentityAdminTestCase.ID_LINK_ROLETAB);
- clickIfVisible(IdentityAdminTestCase.ID_LINK_ROLEMAIN);
+ clickIfVisible(IdentityAdminTestCase.LNK_ROLETAB);
+ clickIfVisible(IdentityAdminTestCase.LNK_ROLEMAIN);
- selenium.click(IdentityAdminTestCase.ID_BUT_ROLE_CREATE);
+ selenium.click(IdentityAdminTestCase.LNK_ROLE_CREATE);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.type(IdentityAdminTestCase.ID_INPUT_ROLENAME, roleName);
- selenium.type(IdentityAdminTestCase.ID_INPUT_ROLEDISNAME, roleDisplayName);
- selenium.click(IdentityAdminTestCase.ID_SUBMIT_ROLE_CREATE);
+ selenium.type(IdentityAdminTestCase.INP_ROLENAME, roleName);
+ selenium.type(IdentityAdminTestCase.INP_ROLEDISNAME, roleDisplayName);
+ selenium.click(IdentityAdminTestCase.SUB_ROLE_CREATE);
selenium.waitForPageToLoad(PAGE_LOAD);
logout();
}
@@ -338,11 +338,11 @@
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent(roleDisplay), "Role display name: " + roleDisplay + " not found on the page.");
- final String CHECK_ROLE = MessageFormat.format(IdentityAdminTestCase.ID_CHECK_ROLE, role);
+ final String CHECK_ROLE = MessageFormat.format(IdentityAdminTestCase.CHK_ROLE, role);
if (!selenium.isChecked(CHECK_ROLE)) {
selenium.click(CHECK_ROLE);
- selenium.click(IdentityAdminTestCase.ID_SUBMIT_ASSIGN_ROLE);
+ selenium.click(IdentityAdminTestCase.SUB_ASSIGN_ROLE);
selenium.waitForPageToLoad(PAGE_LOAD);
}
searchUser(user, email);
@@ -362,11 +362,11 @@
Assert.assertTrue(selenium.isTextPresent(roleDisplay), "Role display name: " + roleDisplay + " not found on the page.");
// check the tempRole check box
- final String CHECK_ROLE = MessageFormat.format(IdentityAdminTestCase.ID_CHECK_ROLE, role);
+ final String CHECK_ROLE = MessageFormat.format(IdentityAdminTestCase.CHK_ROLE, role);
if (selenium.isChecked(CHECK_ROLE)) {
selenium.click(CHECK_ROLE);
- selenium.click(IdentityAdminTestCase.ID_SUBMIT_ASSIGN_ROLE);
+ selenium.click(IdentityAdminTestCase.SUB_ASSIGN_ROLE);
selenium.waitForPageToLoad(PAGE_LOAD);
}
searchUser(user, email);
@@ -386,15 +386,15 @@
selenium.click("link=Members");
selenium.waitForPageToLoad(PAGE_LOAD);
- clickIfVisible(IdentityAdminTestCase.ID_LINK_USERTAB);
- clickIfVisible(IdentityAdminTestCase.ID_LINK_USERMAIN);
- clickIfVisible(IdentityAdminTestCase.LINK_USERMANG_MAIN);
+ clickIfVisible(IdentityAdminTestCase.LNK_USERTAB);
+ clickIfVisible(IdentityAdminTestCase.LNK_USERMAIN);
+ clickIfVisible(IdentityAdminTestCase.LNK_USERMANG_MAIN);
- selenium.click(IdentityAdminTestCase.LINK_SEARCH_USER);
+ selenium.click(IdentityAdminTestCase.LNK_SEARCH_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.type(IdentityAdminTestCase.ID_INPUT_SEARCH_USER, username);
- selenium.click(IdentityAdminTestCase.ID_SUBMIT_SEARCH_USER);
+ selenium.type(IdentityAdminTestCase.INP_SEARCH_USER, username);
+ selenium.click(IdentityAdminTestCase.SUB_SEARCH_USER);
try {
Thread.sleep(5000);
@@ -408,8 +408,8 @@
}
private String butUsrRol_id(String userName) {
- String table = IdentityAdminTestCase.TABLE_USERLIST;
+ String table = IdentityAdminTestCase.TBL_USERLIST;
int r = findTableRow(table, userName, 0);
- return MessageFormat.format(IdentityAdminTestCase.LINK_T_USRLIST_ROLES, r - 1);
+ return MessageFormat.format(IdentityAdminTestCase.LNK_T_USRLIST_ROLES, r - 1);
}
}
17 years, 3 months
JBoss Portal SVN: r12770 - in branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium: cms and 1 other directories.
by portal-commits@lists.jboss.org
Author: vrockai
Date: 2009-02-04 05:06:14 -0500 (Wed, 04 Feb 2009)
New Revision: 12770
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java
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/UserInterceptorPortletTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java
Log:
selenium import fixes, userlogin more tests
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java 2009-02-03 17:46:31 UTC (rev 12769)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java 2009-02-04 10:06:14 UTC (rev 12770)
@@ -17,7 +17,7 @@
private static final String LINK_WEATHER_PORTLET = "link=*WeatherPortlet*";
private static final String LINK_PORTL2 = "link=*Who's online portlet*";
private static final String LINK_PORTL1 = "link=*Welcome portlet*";
- private static final String OPT_PORTL2 = "CurrentUsersPortletWindow";
+ //private static final String OPT_PORTL2 = "CurrentUsersPortletWindow";
private static final String OPT_PORTL1 = "JSPPortletWindow";
private static final String SEL_CONTENT_TYPE = "//select[contains(@id,'contentTypesForm:instanceId')]";
private static final String SUB_DEL_FROM_CENTER_REGION = "//input[contains(@id,'layoutForm:l_center')]";
@@ -32,7 +32,7 @@
private static final String INP_PAGENAME = "//input[contains(@id,':pageName')]";
private static final String SUB_CREATEPAGE = "//form[contains(@id,'j_id3')]/input[@type='submit']";
private static final String SEL_LAYOUT = "//select[contains(@id,'dashboardLayoutForm:layoutSelector')]";
- private static final String SUB_LAYOUTSEL = "//form[contains(@id,'dashboardLayoutForm')]/input[@type='submit']";
+
private static final String SEL_THEME = "//select[contains(@id,'dashboardThemeForm:themeSelector')]";
private static final String SUB_THEMESEL = "//form[contains(@id,'dashboardThemeForm')]/input[@type='submit']";
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 2009-02-03 17:46:31 UTC (rev 12769)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java 2009-02-04 10:06:14 UTC (rev 12770)
@@ -1,16 +1,10 @@
package org.jboss.portal.test.selenium;
-import java.awt.event.InputMethodEvent;
-import java.awt.event.InputMethodListener;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
-import java.util.List;
-import org.testng.IMethodInstance;
-import org.testng.IMethodInterceptor;
-import org.testng.ITestContext;
import org.testng.ITestResult;
import org.testng.TestListenerAdapter;
@@ -40,7 +34,7 @@
public void onTestFailure(ITestResult tr) {
String name = "F_" + tr.getName() + "-" + count;
-
+
if (htmlSource) {
try {
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(name + ".html")));
@@ -50,7 +44,7 @@
e1.printStackTrace();
}
}
- if (screenshot){
+ if (screenshot) {
try {
selenium.windowMaximize();
selenium.captureScreenshot(name + ".jpg");
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserInterceptorPortletTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserInterceptorPortletTestCase.java 2009-02-03 17:46:31 UTC (rev 12769)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserInterceptorPortletTestCase.java 2009-02-04 10:06:14 UTC (rev 12770)
@@ -1,8 +1,6 @@
package org.jboss.portal.test.selenium;
-import java.text.DateFormat;
import java.text.ParseException;
-import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;
@@ -14,6 +12,9 @@
@Test(groups = { "cms_user_interceptor" }, enabled = true, description = "Checking the log of logging of users.")
public class UserInterceptorPortletTestCase extends JBossPortalSeleniumTestCase {
+ private static final String LNK_USER_DETAILS = "link=UsersDetailPage";
+ private static final String DIV_LOGINFO = "//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div";
+
@Test(enabled = true, description = "Checking the logging dates for user.")
public void testTestUserLogger() throws ParseException {
@@ -26,7 +27,6 @@
}
private int dateDiff(String name, String passwd, int ind) throws ParseException {
- DateFormat df = new SimpleDateFormat("E MMM dd HH:mm:ss z yyyy");
Vector<String> vs;
String logInfo;
@@ -34,25 +34,25 @@
logout();
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=UsersDetailPage");
+ selenium.click(LNK_USER_DETAILS);
selenium.waitForPageToLoad(PAGE_LOAD);
- logInfo = selenium.getText("//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div");
+ logInfo = selenium.getText(DIV_LOGINFO);
vs = parseUserInterceptorString(logInfo);
- Date d1 = new Date(Long.valueOf(vs.get(ind)));//df.parse(vs.get(ind));
+ Date d1 = new Date(Long.valueOf(vs.get(ind)));
login(name, passwd);
logout();
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=UsersDetailPage");
+ selenium.click(LNK_USER_DETAILS);
selenium.waitForPageToLoad(PAGE_LOAD);
- logInfo = selenium.getText("//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div");
+ logInfo = selenium.getText(DIV_LOGINFO);
vs = parseUserInterceptorString(logInfo);
- Date d2 = new Date(Long.valueOf(vs.get(ind)));//df.parse(vs.get(ind));
+ Date d2 = new Date(Long.valueOf(vs.get(ind)));
return d2.compareTo(d1);
}
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java 2009-02-03 17:46:31 UTC (rev 12769)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java 2009-02-04 10:06:14 UTC (rev 12770)
@@ -11,111 +11,170 @@
@Test(groups = { "login" }, enabled = true)
public class UserLoginTestCase extends JBossPortalSeleniumTestCase {
+ private static final String ADR_PORTAL = "/portal";
+ private static final String FRM_MAIN = "relative=up";
+ private static final String SUB_CANCEL = "cancel";
+ private static final String LNK_LOGOUT = "link=Logout";
+ private static final String SUB_LOGIN = "login";
+ private static final String INP_PASSWORD = "xpath=id('j_password')";
+ private static final String INP_USERNAME = "xpath=id('j_username')";
+ private static final String FRM_LOGINFORM = "login-content";
+ private static final String LNK_LOGIN = "link=Login";
+
@AfterClass(enabled = true)
public void logoutIfNeeded()
{
- selenium.open("/portal");
+ selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- if (selenium.isElementPresent("link=Logout")){
- selenium.click("link=Logout");
+ if (selenium.isElementPresent(LNK_LOGOUT)){
+ selenium.click(LNK_LOGOUT);
selenium.waitForPageToLoad(PAGE_LOAD);
}
}
@Test(enabled = true, description = "login as default user 'user' with password 'user'.")
public void testDefaultUserLogin() throws Exception {
- //selenium.setSpeed("7000");
- selenium.open("/portal");
+ selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isElementPresent("link=Login"), "Expected DOM element for login link does not exist.");
- Assert.assertEquals(selenium.getText("link=Login"), "Login", "Login button doesn't exist.");
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN), "Expected DOM element for login link does not exist.");
+ Assert.assertEquals(selenium.getText(LNK_LOGIN), "Login", "Login button doesn't exist.");
- selenium.click("link=Login");
- selenium.selectFrame("login-content");
+ selenium.click(LNK_LOGIN);
+ selenium.selectFrame(FRM_LOGINFORM);
- waitForElement("xpath=id('j_username')");
- waitForElement("xpath=id('j_password')");
+ waitForElement(INP_USERNAME);
+ waitForElement(INP_PASSWORD);
- Assert.assertTrue(selenium.isElementPresent("xpath=id('j_username')"), "Expected input DOM element for username doesn't exist.");
- selenium.type("j_username", "user");
- Assert.assertTrue(selenium.isElementPresent("xpath=id('j_password')"), "Expected input DOM element for password doesn't exist.");
- selenium.type("j_password", "user");
- selenium.click("login");
+ Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM element for username doesn't exist.");
+ selenium.type(INP_USERNAME, "user");
+ Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM element for password doesn't exist.");
+ selenium.type(INP_PASSWORD, "user");
+ selenium.click(SUB_LOGIN);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("Logged in as: user"), "\"Logged in as\" message missing.");
- Assert.assertTrue(selenium.isElementPresent("link=Logout"), "Expected DOM element for login link does not exist.");
- Assert.assertEquals(selenium.getText("link=Logout"), "Logout", "Logout has wrong label.");
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGOUT), "Expected DOM element for login link does not exist.");
+ Assert.assertEquals(selenium.getText(LNK_LOGOUT), "Logout", "Logout has wrong label.");
- selenium.click("link=Logout");
+ selenium.click(LNK_LOGOUT);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertFalse(selenium.isTextPresent("Logged in as:"), "\"Logged in as:\" message with no user logged in is missing.");
}
@Test(enabled = true, description = "login as admin user 'admin' with password 'admin'.")
public void testAdminLogin() throws Exception {
- selenium.open("/portal");
+ selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- waitForElement("link=Login");
- Assert.assertTrue(selenium.isElementPresent("link=Login"), "Expected DOM element for login link does not exist.");
- Assert.assertEquals(selenium.getText("link=Login"), "Login", "Login button doesn't exist.");
+ waitForElement(LNK_LOGIN);
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN), "Expected DOM element for login link does not exist.");
+ Assert.assertEquals(selenium.getText(LNK_LOGIN), "Login", "Login button doesn't exist.");
- selenium.click("link=Login");
- selenium.selectFrame("login-content");
+ selenium.click(LNK_LOGIN);
+ selenium.selectFrame(FRM_LOGINFORM);
- waitForElement("xpath=id('j_username')");
- waitForElement("xpath=id('j_password')");
+ waitForElement(INP_USERNAME);
+ waitForElement(INP_PASSWORD);
- Assert.assertTrue(selenium.isElementPresent("xpath=id('j_username')"), "Expected input DOM element for username doesn't exist.");
- selenium.type("j_username", "admin");
- Assert.assertTrue(selenium.isElementPresent("xpath=id('j_password')"), "Expected input DOM element for password doesn't exist.");
- selenium.type("j_password", "admin");
- selenium.click("login");
+ Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM element for username doesn't exist.");
+ selenium.type(INP_USERNAME, "admin");
+ Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM element for password doesn't exist.");
+ selenium.type(INP_PASSWORD, "admin");
+ selenium.click(SUB_LOGIN);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("Logged in as: admin"), "\"Logged in as\" message missing.");
- Assert.assertTrue(selenium.isElementPresent("link=Logout"), "Expected DOM element for login link does not exist.");
- Assert.assertEquals(selenium.getText("link=Logout"), "Logout", "Logout has wrong label.");
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGOUT), "Expected DOM element for login link does not exist.");
+ Assert.assertEquals(selenium.getText(LNK_LOGOUT), "Logout", "Logout has wrong label.");
- selenium.click("link=Logout");
+ selenium.click(LNK_LOGOUT);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertFalse(selenium.isTextPresent("Logged in as:"), "\"Logged in as:\" message with no user logged in is missing.");
}
@Test(enabled = true, description = "canceling of the login form.")
public void testUserLoginCancel() throws Exception {
- selenium.open("/portal");
+ selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertFalse(selenium.isTextPresent("Logged in as:"), "\"Logged in as:\" message with no user logged in is missing.");
- Assert.assertTrue(selenium.isElementPresent("link=Login"), "DOM element for login link not found.");
- Assert.assertEquals(selenium.getText("link=Login"), "Login", "Login button doesn't exist.");
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN), "DOM element for login link not found.");
+ Assert.assertEquals(selenium.getText(LNK_LOGIN), "Login", "Login button doesn't exist.");
- selenium.click("link=Login");
- selenium.selectFrame("login-content");
+ selenium.click(LNK_LOGIN);
+ selenium.selectFrame(FRM_LOGINFORM);
- waitForElement("xpath=id('j_username')");
- waitForElement("xpath=id('j_password')");
+ waitForElement(INP_USERNAME);
+ waitForElement(INP_PASSWORD);
- Assert.assertTrue(selenium.isElementPresent("xpath=id('j_username')"), "Expected input DOM element for username doesn't exist.");
- selenium.type("j_username", "saki");
- Assert.assertTrue(selenium.isElementPresent("xpath=id('j_password')"), "Expected input DOM element for password doesn't exist.");
- selenium.type("j_password", "paki");
+ Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM element for username doesn't exist.");
+ selenium.type(INP_USERNAME, "saki");
+ Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM element for password doesn't exist.");
+ selenium.type(INP_PASSWORD, "paki");
- selenium.click("cancel");
- selenium.selectFrame("relative=up");
+ selenium.click(SUB_CANCEL);
+ selenium.selectFrame(FRM_MAIN);
- Assert.assertTrue(selenium.isElementPresent("link=Login"), "DOM element for login link not found.");
- Assert.assertEquals(selenium.getText("link=Login"), "Login", "Login button doesn't exist.");
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN), "DOM element for login link not found.");
+ Assert.assertEquals(selenium.getText(LNK_LOGIN), "Login", "Login button doesn't exist.");
Assert.assertFalse(selenium.isTextPresent("Logged in as:"), "\"Logged in as:\" message with no user logged in is missing.");
}
+
+ @Test(enabled = true, description = "login as 'us2er' which does not exist.")
+ public void testFalseNameLogin() throws Exception {
+ selenium.open(ADR_PORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN), "Expected DOM element for login link does not exist.");
+ Assert.assertEquals(selenium.getText(LNK_LOGIN), "Login", "Login button doesn't exist.");
+
+ selenium.click(LNK_LOGIN);
+ selenium.selectFrame(FRM_LOGINFORM);
+
+ waitForElement(INP_USERNAME);
+ waitForElement(INP_PASSWORD);
+
+ Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM element for username doesn't exist.");
+ selenium.type(INP_USERNAME, "us2er");
+ Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM element for password doesn't exist.");
+ selenium.type(INP_PASSWORD, "user");
+ selenium.click(SUB_LOGIN);
+
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent("The user doesn't exist or the password is incorrect "), "\"Logged in as\" message missing.");
+ }
+
+ @Test(enabled = true, description = "login as 'user' with wrong password 'us2er'.")
+ public void testFalsePasswordLogin() throws Exception {
+ selenium.open(ADR_PORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN), "Expected DOM element for login link does not exist.");
+ Assert.assertEquals(selenium.getText(LNK_LOGIN), "Login", "Login button doesn't exist.");
+
+ selenium.click(LNK_LOGIN);
+ selenium.selectFrame(FRM_LOGINFORM);
+
+ waitForElement(INP_USERNAME);
+ waitForElement(INP_PASSWORD);
+
+ Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM element for username doesn't exist.");
+ selenium.type(INP_USERNAME, "user");
+ Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM element for password doesn't exist.");
+ selenium.type(INP_PASSWORD, "us2er");
+ selenium.click(SUB_LOGIN);
+
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent("The user doesn't exist or the password is incorrect "), "\"Logged in as\" message missing.");
+ }
+
}
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java 2009-02-03 17:46:31 UTC (rev 12769)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java 2009-02-04 10:06:14 UTC (rev 12770)
@@ -42,9 +42,6 @@
private static final String LINK_T_CONS_DER="//a[contains(@id,''consumer-list-form:consumersList:{0}:register'')]";
private static final String LINK_T_CONS_DEL="//a[contains(@id,''consumer-list-form:consumersList:{0}:delete'')]";
-
-
-
public static String WSRP_CONSUMER_TABLE = "//table[contains(@id,':consumer-list-form:consumersList')]";
@BeforeMethod(groups = { "log" })
public void loginBeforeTest() {
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java 2009-02-03 17:46:31 UTC (rev 12769)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java 2009-02-04 10:06:14 UTC (rev 12770)
@@ -18,8 +18,6 @@
private static final String LNK_EXPLORE = "//area[@href='/portal/content/default/epp.html']";
private static final String LNK_CMS_EXPLORE = "Link=epp.html";
- private static final String LNK_SUPPORT_HTML = "//area[@href='/portal/content/default/project.html']";
- private static final String LNK_CMS_SUPPORT_HTML = "Link=project.html";
private static final String LNK_MEMBERS = "link=Members";
private static final String SUB_SECURITY_SET = "//input[contains(@name,'submit')]";
private static final String SEL_SECUREUSERS_MANAGE = "//select[contains(@name,'secureusers:manage')]";
@@ -165,10 +163,6 @@
login("admin", "admin");
Assert.assertFalse(selenium.isTextPresent("Access to this resource is denied "), "Non secured resource is not visible.#1");
- // Assert.assertFalse(selenium.isTextPresent(
- // "You are not allowed to access the following resource - /default/index.html"
- // ),
- // "Non secured resource is not visible.#2");
selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -401,7 +395,6 @@
selenium.type(IdentityAdminTestCase.ID_INPUT_SEARCH_USER, username);
selenium.click(IdentityAdminTestCase.ID_SUBMIT_SEARCH_USER);
- // selenium.waitForPageToLoad(PAGE_LOAD);
try {
Thread.sleep(5000);
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java 2009-02-03 17:46:31 UTC (rev 12769)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java 2009-02-04 10:06:14 UTC (rev 12770)
@@ -270,7 +270,7 @@
// click on the page layout
selenium.click(MessageFormat.format(PAG_TL_LAYOUT, r));
- //selenium.waitForPageToLoad(PAGE_LOAD);
+
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
17 years, 3 months
JBoss Portal SVN: r12768 - in modules/authorization/trunk: policy-server/src/main/java/org/jboss/security/authz/policy/server and 1 other directory.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2009-02-03 12:30:45 -0500 (Tue, 03 Feb 2009)
New Revision: 12768
Modified:
modules/authorization/trunk/.classpath
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java
Log:
fixing compilation error
Modified: modules/authorization/trunk/.classpath
===================================================================
--- modules/authorization/trunk/.classpath 2009-02-03 17:24:30 UTC (rev 12767)
+++ modules/authorization/trunk/.classpath 2009-02-03 17:30:45 UTC (rev 12768)
@@ -11,11 +11,7 @@
<classpathentry kind="src" path="enforcement/src/main/java"/>
<classpathentry kind="src" path="enforcement/src/main/resources"/>
<classpathentry kind="src" path="enforcement/src/test/java"/>
- <classpathentry kind="src" path="enforcement/src/test/resources"/>
- <classpathentry kind="src" path="provisioning/src/main/java"/>
- <classpathentry kind="src" path="provisioning/src/main/resources"/>
- <classpathentry kind="src" path="provisioning/src/test/java"/>
- <classpathentry kind="src" path="provisioning/src/test/resources"/>
+ <classpathentry kind="src" path="enforcement/src/test/resources"/>
<classpathentry kind="src" path="policy-server/src/main/java"/>
<classpathentry kind="src" path="policy-server/src/main/resources"/>
<classpathentry kind="src" path="policy-server/src/test/java"/>
Modified: modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java
===================================================================
--- modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java 2009-02-03 17:24:30 UTC (rev 12767)
+++ modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java 2009-02-03 17:30:45 UTC (rev 12768)
@@ -109,7 +109,7 @@
* @param request Authorization Request
* @return response which contains the Authorization Decision
*/
- public Response evaluate(Request request)
+ public Response evaluate(Request request) throws PolicyServerException
{
return this.policyDecisionPoint.evaluate(request);
}
@@ -123,7 +123,7 @@
* @param xml
* @return response in xml format confirming to the XACML spec
*/
- public String evaluate(String xml)
+ public String evaluate(String xml) throws PolicyServerException
{
return this.policyDecisionPoint.evaluate(xml);
}
@@ -133,11 +133,18 @@
*
* @param policyMetaData meta data for the policy to be created
*/
- public void newPolicy(PolicyMetaData policyMetaData) throws PolicyException
+ public void newPolicy(PolicyMetaData policyMetaData) throws PolicyServerException
{
- Policy policy = new HierarchialPolicy(GeneralTool.generateUniqueId(), policyMetaData);
- this.policyStore.savePolicy(policy);
- this.policyFinderModule.addPolicy(policy);
+ try
+ {
+ Policy policy = new HierarchialPolicy(GeneralTool.generateUniqueId(), policyMetaData);
+ this.policyStore.savePolicy(policy);
+ this.policyFinderModule.addPolicy(policy);
+ }
+ catch(PolicyException pe)
+ {
+ throw new PolicyServerException(pe);
+ }
}
/**
@@ -146,9 +153,16 @@
* @param policyUri
* @return a stored Policy
*/
- public Policy readPolicy(String policyUri) throws PolicyException
+ public Policy readPolicy(String policyUri) throws PolicyServerException
{
- return this.policyStore.readPolicy(policyUri);
+ try
+ {
+ return this.policyStore.readPolicy(policyUri);
+ }
+ catch(PolicyException pe)
+ {
+ throw new PolicyServerException(pe);
+ }
}
/**
@@ -156,9 +170,16 @@
*
* @return all the stored Policies
*/
- public Policy[] readAllPolicies() throws PolicyException
+ public Policy[] readAllPolicies() throws PolicyServerException
{
- return this.policyStore.readAllPolicies();
+ try
+ {
+ return this.policyStore.readAllPolicies();
+ }
+ catch(PolicyException pe)
+ {
+ throw new PolicyServerException(pe);
+ }
}
/**
@@ -166,8 +187,15 @@
*
* @param policyUri unique identifier for the Policy
*/
- public void deletePolicy(String policyUri) throws PolicyException
+ public void deletePolicy(String policyUri) throws PolicyServerException
{
- this.policyStore.deletePolicy(policyUri);
+ try
+ {
+ this.policyStore.deletePolicy(policyUri);
+ }
+ catch(PolicyException pe)
+ {
+ throw new PolicyServerException(pe);
+ }
}
}
17 years, 3 months
JBoss Portal SVN: r12767 - in modules/authorization/trunk/policy-server: src/main/java/org/jboss/security/authz/policy/server and 5 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2009-02-03 12:24:30 -0500 (Tue, 03 Feb 2009)
New Revision: 12767
Added:
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServerException.java
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/EnterprisePolicyFinderModule.java
Removed:
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/EnterprisePolicyFinder.java
Modified:
modules/authorization/trunk/policy-server/pom.xml
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/decision/PolicyDecisionPoint.java
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/spi/PolicyStore.java
modules/authorization/trunk/policy-server/src/main/resources/META-INF/jboss-beans.xml
modules/authorization/trunk/policy-server/src/main/resources/META-INF/pdp-config.xml
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestPolicyServer.java
Log:
first pass at implementing the EnterprisePolicyFinderModule
Modified: modules/authorization/trunk/policy-server/pom.xml
===================================================================
--- modules/authorization/trunk/policy-server/pom.xml 2009-02-02 11:41:03 UTC (rev 12766)
+++ modules/authorization/trunk/policy-server/pom.xml 2009-02-03 17:24:30 UTC (rev 12767)
@@ -21,6 +21,11 @@
</dependency>
<dependency>
<groupId>org.jboss.security.authz</groupId>
+ <artifactId>jboss-authz-core-components</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.security.authz</groupId>
<artifactId>jboss-authz-enforcement</artifactId>
<version>${project.version}</version>
</dependency>
@@ -60,8 +65,8 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.3.1</version>
<configuration>
- <includes>
- <include>**/TestPolicyServer.java</include>
+ <includes>
+ <include>**/TestPolicyServer.java</include>
</includes>
</configuration>
</plugin>
Modified: modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java
===================================================================
--- modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java 2009-02-02 11:41:03 UTC (rev 12766)
+++ modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java 2009-02-03 17:24:30 UTC (rev 12767)
@@ -21,16 +21,24 @@
*/
package org.jboss.security.authz.policy.server;
+import java.util.Set;
+
import org.apache.log4j.Logger;
import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.model.PolicyMetaData;
import org.jboss.security.authz.model.PolicyException;
+import org.jboss.security.authz.tools.GeneralTool;
import org.jboss.security.authz.policy.server.decision.PolicyDecisionPoint;
import org.jboss.security.authz.policy.server.spi.PolicyStore;
+import org.jboss.security.authz.policy.server.plugin.HierarchialPolicy;
+import org.jboss.security.authz.policy.server.plugin.EnterprisePolicyFinderModule;
import org.jboss.security.authz.enforcement.Request;
import org.jboss.security.authz.enforcement.Response;
+import org.jboss.security.xacml.sunxacml.finder.PolicyFinderModule;
+
/**
* The Central Policy Server
*
@@ -42,6 +50,7 @@
private PolicyDecisionPoint policyDecisionPoint;
private PolicyStore policyStore;
+ private EnterprisePolicyFinderModule policyFinderModule;
public PolicyServer()
{
@@ -49,7 +58,22 @@
}
public void start()
- {
+ {
+ try
+ {
+ Set<PolicyFinderModule> finders = this.policyDecisionPoint.getPDPConfiguration().getPolicyFinder().getModules();
+ for(PolicyFinderModule module: finders)
+ {
+ if(module instanceof EnterprisePolicyFinderModule)
+ {
+ this.policyFinderModule = (EnterprisePolicyFinderModule)module;
+ }
+ }
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException(e);
+ }
}
public void stop()
@@ -105,6 +129,18 @@
}
//------- Provisioning services-----------------------------------------------------------------------------------------------------------------------------
/**
+ * Generates a new Policy instance based on the supplied MetaData and stores it into the Policy Store
+ *
+ * @param policyMetaData meta data for the policy to be created
+ */
+ public void newPolicy(PolicyMetaData policyMetaData) throws PolicyException
+ {
+ Policy policy = new HierarchialPolicy(GeneralTool.generateUniqueId(), policyMetaData);
+ this.policyStore.savePolicy(policy);
+ this.policyFinderModule.addPolicy(policy);
+ }
+
+ /**
* Read a stored Policy identified by the unique policyUri
*
* @param policyUri
@@ -124,18 +160,8 @@
{
return this.policyStore.readAllPolicies();
}
-
+
/**
- * Saves a Policy into storage. If this policy already exists in storage, then it updates it
- *
- * @param policy Policy to be saved into storage
- */
- public void savePolicy(Policy policy) throws PolicyException
- {
- this.policyStore.savePolicy(policy);
- }
-
- /**
* Deletes the specified Policy from storage
*
* @param policyUri unique identifier for the Policy
Added: modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServerException.java
===================================================================
--- modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServerException.java (rev 0)
+++ modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServerException.java 2009-02-03 17:24:30 UTC (rev 12767)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * 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.policy.server;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class PolicyServerException extends Exception
+{
+ public PolicyServerException()
+ {
+ super();
+ }
+
+ public PolicyServerException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public PolicyServerException(String message)
+ {
+ super(message);
+ }
+
+ public PolicyServerException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Modified: modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/decision/PolicyDecisionPoint.java
===================================================================
--- modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/decision/PolicyDecisionPoint.java 2009-02-02 11:41:03 UTC (rev 12766)
+++ modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/decision/PolicyDecisionPoint.java 2009-02-03 17:24:30 UTC (rev 12767)
@@ -27,9 +27,11 @@
import org.jboss.security.authz.enforcement.Request;
import org.jboss.security.authz.enforcement.Response;
+import org.jboss.security.authz.policy.server.PolicyServerException;
import org.jboss.security.xacml.sunxacml.ConfigurationStore;
import org.jboss.security.xacml.sunxacml.PDP;
+import org.jboss.security.xacml.sunxacml.PDPConfig;
/**
* This component processes all incoming Authorization requests and responds with a response
@@ -45,6 +47,7 @@
private static Logger log = Logger.getLogger(PolicyDecisionPoint.class);
private PDP policyDecisionPoint;
+ private ConfigurationStore store;
public PolicyDecisionPoint()
{
@@ -55,11 +58,11 @@
{
try
{
- ConfigurationStore store = new ConfigurationStore(new File(Thread.currentThread().getContextClassLoader().
+ this.store = new ConfigurationStore(new File(Thread.currentThread().getContextClassLoader().
getResource("META-INF/pdp-config.xml").getFile()));
- store.useDefaultFactories();
+ this.store.useDefaultFactories();
- this.policyDecisionPoint = new PDP(store.getDefaultPDPConfig());
+ this.policyDecisionPoint = new PDP(this.store.getDefaultPDPConfig());
log.info("-------------------------------------------------------");
log.info("Policy Decision Point successfully started.....................");
@@ -75,6 +78,7 @@
public void stop()
{
this.policyDecisionPoint = null;
+ this.store = null;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/**
@@ -105,4 +109,16 @@
String responseXml = null;
return responseXml;
}
+ //---------Expose some configuration information--------------------------------------------------------------------------------------------------------------------------------------------------
+ public PDPConfig getPDPConfiguration() throws PolicyServerException
+ {
+ try
+ {
+ return this.store.getDefaultPDPConfig();
+ }
+ catch(Exception e)
+ {
+ throw new PolicyServerException(e);
+ }
+ }
}
Deleted: modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/EnterprisePolicyFinder.java
===================================================================
--- modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/EnterprisePolicyFinder.java 2009-02-02 11:41:03 UTC (rev 12766)
+++ modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/EnterprisePolicyFinder.java 2009-02-03 17:24:30 UTC (rev 12767)
@@ -1,52 +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.policy.server.plugin;
-
-import org.jboss.security.xacml.sunxacml.finder.PolicyFinder;
-import org.jboss.security.xacml.sunxacml.finder.PolicyFinderModule;
-
-/**
- * A production ready Enterprise Policy Finder that would be used by the Policy Server/PDP component.
- *
- * It is designed for being production ready from a performance/scalability/clustering standpoint
- *
- * This particular version will provide performance enhancement by the use of a clustered cache based on JBoss Cache
- * The actual storage of the policies will be done within a relational database
- *
- * This also allows for runtime modification of Security Policies without requiring any restart/refresh of the Applications
- *
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- *
- */
-public class EnterprisePolicyFinder extends PolicyFinderModule
-{
- public EnterprisePolicyFinder()
- {
-
- }
-
- @Override
- public void init(PolicyFinder finder)
- {
- }
-}
\ No newline at end of file
Copied: modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/EnterprisePolicyFinderModule.java (from rev 12766, modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/EnterprisePolicyFinder.java)
===================================================================
--- modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/EnterprisePolicyFinderModule.java (rev 0)
+++ modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/EnterprisePolicyFinderModule.java 2009-02-03 17:24:30 UTC (rev 12767)
@@ -0,0 +1,155 @@
+/******************************************************************************
+ * 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.policy.server.plugin;
+
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.policy.server.PolicyServerException;
+
+import org.jboss.security.xacml.sunxacml.EvaluationCtx;
+import org.jboss.security.xacml.sunxacml.finder.PolicyFinder;
+import org.jboss.security.xacml.sunxacml.finder.PolicyFinderModule;
+import org.jboss.security.xacml.sunxacml.finder.PolicyFinderResult;
+import org.jboss.security.xacml.sunxacml.support.finder.PolicyReader;
+import org.jboss.security.xacml.sunxacml.support.finder.PolicyCollection;
+import org.jboss.security.xacml.sunxacml.support.finder.TopLevelPolicyException;
+import org.jboss.security.xacml.sunxacml.AbstractPolicy;
+
+/**
+ * A production ready Enterprise Policy Finder that would be used by the Policy Server/PDP component.
+ *
+ * It is designed for being production ready from a performance/scalability/clustering standpoint
+ *
+ * This particular version will provide performance enhancement by the use of a clustered cache based on JBoss Cache
+ * The actual storage of the policies will be done within a relational database
+ *
+ * This also allows for runtime modification of Security Policies without requiring any restart/refresh of the Applications
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class EnterprisePolicyFinderModule extends PolicyFinderModule
+{
+ private static Logger log = Logger.getLogger(EnterprisePolicyFinderModule.class);
+
+ private PolicyReader reader;
+ private PolicyCollection policies;
+
+ public EnterprisePolicyFinderModule()
+ {
+ this.policies = new PolicyCollection();
+ }
+
+ public void addPolicy(Policy policy) throws PolicyServerException
+ {
+ ByteArrayInputStream bos = null;
+ try
+ {
+ String xacmlPolicyStr = policy.generateXACMLPolicy();
+ bos = new ByteArrayInputStream(xacmlPolicyStr.getBytes());
+
+
+ AbstractPolicy xacmlPolicy = this.reader.readPolicy(bos);
+ this.policies.addPolicy(xacmlPolicy);
+ }
+ catch(Exception e)
+ {
+ log.error(this, e);
+ throw new PolicyServerException(e);
+ }
+ finally
+ {
+ if(bos != null)
+ {
+ try
+ {
+ bos.close();
+ }catch(IOException ioe){}
+ }
+ }
+ }
+ //-----------PolicyFinderModule Implementation------------------------------------------------------------------------------------------------------------
+ /**
+ * Initializes this module for use by the given finder. Typically this
+ * is called when a <code>PDP</code> is initialized with a
+ * <code>PDPConfig</code> containing the given <code>PolicyFinder</code>.
+ * Because <code>PolicyFinderModule</code>s usually need to parse
+ * policies, and this requires knowing their <code>PolicyFinder<code>,
+ * parsing is usually done at or after this point in the lifetime
+ * of this module. This might also be a good time to reset any internal
+ * caches or temporary data. Note that this method may be called more
+ * than once in the lifetime of a module.
+ *
+ * @param finder the <code>PolicyFinder</code> using this module
+ */
+ public void init(PolicyFinder finder)
+ {
+ this.reader = new PolicyReader(finder, java.util.logging.Logger.getLogger(this.getClass().getName()));
+ }
+
+ /**
+ * Returns true if the module supports finding policies based on a
+ * request (ie, target matching). By default this method returns false.
+ *
+ * @return true if request retrieval is supported
+ */
+ public boolean isRequestSupported()
+ {
+ return true;
+ }
+
+ /**
+ * Tries to find one and only one matching policy given the request
+ * represented by the context data. If more than one policy is found,
+ * this is an error and must be reported as such. If no policies are
+ * found, then an empty result must be returned. By default this
+ * method returns an empty result. This method should never return null.
+ *
+ * @param context the representation of the request
+ *
+ * @return the result of looking for a matching policy
+ */
+ public PolicyFinderResult findPolicy(EvaluationCtx context)
+ {
+ try
+ {
+ AbstractPolicy policy = this.policies.getPolicy(context);
+ if (policy == null)
+ {
+ return new PolicyFinderResult();
+ }
+ else
+ {
+ return new PolicyFinderResult(policy);
+ }
+ }
+ catch (TopLevelPolicyException e)
+ {
+ return new PolicyFinderResult(e.getStatus());
+ }
+ }
+}
\ No newline at end of file
Modified: modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/spi/PolicyStore.java
===================================================================
--- modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/spi/PolicyStore.java 2009-02-02 11:41:03 UTC (rev 12766)
+++ modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/spi/PolicyStore.java 2009-02-03 17:24:30 UTC (rev 12767)
@@ -30,7 +30,7 @@
*
*/
public interface PolicyStore
-{
+{
/**
* Read a stored Policy identified by the unique policyUri
*
Modified: modules/authorization/trunk/policy-server/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- modules/authorization/trunk/policy-server/src/main/resources/META-INF/jboss-beans.xml 2009-02-02 11:41:03 UTC (rev 12766)
+++ modules/authorization/trunk/policy-server/src/main/resources/META-INF/jboss-beans.xml 2009-02-03 17:24:30 UTC (rev 12767)
@@ -16,5 +16,8 @@
</bean>
<bean name="/policy-server/PolicyStore" class="org.jboss.security.authz.policy.server.provisioning.MemoryPolicyStore">
+ </bean>
+
+ <bean name="/policy-server/PolicyDeployer" class="org.jboss.security.authz.policy.server.provisioning.PolicyDeployer">
</bean>
</deployment>
\ No newline at end of file
Modified: modules/authorization/trunk/policy-server/src/main/resources/META-INF/pdp-config.xml
===================================================================
--- modules/authorization/trunk/policy-server/src/main/resources/META-INF/pdp-config.xml 2009-02-02 11:41:03 UTC (rev 12766)
+++ modules/authorization/trunk/policy-server/src/main/resources/META-INF/pdp-config.xml 2009-02-03 17:24:30 UTC (rev 12767)
@@ -6,7 +6,7 @@
<pdp name="pdp">
<attributeFinderModule class="org.jboss.security.xacml.sunxacml.finder.impl.CurrentEnvModule"/>
<attributeFinderModule class="org.jboss.security.xacml.sunxacml.finder.impl.SelectorModule"/>
- <policyFinderModule class="org.jboss.security.authz.policy.server.plugin.EnterprisePolicyFinder">
+ <policyFinderModule class="org.jboss.security.authz.policy.server.plugin.EnterprisePolicyFinderModule">
</policyFinderModule>
</pdp>
Modified: modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestPolicyServer.java
===================================================================
--- modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestPolicyServer.java 2009-02-02 11:41:03 UTC (rev 12766)
+++ modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestPolicyServer.java 2009-02-03 17:24:30 UTC (rev 12767)
@@ -22,24 +22,44 @@
package org.jboss.security.authz.policy.server;
import junit.framework.TestCase;
+import org.apache.log4j.Logger;
+import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.components.http.HttpResource;
+import org.jboss.security.authz.policy.server.PolicyServer;
+
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*/
public class TestPolicyServer extends TestCase
{
+ private static Logger log = Logger.getLogger(TestPolicyServer.class);
+
+ private PolicyServer policyServer;
+
public void setUp() throws Exception
{
Server.bootstrap();
+ this.policyServer = (PolicyServer)Server.lookup("/policy-server/PolicyServer");
}
public void tearDown() throws Exception
{
-
}
- public void test() throws Exception
+ public void testNewPolicy() throws Exception
{
+ HttpResource httpResource = new HttpResource();
+ httpResource.setUrl("/blah/index.html");
+ httpResource.addParameter("param1", "param1Value");
+ policyServer.newPolicy(httpResource.getPolicyMetaData(true));
+
+ //Assert Policy State of the Server
+ Policy[] policies = policyServer.readAllPolicies();
+
+ assertTrue("Policy Store must not be empty!!", (policies != null && policies.length == 1));
+ log.info("------------------------------------------------------------------------------");
+ log.info(policies[0].generateXACMLPolicy());
}
}
17 years, 3 months
JBoss Portal SVN: r12766 - in modules/authorization/trunk: http-profile and 9 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2009-02-02 06:41:03 -0500 (Mon, 02 Feb 2009)
New Revision: 12766
Added:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/configuration/
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/provisioning/
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/provisioning/MemoryPolicyStore.java
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/provisioning/PolicyDeployer.java
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/spi/
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/spi/PolicyConfig.java
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/spi/PolicyStore.java
Removed:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/configuration/HttpPolicyStore.java
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/provisioning/
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/provisioning/TestHttpPolicyDeployer.java
modules/authorization/trunk/http-profile/src/test/resources/META-INF/
modules/authorization/trunk/provisioning/
Modified:
modules/authorization/trunk/http-profile/pom.xml
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/configuration/HttpPolicyConfig.java
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/provisioning/TestHttpPolicyConfig.java
modules/authorization/trunk/policy-server/pom.xml
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java
modules/authorization/trunk/policy-server/src/main/resources/META-INF/jboss-beans.xml
modules/authorization/trunk/pom.xml
Log:
adding provisioning function to the policy server
merging 'provisioning' component into the 'policy-server' component
Modified: modules/authorization/trunk/http-profile/pom.xml
===================================================================
--- modules/authorization/trunk/http-profile/pom.xml 2009-02-02 11:20:45 UTC (rev 12765)
+++ modules/authorization/trunk/http-profile/pom.xml 2009-02-02 11:41:03 UTC (rev 12766)
@@ -23,24 +23,13 @@
<groupId>org.jboss.security.authz</groupId>
<artifactId>jboss-authz-core-components</artifactId>
<version>${project.version}</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.jboss.security.authz</groupId>
- <artifactId>jboss-authz-provisioning</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.security.authz</groupId>
<artifactId>jboss-authz-policy-server</artifactId>
<version>${project.version}</version>
</dependency>
-
- <dependency>
- <groupId>org.jboss.microcontainer</groupId>
- <artifactId>jboss-kernel</artifactId>
- <scope>test</scope>
- </dependency>
-
+
<!-- test dependencies -->
<!-- jboss xacml -->
<dependency>
Copied: modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/configuration (from rev 12764, modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/provisioning)
Modified: modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/configuration/HttpPolicyConfig.java
===================================================================
--- modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/provisioning/HttpPolicyConfig.java 2009-02-02 04:10:43 UTC (rev 12764)
+++ modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/configuration/HttpPolicyConfig.java 2009-02-02 11:41:03 UTC (rev 12766)
@@ -20,15 +20,13 @@
* 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.http.provisioning;
+package org.jboss.security.authz.http.configuration;
import java.io.IOException;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.List;
import java.util.ArrayList;
-import java.util.Set;
-import java.util.HashSet;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -41,10 +39,8 @@
import org.jboss.security.authz.components.http.HttpResource;
import org.jboss.security.authz.model.Policy;
-import org.jboss.security.authz.model.Rule;
-import org.jboss.security.authz.model.Target;
import org.jboss.security.authz.policy.server.plugin.HierarchialPolicy;
-import org.jboss.security.authz.provisioning.spi.PolicyConfig;
+import org.jboss.security.authz.policy.server.spi.PolicyConfig;
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
Deleted: modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/configuration/HttpPolicyStore.java
===================================================================
--- modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/provisioning/HttpPolicyStore.java 2009-02-02 04:10:43 UTC (rev 12764)
+++ modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/configuration/HttpPolicyStore.java 2009-02-02 11:41:03 UTC (rev 12766)
@@ -1,90 +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.http.provisioning;
-
-import java.util.Map;
-import java.util.HashMap;
-
-import org.jboss.security.authz.model.Policy;
-import org.jboss.security.authz.model.PolicyException;
-import org.jboss.security.authz.provisioning.spi.PolicyStore;
-
-/**
- *
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- *
- */
-public class HttpPolicyStore implements PolicyStore
-{
- /**
- * TODO: this method of Policy Storage is only for testing. Eventually this should be replaced by
- * a Database based Policy Storage Implementation
- */
- private Map<String, Policy> policies;
-
- public HttpPolicyStore()
- {
- this.policies = new HashMap<String, Policy>();
- }
-
- /**
- * Read a stored Policy identified by the unique policyUri
- *
- * @param policyUri
- * @return a stored Policy
- */
- public Policy readPolicy(String policyUri) throws PolicyException
- {
- return this.policies.get(policyUri);
- }
-
- /**
- * Returns all the stored Policies for the system
- *
- * @return all the stored Policies
- */
- public Policy[] readAllPolicies() throws PolicyException
- {
- return this.policies.values().toArray(new Policy[0]);
- }
-
- /**
- * Saves a Policy into storage. If this policy already exists in storage, then it updates it
- *
- * @param policy Policy to be saved into storage
- */
- public void savePolicy(Policy policy) throws PolicyException
- {
- this.policies.put(policy.getPolicyUri(), policy);
- }
-
- /**
- * Deletes the specified Policy from storage
- *
- * @param policyUri unique identifier for the Policy
- */
- public void deletePolicy(String policyUri) throws PolicyException
- {
- this.policies.remove(policyUri);
- }
-}
Modified: modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/provisioning/TestHttpPolicyConfig.java
===================================================================
--- modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/provisioning/TestHttpPolicyConfig.java 2009-02-02 11:20:45 UTC (rev 12765)
+++ modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/provisioning/TestHttpPolicyConfig.java 2009-02-02 11:41:03 UTC (rev 12766)
@@ -26,9 +26,9 @@
import org.apache.log4j.Logger;
-import org.jboss.security.authz.http.provisioning.HttpPolicyConfig;
+import org.jboss.security.authz.http.configuration.HttpPolicyConfig;
import org.jboss.security.authz.model.Policy;
-import org.jboss.security.authz.provisioning.spi.PolicyConfig;
+import org.jboss.security.authz.policy.server.spi.PolicyConfig;
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
Deleted: modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/provisioning/TestHttpPolicyDeployer.java
===================================================================
--- modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/provisioning/TestHttpPolicyDeployer.java 2009-02-02 11:20:45 UTC (rev 12765)
+++ modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/provisioning/TestHttpPolicyDeployer.java 2009-02-02 11:41:03 UTC (rev 12766)
@@ -1,62 +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.http.provisioning;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-
-import org.jboss.security.authz.model.Policy;
-import org.jboss.security.authz.policy.server.Server;
-import org.jboss.security.authz.provisioning.policy.PolicyDeployer;
-
-/**
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- *
- */
-public class TestHttpPolicyDeployer extends TestCase
-{
- private static Logger log = Logger.getLogger(TestHttpPolicyDeployer.class);
-
- @Override
- protected void setUp() throws Exception
- {
- Server.bootstrap();
- }
-
- public void testPolicyDeploy() throws Exception
- {
- PolicyDeployer policyDeployer = (PolicyDeployer)Server.lookup("/http-profile/PolicyDeployer");
-
- policyDeployer.deploy(Thread.currentThread().getContextClassLoader().getResource("http-policy.xml"));
-
- Policy[] policies = policyDeployer.getStore().readAllPolicies();
- this.assertTrue("Should not be empty", policies != null && policies.length>0);
- for(int i=0; i<policies.length; i++)
- {
- log.info("-------------------------------------------------------------");
- log.info(policies[i].generateXACMLPolicy());
- log.info("-------------------------------------------------------------");
- }
- }
-}
Modified: modules/authorization/trunk/policy-server/pom.xml
===================================================================
--- modules/authorization/trunk/policy-server/pom.xml 2009-02-02 11:20:45 UTC (rev 12765)
+++ modules/authorization/trunk/policy-server/pom.xml 2009-02-02 11:41:03 UTC (rev 12766)
@@ -23,6 +23,11 @@
<groupId>org.jboss.security.authz</groupId>
<artifactId>jboss-authz-enforcement</artifactId>
<version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.security.authz</groupId>
+ <artifactId>jboss-authz-provisioning</artifactId>
+ <version>${project.version}</version>
</dependency>
<!-- jboss xacml -->
Modified: modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java
===================================================================
--- modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java 2009-02-02 11:20:45 UTC (rev 12765)
+++ modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java 2009-02-02 11:41:03 UTC (rev 12766)
@@ -21,11 +21,12 @@
*/
package org.jboss.security.authz.policy.server;
-import java.io.File;
-
import org.apache.log4j.Logger;
+import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.model.PolicyException;
import org.jboss.security.authz.policy.server.decision.PolicyDecisionPoint;
+import org.jboss.security.authz.policy.server.spi.PolicyStore;
import org.jboss.security.authz.enforcement.Request;
import org.jboss.security.authz.enforcement.Response;
@@ -40,6 +41,7 @@
private static Logger log = Logger.getLogger(PolicyServer.class);
private PolicyDecisionPoint policyDecisionPoint;
+ private PolicyStore policyStore;
public PolicyServer()
{
@@ -64,6 +66,16 @@
{
this.policyDecisionPoint = policyDecisionPoint;
}
+
+ public PolicyStore getPolicyStore()
+ {
+ return policyStore;
+ }
+
+ public void setPolicyStore(PolicyStore policyStore)
+ {
+ this.policyStore = policyStore;
+ }
//--------Decision making services--------------------------------------------------------------------------------------------------------------------------
/**
* Makes an Authorization Decision
@@ -91,6 +103,45 @@
{
return this.policyDecisionPoint.evaluate(xml);
}
- //------- Provisioning services-----------------------------------------------------------------------------------------------------------------------------
-
+ //------- Provisioning services-----------------------------------------------------------------------------------------------------------------------------
+ /**
+ * Read a stored Policy identified by the unique policyUri
+ *
+ * @param policyUri
+ * @return a stored Policy
+ */
+ public Policy readPolicy(String policyUri) throws PolicyException
+ {
+ return this.policyStore.readPolicy(policyUri);
+ }
+
+ /**
+ * Returns all the stored Policies for the system
+ *
+ * @return all the stored Policies
+ */
+ public Policy[] readAllPolicies() throws PolicyException
+ {
+ return this.policyStore.readAllPolicies();
+ }
+
+ /**
+ * Saves a Policy into storage. If this policy already exists in storage, then it updates it
+ *
+ * @param policy Policy to be saved into storage
+ */
+ public void savePolicy(Policy policy) throws PolicyException
+ {
+ this.policyStore.savePolicy(policy);
+ }
+
+ /**
+ * Deletes the specified Policy from storage
+ *
+ * @param policyUri unique identifier for the Policy
+ */
+ public void deletePolicy(String policyUri) throws PolicyException
+ {
+ this.policyStore.deletePolicy(policyUri);
+ }
}
Added: modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/provisioning/MemoryPolicyStore.java
===================================================================
--- modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/provisioning/MemoryPolicyStore.java (rev 0)
+++ modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/provisioning/MemoryPolicyStore.java 2009-02-02 11:41:03 UTC (rev 12766)
@@ -0,0 +1,102 @@
+/******************************************************************************
+ * 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.policy.server.provisioning;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import org.apache.log4j.Logger;
+import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.model.PolicyException;
+import org.jboss.security.authz.policy.server.spi.PolicyStore;
+
+/**
+ * this method of Policy Storage is only for testing. In an Enterprise setup this would be replaced by a Database Policy Store
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MemoryPolicyStore implements PolicyStore
+{
+ private static Logger log = Logger.getLogger(MemoryPolicyStore.class);
+
+ private Map<String, Policy> policies;
+
+ public MemoryPolicyStore()
+ {
+ this.policies = new HashMap<String, Policy>();
+ }
+
+ public void start()
+ {
+ log.info("-----------------------------------------------------------------------");
+ log.info("In-Memory Policy Store successfully started............................");
+ log.info("-----------------------------------------------------------------------");
+ }
+
+ public void stop()
+ {
+
+ }
+ //-----------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ * Read a stored Policy identified by the unique policyUri
+ *
+ * @param policyUri
+ * @return a stored Policy
+ */
+ public Policy readPolicy(String policyUri) throws PolicyException
+ {
+ return this.policies.get(policyUri);
+ }
+
+ /**
+ * Returns all the stored Policies for the system
+ *
+ * @return all the stored Policies
+ */
+ public Policy[] readAllPolicies() throws PolicyException
+ {
+ return this.policies.values().toArray(new Policy[0]);
+ }
+
+ /**
+ * Saves a Policy into storage. If this policy already exists in storage, then it updates it
+ *
+ * @param policy Policy to be saved into storage
+ */
+ public void savePolicy(Policy policy) throws PolicyException
+ {
+ this.policies.put(policy.getPolicyUri(), policy);
+ }
+
+ /**
+ * Deletes the specified Policy from storage
+ *
+ * @param policyUri unique identifier for the Policy
+ */
+ public void deletePolicy(String policyUri) throws PolicyException
+ {
+ this.policies.remove(policyUri);
+ }
+}
Added: modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/provisioning/PolicyDeployer.java
===================================================================
--- modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/provisioning/PolicyDeployer.java (rev 0)
+++ modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/provisioning/PolicyDeployer.java 2009-02-02 11:41:03 UTC (rev 12766)
@@ -0,0 +1,128 @@
+/******************************************************************************
+ * 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.policy.server.provisioning;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.URL;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.model.PolicyException;
+import org.jboss.security.authz.policy.server.spi.PolicyConfig;
+import org.jboss.security.authz.policy.server.spi.PolicyStore;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class PolicyDeployer
+{
+ private static Logger log = Logger.getLogger(PolicyDeployer.class);
+
+ private PolicyConfig configuration = null;
+ private PolicyStore store = null;
+
+ public PolicyDeployer()
+ {
+
+ }
+
+ public PolicyConfig getConfiguration()
+ {
+ return configuration;
+ }
+
+ public void setConfiguration(PolicyConfig configuration)
+ {
+ this.configuration = configuration;
+ }
+
+ public PolicyStore getStore()
+ {
+ return store;
+ }
+
+ public void setStore(PolicyStore store)
+ {
+ this.store = store;
+ }
+
+ public void deploy(URL url) throws PolicyException
+ {
+ BufferedInputStream is = null;
+ ByteArrayOutputStream bos = null;
+ try
+ {
+ is = new BufferedInputStream(url.openStream());
+ bos = new ByteArrayOutputStream();
+
+ byte[] buffer = new byte[1024]; //using a 1K buffer
+ int bytesRead = -1;
+ while((bytesRead=is.read(buffer)) != -1)
+ {
+ bos.write(buffer, 0, bytesRead);
+ }
+
+ String deploymentXml = new String(bos.toByteArray());
+
+ //Get Policy instances
+ Policy[] policies = this.configuration.configure(deploymentXml);
+
+ //Persist Policy instances into the Policy Store
+ if(policies != null)
+ {
+ for(int i=0; i<policies.length; i++)
+ {
+ this.store.savePolicy(policies[i]);
+ }
+ }
+ }
+ catch(IOException ioe)
+ {
+ log.error(this, ioe);
+ throw new PolicyException(ioe);
+ }
+ finally
+ {
+ try
+ {
+ if(is != null)
+ {
+ is.close();
+ }
+
+ if(bos != null)
+ {
+ bos.close();
+ }
+ }
+ catch(IOException ioe)
+ {
+ log.warn(this, ioe);
+ }
+ }
+ }
+}
Added: modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/spi/PolicyConfig.java
===================================================================
--- modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/spi/PolicyConfig.java (rev 0)
+++ modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/spi/PolicyConfig.java 2009-02-02 11:41:03 UTC (rev 12766)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * 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.policy.server.spi;
+
+import org.jboss.security.authz.model.Policy;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public interface PolicyConfig
+{
+ /**
+ * Configures the Policy instances that can be represented in system level XACML format. The easyDomainXml is a user friendly XML configuration that is within the context
+ * of the application tier being protected. For instance, to apply Access Control at the web tier, the XML configuration would consist of Resources and
+ * Actions in the context of the Web Tier such as HTTP Uris, HttpServletRequest parameters, HTTP actions like GET, POST, PUT, etc
+ *
+ * @param easyDomainXml User Friendly XML configuration within the context of the Application being protected
+ * @return a fully configured Policy instance
+ */
+ public Policy[] configure(String easyDomainXml);
+}
Added: modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/spi/PolicyStore.java
===================================================================
--- modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/spi/PolicyStore.java (rev 0)
+++ modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/spi/PolicyStore.java 2009-02-02 11:41:03 UTC (rev 12766)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * 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.policy.server.spi;
+
+import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.model.PolicyException;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public interface PolicyStore
+{
+ /**
+ * Read a stored Policy identified by the unique policyUri
+ *
+ * @param policyUri
+ * @return a stored Policy
+ */
+ public Policy readPolicy(String policyUri) throws PolicyException;
+
+ /**
+ * Returns all the stored Policies for the system
+ *
+ * @return all the stored Policies
+ */
+ public Policy[] readAllPolicies() throws PolicyException;
+
+ /**
+ * Saves a Policy into storage. If this policy already exists in storage, then it updates it
+ *
+ * @param policy Policy to be saved into storage
+ */
+ public void savePolicy(Policy policy) throws PolicyException;
+
+ /**
+ * Deletes the specified Policy from storage
+ *
+ * @param policyUri unique identifier for the Policy
+ */
+ public void deletePolicy(String policyUri) throws PolicyException;
+}
Modified: modules/authorization/trunk/policy-server/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- modules/authorization/trunk/policy-server/src/main/resources/META-INF/jboss-beans.xml 2009-02-02 11:20:45 UTC (rev 12765)
+++ modules/authorization/trunk/policy-server/src/main/resources/META-INF/jboss-beans.xml 2009-02-02 11:41:03 UTC (rev 12766)
@@ -7,8 +7,14 @@
<property name="policyDecisionPoint">
<inject bean="/policy-server/PolicyDecisionPoint"/>
</property>
+ <property name="policyStore">
+ <inject bean="/policy-server/PolicyStore"/>
+ </property>
</bean>
<bean name="/policy-server/PolicyDecisionPoint" class="org.jboss.security.authz.policy.server.decision.PolicyDecisionPoint">
+ </bean>
+
+ <bean name="/policy-server/PolicyStore" class="org.jboss.security.authz.policy.server.provisioning.MemoryPolicyStore">
</bean>
</deployment>
\ No newline at end of file
Modified: modules/authorization/trunk/pom.xml
===================================================================
--- modules/authorization/trunk/pom.xml 2009-02-02 11:20:45 UTC (rev 12765)
+++ modules/authorization/trunk/pom.xml 2009-02-02 11:41:03 UTC (rev 12766)
@@ -13,7 +13,6 @@
<module>common</module>
<module>core-components</module>
<module>enforcement</module>
- <module>provisioning</module>
<module>policy-server</module>
<module>http-profile</module>
<!--
17 years, 3 months
JBoss Portal SVN: r12765 - branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium.
by portal-commits@lists.jboss.org
Author: vrockai
Date: 2009-02-02 06:20:45 -0500 (Mon, 02 Feb 2009)
New Revision: 12765
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java
Log:
dashboard layout fix
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java 2009-02-02 04:10:43 UTC (rev 12764)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java 2009-02-02 11:20:45 UTC (rev 12765)
@@ -10,7 +10,8 @@
*/
@Test(groups = { "cms_dashboard" }, enabled = true, description = "Dashboard issues test case.")
public class DashboardTestCase extends JBossPortalSeleniumTestCase {
-
+
+ private static final String SUB_LAYOUT_UPDATE = "//input[contains(@name,'dashboardLayoutForm:j_id12')]";
private static final String SUB_PAGE_RENAME = "//form[contains(@id,'renameForm')]/input[@type='submit']";
private static final String INP_PAGE_RENAME = "//input[contains(@id,'renameForm:newName')]";
private static final String LINK_WEATHER_PORTLET = "link=*WeatherPortlet*";
@@ -153,7 +154,7 @@
selenium.select(SEL_LAYOUT, "label=generic");
- selenium.click("//input[@name='jbpnsabcsnpbj:_viewRoot:dashboardLayoutForm:j_id12']");
+ selenium.click(SUB_LAYOUT_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_DASHBOARD);
17 years, 3 months
JBoss Portal SVN: r12764 - in modules/authorization/trunk: core-components/src/test/java/org/jboss/security/authz/components/subject and 2 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2009-02-01 23:10:43 -0500 (Sun, 01 Feb 2009)
New Revision: 12764
Modified:
modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/http/TestHttpResource.java
modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/subject/TestIdentity.java
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/provisioning/HttpPolicyConfig.java
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestDroolsFunction.java
Log:
fixing Policy code. Concept of PolicyMetaData introduced
Modified: modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/http/TestHttpResource.java
===================================================================
--- modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/http/TestHttpResource.java 2009-02-01 17:28:39 UTC (rev 12763)
+++ modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/http/TestHttpResource.java 2009-02-02 04:10:43 UTC (rev 12764)
@@ -49,7 +49,7 @@
Target target = httpResource.getURLTarget(false);
- Policy policy = new MockPolicy("testGetURLTargetNoParameters", target, new HashSet<Rule>());
+ Policy policy = new MockPolicy("testGetURLTargetNoParameters", httpResource.getPolicyMetaData(false));
log.info("------------------------------------------------------------------");
log.info(policy.generateXACMLPolicy());
@@ -64,7 +64,7 @@
Target target = httpResource.getURLTarget(true);
- Policy policy = new MockPolicy("testGetURLTargetWithParameters", target, new HashSet<Rule>());
+ Policy policy = new MockPolicy("testGetURLTargetWithParameters", httpResource.getPolicyMetaData(true));
log.info("------------------------------------------------------------------");
log.info(policy.generateXACMLPolicy());
@@ -84,7 +84,7 @@
rules.add(httpResource.getPermittedRolesRule());
rules.add(httpResource.getDeniedRolesRule());
- Policy policy = new MockPolicy("testRoleRules", target, rules);
+ Policy policy = new MockPolicy("testRoleRules", httpResource.getPolicyMetaData(true));
log.info("------------------------------------------------------------------");
log.info(policy.generateXACMLPolicy());
@@ -106,7 +106,7 @@
rules.add(httpResource.getDeniedRolesRule());
rules.add(httpResource.getAllowedIpsRule());
- Policy policy = new MockPolicy("testIPRules", target, rules);
+ Policy policy = new MockPolicy("testIPRules", httpResource.getPolicyMetaData(true));
log.info("------------------------------------------------------------------");
log.info(policy.generateXACMLPolicy());
Modified: modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/subject/TestIdentity.java
===================================================================
--- modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/subject/TestIdentity.java 2009-02-01 17:28:39 UTC (rev 12763)
+++ modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/subject/TestIdentity.java 2009-02-02 04:10:43 UTC (rev 12764)
@@ -27,6 +27,7 @@
import junit.framework.TestCase;
import org.apache.log4j.Logger;
+import org.jboss.security.authz.model.PolicyMetaData;
import org.jboss.security.authz.model.Target;
import org.jboss.security.authz.model.Policy;
import org.jboss.security.authz.model.Rule;
@@ -52,7 +53,10 @@
Set<Rule> rules = new HashSet<Rule>();
rules.add(identity.getAllowAuthMethodRule());
- Policy policy = new MockPolicy("testGetAllowAuthMethodRule", target, rules);
+ PolicyMetaData metadata = new PolicyMetaData();
+ metadata.setTarget(target);
+ metadata.setRules(rules);
+ Policy policy = new MockPolicy("testGetAllowAuthMethodRule", metadata);
log.info("----------------------------------------------------------------");
log.info(policy.generateXACMLPolicy());
@@ -70,7 +74,10 @@
Set<Rule> rules = new HashSet<Rule>();
rules.add(identity.getDenyAuthMethodRule());
- Policy policy = new MockPolicy("testGetDenyAuthMethodRule", target, rules);
+ PolicyMetaData metadata = new PolicyMetaData();
+ metadata.setTarget(target);
+ metadata.setRules(rules);
+ Policy policy = new MockPolicy("testGetDenyAuthMethodRule", metadata);
log.info("----------------------------------------------------------------");
log.info(policy.generateXACMLPolicy());
@@ -88,7 +95,10 @@
Set<Rule> rules = new HashSet<Rule>();
rules.add(identity.getAllowIdentityRule());
- Policy policy = new MockPolicy("testGetAllowIdentityRule", target, rules);
+ PolicyMetaData metadata = new PolicyMetaData();
+ metadata.setTarget(target);
+ metadata.setRules(rules);
+ Policy policy = new MockPolicy("testGetAllowIdentityRule", metadata);
log.info("----------------------------------------------------------------");
log.info(policy.generateXACMLPolicy());
@@ -105,9 +115,12 @@
Set<Rule> rules = new HashSet<Rule>();
rules.add(identity.getDenyIdentityRule());
+
+ PolicyMetaData metadata = new PolicyMetaData();
+ metadata.setTarget(target);
+ metadata.setRules(rules);
+ Policy policy = new MockPolicy("testGetDenyIdentityRule", metadata);
- Policy policy = new MockPolicy("testGetDenyIdentityRule", target, rules);
-
log.info("----------------------------------------------------------------");
log.info(policy.generateXACMLPolicy());
}
Modified: modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/provisioning/HttpPolicyConfig.java
===================================================================
--- modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/provisioning/HttpPolicyConfig.java 2009-02-01 17:28:39 UTC (rev 12763)
+++ modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/provisioning/HttpPolicyConfig.java 2009-02-02 04:10:43 UTC (rev 12764)
@@ -84,35 +84,9 @@
HttpResource httpResource = new HttpResource();
this.parseTarget(httpResource, aclRuleElem);
this.parseRules(httpResource, aclRuleElem);
-
-
- Target target = httpResource.getURLTarget(true); //a target with all the parameters matched
-
- Set<Rule> rules = new HashSet<Rule>();
-
- //Permitted Roles
- Rule permittedRoles = httpResource.getPermittedRolesRule();
- if(permittedRoles != null)
- {
- rules.add(permittedRoles);
- }
-
- //Denied Roles
- Rule deniedRoles = httpResource.getDeniedRolesRule();
- if(deniedRoles != null)
- {
- rules.add(deniedRoles);
- }
-
- //AllowedIP Rules
- Rule allowedIps = httpResource.getAllowedIpsRule();
- if(allowedIps != null)
- {
- rules.add(allowedIps);
- }
-
+
//Generate the policy from the HttpResource component
- Policy policy = new HierarchialPolicy(policyUri, target, rules);
+ Policy policy = new HierarchialPolicy(policyUri, httpResource.getPolicyMetaData(true));
cour.add(policy);
}
Modified: modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestDroolsFunction.java
===================================================================
--- modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestDroolsFunction.java 2009-02-01 17:28:39 UTC (rev 12763)
+++ modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestDroolsFunction.java 2009-02-02 04:10:43 UTC (rev 12764)
@@ -212,7 +212,10 @@
rules.add(writeRule);
//Populate the HierarchialPolicy
- HierarchialPolicy policy = new HierarchialPolicy("simpleHierarchialPolicy", target, rules);
+ PolicyMetaData metadata = new PolicyMetaData();
+ metadata.setTarget(target);
+ metadata.setRules(rules);
+ HierarchialPolicy policy = new HierarchialPolicy("simpleHierarchialPolicy", metadata);
return policy;
}
17 years, 3 months
JBoss Portal SVN: r12763 - in modules/authorization/trunk: common/src/main/java/org/jboss/security/authz/model and 4 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2009-02-01 12:28:39 -0500 (Sun, 01 Feb 2009)
New Revision: 12763
Added:
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/PolicyMetaData.java
Modified:
modules/authorization/trunk/.classpath
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Policy.java
modules/authorization/trunk/core-components/src/main/java/org/jboss/security/authz/components/http/HttpResource.java
modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/test/MockPolicy.java
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/HierarchialPolicy.java
Log:
backing up code.....leaving the hospital finallyyyyyyy ;)
Modified: modules/authorization/trunk/.classpath
===================================================================
--- modules/authorization/trunk/.classpath 2009-02-01 15:16:39 UTC (rev 12762)
+++ modules/authorization/trunk/.classpath 2009-02-01 17:28:39 UTC (rev 12763)
@@ -16,14 +16,14 @@
<classpathentry kind="src" path="provisioning/src/main/resources"/>
<classpathentry kind="src" path="provisioning/src/test/java"/>
<classpathentry kind="src" path="provisioning/src/test/resources"/>
- <classpathentry kind="src" path="http-profile/src/main/java"/>
- <classpathentry kind="src" path="http-profile/src/main/resources"/>
- <classpathentry kind="src" path="http-profile/src/test/java"/>
- <classpathentry kind="src" path="http-profile/src/test/resources"/>
<classpathentry kind="src" path="policy-server/src/main/java"/>
<classpathentry kind="src" path="policy-server/src/main/resources"/>
<classpathentry kind="src" path="policy-server/src/test/java"/>
<classpathentry kind="src" path="policy-server/src/test/resources"/>
+ <classpathentry kind="src" path="http-profile/src/main/java"/>
+ <classpathentry kind="src" path="http-profile/src/main/resources"/>
+ <classpathentry kind="src" path="http-profile/src/test/java"/>
+ <classpathentry kind="src" path="http-profile/src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="M2_REPO/asm/asm/1.5.3/asm-1.5.3.jar"/>
<classpathentry kind="var" path="M2_REPO/cglib/cglib/2.1_3/cglib-2.1_3.jar"/>
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 2009-02-01 15:16:39 UTC (rev 12762)
+++ modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/Policy.java 2009-02-01 17:28:39 UTC (rev 12763)
@@ -22,10 +22,6 @@
******************************************************************************/
package org.jboss.security.authz.model;
-import java.util.Set;
-import java.util.HashSet;
-
-
/**
* Represents an Authorization Policy
*
@@ -34,50 +30,27 @@
*/
public abstract class Policy extends BaseObject
{
- protected String policyUri = null;
- 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");
- }
+ protected String policyUri;
+ protected PolicyMetaData metaData;
- this.policyUri = policyUri;
- this.rules = new HashSet<Rule>();
- }
-
-
/**
*
*
*/
- public Policy(String policyUri, Target target, Set<Rule> rules)
+ public Policy(String policyUri, PolicyMetaData metaData)
{
if(policyUri == null)
{
throw new IllegalArgumentException("PolicyUri cannot be Null");
}
- if(target == null)
+ if(metaData == null)
{
- throw new IllegalArgumentException("Target cannot be Null");
+ throw new IllegalArgumentException("PolicyMetaData cannot be Null");
}
-
- if(rules == null)
- {
- throw new IllegalArgumentException("Rules cannot be Null");
- }
-
+
this.policyUri = policyUri;
- this.target = target;
- this.rules = rules;
+ this.metaData = metaData;
}
/**
@@ -99,29 +72,16 @@
this.policyUri = policyUri;
}
- public Set<Rule> getRules()
+
+ public PolicyMetaData getMetaData()
{
- return rules;
+ return metaData;
}
- public void setRules(Set<Rule> rules)
+ public void setMetaData(PolicyMetaData metaData)
{
- if(rules == null)
- {
- rules = new HashSet<Rule>();
- }
- this.rules = rules;
+ this.metaData = metaData;
}
-
- public Target getTarget()
- {
- return target;
- }
-
- public void setTarget(Target target)
- {
- this.target = target;
- }
//------------------------------------------------------------------------------------------------------------------------------------------------
/**
* Generates the standard XACML markup that represents the Policy instance in question
Added: modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/PolicyMetaData.java
===================================================================
--- modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/PolicyMetaData.java (rev 0)
+++ modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/model/PolicyMetaData.java 2009-02-01 17:28:39 UTC (rev 12763)
@@ -0,0 +1,60 @@
+/*
+* 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 java.io.Serializable;
+import java.util.Set;
+
+/**
+ * Represents the Policy Information that is required to generate an instance of a Policy
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class PolicyMetaData implements Serializable
+{
+ private Target target;
+ private Set<Rule> rules;
+
+ public PolicyMetaData()
+ {
+ }
+
+ public Target getTarget()
+ {
+ return target;
+ }
+
+ public void setTarget(Target target)
+ {
+ this.target = target;
+ }
+
+ public Set<Rule> getRules()
+ {
+ return rules;
+ }
+
+ public void setRules(Set<Rule> rules)
+ {
+ this.rules = rules;
+ }
+}
Modified: modules/authorization/trunk/core-components/src/main/java/org/jboss/security/authz/components/http/HttpResource.java
===================================================================
--- modules/authorization/trunk/core-components/src/main/java/org/jboss/security/authz/components/http/HttpResource.java 2009-02-01 15:16:39 UTC (rev 12762)
+++ modules/authorization/trunk/core-components/src/main/java/org/jboss/security/authz/components/http/HttpResource.java 2009-02-01 17:28:39 UTC (rev 12763)
@@ -34,6 +34,7 @@
import org.jboss.security.authz.model.Target;
import org.jboss.security.authz.model.Attribute;
import org.jboss.security.authz.model.Resource;
+import org.jboss.security.authz.model.PolicyMetaData;
import org.jboss.security.authz.tools.GeneralTool;
import org.jboss.security.xacml.interfaces.XACMLConstants;
@@ -285,6 +286,41 @@
return rule;
}
+
+ public PolicyMetaData getPolicyMetaData(boolean matchAllParameters)
+ {
+ PolicyMetaData metadata = new PolicyMetaData();
+
+ Target target = this.getURLTarget(matchAllParameters);
+
+ Set<Rule> rules = new HashSet<Rule>();
+
+ //Permitted Roles
+ Rule permittedRoles = this.getPermittedRolesRule();
+ if(permittedRoles != null)
+ {
+ rules.add(permittedRoles);
+ }
+
+ //Denied Roles
+ Rule deniedRoles = this.getDeniedRolesRule();
+ if(deniedRoles != null)
+ {
+ rules.add(deniedRoles);
+ }
+
+ //AllowedIP Rules
+ Rule allowedIps = this.getAllowedIpsRule();
+ if(allowedIps != null)
+ {
+ rules.add(allowedIps);
+ }
+
+ metadata.setTarget(target);
+ metadata.setRules(rules);
+
+ return metadata;
+ }
//---------Services for RequestContext Generation------------------------------------------------------------------------------------------------------------------------------
/**
* Represents the Resource that is currently being accessed
Modified: modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/test/MockPolicy.java
===================================================================
--- modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/test/MockPolicy.java 2009-02-01 15:16:39 UTC (rev 12762)
+++ modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/test/MockPolicy.java 2009-02-01 17:28:39 UTC (rev 12763)
@@ -31,8 +31,8 @@
import javax.xml.bind.JAXBElement;
import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.model.PolicyMetaData;
import org.jboss.security.authz.model.Rule;
-import org.jboss.security.authz.model.Target;
import org.jboss.security.authz.model.Effect;
import org.jboss.security.authz.model.PolicyException;
import org.jboss.security.authz.model.AttributeExpression;
@@ -72,18 +72,10 @@
*/
public class MockPolicy extends Policy
{
- /**
- *
- * @param policyUri
- */
- public MockPolicy(String policyUri)
- {
- super(policyUri);
- }
- public MockPolicy(String policyUri, Target target, Set<Rule> rules) throws PolicyException
+ public MockPolicy(String policyUri, PolicyMetaData metaData) throws PolicyException
{
- super(policyUri, target, rules);
+ super(policyUri, metaData);
}
@@ -106,7 +98,7 @@
policyType.setTarget(targetType);
//Process Resource Matches as Targets for the Policy
- List<AttributeExpression> resourceMatches = this.target.getResourceMatches();
+ List<AttributeExpression> resourceMatches = this.metaData.getTarget().getResourceMatches();
if(resourceMatches != null && !resourceMatches.isEmpty())
{
ResourcesType resourcesType = new ResourcesType();
@@ -129,9 +121,10 @@
}
//Process the Policy Rules
- if(this.rules != null && !this.rules.isEmpty())
+ Set<Rule> rules = this.metaData.getRules();
+ if(rules != null && !rules.isEmpty())
{
- for(Rule rule: this.rules)
+ for(Rule rule: rules)
{
RuleType ruleType = new RuleType();
ruleType.setRuleId(rule.getRuleId());
Modified: modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java
===================================================================
--- modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java 2009-02-01 15:16:39 UTC (rev 12762)
+++ modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java 2009-02-01 17:28:39 UTC (rev 12763)
@@ -92,4 +92,5 @@
return this.policyDecisionPoint.evaluate(xml);
}
//------- Provisioning services-----------------------------------------------------------------------------------------------------------------------------
+
}
Modified: modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/HierarchialPolicy.java
===================================================================
--- modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/HierarchialPolicy.java 2009-02-01 15:16:39 UTC (rev 12762)
+++ modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/HierarchialPolicy.java 2009-02-01 17:28:39 UTC (rev 12763)
@@ -26,7 +26,6 @@
import java.util.Set;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.util.UUID;
import javax.xml.bind.JAXBElement;
@@ -39,7 +38,7 @@
import org.jboss.security.authz.model.Policy;
import org.jboss.security.authz.model.PolicyException;
import org.jboss.security.authz.model.Rule;
-import org.jboss.security.authz.model.Target;
+import org.jboss.security.authz.model.PolicyMetaData;
import org.jboss.security.xacml.core.model.policy.ActionMatchType;
import org.jboss.security.xacml.core.model.policy.SubjectMatchType;
@@ -71,20 +70,11 @@
*
*/
public class HierarchialPolicy extends Policy
-{
- /**
- *
- * @param policyUri
- */
- public HierarchialPolicy(String policyUri)
+{
+ public HierarchialPolicy(String policyUri, PolicyMetaData metaData) throws PolicyException
{
- super(policyUri);
+ super(policyUri, metaData);
}
-
- public HierarchialPolicy(String policyUri, Target target, Set<Rule> rules) throws PolicyException
- {
- super(policyUri, target, rules);
- }
@Override
@@ -106,7 +96,7 @@
policyType.setTarget(targetType);
//Process Resource Matches as Targets for the Policy
- List<AttributeExpression> resourceMatches = this.target.getResourceMatches();
+ List<AttributeExpression> resourceMatches = this.metaData.getTarget().getResourceMatches();
if(resourceMatches != null && !resourceMatches.isEmpty())
{
ResourcesType resourcesType = new ResourcesType();
@@ -129,9 +119,10 @@
}
//Process the Policy Rules
- if(this.rules != null && !this.rules.isEmpty())
+ Set<Rule> rules = this.metaData.getRules();
+ if(rules != null && !rules.isEmpty())
{
- for(Rule rule: this.rules)
+ for(Rule rule: rules)
{
RuleType ruleType = new RuleType();
ruleType.setRuleId(rule.getRuleId());
@@ -274,10 +265,5 @@
}
return condition;
- }
-
- private String generateUniqueId()
- {
- return UUID.randomUUID().toString();
- }
+ }
}
17 years, 3 months