JBoss Portal SVN: r13458 - branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2009-06-15 17:56:01 -0400 (Mon, 15 Jun 2009)
New Revision: 13458
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java
Log:
JBPORTAL-2413: Fixed issue with predefined properties. Values should also be properly validated now.
Modified: branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java 2009-06-15 21:31:18 UTC (rev 13457)
+++ branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java 2009-06-15 21:56:01 UTC (rev 13458)
@@ -23,6 +23,7 @@
package org.jboss.portal.core.admin.ui.actions;
+import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.core.admin.ui.PortalObjectManagerBean;
import org.jboss.portal.core.impl.model.portal.PortalObjectImpl;
import org.jboss.portal.faces.gui.ManagedBean;
@@ -51,6 +52,14 @@
public PropertyAction(PortalObjectManagerBean pomgr)
{
this.pomgr = pomgr;
+ setValidator(new DefaultPropertyValidator()
+ {
+ @Override
+ public String doSimpleChecks(String name)
+ {
+ return name.indexOf('/') != -1 ? null : name;
+ }
+ });
}
public String getSelectedProperty()
@@ -85,14 +94,21 @@
public void updateProperty()
{
- String propertyName = checkNameValidity(otherPropertyName, "common-edit-prop-form:property");
- if (propertyName != null)
+ String propertyName = null;
+ if (!ParameterValidation.isNullOrEmpty(otherPropertyName))
{
- if (propertyName.length() == 0 && selectedProperty != null)
+ propertyName = checkNameValidity(otherPropertyName, "common-edit-prop-form:property");
+ }
+ else
+ {
+ if (selectedProperty != null)
{
propertyName = selectedProperty.trim();
}
+ }
+ if (propertyName != null)
+ {
if (propertyName.length() > 0)
{
String value = "";
16 years, 10 months
JBoss Portal SVN: r13457 - in modules/authorization/trunk: core-components-api/src/main/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-06-15 17:31:18 -0400 (Mon, 15 Jun 2009)
New Revision: 13457
Added:
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/RuleComposer.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/RuleComposition.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/TargetComposition.java
modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/repository/TestPolicyComposition.java
Modified:
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentCategory.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/PolicyComposer.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Roles.java
modules/authorization/trunk/core-components-api/src/main/resources/authz-components.xml
Log:
backing up Policy Composition Framework prototyping code
Modified: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentCategory.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentCategory.java 2009-06-15 16:26:03 UTC (rev 13456)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentCategory.java 2009-06-15 21:31:18 UTC (rev 13457)
@@ -21,10 +21,57 @@
*/
package org.jboss.security.authz.component;
+import org.jboss.security.authz.model.Target;
+import org.jboss.security.authz.model.AttributeExpression;
+import org.jboss.security.xacml.interfaces.XACMLConstants;
+
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*/
public enum ComponentCategory
{
- RESOURCE, SUBJECT, ACTION, ENVIRONMENT
+ RESOURCE
+ {
+ String getAttributeCategory()
+ {
+ return XACMLConstants.ATTRIBUTEID_RESOURCE_ID;
+ }
+
+ void setExpression(Target target,AttributeExpression expression)
+ {
+ target.addResourceMatch(expression);
+ }
+ },
+
+
+ SUBJECT
+ {
+ String getAttributeCategory()
+ {
+ return XACMLConstants.ATTRIBUTEID_SUBJECT_ID;
+ }
+
+ void setExpression(Target target, AttributeExpression expression)
+ {
+ target.addSubjectMatch(expression);
+ }
+ },
+
+
+ ACTION
+ {
+ String getAttributeCategory()
+ {
+ return XACMLConstants.ATTRIBUTEID_ACTION_ID;
+ }
+
+ void setExpression(Target target, AttributeExpression expression)
+ {
+ target.addActionMatch(expression);
+ }
+ };
+
+ //Define the enum behavior
+ abstract String getAttributeCategory();
+ abstract void setExpression(Target target, AttributeExpression expression);
}
Modified: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/PolicyComposer.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/PolicyComposer.java 2009-06-15 16:26:03 UTC (rev 13456)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/PolicyComposer.java 2009-06-15 21:31:18 UTC (rev 13457)
@@ -26,5 +26,5 @@
*/
public class PolicyComposer
{
-
+
}
Added: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/RuleComposer.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/RuleComposer.java (rev 0)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/RuleComposer.java 2009-06-15 21:31:18 UTC (rev 13457)
@@ -0,0 +1,30 @@
+/*
+* 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.component;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class RuleComposer
+{
+
+}
Added: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/RuleComposition.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/RuleComposition.java (rev 0)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/RuleComposition.java 2009-06-15 21:31:18 UTC (rev 13457)
@@ -0,0 +1,174 @@
+/*
+* 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.component;
+
+import java.lang.reflect.Method;
+import java.lang.annotation.Annotation;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.security.authz.model.Rule;
+import org.jboss.security.authz.model.Expression;
+import org.jboss.security.authz.model.Effect;
+import org.jboss.security.authz.model.DroolsRuleExpression;
+import org.jboss.security.authz.tools.GeneralTool;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class RuleComposition
+{
+ private static Logger log = Logger.getLogger(RuleComposition.class);
+
+ private Object targetComponent;
+ private Object logicComponent;
+ private String expressionName;
+ private Effect effect;
+
+ public RuleComposition()
+ {
+
+ }
+
+ public Object getTargetComponent()
+ {
+ return targetComponent;
+ }
+
+ public void setTargetComponent(Object targetComponent)
+ {
+ this.targetComponent = targetComponent;
+ }
+
+ public Object getLogicComponent()
+ {
+ return logicComponent;
+ }
+
+ public void setLogicComponent(Object logicComponent)
+ {
+ this.logicComponent = logicComponent;
+ }
+
+ public Effect getEffect()
+ {
+ return effect;
+ }
+
+ public void setEffect(Effect effect)
+ {
+ this.effect = effect;
+ }
+
+ public String getExpressionName()
+ {
+ return expressionName;
+ }
+
+ public void setExpressionName(String expressionName)
+ {
+ this.expressionName = expressionName;
+ }
+ //----------------------------------------------------------------------------------------------------------------------------------------------------------------
+ public Rule compose()
+ {
+ if(this.effect == null)
+ {
+ throw new IllegalStateException("Effect is missing!!");
+ }
+
+ if(this.expressionName != null)
+ {
+ if(this.logicComponent == null)
+ {
+ throw new IllegalStateException("Logic Component is missing!!");
+ }
+ }
+
+ try
+ {
+ Rule rule = new Rule();
+
+ rule.setRuleId(GeneralTool.generateUniqueId());
+ rule.setEffect(this.effect);
+
+ //Generate the Target for this rule
+ if(this.targetComponent != null)
+ {
+ TargetComposition targetComposition = new TargetComposition();
+ targetComposition.setTargetComponent(this.targetComponent);
+ rule.setTarget(targetComposition.compose());
+ }
+
+ //Generate the Logic Expression of this rule
+ if(this.expressionName != null)
+ {
+ rule.setExpression(this.generateExpression());
+ }
+
+ return rule;
+ }
+ catch(Exception e)
+ {
+ //TODO: handle this properly
+ log.error(this, e);
+ throw new RuntimeException(e);
+ }
+ }
+ //----------------------------------------------------------------------------------------------------------------------------------------------------------------
+ private Expression generateExpression() throws Exception
+ {
+ DroolsRuleExpression expression = new DroolsRuleExpression();
+
+ //Read the LogicExpression of the Logic Component
+ Method expressionMethod = this.findExpression(this.logicComponent.getClass(), this.expressionName);
+ expressionMethod.setAccessible(true);
+
+ String[] expressionMetaData = (String[])expressionMethod.invoke(this.logicComponent, null);
+
+ expression.setRuleReference(expressionMetaData[0]);
+ expression.setRule(expressionMetaData[1]);
+
+ return expression;
+ }
+
+ private Method findExpression(Class targetClass, String expressionName)
+ {
+ Method[] declaredMethods = targetClass.getDeclaredMethods();
+ if(declaredMethods != null)
+ {
+ for(Method declaredMethod: declaredMethods)
+ {
+ Annotation logicExpression = declaredMethod.getAnnotation(LogicExpression.class);
+ if(logicExpression != null)
+ {
+ if(declaredMethod.getName().equals(expressionName))
+ {
+ return declaredMethod;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+}
Added: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/TargetComposition.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/TargetComposition.java (rev 0)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/TargetComposition.java 2009-06-15 21:31:18 UTC (rev 13457)
@@ -0,0 +1,160 @@
+/*
+* 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.component;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.security.authz.model.Target;
+import org.jboss.security.authz.model.Attribute;
+import org.jboss.security.authz.model.AttributeExpression;
+import org.jboss.security.xacml.interfaces.XACMLConstants;
+import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class TargetComposition
+{
+ private static Logger log = Logger.getLogger(TargetComposition.class);
+
+ private Object targetComponent;
+
+ public TargetComposition()
+ {
+
+ }
+
+ public Object getTargetComponent()
+ {
+ return targetComponent;
+ }
+
+ public void setTargetComponent(Object targetComponent)
+ {
+ this.targetComponent = targetComponent;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ public Target compose()
+ {
+ if(this.targetComponent == null)
+ {
+ throw new IllegalStateException("Target Component is null!!");
+ }
+
+ try
+ {
+ return this.generateTarget();
+ }
+ catch(Exception e)
+ {
+ //TODO: handle this properly
+ log.error(this, e);
+ throw new RuntimeException(e);
+ }
+ }
+ //----------------------------------------------------------------------------------------------------------------------------------------------------------------
+ //TODO: Add TargetUri annotation inheritance
+ private Target generateTarget() throws Exception
+ {
+ Target target = new Target();
+
+ //Read the TargetUri
+ Field targetField = this.findTargetField(this.targetComponent.getClass());
+ targetField.setAccessible(true);
+ Object targetUriObj = targetField.get(this.targetComponent);
+
+ //Get a String representation of this URI
+ String uriStr = targetUriObj.toString();
+
+ //use the proper category for the data
+ ComponentCategory category = this.findComponentCategory(this.targetComponent.getClass());
+ String attributeCategory = category.getAttributeCategory();
+
+ AttributeExpression urlExpression = new AttributeExpression();
+ if (uriStr.charAt(0) == '/' && uriStr.endsWith("/*"))
+ {
+ // If URL starts with '/' and ends with "/*", use a regular
+ // expression to match it (In consistency with the servlet spec)
+ urlExpression
+ .setFunctionId(XACMLConstants.FUNCTION_REGEXP_STRING_MATCH);
+
+ String uriexp = uriStr.substring(1, uriStr.length() - 2);
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("^/" + uriexp + "$|");
+ buffer.append("^" + uriexp + "$|");
+ buffer.append("^/" + uriexp + "/.*|");
+ buffer.append("^" + uriexp + "/.*");
+
+ Attribute attribute = new Attribute(
+ attributeCategory,
+ XMLSchemaConstants.DATATYPE_STRING, buffer.toString());
+ urlExpression.setAttribute(attribute);
+ }
+ else
+ {
+ // use an exact match
+ urlExpression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
+
+ Attribute attribute = new Attribute(
+ attributeCategory,
+ XMLSchemaConstants.DATATYPE_STRING, uriStr);
+ urlExpression.setAttribute(attribute);
+ }
+
+ //Depending up the data category add the appropriate match expression
+ category.setExpression(target, urlExpression);
+
+ return target;
+ }
+
+ private ComponentCategory findComponentCategory(Class targetClass)
+ {
+ Annotation component = targetClass.getAnnotation(Component.class);
+ if(component != null)
+ {
+ return ((Component)component).category();
+ }
+
+ return null;
+ }
+
+ private Field findTargetField(Class targetClass)
+ {
+ Field[] declaredFields = targetClass.getDeclaredFields();
+ if(declaredFields != null)
+ {
+ for(Field declaredField: declaredFields)
+ {
+ Annotation targetUri = declaredField.getAnnotation(TargetUri.class);
+ if(targetUri != null)
+ {
+ return declaredField;
+ }
+ }
+ }
+
+ return null;
+ }
+}
Modified: modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Roles.java
===================================================================
--- modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Roles.java 2009-06-15 16:26:03 UTC (rev 13456)
+++ modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Roles.java 2009-06-15 21:31:18 UTC (rev 13457)
@@ -130,7 +130,6 @@
*
* @return the rule
*/
- @LogicExpression
public Rule allowIfUserHasRole()
{
if(this.getNames().isEmpty())
@@ -168,7 +167,6 @@
*
* @return the rule
*/
- @LogicExpression
public Rule denyIfUserHasRole()
{
if(this.getNames().isEmpty())
@@ -222,4 +220,52 @@
return subject;
}
+ //------------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ * Creates a Policy Rule suggesting the roles indicated by this object are permitted access to the 'Resource' designated in the Policy
+ * The User must belong to atleast one of the specified roles to gain access
+ *
+ * @return the rule
+ */
+ @LogicExpression
+ public String[] allowExpression()
+ {
+ String ruleReference = "roles://allowRule/"+GeneralTool.generateUniqueId();
+
+ //Generate a Drools Rule Expression
+ StringBuffer buffer = new StringBuffer();
+ for(String role: this.getNames())
+ {
+ buffer.append("$roles.contains(\""+role.toLowerCase()+"\") || ");
+ }
+ String condition = buffer.toString().trim();
+ String ruleLogic = MessageFormat.format(Roles.allowRule,
+ ruleReference, condition.substring(0, condition.length()-2).trim());
+
+ return new String[]{ruleReference, buffer.toString()};
+ }
+
+ /**
+ * Creates a Policy Rule suggesting the roles indicated by this object are denied access to the 'Resource' designated in the Policy
+ * If the user belongs to atleast one of these roles, he will be denied access
+ *
+ * @return the rule
+ */
+ @LogicExpression
+ public String[] denyExpression()
+ {
+ String ruleReference = "roles://denyRule/"+GeneralTool.generateUniqueId();
+
+ //Generate a Drools Rule Expression
+ StringBuffer buffer = new StringBuffer();
+ for(String role: this.getNames())
+ {
+ buffer.append("$roles.contains(\""+role.toLowerCase()+"\") || ");
+ }
+ String condition = buffer.toString().trim();
+ String ruleLogic = MessageFormat.format(Roles.denyRule,
+ ruleReference, condition.substring(0, condition.length()-2).trim());
+
+ return new String[]{ruleReference, buffer.toString()};
+ }
}
Modified: modules/authorization/trunk/core-components-api/src/main/resources/authz-components.xml
===================================================================
--- modules/authorization/trunk/core-components-api/src/main/resources/authz-components.xml 2009-06-15 16:26:03 UTC (rev 13456)
+++ modules/authorization/trunk/core-components-api/src/main/resources/authz-components.xml 2009-06-15 21:31:18 UTC (rev 13457)
@@ -36,8 +36,8 @@
<data>names</data>
</logic-data>
<logic-expressions>
- <expression>permitOperationIfUserHasRole</expression>
- <expression>denyOperationIfUserHasRole</expression>
+ <expression>allowExpression</expression>
+ <expression>denyExpression</expression>
</logic-expressions>
</logic-component>
@@ -46,16 +46,6 @@
Core Rule Compositions shipped with the framework. These can be re-used and more compositions can be added
depending upon Application/Profile Requirements
-->
- <rule-composition name="permitOperationIfUserHasRole" outcome="permit">
- <target-component>operation</target-component>
- <logic-component>roles</logic-component>
- </rule-composition>
-
- <rule-composition name="denyOperationIfUserHasRole" outcome="deny">
- <target-component>operation</target-component>
- <logic-component>roles</logic-component>
- </rule-composition>
-
<rule-composition name="permitIdentity" outcome="permit">
<target-component>identity</target-component>
</rule-composition>
@@ -63,4 +53,14 @@
<rule-composition name="denyIdentity" outcome="deny">
<target-component>identity</target-component>
</rule-composition>
+
+ <rule-composition name="permitRole" outcome="permit">
+ <target-component>operation</target-component>
+ <logic-component expression="allowExpression">roles</logic-component>
+ </rule-composition>
+
+ <rule-composition name="denyRole" outcome="deny">
+ <target-component>operation</target-component>
+ <logic-component expression="denyExpression">roles</logic-component>
+ </rule-composition>
</components>
\ No newline at end of file
Added: modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/repository/TestPolicyComposition.java
===================================================================
--- modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/repository/TestPolicyComposition.java (rev 0)
+++ modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/repository/TestPolicyComposition.java 2009-06-15 21:31:18 UTC (rev 13457)
@@ -0,0 +1,126 @@
+/*
+* 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.repository;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.security.authz.model.Effect;
+import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.model.PolicyMetaData;
+import org.jboss.security.authz.model.Target;
+import org.jboss.security.authz.model.Rule;
+
+import org.jboss.security.authz.components.subject.Identity;
+import org.jboss.security.authz.components.subject.Roles;
+import org.jboss.security.authz.components.action.Read;
+import org.jboss.security.authz.components.resource.URIResource;
+import org.jboss.security.authz.component.RuleComposition;
+import org.jboss.security.authz.component.TargetComposition;
+
+import org.jboss.security.authz.test.MockPolicy;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class TestPolicyComposition extends TestCase
+{
+ private static Logger log = Logger.getLogger(TestPolicyComposition.class);
+
+ protected void setUp() throws Exception
+ {
+ }
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------
+ public void testComposePermitIdentity() throws Exception
+ {
+ URIResource uriResource = new URIResource();
+ uriResource.setUri(new URI("/portal/admin-tool/modifyLayout"));
+
+ Identity identity = new Identity();
+ identity.setName("blahUser");
+
+ TargetComposition targetComposition = new TargetComposition();
+ targetComposition.setTargetComponent(uriResource);
+
+ RuleComposition ruleComposition = new RuleComposition();
+ ruleComposition.setTargetComponent(identity);
+ ruleComposition.setEffect(Effect.PERMIT);
+
+
+ Target policyTarget = targetComposition.compose();
+ Rule policyRule = ruleComposition.compose();
+
+ //Assert the State
+ assertNotNull("Target must not be null!!", policyTarget);
+ assertNotNull("Rule must not be null!!", policyRule);
+
+ PolicyMetaData metadata = new PolicyMetaData();
+ metadata.setTarget(policyTarget);
+ metadata.addRule(policyRule);
+ Policy policy = new MockPolicy("testComposePermitIdentity", metadata);
+
+ log.info("----------------------------------------------------------------");
+ log.info(policy.generateSystemPolicy());
+ }
+
+ public void testComposePermitRole() throws Exception
+ {
+ Roles roles = new Roles();
+ Set<String> names = new HashSet<String>();
+ names.add("admin");
+ names.add("user");
+ roles.setNames(names);
+
+ URIResource uriResource = new URIResource();
+ uriResource.setUri(new URI("/portal/admin-tool/modifyLayout"));
+
+ TargetComposition targetComposition = new TargetComposition();
+ targetComposition.setTargetComponent(uriResource);
+
+ RuleComposition ruleComposition = new RuleComposition();
+ ruleComposition.setEffect(Effect.PERMIT);
+ ruleComposition.setLogicComponent(roles);
+ ruleComposition.setExpressionName("allowExpression");
+ ruleComposition.setTargetComponent(new Read());
+
+
+ Target policyTarget = targetComposition.compose();
+ Rule policyRule = ruleComposition.compose();
+
+ //Assert the State
+ assertNotNull("Target must not be null!!", policyTarget);
+ assertNotNull("Rule must not be null!!", policyRule);
+
+ PolicyMetaData metadata = new PolicyMetaData();
+ metadata.setTarget(policyTarget);
+ metadata.addRule(policyRule);
+ Policy policy = new MockPolicy("testComposePermitRole", metadata);
+
+ log.info("----------------------------------------------------------------");
+ log.info(policy.generateSystemPolicy());
+ }
+}
16 years, 10 months
JBoss Portal SVN: r13456 - branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2009-06-15 12:26:03 -0400 (Mon, 15 Jun 2009)
New Revision: 13456
Modified:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
Log:
- JBPORTAL-2410: fixed error reporting.
Modified: branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2009-06-15 14:24:35 UTC (rev 13455)
+++ branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2009-06-15 16:26:03 UTC (rev 13456)
@@ -28,6 +28,7 @@
import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
import org.jboss.portal.wsrp.consumer.ProducerInfo;
+import org.jboss.portal.wsrp.consumer.RefreshResult;
import org.jboss.portal.wsrp.consumer.RegistrationInfo;
import org.jboss.portal.wsrp.consumer.RegistrationProperty;
@@ -427,7 +428,11 @@
// if the registration is locally modified, bypass the refresh as it will not yield a proper result
if (!isRegistrationLocallyModified())
{
- manager.refresh(consumer);
+ RefreshResult refreshResult = manager.refresh(consumer);
+ if (refreshResult == null)
+ {
+ return null;
+ }
}
else
{
16 years, 10 months
JBoss Portal SVN: r13455 - in branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests: src/org/jboss/portal/test/selenium and 1 other directory.
by portal-commits@lists.jboss.org
Author: vrockai
Date: 2009-06-15 10:24:35 -0400 (Mon, 15 Jun 2009)
New Revision: 13455
Removed:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/temp-testng-customsuite.xml
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/CoordinationSamplesTestCase.java
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/EndToEndBeaPortlet.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java
Log:
[selenium] - fixing new wsrp interface issues
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/CoordinationSamplesTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/CoordinationSamplesTestCase.java 2009-06-14 15:23:17 UTC (rev 13454)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/CoordinationSamplesTestCase.java 2009-06-15 14:24:35 UTC (rev 13455)
@@ -7,8 +7,6 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
-
/**
* The Class Coordination Samples TestCase is responsible for testing of
* coordination features of JBoss Portal using it's coordination samples page.
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-06-14 15:23:17 UTC (rev 13454)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java 2009-06-15 14:24:35 UTC (rev 13455)
@@ -1,6 +1,7 @@
package org.jboss.portal.test.selenium;
import org.testng.Assert;
+import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -58,11 +59,12 @@
logoutIfPossible();
login("admin", "admin");
}
-
+/*
@AfterMethod(groups = {"log"})
protected void logoutAfterTest() {
+ System.out.println("vilko");
}
-
+*/
/**
* Simple drag and drop test processed on "user" dashboard. The greetings
* portlet is moved from left to right column and the cms portlet is moved
@@ -88,7 +90,6 @@
Assert.assertEquals(selenium.getText(SPAN_R1), "Greetings !");
}
-
/**
* Creates a page. In Dashboard configuration a new page named
* "DashTestPage" is created. The existence of the link (page) is then
@@ -171,7 +172,6 @@
*/
@Test(enabled = true, dependsOnMethods = {"testCreatePage"})
public void testUpdateTheme() {
- // selenium.setSpeed("10000");
selenium.click(LNK_DASHBOARD);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
@@ -205,7 +205,6 @@
*/
@Test(enabled = true, dependsOnMethods = {"testCreatePage"})
public void testUpdateLayout() {
- // selenium.setSpeed("10000");
selenium.click(LNK_DASHBOARD);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
@@ -238,7 +237,6 @@
*/
@Test(enabled = true, dependsOnMethods = {"testCreatePage"})
public void testAddPortlet() {
- // selenium.setSpeed("10000");
selenium.click(LNK_DASHBOARD);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -262,7 +260,6 @@
Assert.assertTrue(selenium.isTextPresent("Current users"));
Assert.assertTrue(selenium.isTextPresent("Among them: * logged-in"));
Assert.assertTrue(selenium.isTextPresent("[admin]"));
- // selenium.setSpeed("0");
}
/**
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/EndToEndBeaPortlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/EndToEndBeaPortlet.java 2009-06-14 15:23:17 UTC (rev 13454)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/EndToEndBeaPortlet.java 2009-06-15 14:24:35 UTC (rev 13455)
@@ -124,13 +124,13 @@
selenium.type(INPUT_CONSWSDL, "http://wsrp.bea.com:7001/producer/producer?WSDL");
selenium.click(SUBMIT_REFRESHSAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Refresh failed (probably because the registration information was not valid)."));
+ //Assert.assertTrue(selenium.isTextPresent("Refresh failed (probably because the registration information was not valid)."));
Assert.assertTrue(selenium.isTextPresent("Missing value"));
selenium.type(INPUT_CONS_REGVALUE, "public");
selenium.click(SUBMIT_CONS_REGVAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Refresh was successful."));
+ Assert.assertTrue(selenium.isTextPresent("configuration (active)"));
selenium.click(SUBMIT_REFRESHFINAL);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent(consumerName));
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-06-14 15:23:17 UTC (rev 13454)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java 2009-06-15 14:24:35 UTC (rev 13455)
@@ -109,13 +109,13 @@
selenium.type(INPUT_CONSWSDL, "http://wsrp.bea.com:7001/producer/producer?WSDL");
selenium.click(SUBMIT_REFRESHSAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Refresh failed (probably because the registration information was not valid)."));
+ //Assert.assertTrue(selenium.isTextPresent("Refresh failed (probably because the registration information was not valid)."));
Assert.assertTrue(selenium.isTextPresent("Missing value"));
selenium.type(INPUT_CONS_REGVALUE, "public");
selenium.click(SUB_CONS_REGVAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Refresh was successful."));
+ Assert.assertTrue(selenium.isTextPresent("configuration (active)"));
selenium.click(SUB_REFRESHFINAL);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("BEA"));
@@ -433,6 +433,7 @@
Assert.assertTrue(selenium.isTextPresent("must be a number between"));
+ selenium.setSpeed("5000");
selenium.type(INP_PRODID, XSS_STR1);
selenium.type(INPUT_CACHEEXP, "600");
selenium.type(INPUT_CONSWSDL, "http://wsrp.bea.com:7001/producer/producer?WSDL");
@@ -464,13 +465,13 @@
selenium.type("//input[contains(@id,'producer-form:registrationPolicy')]", XSS_STR1);
selenium.click(SUB_PROD_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Couldn't find policy class"));
+ Assert.assertTrue(selenium.isTextPresent("is an invalid class nam"));
goToProducers();
selenium.type("//input[contains(@id,'producer-form:validator')]", XSS_STR1);
selenium.click(SUB_PROD_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Couldn't find policy class"));
+ Assert.assertTrue(selenium.isTextPresent("is an invalid class nam"));
// properties
selenium.open("/portal/");
Deleted: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/temp-testng-customsuite.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/temp-testng-customsuite.xml 2009-06-14 15:23:17 UTC (rev 13454)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/temp-testng-customsuite.xml 2009-06-15 14:24:35 UTC (rev 13455)
@@ -1,8 +0,0 @@
-<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<suite name="SeleniumTest">
- <test verbose="2" name="org.jboss.portal.test.selenium.AdminTest" annotations="JDK">
- <classes>
- <class name="org.jboss.portal.test.selenium.AdminTest"/>
- </classes>
- </test>
-</suite>
16 years, 10 months
JBoss Portal SVN: r13454 - modules/authorization/trunk/portal-profile.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2009-06-14 11:23:17 -0400 (Sun, 14 Jun 2009)
New Revision: 13454
Modified:
modules/authorization/trunk/portal-profile/
Log:
target ignores
Property changes on: modules/authorization/trunk/portal-profile
___________________________________________________________________
Name: svn:ignore
+ target
16 years, 10 months
JBoss Portal SVN: r13453 - in modules/authorization/trunk: common-api and 26 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2009-06-13 19:09:48 -0400 (Sat, 13 Jun 2009)
New Revision: 13453
Added:
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/agent/
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/agent/Agent.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/agent/EmbeddedBootstrap.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/Component.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentCategory.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentMarker.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentRepository.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentType.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicData.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicExpression.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/PolicyComposer.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/RuleDeclarationRepository.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/TargetUri.java
modules/authorization/trunk/core-components-api/src/main/resources/META-INF/
modules/authorization/trunk/core-components-api/src/main/resources/META-INF/jboss-beans.xml
modules/authorization/trunk/core-components-api/src/main/resources/authz-components.xml
modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/repository/
modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/repository/TestConfiguration.java
modules/authorization/trunk/portal-profile/
modules/authorization/trunk/portal-profile/pom.xml
modules/authorization/trunk/portal-profile/src/
modules/authorization/trunk/portal-profile/src/main/
modules/authorization/trunk/portal-profile/src/main/java/
modules/authorization/trunk/portal-profile/src/main/java/org/
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/components/
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/components/PortletResource.java
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/components/Preferences.java
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/configuration/
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/configuration/PortalObjectPolicyConfig.java
modules/authorization/trunk/portal-profile/src/main/resources/
modules/authorization/trunk/portal-profile/src/main/resources/authz-components.xml
modules/authorization/trunk/portal-profile/src/main/resources/portal-policy.xml
modules/authorization/trunk/portal-profile/src/test/
modules/authorization/trunk/portal-profile/src/test/java/
modules/authorization/trunk/portal-profile/src/test/resources/
Modified:
modules/authorization/trunk/.classpath
modules/authorization/trunk/common-api/pom.xml
modules/authorization/trunk/core-components-api/pom.xml
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Manage.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Operation.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Read.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Write.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/HttpResource.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/URIResource.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Identity.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Roles.java
modules/authorization/trunk/core-components-api/src/test/resources/log4j.properties
modules/authorization/trunk/pom.xml
Log:
backing up some code before storms decide to knock out power again!!!
Modified: modules/authorization/trunk/.classpath
===================================================================
--- modules/authorization/trunk/.classpath 2009-06-12 21:09:47 UTC (rev 13452)
+++ modules/authorization/trunk/.classpath 2009-06-13 23:09:48 UTC (rev 13453)
@@ -16,6 +16,10 @@
<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="portal-profile/src/main/java"/>
+ <classpathentry kind="src" path="portal-profile/src/main/resources"/>
+ <classpathentry kind="src" path="portal-profile/src/test/java"/>
+ <classpathentry kind="src" path="portal-profile/src/test/resources"/>
<classpathentry kind="src" path="documentation/reference-guide/en/modules"/>
<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"/>
Modified: modules/authorization/trunk/common-api/pom.xml
===================================================================
--- modules/authorization/trunk/common-api/pom.xml 2009-06-12 21:09:47 UTC (rev 13452)
+++ modules/authorization/trunk/common-api/pom.xml 2009-06-13 23:09:48 UTC (rev 13453)
@@ -18,6 +18,12 @@
<dependency>
<groupId>org.jboss.security</groupId>
<artifactId>jboss-xacml</artifactId>
- </dependency>
- </dependencies>
+ </dependency>
+
+ <!-- jboss microcontainer -->
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </dependency>
+ </dependencies>
</project>
Added: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/agent/Agent.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/agent/Agent.java (rev 0)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/agent/Agent.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,81 @@
+/******************************************************************************
+ * 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.agent;
+
+import java.net.URL;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.dependency.spi.ControllerContext;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public final class Agent
+{
+ private static Logger log = Logger.getLogger(Agent.class);
+
+ private static Kernel kernel;
+
+ public Agent()
+ {
+
+ }
+
+ public static void bootstrap()
+ {
+ try
+ {
+ EmbeddedBootstrap bootstrap = new EmbeddedBootstrap();
+ bootstrap.run();
+
+ URL url = Thread.currentThread().getContextClassLoader().getResource("META-INF/jboss-beans.xml");
+
+ bootstrap.deploy(url);
+
+ kernel = bootstrap.getKernel();
+ }
+ catch(Exception e)
+ {
+ log.error("org.jboss.security.authz.policy.server.Server", e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static Object lookup(String serviceId)
+ {
+ Object service = null;
+
+ KernelController kernelController = kernel.getController();
+ ControllerContext controllerContext = kernelController.getInstalledContext(serviceId);
+ if(controllerContext != null)
+ {
+ service = controllerContext.getTarget();
+ }
+
+ return service;
+ }
+}
Added: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/agent/EmbeddedBootstrap.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/agent/EmbeddedBootstrap.java (rev 0)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/agent/EmbeddedBootstrap.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,98 @@
+/******************************************************************************
+ * 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.agent;
+
+import java.net.URL;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+final class EmbeddedBootstrap extends BasicBootstrap
+{
+ private static Logger log = Logger.getLogger(EmbeddedBootstrap.class);
+
+ protected BasicXMLDeployer deployer;
+
+ public EmbeddedBootstrap() throws Exception
+ {
+ super();
+ }
+
+ public void bootstrap() throws Throwable
+ {
+ super.bootstrap();
+ deployer = new BasicXMLDeployer(getKernel());
+ Runtime.getRuntime().addShutdownHook(new Shutdown());
+ }
+
+ public void deploy(URL url)
+ {
+ try
+ {
+ // Workaround the fact that the BasicXMLDeployer does not handle
+ // redeployment correctly
+ if (deployer.getDeploymentNames().contains(url.toString()))
+ {
+ log.debug("Service is already deployed.");
+ return;
+ }
+ deployer.deploy(url);
+ }
+ catch (Throwable t)
+ {
+ log.error(this, t);
+ }
+ }
+
+ public void undeploy(URL url)
+ {
+ if (!deployer.getDeploymentNames().contains(url.toString()))
+ {
+ log.debug("Service is already undeployed.");
+ return;
+ }
+ try
+ {
+ deployer.undeploy(url);
+ }
+ catch (Throwable t)
+ {
+ log.error(this, t);
+ }
+ }
+
+ protected class Shutdown extends Thread
+ {
+ public void run()
+ {
+ log.info("Shutting down");
+ deployer.shutdown();
+ }
+ }
+}
Added: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/Component.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/Component.java (rev 0)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/Component.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,56 @@
+/*
+* 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.component;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+(a)Target(ElementType.TYPE)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface Component
+{
+ /**
+ * Unique name of the component
+ *
+ * @return
+ */
+ String name();
+
+ /**
+ * The type of component
+ *
+ * @return
+ */
+ ComponentType type();
+
+ /**
+ * The Enforcement Data Category that this component signifies
+ *
+ * @return
+ */
+ ComponentCategory category();
+}
Added: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentCategory.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentCategory.java (rev 0)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentCategory.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,30 @@
+/*
+* 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.component;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public enum ComponentCategory
+{
+ RESOURCE, SUBJECT, ACTION, ENVIRONMENT
+}
Added: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentMarker.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentMarker.java (rev 0)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentMarker.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,35 @@
+/*
+* 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.component;
+
+/**
+ * Just a marker interface used for Microcontainer callbacks for registration of security components with the Agent Component Repository
+ *
+ * TODO: need to check with Microcontainer team if callbacks can be received based on Type level Annotations. If so, this marker interface can be completely avoided and
+ * kept more elegant. This is more of an elegance issue and not a performance or too much developer pain the ass issue.
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public interface ComponentMarker
+{
+
+}
Added: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentRepository.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentRepository.java (rev 0)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentRepository.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -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.component;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class ComponentRepository
+{
+ private Map<String, Component> registeredComponents;
+
+ public ComponentRepository()
+ {
+
+ }
+
+ public void start()
+ {
+
+ }
+
+ public void stop()
+ {
+
+ }
+ //-----------Repository Access related services----------------------------------------------------------------------------------------------------------------------------------------------------------
+ public void register(String name, Component component)
+ {
+ this.registeredComponents.put(name, component);
+ }
+
+ public Component getComponent(String name)
+ {
+ return this.registeredComponents.get(name);
+ }
+
+ public void unregister(String name)
+ {
+ this.registeredComponents.remove(name);
+ }
+}
Added: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentType.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentType.java (rev 0)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentType.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,30 @@
+/*
+* 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.component;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public enum ComponentType
+{
+ TARGET, LOGIC
+}
Added: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicData.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicData.java (rev 0)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicData.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,37 @@
+/*
+* 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.component;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+(a)Target(ElementType.FIELD)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface LogicData
+{
+
+}
Added: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicExpression.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicExpression.java (rev 0)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicExpression.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,37 @@
+/*
+* 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.component;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+(a)Target(ElementType.METHOD)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface LogicExpression
+{
+
+}
Added: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/PolicyComposer.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/PolicyComposer.java (rev 0)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/PolicyComposer.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,30 @@
+/*
+* 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.component;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class PolicyComposer
+{
+
+}
Added: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/RuleDeclarationRepository.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/RuleDeclarationRepository.java (rev 0)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/RuleDeclarationRepository.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,64 @@
+/*
+* 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.component;
+
+import java.util.Set;
+import java.util.HashSet;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class RuleDeclarationRepository
+{
+ private static Logger log = Logger.getLogger(RuleDeclarationRepository.class);
+
+ private Set<ComponentMarker> components;
+
+ public RuleDeclarationRepository()
+ {
+ }
+
+ public void start()
+ {
+ this.components = new HashSet<ComponentMarker>();
+ log.info("-------------------------------------------------------------------");
+ log.info("RuleDeclarationRepository successfully started.....................");
+ log.info("-------------------------------------------------------------------");
+ }
+
+ public void stop()
+ {
+
+ }
+
+ public void register(ComponentMarker component)
+ {
+ this.components.add(component);
+
+ log.debug("--------------------------------------------------------------");
+ log.debug(component.getClass()+" was successfully registered.............");
+ log.debug("--------------------------------------------------------------");
+ }
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------
+}
Added: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/TargetUri.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/TargetUri.java (rev 0)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/TargetUri.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,37 @@
+/*
+* 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.component;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+(a)Target(ElementType.FIELD)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface TargetUri
+{
+
+}
Modified: modules/authorization/trunk/core-components-api/pom.xml
===================================================================
--- modules/authorization/trunk/core-components-api/pom.xml 2009-06-12 21:09:47 UTC (rev 13452)
+++ modules/authorization/trunk/core-components-api/pom.xml 2009-06-13 23:09:48 UTC (rev 13453)
@@ -34,6 +34,14 @@
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
- </dependency>
+ </dependency>
+
+ <!-- Test Dependencies -->
+ <!-- jboss microcontainer -->
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified: modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Manage.java
===================================================================
--- modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Manage.java 2009-06-12 21:09:47 UTC (rev 13452)
+++ modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Manage.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -24,6 +24,10 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.component.ComponentCategory;
+
import org.jboss.security.authz.model.Target;
/**
@@ -33,6 +37,11 @@
*
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*/
+@Component(
+ name="manage",
+ type=ComponentType.TARGET,
+ category=ComponentCategory.ACTION
+)
public class Manage extends Operation
{
public Manage()
Modified: modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Operation.java
===================================================================
--- modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Operation.java 2009-06-12 21:09:47 UTC (rev 13452)
+++ modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Operation.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -28,6 +28,10 @@
import org.jboss.security.authz.model.AttributeExpression;
import org.jboss.security.authz.model.Target;
import org.jboss.security.authz.model.Action;
+
+import org.jboss.security.authz.component.ComponentMarker;
+import org.jboss.security.authz.component.TargetUri;
+
import org.jboss.security.xacml.interfaces.XACMLConstants;
import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
@@ -36,8 +40,9 @@
*
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*/
-public abstract class Operation
+public abstract class Operation implements ComponentMarker
{
+ @TargetUri
protected String name;
public Operation()
Modified: modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Read.java
===================================================================
--- modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Read.java 2009-06-12 21:09:47 UTC (rev 13452)
+++ modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Read.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -21,11 +21,20 @@
*/
package org.jboss.security.authz.components.action;
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.component.ComponentCategory;
+
/**
* Read represents a "read" action that can be performed on a Resource
*
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*/
+@Component(
+ name="read",
+ type=ComponentType.TARGET,
+ category=ComponentCategory.ACTION
+)
public class Read extends Operation
{
public Read()
Modified: modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Write.java
===================================================================
--- modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Write.java 2009-06-12 21:09:47 UTC (rev 13452)
+++ modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Write.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -24,6 +24,10 @@
import java.util.List;
import java.util.ArrayList;
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.component.ComponentCategory;
+
import org.jboss.security.authz.model.Target;
/**
@@ -33,6 +37,11 @@
*
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*/
+@Component(
+ name="write",
+ type=ComponentType.TARGET,
+ category=ComponentCategory.ACTION
+)
public class Write extends Operation
{
public Write()
Modified: modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/HttpResource.java
===================================================================
--- modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/HttpResource.java 2009-06-12 21:09:47 UTC (rev 13452)
+++ modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/HttpResource.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -167,4 +167,6 @@
{
return super.clone();
}
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
}
Modified: modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/URIResource.java
===================================================================
--- modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/URIResource.java 2009-06-12 21:09:47 UTC (rev 13452)
+++ modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/URIResource.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -27,6 +27,8 @@
import java.util.List;
import java.util.ArrayList;
+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.Rule;
@@ -35,6 +37,11 @@
import org.jboss.security.authz.model.Attribute;
import org.jboss.security.authz.components.subject.Roles;
import org.jboss.security.authz.components.action.Operation;
+import org.jboss.security.authz.component.ComponentMarker;
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.component.ComponentCategory;
+import org.jboss.security.authz.component.TargetUri;
import org.jboss.security.xacml.interfaces.XACMLConstants;
import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
@@ -44,11 +51,19 @@
*
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*/
-public class URIResource
+@Component(
+ name="uri",
+ type=ComponentType.TARGET,
+ category=ComponentCategory.RESOURCE
+)
+public class URIResource implements ComponentMarker
{
+ private static Logger log = Logger.getLogger(URIResource.class);
+
/**
* The unique URI that identifies this resource
*/
+ @TargetUri
protected URI uri;
/**
@@ -287,5 +302,17 @@
uriResource.addAttribute(attribute);
return uriResource;
+ }
+
+ public void start()
+ {
+ log.debug("-------------------------------------------------------");
+ log.debug("URIResource component successfully started.............");
+ log.debug("-------------------------------------------------------");
}
+
+ public void stop()
+ {
+
+ }
}
Modified: modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Identity.java
===================================================================
--- modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Identity.java 2009-06-12 21:09:47 UTC (rev 13452)
+++ modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Identity.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -30,6 +30,13 @@
import org.jboss.security.authz.model.Attribute;
import org.jboss.security.authz.tools.GeneralTool;
+import org.jboss.security.authz.component.ComponentMarker;
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.component.ComponentCategory;
+import org.jboss.security.authz.component.TargetUri;
+import org.jboss.security.authz.component.LogicData;
+
import org.jboss.security.xacml.interfaces.XACMLConstants;
import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
@@ -42,11 +49,18 @@
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*
*/
-public class Identity
+@Component(
+ name="identity",
+ type=ComponentType.LOGIC,
+ category=ComponentCategory.SUBJECT
+)
+public class Identity implements ComponentMarker
{
/**
* Unique id/name of the Identity
*/
+ @TargetUri
+ @LogicData
private String name;
@@ -143,5 +157,5 @@
subject.addAttribute(attribute);
return subject;
- }
+ }
}
Modified: modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Roles.java
===================================================================
--- modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Roles.java 2009-06-12 21:09:47 UTC (rev 13452)
+++ modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Roles.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -32,6 +32,14 @@
import org.jboss.security.authz.model.Subject;
import org.jboss.security.authz.tools.GeneralTool;
import org.jboss.security.authz.model.Effect;
+
+import org.jboss.security.authz.component.ComponentMarker;
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.component.ComponentCategory;
+import org.jboss.security.authz.component.LogicData;
+import org.jboss.security.authz.component.LogicExpression;
+
import org.jboss.security.xacml.interfaces.XACMLConstants;
import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
@@ -45,7 +53,12 @@
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*
*/
-public class Roles
+@Component(
+ name="roles",
+ type=ComponentType.LOGIC,
+ category=ComponentCategory.SUBJECT
+)
+public class Roles implements ComponentMarker
{
//make it package-level access so that unit tests can test these rules
static final String allowRule =
@@ -80,6 +93,7 @@
/**
* Role Names
*/
+ @LogicData
private Set<String> names;
public Roles()
@@ -116,6 +130,7 @@
*
* @return the rule
*/
+ @LogicExpression
public Rule allowIfUserHasRole()
{
if(this.getNames().isEmpty())
@@ -153,6 +168,7 @@
*
* @return the rule
*/
+ @LogicExpression
public Rule denyIfUserHasRole()
{
if(this.getNames().isEmpty())
Added: modules/authorization/trunk/core-components-api/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- modules/authorization/trunk/core-components-api/src/main/resources/META-INF/jboss-beans.xml (rev 0)
+++ modules/authorization/trunk/core-components-api/src/main/resources/META-INF/jboss-beans.xml 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer:2.0 bean-deployer_2_0.xsd"
+ xmlns="urn:jboss:bean-deployer:2.0">
+ <bean name="/agent/RuleDeclarationRepository" class="org.jboss.security.authz.component.RuleDeclarationRepository">
+ <incallback method="register"/>
+ </bean>
+
+ <bean name="/component/URIResource" class="org.jboss.security.authz.components.resource.URIResource">
+ </bean>
+
+ <bean name="/component/Identity" class="org.jboss.security.authz.components.subject.Identity">
+ </bean>
+
+ <bean name="/component/Roles" class="org.jboss.security.authz.components.subject.Roles">
+ </bean>
+
+ <bean name="/component/Read" class="org.jboss.security.authz.components.action.Read">
+ </bean>
+
+ <bean name="/component/Write" class="org.jboss.security.authz.components.action.Write">
+ </bean>
+
+ <bean name="/component/Manage" class="org.jboss.security.authz.components.action.Manage">
+ </bean>
+</deployment>
\ No newline at end of file
Added: modules/authorization/trunk/core-components-api/src/main/resources/authz-components.xml
===================================================================
--- modules/authorization/trunk/core-components-api/src/main/resources/authz-components.xml (rev 0)
+++ modules/authorization/trunk/core-components-api/src/main/resources/authz-components.xml 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components>
+ <!--
+ TODO: Just for prototyping the Component Contract. Eventually the method of configuration will be POJO components with Annotations
+ -->
+ <target-component name="uri" category="resource" class="org.jboss.security.authz.components.resource.URIResource">
+ <target-uri>uniqueUri</target-uri>
+ </target-component>
+
+ <target-component name="operation" category="action" class="org.jboss.security.authz.components.action.Operation">
+ <target-uri>name</target-uri>
+ </target-component>
+
+ <target-component name="read" category="action" class="org.jboss.security.authz.components.action.Read">
+ <target-uri>name</target-uri>
+ </target-component>
+
+ <target-component name="write" category="action" class="org.jboss.security.authz.components.action.Write">
+ <target-uri>name</target-uri>
+ </target-component>
+
+ <target-component name="manage" category="action" class="org.jboss.security.authz.components.action.Manage">
+ <target-uri>name</target-uri>
+ </target-component>
+
+ <logic-component name="identity" category="subject" class="org.jboss.security.authz.components.subject.Identity">
+ <target-uri>uri</target-uri>
+ <logic-data>
+ <data>name</data>
+ </logic-data>
+ </logic-component>
+
+ <logic-component name="roles" category="subject" class="org.jboss.security.authz.components.subject.Roles">
+ <target-uri></target-uri>
+ <logic-data>
+ <data>names</data>
+ </logic-data>
+ <logic-expressions>
+ <expression>permitOperationIfUserHasRole</expression>
+ <expression>denyOperationIfUserHasRole</expression>
+ </logic-expressions>
+ </logic-component>
+
+
+ <!--
+ Core Rule Compositions shipped with the framework. These can be re-used and more compositions can be added
+ depending upon Application/Profile Requirements
+ -->
+ <rule-composition name="permitOperationIfUserHasRole" outcome="permit">
+ <target-component>operation</target-component>
+ <logic-component>roles</logic-component>
+ </rule-composition>
+
+ <rule-composition name="denyOperationIfUserHasRole" outcome="deny">
+ <target-component>operation</target-component>
+ <logic-component>roles</logic-component>
+ </rule-composition>
+
+ <rule-composition name="permitIdentity" outcome="permit">
+ <target-component>identity</target-component>
+ </rule-composition>
+
+ <rule-composition name="denyIdentity" outcome="deny">
+ <target-component>identity</target-component>
+ </rule-composition>
+</components>
\ No newline at end of file
Added: modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/repository/TestConfiguration.java
===================================================================
--- modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/repository/TestConfiguration.java (rev 0)
+++ modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/repository/TestConfiguration.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,76 @@
+/*
+* 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.repository;
+
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.security.authz.tools.GeneralTool;
+import org.jboss.security.authz.component.ComponentRepository;
+import org.jboss.security.authz.agent.Agent;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class TestConfiguration extends TestCase
+{
+ private static Logger log = Logger.getLogger(TestConfiguration.class);
+
+ protected void setUp() throws Exception
+ {
+ Agent.bootstrap();
+ }
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------
+ public void test() throws Exception
+ {
+ InputStream is = null;
+ try
+ {
+ is = Thread.currentThread().getContextClassLoader().getResourceAsStream("authz-components.xml");
+ String xmlConfig = GeneralTool.readStream(is);
+
+ ComponentRepository repository = new ComponentRepository();
+ this.parse(xmlConfig);
+
+ //Assert
+ }
+ finally
+ {
+ if(is != null)
+ {
+ is.close();
+ }
+ }
+ }
+ //------------Configuration related services---------------------------------------------------------------------------------------------------------------------------------------------------------
+ private void parse(String xmlConfig)
+ {
+ log.info("------------------------------------------------------");
+ log.info("Parsing-----------------------------------------------");
+ log.info(xmlConfig);
+ log.info("------------------------------------------------------");
+ }
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+}
Modified: modules/authorization/trunk/core-components-api/src/test/resources/log4j.properties
===================================================================
--- modules/authorization/trunk/core-components-api/src/test/resources/log4j.properties 2009-06-12 21:09:47 UTC (rev 13452)
+++ modules/authorization/trunk/core-components-api/src/test/resources/log4j.properties 2009-06-13 23:09:48 UTC (rev 13453)
@@ -1,8 +1,8 @@
# Set root category priority to INFO and its only appender to CONSOLE.
-log4j.rootCategory=INFO, CONSOLE
+log4j.rootCategory=DEBUG, CONSOLE
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
+log4j.appender.CONSOLE.Threshold=DEBUG
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Threshold=INFO
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n
Modified: modules/authorization/trunk/pom.xml
===================================================================
--- modules/authorization/trunk/pom.xml 2009-06-12 21:09:47 UTC (rev 13452)
+++ modules/authorization/trunk/pom.xml 2009-06-13 23:09:48 UTC (rev 13453)
@@ -13,7 +13,8 @@
<module>common-api</module>
<module>core-components-api</module>
<module>policy-server</module>
- <module>http-profile</module>
+ <module>http-profile</module>
+ <module>portal-profile</module>
</modules>
<properties>
Added: modules/authorization/trunk/portal-profile/pom.xml
===================================================================
--- modules/authorization/trunk/portal-profile/pom.xml (rev 0)
+++ modules/authorization/trunk/portal-profile/pom.xml 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,71 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.security.authz</groupId>
+ <artifactId>jboss-authz-parent</artifactId>
+ <version>trunk-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>portal-profile</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Authorization for a Portal</name>
+ <url>http://www.jboss.org</url>
+ <description>Contains Authorization Infrastructure for a Portal</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.security.authz</groupId>
+ <artifactId>common-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.security.authz</groupId>
+ <artifactId>core-components-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.security.authz</groupId>
+ <artifactId>policy-server</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+
+ <!-- test dependencies -->
+ <!-- jboss xacml -->
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-xacml</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!-- jboss microcontainer -->
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!-- Drools -->
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-compiler</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.3.1</version>
+ <configuration>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Added: modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/components/PortletResource.java
===================================================================
--- modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/components/PortletResource.java (rev 0)
+++ modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/components/PortletResource.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,75 @@
+/*
+* 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.portal.api.components;
+
+import java.util.Set;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class PortletResource
+{
+ private String name;
+ private Set<String> modes;
+ private Map<String, String> parameters;
+
+ public PortletResource()
+ {
+
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public Set<String> getModes()
+ {
+ return modes;
+ }
+
+ public void setModes(Set<String> modes)
+ {
+ this.modes = modes;
+ }
+
+ public Map<String, String> getParameters()
+ {
+ return parameters;
+ }
+
+ public void setParameters(Map<String, String> parameters)
+ {
+ this.parameters = parameters;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ public String getUri()
+ {
+ return null;
+ }
+}
Added: modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/components/Preferences.java
===================================================================
--- modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/components/Preferences.java (rev 0)
+++ modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/components/Preferences.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,49 @@
+/*
+* 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.portal.api.components;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class Preferences
+{
+ private Map<String, String> preferences;
+
+ public Preferences()
+ {
+
+ }
+
+ public Map<String, String> getPreferences()
+ {
+ return preferences;
+ }
+
+ public void setPreferences(Map<String, String> preferences)
+ {
+ this.preferences = preferences;
+ }
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+}
Added: modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/configuration/PortalObjectPolicyConfig.java
===================================================================
--- modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/configuration/PortalObjectPolicyConfig.java (rev 0)
+++ modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/configuration/PortalObjectPolicyConfig.java 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,44 @@
+/*
+* 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.portal.configuration;
+
+import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.policy.server.spi.PolicyConfig;
+
+/**
+ * Used to configure Security Policies for a Portal Object Tree using Easy Domain specific XML
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class PortalObjectPolicyConfig implements PolicyConfig
+{
+ public PortalObjectPolicyConfig()
+ {
+
+ }
+ //-----PolicyConfig Implementation--------------------------------------------------------------------------------------------------------------------------
+ public Policy[] configure(String easyDomainXml)
+ {
+ return null;
+ }
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------
+}
Added: modules/authorization/trunk/portal-profile/src/main/resources/authz-components.xml
===================================================================
--- modules/authorization/trunk/portal-profile/src/main/resources/authz-components.xml (rev 0)
+++ modules/authorization/trunk/portal-profile/src/main/resources/authz-components.xml 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components>
+ <component name="portlet" configType="target" contextType="resource" class="org.jboss.security.authz.portal.api.components.PortletResource">
+ <unique-uri>uri</unique-uri>
+ </component>
+
+
+ <component name="preferences" configType="rule" contextType="environment" class="org.jboss.security.authz.portal.api.components.Preferences">
+ <attribute>preferences</attribute>
+ </component>
+</components>
\ No newline at end of file
Added: modules/authorization/trunk/portal-profile/src/main/resources/portal-policy.xml
===================================================================
--- modules/authorization/trunk/portal-profile/src/main/resources/portal-policy.xml (rev 0)
+++ modules/authorization/trunk/portal-profile/src/main/resources/portal-policy.xml 2009-06-13 23:09:48 UTC (rev 13453)
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<portal-security>
+ <!--
+ Demonstrates Application Level Authorization
+
+ Security Rule:
+ The specified topics "1234 and 5678" are available only when:
+ * User is an Employee
+ * User's IP fits into the specified range
+ * Time of Access falls between the specified range
+ -->
+ <portlet-security-constraint>
+ <portlet-resource-collection>
+ <portlet-resource>
+ <portlet-name>forums</portlet-name>
+ <request-parameters>
+ <parameter name="topicId">1234</parameter>
+ </request-parameters>
+ </portlet-resource>
+ <portlet-resource>
+ <portlet-name>forums</portlet-name>
+ <request-parameters>
+ <parameter name="topicId">5678</parameter>
+ </request-parameters>
+ </portlet-resource>
+ </portlet-resource-collection>
+ <auth-constraints>
+ <auth-constraint>
+ <roles allow="true">
+ <role-name>employees</role-name>
+ <role-name>partners</role-name>
+ </roles>
+ </auth-constraint>
+ <auth-constraint>
+ <ip-address allow="true">
+ <ip-range>
+ <address-from></address-from>
+ <address-to></address-to>
+ </ip-range>
+ </ip-address>
+ </auth-constraint>
+ <auth-constraint>
+ <time allow="true">
+ <from></from>
+ <to></to>
+ </time>
+ </auth-constraint>
+ </auth-constraints>
+ </portlet-security-constraint>
+
+ <!--
+ Demonstrates Application Level Authorization
+
+ Security Rule:
+ The specified topics "1111 and 2222" are available only when:
+ * User is 18 years or older
+ -->
+ <portlet-security-constraint>
+ <portlet-resource-collection>
+ <portlet-resource>
+ <portlet-name>forums</portlet-name>
+ <request-parameters>
+ <parameter name="topicId">1111</parameter>
+ </request-parameters>
+ </portlet-resource>
+ <portlet-resource>
+ <portlet-name>forums</portlet-name>
+ <request-parameters>
+ <parameter name="topicId">2222</parameter>
+ </request-parameters>
+ </portlet-resource>
+ </portlet-resource-collection>
+ <auth-constraints>
+ <auth-constraint>
+ <preferences allow="true">
+ <preference name="age">>=18</preference>
+ </preferences>
+ </auth-constraint>
+ </auth-constraints>
+ </portlet-security-constraint>
+
+ <!--
+ Demonstrates Portlet Level Authorization by protecting Portlet Modes
+
+ Security Rule: The Forums Portlet is available in VIEW, HELP, and EDIT mode when:
+ * User is a member of the Community
+ -->
+ <portlet-security-constraint>
+ <portlet-resource-collection>
+ <portlet-resource>
+ <portlet-name>forums</portlet-name>
+ <modes>
+ <mode>VIEW</mode>
+ <mode>HELP</mode>
+ <mode>EDIT</mode>
+ </modes>
+ </portlet-resource>
+ </portlet-resource-collection>
+ <auth-constraints>
+ <auth-constraint>
+ <roles allow="true">
+ <role-name>community</role-name>
+ </roles>
+ </auth-constraint>
+ </auth-constraints>
+ </portlet-security-constraint>
+
+ <!--
+ Demonstrates Portlet Level Authorization by protecting Portlet Modes
+
+ Security Rule: The Forums Portlet is available in ADMIN mode when:
+ * User is an Admin
+ -->
+ <portlet-security-constraint>
+ <portlet-resource-collection>
+ <portlet-resource>
+ <portlet-name>forums</portlet-name>
+ <modes>
+ <mode>ADMIN</mode>
+ </modes>
+ </portlet-resource>
+ </portlet-resource-collection>
+ <auth-constraints>
+ <auth-constraint>
+ <roles allow="true">
+ <role-name>admin</role-name>
+ </roles>
+ </auth-constraint>
+ </auth-constraints>
+ </portlet-security-constraint>
+
+ <!--
+ Configuration for the Portal Enforcement Engine
+ -->
+ <enforcement-config>
+ <!--
+ default value, (false)
+ If resource match is set to "policy-match-mandatory=true", it means that if there is an http request to the web application,
+ that does not have any specified/matching "security policy" for it, then this access should be "Denied".
+
+ The default value is set to "false" since this makes Policy Provisioning less intensive for most web applications. This means that if
+ a "Policy" is not specified for a http request, it means that resource does not need to be "protected", and access should be "Granted".
+
+ The protection can be increased depending on the application by changing this to "true". In which case only Http Requests that have a matching "Security Policy" will
+ be considered for "Access Control". All others will be "Denied" access.
+ -->
+ <policy-match-mandatory>false</policy-match-mandatory>
+ </enforcement-config>
+</portal-security>
\ No newline at end of file
16 years, 11 months
JBoss Portal SVN: r13452 - in branches/JBoss_Portal_Branch_2_7: core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes and 2 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2009-06-12 17:09:47 -0400 (Fri, 12 Jun 2009)
New Revision: 13452
Modified:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ProducerBean.java
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/Resource.properties
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/Resource_fr.properties
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/jsf/producer/producer.xhtml
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/ManagedBean.java
Log:
JBPORTAL-2412: Validate registration policy and registration validator class names.
Modified: branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ProducerBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ProducerBean.java 2009-06-12 16:24:04 UTC (rev 13451)
+++ branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ProducerBean.java 2009-06-12 21:09:47 UTC (rev 13452)
@@ -40,6 +40,7 @@
import java.util.Comparator;
import java.util.List;
import java.util.Map;
+import java.util.regex.Pattern;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
@@ -55,6 +56,40 @@
private static final String PRODUCER = "producer";
private String selectedProp;
+ // todo: use ParameterValidation.VALID_ASCII_CLASS_NAME when available...
+ public final static Pattern VALID_ASCII_CLASS_NAME = Pattern.compile("([a-z][a-z0-9_]*\\.)*[A-Z][A-Za-z0-9_$]*");
+
+ public ProducerBean()
+ {
+ setValidator(new DefaultPropertyValidator()
+ {
+ @Override
+ public String getObjectTypeName()
+ {
+ return "CLASS_TYPE";
+ }
+
+ @Override
+ public String doSimpleChecks(String name)
+ {
+ return name;
+ }
+
+ @Override
+ public Pattern getValidationPattern()
+ {
+ return VALID_ASCII_CLASS_NAME;
+ }
+
+ @Override
+ public String getErrorMessageKey()
+ {
+ return "INVALID_CLASS_NAME_ERROR";
+ }
+ });
+
+ }
+
public ProducerConfigurationService getConfigurationService()
{
return configurationService;
@@ -110,7 +145,11 @@
public void setRegistrationPolicyClassName(String className)
{
- policyClassName = className;
+ className = checkNameValidity(className, "producer-form:registrationPolicy");
+ if (className != null)
+ {
+ policyClassName = className;
+ }
}
public boolean isDefaultRegistrationPolicy()
@@ -129,7 +168,11 @@
public void setValidatorClassName(String className)
{
- validatorClassName = className;
+ className = checkNameValidity(className, "producer-form:validator");
+ if (className != null)
+ {
+ validatorClassName = className;
+ }
}
public boolean isStrictMode()
Modified: branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/Resource.properties
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/Resource.properties 2009-06-12 16:24:04 UTC (rev 13451)
+++ branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/Resource.properties 2009-06-12 21:09:47 UTC (rev 13452)
@@ -179,4 +179,7 @@
org.jboss.portal.object.name.admin.WSRP=WSRP
INVALID_NAME_ERROR=''{0}'' is an invalid {1} name: Cannot be null, empty or contain '/', '.', '\\', '<', '>', '(', ')', '=' or '%5c'
-DUPLICATE_ERROR=A {1} named ''{0}'' already exists!
\ No newline at end of file
+DUPLICATE_ERROR=A {1} named ''{0}'' already exists!
+
+CLASS_TYPE = class
+INVALID_CLASS_NAME_ERROR=''{0}'' is an invalid {1} name: Must be a valid ASCII class name.
\ No newline at end of file
Modified: branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/Resource_fr.properties
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/Resource_fr.properties 2009-06-12 16:24:04 UTC (rev 13451)
+++ branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/Resource_fr.properties 2009-06-12 21:09:47 UTC (rev 13452)
@@ -20,7 +20,6 @@
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA #
# 02110-1301 USA, or see the FSF site: http://www.fsf.org. #
################################################################################
-# JBoss Portal display information
org.jboss.portal.object.name.WSRPConfigurationPortlet = Configuration WSRP
org.jboss.portal.instance.name.WSRPConfigurationPortletInstance = Portlet de Configuration pour WSRP
@@ -147,4 +146,6 @@
consumers_table_reload=Recharger consommateurs
CONSUMER_TYPE=Consommateur
DUPLICATE_ERROR=Un {1} nomm\u00e9 ''{0}'' existe d\u00e9j\u00e0!
-INVALID_NAME_ERROR=''{0}'' est un nom invalide pour un {1} : Ne peut pas \u00eatre null, vide ou contenir '/', '.', '\\', '<', '>', '(', ')', '=' ou '%5c'
\ No newline at end of file
+INVALID_NAME_ERROR=''{0}'' est un nom invalide pour un {1} : Ne peut pas \u00eatre null, vide ou contenir '/', '.', '\\', '<', '>', '(', ')', '=' ou '%5c'
+CLASS_TYPE=classe
+INVALID_CLASS_NAME_ERROR=''{0}'' est un nom invalid pour une {1}: Doit \u00eatre un nom de classe ASCII valide!
\ No newline at end of file
Modified: branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/jsf/producer/producer.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/jsf/producer/producer.xhtml 2009-06-12 16:24:04 UTC (rev 13451)
+++ branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/jsf/producer/producer.xhtml 2009-06-12 21:09:47 UTC (rev 13452)
@@ -35,6 +35,7 @@
<h:selectBooleanCheckbox id="cons-reg-req-check"
value="#{producer.registrationRequiredForFullDescription}"/>
<h:outputText value="#{i18n.producer_config_sd_requires_reg}"/>
+
<h:selectBooleanCheckbox value="#{producer.strictMode}"/>
<h:outputText value="#{i18n.producer_config_strict}"/>
@@ -45,14 +46,16 @@
<h:outputText value=" " rendered="#{producer.registrationRequired}"/>
<h:panelGroup rendered="#{producer.registrationRequired}">
- <h:panelGrid columns="2" width="100%">
+ <h:panelGrid columns="3" width="95%">
<h:outputLabel value="#{i18n.producer_config_reg_policy}" for="registrationPolicy"/>
<h:inputText id="registrationPolicy" value="#{producer.registrationPolicyClassName}" size="80"/>
+ <h:message styleClass="portlet-msg-error" for="registrationPolicy"/>
<h:outputLabel value="#{i18n.producer_config_reg_prop_validator}" for="validator"
rendered="#{producer.defaultRegistrationPolicy}"/>
<h:inputText id="validator" value="#{producer.validatorClassName}" size="80"
rendered="#{producer.defaultRegistrationPolicy}"/>
+ <h:message styleClass="portlet-msg-error" for="validator"/>
</h:panelGrid>
</h:panelGroup>
@@ -63,7 +66,7 @@
<h:panelGroup styleClass="portlet-area-body">
<c:choose>
<c:when test="#{!empty producer.registrationProperties}">
- <h:dataTable id="reg-properties" var="property" width="100%"
+ <h:dataTable id="reg-properties" var="property" width="95%"
value="#{producer.registrationProperties}"
rendered="#{producer.registrationRequired}"
headerClass="portlet-section-header">
Modified: branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/ManagedBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/ManagedBean.java 2009-06-12 16:24:04 UTC (rev 13451)
+++ branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/ManagedBean.java 2009-06-12 21:09:47 UTC (rev 13452)
@@ -91,17 +91,18 @@
else
{
String original = name;
- name = validator.doSimpleChecks(name);
+ // Trim name
+ name = name.trim();
+
// we got an invalid name after simple checks, fail!
+ name = validator.doSimpleChecks(name);
if (name == null)
{
beanContext.createTargetedErrorMessage(targetForErrorMessage, validator.getErrorMessageKey(), original, getLocalizedType(objectTypeName));
return null;
}
- // Trim name
- name = name.trim();
// "sanitize" name: if it's invalid, return null and output message
name = ParameterValidation.sanitizeFromPatternWithHandler(name, validator.getValidationPattern(),
16 years, 11 months
JBoss Portal SVN: r13451 - 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-06-12 12:24:04 -0400 (Fri, 12 Jun 2009)
New Revision: 13451
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java
Log:
[selenium] - dashboard input validation
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-06-12 15:33:59 UTC (rev 13450)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java 2009-06-12 16:24:04 UTC (rev 13451)
@@ -14,8 +14,9 @@
@Test(groups = {"cms_dashboard"}, enabled = true, description = "Dashboard issues test case.")
public class DashboardTestCase extends JBossPortalSeleniumTestCase {
- /** prefix for locator properties = dash. */
+ /** prefix for locator properties = dash. */
public String casePfx = "dash.";
+ private final String DIV_PORTET_EDITOR_TITLE = getLoc(casePfx + "div.portlet.editor.title", "portlet-editor-title");
private final String HAND_R1 = getLoc(casePfx + "hand.r1", "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div[2]/div/div");
private final String HAND_L1 = getLoc(casePfx + "hand.l1", "//html/body/div[2]/div/div/div[2]/div/div/div/div/div/div/table/tbody/tr/td[2]/div");
private final String SPAN_R1 = getLoc(casePfx + "span.r1", "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/div/table/tbody/tr/td[2]/div/div/span");
@@ -29,7 +30,9 @@
private final String SUB_LAYOUT_UPDATE = getLoc(casePfx + "sub.layout.update", "//input[contains(@name,'dashboardLayoutForm:j_id12')]");
private final String SUB_PAGE_RENAME = getLoc(casePfx + "sub.page.rename", "//form[contains(@id,'renameForm')]/input[@type='submit']");
private final String INP_PAGE_RENAME = getLoc(casePfx + "inp.page.rename", "//input[contains(@id,'renameForm:newName')]");
+ private final String INP_WINDOW_NAME = getLoc(casePfx + "inp.window.name", "//input[contains(@id,'windowForm:windowName')]");
private final String LINK_WEATHER_PORTLET = getLoc(casePfx + "link.weather.portlet", "link=*WeatherPortlet*");
+ private final String LINK_PORTL3 = getLoc(casePfx + "link.portl2", "link=*WSRP admin portlet*");
private final String LINK_PORTL2 = getLoc(casePfx + "link.portl2", "link=*Who's online portlet*");
private final String LINK_PORTL1 = getLoc(casePfx + "link.portl1", "link=*Welcome portlet*");
private final String OPT_PORTL2 = getLoc(casePfx + "opt.portl2", "IdentityUserPortletWindow");
@@ -94,7 +97,6 @@
@Test(enabled = true)
public void testCreatePage() {
selenium.click(LNK_DASHBOARD);
- // selenium.setSpeed("5000");
selenium.waitForPageToLoad(PAGE_LOAD);
waitFor(AJAX_LOAD);
@@ -246,7 +248,7 @@
selectIfNotSelected(SEL_PAGE, "DashTestPage");
selenium.click(LINK_PORTL2);
selenium.waitForPageToLoad(PAGE_LOAD);
- waitForElement("portlet-editor-title");
+ waitForElement(DIV_PORTET_EDITOR_TITLE);
selenium.click(SUB_ADDCENTER);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -420,7 +422,76 @@
Assert.assertTrue(selenium.isTextPresent("Band Culinaria"));
Assert.assertTrue(selenium.isTextPresent("Gadgets powered by Google"));
}
+
+ @Test(enabled = true)
+ public void testXssCreatePage() {
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.type(INP_PAGENAME, XSS_STR1);
+ clickAndWait(SUB_CREATEPAGE);
+
+ Assert.assertTrue(selenium.isTextPresent("is an invalid page name"),"Message \""+"is an invalid page name"+"\" not found.");
+ }
+
+ @Test(enabled = true)
+ public void testXssRenamePage() {
+ selenium.click(LNK_DASHBOARD);
+ waitFor(AJAX_LOAD);
+
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ final String pageName = "DashXSSToRenamePage";
+
+ selenium.type(INP_PAGENAME, pageName);
+
+ clickAndWait(SUB_CREATEPAGE);
+
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
+ Assert.assertTrue(selenium.isElementPresent("link=" + pageName));
+ selenium.click("link=" + pageName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(MSG_POWER));
+
+ // then rename it
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selectIfNotSelected(SEL_PAGE, pageName);
+
+ selenium.type(INP_PAGE_RENAME, XSS_STR1);
+ selenium.click(SUB_PAGE_RENAME);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent("is an invalid portal object name"),"Message: \""+"is an invalid portal object name"+"\" not found");
+ }
+
+ @Test(enabled = true, dependsOnMethods = {"testCreatePage"})
+ public void testXssWindowName() {
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ waitFor(AJAX_LOAD);
+
+ selectIfNotSelected(SEL_PAGE, "DashTestPage");
+ selenium.click(LINK_PORTL3);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ waitForElement(DIV_PORTET_EDITOR_TITLE);
+ selenium.type(INP_WINDOW_NAME, XSS_STR1);
+ selenium.click(SUB_ADDCENTER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent("is an invalid window name"));
+ }
+
// http://www.jboss.com/index.html?module=bb&op=viewtopic&t=143023
// https://jira.jboss.org/jira/browse/JBPORTAL-2177
/**
16 years, 11 months
JBoss Portal SVN: r13450 - in branches/JBoss_Portal_Branch_2_7/core-wsrp/src: resources/portal-wsrp-admin-war/jsf/common and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2009-06-12 11:33:59 -0400 (Fri, 12 Jun 2009)
New Revision: 13450
Modified:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/jsf/common/template.xhtml
Log:
JBPORTAL-2410: Use h:message instead of h:messages for error reporting (need to test more that this doesn't have unexpected side-effects since I've seen some already)
Modified: branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2009-06-11 14:49:17 UTC (rev 13449)
+++ branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2009-06-12 15:33:59 UTC (rev 13450)
@@ -232,7 +232,11 @@
{
if (refreshConsumerId() != null)
{
- internalRefresh(getSelectedConsumer());
+ RefreshResult refreshResult = internalRefresh(getSelectedConsumer());
+ if (refreshResult == null)
+ {
+ return null;
+ }
return configureConsumer();
}
Modified: branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/jsf/common/template.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/jsf/common/template.xhtml 2009-06-11 14:49:17 UTC (rev 13449)
+++ branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/jsf/common/template.xhtml 2009-06-12 15:33:59 UTC (rev 13450)
@@ -1,3 +1,26 @@
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2009, 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
@@ -2,2 +25,3 @@
<f:loadBundle basename="Resource" var="i18n"/>
+
<div class="wsrp-consumers-ui">
@@ -11,18 +35,18 @@
<ui:insert name="objectpath">Object path if needed</ui:insert>
<div class="wsrp-content-container">
- <c:if test="#{!empty title}">
- <h3 class="sectionTitle">${title}</h3>
- </c:if>
+ <c:if test="#{!empty title}">
+ <h3 class="sectionTitle">${title}</h3>
+ </c:if>
- <!-- Status message -->
- <h:messages id="status" for="status" infoClass="portlet-msg-success" errorClass="portlet-msg-error"
- fatalClass="portlet-msg-error" warnClass="portlet-msg-alert"/>
+ <!-- Status message -->
+ <h:message id="status" for="status" infoClass="portlet-msg-success" errorClass="portlet-msg-error"
+ fatalClass="portlet-msg-error" warnClass="portlet-msg-alert"/>
- <!-- Content -->
- <ui:insert name="content">Content</ui:insert>
+ <!-- Content -->
+ <ui:insert name="content">Content</ui:insert>
</div>
-
+
</div>
</div>
</ui:composition>
\ No newline at end of file
16 years, 11 months
JBoss Portal SVN: r13449 - 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-06-11 10:49:17 -0400 (Thu, 11 Jun 2009)
New Revision: 13449
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/IdentityAdminTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortalSamplesTestCase.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/PortletDefinitionsTestCase.java
Log:
[selenium] - some refactoring
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-06-11 12:02:18 UTC (rev 13448)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java 2009-06-11 14:49:17 UTC (rev 13449)
@@ -11,508 +11,514 @@
*
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
-@Test(groups = { "cms_dashboard" }, enabled = true, description = "Dashboard issues test case.")
+@Test(groups = {"cms_dashboard"}, enabled = true, description = "Dashboard issues test case.")
public class DashboardTestCase extends JBossPortalSeleniumTestCase {
- /** prefix for locator properties = dash. */
- public String casePfx = "dash.";
+ /** prefix for locator properties = dash. */
+ public String casePfx = "dash.";
+ private final String HAND_R1 = getLoc(casePfx + "hand.r1", "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div[2]/div/div");
+ private final String HAND_L1 = getLoc(casePfx + "hand.l1", "//html/body/div[2]/div/div/div[2]/div/div/div/div/div/div/table/tbody/tr/td[2]/div");
+ private final String SPAN_R1 = getLoc(casePfx + "span.r1", "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/div/table/tbody/tr/td[2]/div/div/span");
+ private final String DIV_REG_A = getLoc(casePfx + "div.reg.a", "//div[@id='regionA']");
+ private final String DIV_REG_B = getLoc(casePfx + "div.reg.b", "//div[@id='regionB']");
+ private final String SPAN_L2 = getLoc(casePfx + "span.l2", "//html/body/div[2]/div/div/div[2]/div/div/div/div[2]/div/div/table/tbody/tr/td[2]/div/div/span");
+ private final String SPAN_L1 = getLoc(casePfx + "span.l1", "//html/body/div[2]/div/div/div[2]/div/div/div/div/div/div/table/tbody/tr/td[2]/div/div/span");
+ private final String MSG_POWER = getMess(casePfx + "msg.power", "Powered by JBoss");
+ private final String LNK_POR_WEA_EDIT = getLoc(casePfx + "lnk.por.wea.edit",
+ "//body/div[2]/div/div/div[2]/div/div/div/div/div/div/table/tbody/tr/td[2]/div/div/div[2]/span/a");
+ private final String SUB_LAYOUT_UPDATE = getLoc(casePfx + "sub.layout.update", "//input[contains(@name,'dashboardLayoutForm:j_id12')]");
+ private final String SUB_PAGE_RENAME = getLoc(casePfx + "sub.page.rename", "//form[contains(@id,'renameForm')]/input[@type='submit']");
+ private final String INP_PAGE_RENAME = getLoc(casePfx + "inp.page.rename", "//input[contains(@id,'renameForm:newName')]");
+ private final String LINK_WEATHER_PORTLET = getLoc(casePfx + "link.weather.portlet", "link=*WeatherPortlet*");
+ private final String LINK_PORTL2 = getLoc(casePfx + "link.portl2", "link=*Who's online portlet*");
+ private final String LINK_PORTL1 = getLoc(casePfx + "link.portl1", "link=*Welcome portlet*");
+ private final String OPT_PORTL2 = getLoc(casePfx + "opt.portl2", "IdentityUserPortletWindow");
+ private final String OPT_PORTL1 = getLoc(casePfx + "opt.portl1", "JSPPortletWindow");
+ private final String SEL_CONTENT_TYPE = getLoc(casePfx + "sel.content.type", "//select[contains(@id,'contentTypesForm:instanceId')]");
+ private final String SUB_DEL_FROM_CENTER_REGION = getLoc(casePfx + "sub.del.from.center.region", "//input[contains(@id,'layoutForm:l_center')]");
+ private final String SUB_DOWN_CENTER_REGION = getLoc(casePfx + "sub.down.center.region", "//input[contains(@id,'layoutForm:d_center')]");
+ private final String SUB_UP_CENTER_REGION = getLoc(casePfx + "sub.up.center.region", "//input[contains(@id,'layoutForm:u_center')]");
+ private final String SEL_CENTER_REGION = getLoc(casePfx + "sel.center.region", "//select[contains(@id,'layoutForm:selectMany_center')]");
+ private final String SUB_ADDCENTER = getLoc(casePfx + "sub.addcenter", "//input[contains(@id,'layoutForm:a_center')]");
+ private final String SUB_ADDLEFT = getLoc(casePfx + "sub.addleft", "//input[contains(@id,'layoutForm:a_left')]");
+ private final String LNK_CONFIGURE_DASHBOARD = getLoc(casePfx + "lnk.configure.dashboard", "link=Configure dashboard");
+ private final String LNK_DASHBOARD = getLoc(casePfx + "lnk.dashboard", "link=Dashboard");
+ private final String SEL_PAGE = getLoc(casePfx + "sel.page", "//select[contains(@id,'pageNameSelector')]");
+ private final String INP_PAGENAME = getLoc(casePfx + "inp.pagename", "//input[contains(@id,':pageName')]");
+ private final String SUB_CREATEPAGE = getLoc(casePfx + "sub.createpage", "//form[contains(@id,'j_id3')]/input[@type='submit']");
+ private final String SEL_LAYOUT = getLoc(casePfx + "sel.layout", "//select[contains(@id,'dashboardLayoutForm:layoutSelector')]");
+ private final String SEL_THEME = getLoc(casePfx + "sel.theme", "//select[contains(@id,'dashboardThemeForm:themeSelector')]");
+ private final String SUB_THEMESEL = getLoc(casePfx + "sub.themesel", "//form[contains(@id,'dashboardThemeForm')]/input[@type='submit']");
- private final String HAND_R1 = getLoc(casePfx + "hand.r1", "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div[2]/div/div");
- private final String HAND_L1 = getLoc(casePfx + "hand.l1", "//html/body/div[2]/div/div/div[2]/div/div/div/div/div/div/table/tbody/tr/td[2]/div");
- private final String SPAN_R1 = getLoc(casePfx + "span.r1", "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/div/table/tbody/tr/td[2]/div/div/span");
- private final String DIV_REG_A = getLoc(casePfx + "div.reg.a", "//div[@id='regionA']");
- private final String DIV_REG_B = getLoc(casePfx + "div.reg.b", "//div[@id='regionB']");
- private final String SPAN_L2 = getLoc(casePfx + "span.l2", "//html/body/div[2]/div/div/div[2]/div/div/div/div[2]/div/div/table/tbody/tr/td[2]/div/div/span");
- private final String SPAN_L1 = getLoc(casePfx + "span.l1", "//html/body/div[2]/div/div/div[2]/div/div/div/div/div/div/table/tbody/tr/td[2]/div/div/span");
+ @BeforeMethod(groups = {"log"})
+ protected void loginBeforeTest() {
+ logoutIfPossible();
+ login("admin", "admin");
+ }
- private final String MSG_POWER = getMess(casePfx + "msg.power", "Powered by JBoss");
+ @AfterMethod(groups = {"log"})
+ protected void logoutAfterTest() {
+ }
- private final String LNK_POR_WEA_EDIT = getLoc(casePfx + "lnk.por.wea.edit",
- "//body/div[2]/div/div/div[2]/div/div/div/div/div/div/table/tbody/tr/td[2]/div/div/div[2]/span/a");
- private final String SUB_LAYOUT_UPDATE = getLoc(casePfx + "sub.layout.update", "//input[contains(@name,'dashboardLayoutForm:j_id12')]");
- private final String SUB_PAGE_RENAME = getLoc(casePfx + "sub.page.rename", "//form[contains(@id,'renameForm')]/input[@type='submit']");
- private final String INP_PAGE_RENAME = getLoc(casePfx + "inp.page.rename", "//input[contains(@id,'renameForm:newName')]");
- private final String LINK_WEATHER_PORTLET = getLoc(casePfx + "link.weather.portlet", "link=*WeatherPortlet*");
- private final String LINK_PORTL2 = getLoc(casePfx + "link.portl2", "link=*Who's online portlet*");
- private final String LINK_PORTL1 = getLoc(casePfx + "link.portl1", "link=*Welcome portlet*");
- private final String OPT_PORTL1 = getLoc(casePfx + "opt.portl1", "JSPPortletWindow");
- private final String SEL_CONTENT_TYPE = getLoc(casePfx + "sel.content.type", "//select[contains(@id,'contentTypesForm:instanceId')]");
- private final String SUB_DEL_FROM_CENTER_REGION = getLoc(casePfx + "sub.del.from.center.region", "//input[contains(@id,'layoutForm:l_center')]");
- private final String SUB_DOWN_CENTER_REGION = getLoc(casePfx + "sub.down.center.region", "//input[contains(@id,'layoutForm:d_center')]");
- private final String SUB_UP_CENTER_REGION = getLoc(casePfx + "sub.up.center.region", "//input[contains(@id,'layoutForm:u_center')]");
- private final String SEL_CENTER_REGION = getLoc(casePfx + "sel.center.region", "//select[contains(@id,'layoutForm:selectMany_center')]");
- private final String SUB_ADDCENTER = getLoc(casePfx + "sub.addcenter", "//input[contains(@id,'layoutForm:a_center')]");
- private final String SUB_ADDLEFT = getLoc(casePfx + "sub.addleft", "//input[contains(@id,'layoutForm:a_left')]");
- private final String LNK_CONFIGURE_DASHBOARD = getLoc(casePfx + "lnk.configure.dashboard", "link=Configure dashboard");
- private final String LNK_DASHBOARD = getLoc(casePfx + "lnk.dashboard", "link=Dashboard");
- private final String SEL_PAGE = getLoc(casePfx + "sel.page", "//select[contains(@id,'pageNameSelector')]");
- private final String INP_PAGENAME = getLoc(casePfx + "inp.pagename", "//input[contains(@id,':pageName')]");
- private final String SUB_CREATEPAGE = getLoc(casePfx + "sub.createpage", "//form[contains(@id,'j_id3')]/input[@type='submit']");
- private final String SEL_LAYOUT = getLoc(casePfx + "sel.layout", "//select[contains(@id,'dashboardLayoutForm:layoutSelector')]");
- private final String SEL_THEME = getLoc(casePfx + "sel.theme", "//select[contains(@id,'dashboardThemeForm:themeSelector')]");
- private final String SUB_THEMESEL = getLoc(casePfx + "sub.themesel", "//form[contains(@id,'dashboardThemeForm')]/input[@type='submit']");
+ /**
+ * Simple drag and drop test processed on "user" dashboard. The greetings
+ * portlet is moved from left to right column and the cms portlet is moved
+ * from the right to left corner. The names of Greetings and User profile
+ * portlets are then used for final assertion. The Greetings portlet message
+ * must be at the top right corner and the "user profile" message should be
+ * in the top left corner.
+ */
+ @Test(enabled = true)
+ public void testDragAndDrop() {
+ logout();
+ login("user", "user");
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- @BeforeMethod(groups = { "log" })
- protected void loginBeforeTest() {
- logoutIfPossible();
- login("admin", "admin");
- }
+ Assert.assertEquals(selenium.getText(SPAN_L1), "Greetings !");
+ Assert.assertEquals(selenium.getText(SPAN_L2), "User profile");
- @AfterMethod(groups = { "log" })
- protected void logoutAfterTest() {
+ selenium.dragAndDropToObject(HAND_L1, DIV_REG_B);
+ selenium.dragAndDropToObject(HAND_R1, DIV_REG_A);
- }
+ Assert.assertEquals(selenium.getText(SPAN_L1), "User profile");
+ Assert.assertEquals(selenium.getText(SPAN_R1), "Greetings !");
- private void wait(int t) {
- try {
- Thread.sleep(t);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
+ }
- /**
- * Simple drag and drop test processed on "user" dashboard. The greetings
- * portlet is moved from left to right column and the cms portlet is moved
- * from the right to left corner. The names of Greetings and User profile
- * portlets are then used for final assertion. The Greetings portlet message
- * must be at the top right corner and the "user profile" message should be
- * in the top left corner.
- */
- @Test(enabled = true)
- public void testDragAndDrop() {
- logout();
- login("user", "user");
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ /**
+ * Creates a page. In Dashboard configuration a new page named
+ * "DashTestPage" is created. The existence of the link (page) is then
+ * asserted on dashboard.s
+ */
+ @Test(enabled = true)
+ public void testCreatePage() {
+ selenium.click(LNK_DASHBOARD);
+ // selenium.setSpeed("5000");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
- Assert.assertEquals(selenium.getText(SPAN_L1), "Greetings !");
- Assert.assertEquals(selenium.getText(SPAN_L2), "User profile");
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.dragAndDropToObject(HAND_L1, DIV_REG_B);
- selenium.dragAndDropToObject(HAND_R1, DIV_REG_A);
+ final String pageName = "DashTestPage";
+ selenium.type(INP_PAGENAME, pageName);
- Assert.assertEquals(selenium.getText(SPAN_L1), "User profile");
- Assert.assertEquals(selenium.getText(SPAN_R1), "Greetings !");
+ clickAndWait(SUB_CREATEPAGE);
- }
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
+ Assert.assertTrue(selenium.isElementPresent("link=" + pageName));
+ selenium.click("link=" + pageName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(MSG_POWER));
+ }
- /**
- * Creates a page. In Dashboard configuration a new page named
- * "DashTestPage" is created. The existence of the link (page) is then
- * asserted on dashboard.s
- */
- @Test(enabled = true)
- public void testCreatePage() {
- selenium.click(LNK_DASHBOARD);
- // selenium.setSpeed("5000");
- selenium.waitForPageToLoad(PAGE_LOAD);
- waitFor(AJAX_LOAD);
+ /**
+ * Renaming of a page on dashboard. firstly a page named "DashToRenamePage"
+ * is created the same way as in {@link DashboardTestCase#testCreatePage()}.
+ * The page is then renamed to "DashRenamedPage". The existence of the link named by renamed page on the dashboard is then used as a final assertion.
+ */
+ @Test(enabled = true, dependsOnMethods = {"testCreatePage"})
+ public void testRenamePage() {
- selenium.click(LNK_CONFIGURE_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ // firstly create page
- final String pageName = "DashTestPage";
- selenium.type(INP_PAGENAME, pageName);
+ selenium.click(LNK_DASHBOARD);
+ waitFor(AJAX_LOAD);
- clickAndWait(SUB_CREATEPAGE);
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- waitFor(AJAX_LOAD);
- Assert.assertTrue(selenium.isElementPresent("link=" + pageName));
- selenium.click("link=" + pageName);
- selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent(MSG_POWER));
- }
+ final String pageName = "DashToRenamePage";
+ final String pageNameNew = "DashRenamedPage";
+ selenium.type(INP_PAGENAME, pageName);
- /**
- * Renaming of a page on dashboard. firstly a page named "DashToRenamePage"
- * is created the same way as in {@link DashboardTestCase#testCreatePage()}.
- * The page is then renamed to "DashRenamedPage".
- */
- // TODO final assertion is missing
- @Test(enabled = true, dependsOnMethods = { "testCreatePage" })
- public void testRenamePage() {
+ clickAndWait(SUB_CREATEPAGE);
- // firstly create page
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
+ Assert.assertTrue(selenium.isElementPresent("link=" + pageName));
+ selenium.click("link=" + pageName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(MSG_POWER));
- selenium.click(LNK_DASHBOARD);
- waitFor(AJAX_LOAD);
+ // then rename it
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_CONFIGURE_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selectIfNotSelected(SEL_PAGE, pageName);
- final String pageName = "DashToRenamePage";
- final String pageNameNew = "DashRenamedPage";
- selenium.type(INP_PAGENAME, pageName);
+ selenium.type(INP_PAGE_RENAME, pageNameNew);
+ selenium.click(SUB_PAGE_RENAME);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- clickAndWait(SUB_CREATEPAGE);
+ selenium.click(LNK_DASHBOARD);
+ waitFor(AJAX_LOAD);
+ Assert.assertTrue(selenium.isElementPresent("Link="+pageNameNew));
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- waitFor(AJAX_LOAD);
- Assert.assertTrue(selenium.isElementPresent("link=" + pageName));
- selenium.click("link=" + pageName);
- selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent(MSG_POWER));
+ }
- // then rename it
- selenium.click(LNK_CONFIGURE_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ /**
+ * Updating a theme on a page. On a page created in
+ * {@link DashboardTestCase#testCreatePage()} a theme is changed to
+ * "renaissance". It is asserted that it was not selected before and at the
+ * end it is asserted, that the renaissance value is selected.
+ */
+ @Test(enabled = true, dependsOnMethods = {"testCreatePage"})
+ public void testUpdateTheme() {
+ // selenium.setSpeed("10000");
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ // selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
- selectIfNotSelected(SEL_PAGE, pageName);
+ selectIfNotSelected(SEL_PAGE, "DashTestPage");
- selenium.type(INP_PAGE_RENAME, pageNameNew);
- selenium.click(SUB_PAGE_RENAME);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertFalse(selenium.getSelectedLabel(SEL_THEME).equals("renaissance"), "Previously selected theme other then expected.");
- }
+ selenium.select(SEL_THEME, "label=renaissance");
- /**
- * Updating a theme on a page. On a page created in
- * {@link DashboardTestCase#testCreatePage()} a theme is changed to
- * "renaissance". It is asserted that it was not selected before and at the
- * end it is asserted, that the renaissance value is selected.
- */
- @Test(enabled = true, dependsOnMethods = { "testCreatePage" })
- public void testUpdateTheme() {
- // selenium.setSpeed("10000");
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_CONFIGURE_DASHBOARD);
- // selenium.waitForPageToLoad(PAGE_LOAD);
- waitFor(AJAX_LOAD);
+ selenium.click(SUB_THEMESEL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- selectIfNotSelected(SEL_PAGE, "DashTestPage");
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertFalse(selenium.getSelectedLabel(SEL_THEME).equals("renaissance"), "Previously selected theme other then expected.");
+ selectIfNotSelected(SEL_PAGE, "DashTestPage");
- selenium.select(SEL_THEME, "label=renaissance");
+ Assert.assertEquals(selenium.getSelectedLabel(SEL_THEME), "renaissance", "Previously selected theme other then expected.");
+ }
- selenium.click(SUB_THEMESEL);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ /**
+ * Updating a layout on a page. On a page created in
+ * {@link DashboardTestCase#testCreatePage()} a theme is changed to
+ * "generic". It is asserted that it was not selected before and at the end
+ * it is asserted, that the renaissance value is selected.
+ */
+ @Test(enabled = true, dependsOnMethods = {"testCreatePage"})
+ public void testUpdateLayout() {
+ // selenium.setSpeed("10000");
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ // selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
+ selenium.windowMaximize();
+ selectIfNotSelected(SEL_PAGE, "DashTestPage");
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_CONFIGURE_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertFalse(selenium.getSelectedLabel(SEL_LAYOUT).equals("generic"), "Previously selected layout other then expected.");
- selectIfNotSelected(SEL_PAGE, "DashTestPage");
+ selenium.select(SEL_LAYOUT, "label=generic");
- Assert.assertEquals(selenium.getSelectedLabel(SEL_THEME), "renaissance", "Previously selected theme other then expected.");
- }
+ selenium.click(SUB_LAYOUT_UPDATE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- /**
- * Updating a layout on a page. On a page created in
- * {@link DashboardTestCase#testCreatePage()} a theme is changed to
- * "generic". It is asserted that it was not selected before and at the end
- * it is asserted, that the renaissance value is selected.
- */
- @Test(enabled = true, dependsOnMethods = { "testCreatePage" })
- public void testUpdateLayout() {
- // selenium.setSpeed("10000");
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_CONFIGURE_DASHBOARD);
- // selenium.waitForPageToLoad(PAGE_LOAD);
- waitFor(AJAX_LOAD);
- selenium.windowMaximize();
- selectIfNotSelected(SEL_PAGE, "DashTestPage");
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertFalse(selenium.getSelectedLabel(SEL_LAYOUT).equals("generic"), "Previously selected layout other then expected.");
+ selectIfNotSelected(SEL_PAGE, "DashTestPage");
- selenium.select(SEL_LAYOUT, "label=generic");
+ Assert.assertEquals(selenium.getSelectedLabel(SEL_LAYOUT), "generic", "Previously selected layout other then expected.");
+ }
- selenium.click(SUB_LAYOUT_UPDATE);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ /**
+ * Adding a portlet to dashboard. Adding a "Who's online portlet" to
+ * dashboard (center). At the end some strings specific for the portlet are
+ * asserted to appear on a dashboard.
+ */
+ @Test(enabled = true, dependsOnMethods = {"testCreatePage"})
+ public void testAddPortlet() {
+ // selenium.setSpeed("10000");
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_CONFIGURE_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ // selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
+ selectIfNotSelected(SEL_PAGE, "DashTestPage");
+ selenium.click(LINK_PORTL2);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ waitForElement("portlet-editor-title");
+ selenium.click(SUB_ADDCENTER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- selectIfNotSelected(SEL_PAGE, "DashTestPage");
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=DashTestPage");
+ selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertEquals(selenium.getSelectedLabel(SEL_LAYOUT), "generic", "Previously selected layout other then expected.");
- }
+ waitFor(AJAX_LOAD);
- /**
- * Adding a portlet to dashboard. Adding a "Who's online portlet" to
- * dashboard (center). At the end some strings specific for the portlet are
- * asserted to appear on a dashboard.
- */
- @Test(enabled = true, dependsOnMethods = { "testCreatePage" })
- public void testAddPortlet() {
- // selenium.setSpeed("10000");
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent("Current users"));
+ Assert.assertTrue(selenium.isTextPresent("Among them: * logged-in"));
+ Assert.assertTrue(selenium.isTextPresent("[admin]"));
+ // selenium.setSpeed("0");
+ }
- selenium.click(LNK_CONFIGURE_DASHBOARD);
- // selenium.waitForPageToLoad(PAGE_LOAD);
- waitFor(AJAX_LOAD);
- selectIfNotSelected(SEL_PAGE, "DashTestPage");
- selenium.click(LINK_PORTL2);
- selenium.waitForPageToLoad(PAGE_LOAD);
- waitForElement("portlet-editor-title");
- selenium.click(SUB_ADDCENTER);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ /**
+ * Moving with portlets on a dashboard. Firstly a page called "DashMovePage"
+ * is created the same way as in {@link DashboardTestCase#testCreatePage()}.
+ * Then two portlets ("Welcome portlet", "Who's online portlet" in that
+ * order) are added to the page the same way as in
+ * {@link DashboardTestCase#testAddPortlet()}. Their positions are swapped
+ * at the end and the ordering of strings on a dashboard page is used for
+ * assertion.
+ *
+ */
+ @Test(enabled = true, dependsOnMethods = {"testCreatePage", "testAddPortlet"})
+ public void testMovePortlet() {
+ final String pageName = "DashMovePage";
+
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ // selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=DashTestPage");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.type(INP_PAGENAME, pageName);
+ selenium.click(SUB_CREATEPAGE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- waitFor(AJAX_LOAD);
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Current users"));
- Assert.assertTrue(selenium.isTextPresent("Among them: * logged-in"));
- Assert.assertTrue(selenium.isTextPresent("[admin]"));
- // selenium.setSpeed("0");
- }
+ selectIfNotSelected(SEL_PAGE, pageName);
+ selenium.click(LINK_PORTL1);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(SUB_ADDCENTER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- /**
- * Moving with portlets on a dashboard. Firstly a page called "DashMovePage"
- * is created the same way as in {@link DashboardTestCase#testCreatePage()}.
- * Then two portlets ("Welcome portlet", "Who's online portlet" in that
- * order) are added to the page the same way as in
- * {@link DashboardTestCase#testAddPortlet()}. Their positions are swapped
- * at the end and the ordering of strings on a dashboard page is used for
- * assertion.
- *
- */
- // TODO assert the the ordering just after adding
- @Test(enabled = true, dependsOnMethods = { "testCreatePage", "testAddPortlet" })
- public void testMovePortlet() {
- final String pageName = "DashMovePage";
+ selectIfNotSelected(SEL_PAGE, pageName);
+ selenium.click(LINK_PORTL2);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(SUB_ADDCENTER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_CONFIGURE_DASHBOARD);
- // selenium.waitForPageToLoad(PAGE_LOAD);
- waitFor(AJAX_LOAD);
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=" + pageName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.type(INP_PAGENAME, pageName);
- selenium.click(SUB_CREATEPAGE);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertFalse(assertTextOrder("Current;Greetings"));
+ Assert.assertTrue(assertTextOrder("Greetings;Current"));
+
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ // selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
+ selectIfNotSelected(SEL_PAGE, pageName);
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_CONFIGURE_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.addSelection(SEL_CENTER_REGION, OPT_PORTL2);
+ selenium.click(SUB_UP_CENTER_REGION);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- selectIfNotSelected(SEL_PAGE, pageName);
- selenium.click(LINK_PORTL1);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(SUB_ADDCENTER);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=" + pageName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- selectIfNotSelected(SEL_PAGE, pageName);
- selenium.click(LINK_PORTL2);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(SUB_ADDCENTER);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(assertTextOrder("Current;Greetings"));
+ Assert.assertFalse(assertTextOrder("Greetings;Current"));
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=" + pageName);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ }
- Assert.assertFalse(assertTextOrder("Current;Greetings"));
- Assert.assertTrue(assertTextOrder("Greetings;Current"));
+ /**
+ * Reordering of portlets. After the portlets are moved in
+ * {@link DashboardTestCase#testMovePortlet()}, they are swaped to the
+ * previous position (reordered again) with this test. The ordering of
+ * strings on a dashboard page is used for assertion.
+ */
+ @Test(enabled = true, dependsOnMethods = {"testCreatePage", "testMovePortlet"})
+ public void testReorder() {
+ final String pageName = "DashMovePage";
- }
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ // selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
+ selectIfNotSelected(SEL_PAGE, pageName);
- /**
- * Reordering of portlets. After the portlets are moved in
- * {@link DashboardTestCase#testMovePortlet()}, they are swaped to the
- * previous position (reordered again) with this test. The ordering of
- * strings on a dashboard page is used for assertion.
- */
- @Test(enabled = true, dependsOnMethods = { "testCreatePage", "testMovePortlet" })
- public void testReorder() {
- final String pageName = "DashMovePage";
+ selenium.addSelection(SEL_CENTER_REGION, OPT_PORTL1);
+ selenium.click(SUB_UP_CENTER_REGION);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_CONFIGURE_DASHBOARD);
- // selenium.waitForPageToLoad(PAGE_LOAD);
- waitFor(AJAX_LOAD);
- selectIfNotSelected(SEL_PAGE, pageName);
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=" + pageName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertFalse(assertTextOrder("Current;Greetings"));
+ Assert.assertTrue(assertTextOrder("Greetings;Current"));
+ }
- selenium.addSelection(SEL_CENTER_REGION, OPT_PORTL1);
- selenium.click(SUB_DOWN_CENTER_REGION);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ /**
+ * Deleting of a portlet. Portlet added in
+ * {@link DashboardTestCase#testAddPortlet()} is used in this test. The
+ * portlet is deleted and it is asserted that string specific for this
+ * portlet are not appearing on the dashboard anymore.
+ */
+ @Test(enabled = true, dependsOnMethods = {"testAddPortlet"})
+ public void testDeletePortlet() {
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=" + pageName);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ // selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
- Assert.assertFalse(assertTextOrder("Greetings;Current"));
- Assert.assertTrue(assertTextOrder("Current;Greetings"));
- }
+ selectIfNotSelected(SEL_PAGE, "DashTestPage");
- /**
- * Deleting of a portlet. Portlet added in
- * {@link DashboardTestCase#testAddPortlet()} is used in this test. The
- * portlet is deleted and it is asserted that string specific for this
- * portlet are not appearing on the dashboard anymore.
- */
- @Test(enabled = true, dependsOnMethods = { "testAddPortlet" })
- public void testDeletePortlet() {
+ selenium.addSelection(SEL_CENTER_REGION, "label=CurrentUsersPortletWindow");
+ selenium.click(SUB_DEL_FROM_CENTER_REGION);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_CONFIGURE_DASHBOARD);
- // selenium.waitForPageToLoad(PAGE_LOAD);
- waitFor(AJAX_LOAD);
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=DashTestPage");
+ selenium.waitForPageToLoad(PAGE_LOAD);
- selectIfNotSelected(SEL_PAGE, "DashTestPage");
+ Assert.assertFalse(selenium.isTextPresent("Current users"));
+ Assert.assertFalse(selenium.isTextPresent("Whose 1 is logged-in:"));
+ Assert.assertFalse(selenium.isTextPresent("[admin]"));
+ }
- selenium.addSelection(SEL_CENTER_REGION, "label=CurrentUsersPortletWindow");
- selenium.click(SUB_DEL_FROM_CENTER_REGION);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ /**
+ * Adding of google portlet. Same as
+ * {@link DashboardTestCase#testAddPortlet()} but added portlet is of type
+ * "widget/google" (content type selector). "Band Culinaria" google portlet
+ * is used in this test.
+ */
+ @Test(enabled = false, dependsOnMethods = {"testCreatePage"})
+ public void testAddGooglePortlet() {
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ // selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
+ selectIfNotSelected(SEL_PAGE, "DashTestPage");
+ selenium.select(SEL_CONTENT_TYPE, "label=widget/google");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Band Culinaria");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(SUB_ADDCENTER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=DashTestPage");
+ selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=DashTestPage");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent("Band Culinaria"));
+ Assert.assertTrue(selenium.isTextPresent("Gadgets powered by Google"));
+ }
- Assert.assertFalse(selenium.isTextPresent("Current users"));
- Assert.assertFalse(selenium.isTextPresent("Whose 1 is logged-in:"));
- Assert.assertFalse(selenium.isTextPresent("[admin]"));
- }
+ // http://www.jboss.com/index.html?module=bb&op=viewtopic&t=143023
+ // https://jira.jboss.org/jira/browse/JBPORTAL-2177
+ /**
+ * Dashboard rename page loses portlet state settings bug testing. From
+ * forum reference <a
+ * href="http://www.jboss.com/index.html?module=bb&op=viewtopic&t=143023"
+ * >http://www.jboss.com/index.html?module=bb&op=viewtopic&t=143023</a>.
+ * Jira for this issue already created in <a
+ * href="https://jira.jboss.org/jira/browse/JBPORTAL-2177"
+ * >https://jira.jboss.org/jira/browse/JBPORTAL-2177</a>.
+ *
+ * <pre>
+ * - in Configure Dashboard, create a new dashboard page; I called mine test1
+ * - in the left region, add the Weather portlet
+ * - return to the Dashboard, select the new tab/page (test1), you see Miami weather (the default)
+ * - EDIT the weather portlet and enter a local zipcode, press OK, you see local weather, so far so good
+ * - return to Configure Dashboard, rename the page (test1a)
+ * - return to the Dashboard, select the newly renamed tab
+ * - now you no longer see the local weather because renaming the page has lost the portlet window-specific settings
+ * </pre>
+ */
+ @Test(enabled = true)
+ public void testBugResetPortletSetting() {
+ final String pageName = "page1";
+ final String pageNameNew = "page1a";
- /**
- * Adding of google portlet. Same as
- * {@link DashboardTestCase#testAddPortlet()} but added portlet is of type
- * "widget/google" (content type selector). "Band Culinaria" google portlet
- * is used in this test.
- */
- @Test(enabled = false, dependsOnMethods = { "testCreatePage" })
- public void testAddGooglePortlet() {
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_CONFIGURE_DASHBOARD);
- // selenium.waitForPageToLoad(PAGE_LOAD);
- waitFor(AJAX_LOAD);
- selectIfNotSelected(SEL_PAGE, "DashTestPage");
- selenium.select(SEL_CONTENT_TYPE, "label=widget/google");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Band Culinaria");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(SUB_ADDCENTER);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=DashTestPage");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ // create page
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ // selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
+ selenium.type(INP_PAGENAME, pageName);
+ selenium.click(SUB_CREATEPAGE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Band Culinaria"));
- Assert.assertTrue(selenium.isTextPresent("Gadgets powered by Google"));
- }
+ Assert.assertTrue(selenium.isElementPresent("link=" + pageName));
+ selenium.click("link=" + pageName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- // http://www.jboss.com/index.html?module=bb&op=viewtopic&t=143023
- // https://jira.jboss.org/jira/browse/JBPORTAL-2177
- /**
- * Dashboard rename page loses portlet state settings bug testing. From
- * forum reference <a
- * href="http://www.jboss.com/index.html?module=bb&op=viewtopic&t=143023"
- * >http://www.jboss.com/index.html?module=bb&op=viewtopic&t=143023</a>.
- * Jira for this issue already created in <a
- * href="https://jira.jboss.org/jira/browse/JBPORTAL-2177"
- * >https://jira.jboss.org/jira/browse/JBPORTAL-2177</a>.
- *
- * <pre>
- * - in Configure Dashboard, create a new dashboard page; I called mine test1
- * - in the left region, add the Weather portlet
- * - return to the Dashboard, select the new tab/page (test1), you see Miami weather (the default)
- * - EDIT the weather portlet and enter a local zipcode, press OK, you see local weather, so far so good
- * - return to Configure Dashboard, rename the page (test1a)
- * - return to the Dashboard, select the newly renamed tab
- * - now you no longer see the local weather because renaming the page has lost the portlet window-specific settings
- * </pre>
- */
- @Test(enabled = true)
- public void testBugResetPortletSetting() {
- final String pageName = "page1";
- final String pageNameNew = "page1a";
+ Assert.assertTrue(selenium.isTextPresent(MSG_POWER));
- // create page
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_CONFIGURE_DASHBOARD);
- // selenium.waitForPageToLoad(PAGE_LOAD);
- waitFor(AJAX_LOAD);
- selenium.type(INP_PAGENAME, pageName);
- selenium.click(SUB_CREATEPAGE);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ // add weather portlet
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isElementPresent("link=" + pageName));
- selenium.click("link=" + pageName);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selectIfNotSelected(SEL_PAGE, pageName);
- Assert.assertTrue(selenium.isTextPresent(MSG_POWER));
+ selenium.click(LINK_WEATHER_PORTLET);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(SUB_ADDLEFT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=" + pageName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- // add weather portlet
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_CONFIGURE_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent("Miami, FL, US"));
- selectIfNotSelected(SEL_PAGE, pageName);
+ // change the properties
+ selenium.click(LNK_POR_WEA_EDIT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.type("newzip", "41001");
+ selenium.click("submit");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent("Alexandria"));
- selenium.click(LINK_WEATHER_PORTLET);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(SUB_ADDLEFT);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=" + pageName);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ // rename portal
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ // selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Miami, FL, US"));
+ selectIfNotSelected(SEL_PAGE, pageName);
- // change the properties
- selenium.click(LNK_POR_WEA_EDIT);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.type("newzip", "41001");
- selenium.click("submit");
- selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Alexandria"));
+ selenium.type(INP_PAGE_RENAME, pageNameNew);
+ selenium.click(SUB_PAGE_RENAME);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- // rename portal
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_CONFIGURE_DASHBOARD);
- // selenium.waitForPageToLoad(PAGE_LOAD);
- waitFor(AJAX_LOAD);
+ // check the portlet again
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=" + pageNameNew);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- selectIfNotSelected(SEL_PAGE, pageName);
-
- selenium.type(INP_PAGE_RENAME, pageNameNew);
- selenium.click(SUB_PAGE_RENAME);
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- // check the portlet again
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=" + pageNameNew);
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- Assert.assertTrue(selenium.isTextPresent("Alexandria"), "Previously selected portlet settings were changed after renaming of portal page.");
- }
-
+ Assert.assertTrue(selenium.isTextPresent("Alexandria"), "Previously selected portlet settings were changed after renaming of portal page.");
+ }
}
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-06-11 12:02:18 UTC (rev 13448)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java 2009-06-11 14:49:17 UTC (rev 13449)
@@ -215,12 +215,7 @@
selenium.click(LINK_LOGIN);
selenium.selectFrame(FRAME_LOGIN_CONTENT);
- try {
- Thread.sleep(2000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ waitFor(AJAX_LOAD);
selenium.type(INPUT_USERNAME, userName);
selenium.type(INPUT_PASSWORD, userPass);
@@ -502,8 +497,6 @@
* e-mail input, the form is submitted and text indicating incorrect user
* e-mail input is asserted.
*/
- // TODO Q: password can be anystring?
- // TODO Q: what about serach input?
@Test(enabled = true)
public void testXssUserCreate() {
openAndWait(ADR_PORTAL);
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2009-06-11 12:02:18 UTC (rev 13448)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2009-06-11 14:49:17 UTC (rev 13449)
@@ -297,7 +297,6 @@
try {
Thread.sleep(time);
} 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/JBossSeleniumTestListener.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java 2009-06-11 12:02:18 UTC (rev 13448)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java 2009-06-11 14:49:17 UTC (rev 13449)
@@ -115,7 +115,6 @@
try {
Thread.sleep(time);
} 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/PortalSamplesTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortalSamplesTestCase.java 2009-06-11 12:02:18 UTC (rev 13448)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortalSamplesTestCase.java 2009-06-11 14:49:17 UTC (rev 13449)
@@ -5,7 +5,6 @@
import org.testng.annotations.Test;
import static org.testng.Assert.*;
-// TODO: Auto-generated Javadoc
/**
* The Class PortalSamplesTestCase.
*/
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-06-11 12:02:18 UTC (rev 13448)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java 2009-06-11 14:49:17 UTC (rev 13449)
@@ -465,12 +465,7 @@
selenium.type(INP_SEARCH_USER, username);
selenium.click(SUB_SEARCH_USER);
- try {
- Thread.sleep(10000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ waitFor(10000);
Assert.assertTrue(selenium.isTextPresent(username), "Username was not found.");
Assert.assertTrue(selenium.isTextPresent(email), "User email adress was not found.");
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletDefinitionsTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletDefinitionsTestCase.java 2009-06-11 12:02:18 UTC (rev 13448)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletDefinitionsTestCase.java 2009-06-11 14:49:17 UTC (rev 13449)
@@ -50,7 +50,7 @@
public void testShowInfo(){
selenium.click(LINK_ADMIN_PORT);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Administration Portlet details "));
+ Assert.assertTrue(selenium.isTextPresent("Administration Portlet details"));
Assert.assertTrue(selenium.isTextPresent("Administration Portlet"));
Assert.assertTrue(selenium.isTextPresent("Management Portlet"));
Assert.assertTrue(selenium.isTextPresent("management,admin"));
@@ -91,7 +91,7 @@
selenium.type(INPUT_INSTANCE_NAME, "str|nge|n|me");
selenium.click(SUBMIT_CREATE_INST);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("str|nge|n|me"+" portlet details"));
+ Assert.assertTrue(selenium.isTextPresent("str|nge|n|me"+" portlet details"),"instance name not found on screen");
}
@Test(enabled = true)
16 years, 11 months