Author: trong.tran
Date: 2011-11-15 07:21:46 -0500 (Tue, 15 Nov 2011)
New Revision: 8072
Modified:
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/PortalURL.java
portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/performance/Standalone.java
portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/Names.java
portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java
portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java
portal/trunk/component/web/controller/src/test/resources/org/exoplatform/web/controller/performance/controller.xml
portal/trunk/packaging/jboss-as5/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml
portal/trunk/packaging/jboss-as6/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml
portal/trunk/packaging/jboss-as7/pkg/src/main/resources/jboss/standalone/configuration/gatein/controller.xml
portal/trunk/packaging/jetty/pkg/src/main/resources/jetty/gatein/conf/controller.xml
portal/trunk/packaging/tomcat/pkg/src/main/resources/tomcat/gatein/conf/controller.xml
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentURL.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalURLBuilder.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/login/UIForgetPassword.java
Log:
GTNPORTAL-2273 Sanitize controller.xml
Modified:
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/PortalURL.java
===================================================================
---
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/PortalURL.java 2011-11-15
09:22:58 UTC (rev 8071)
+++
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/PortalURL.java 2011-11-15
12:21:46 UTC (rev 8072)
@@ -243,6 +243,18 @@
}
/**
+ * Reset the Portal URL state
+ */
+ public void reset()
+ {
+ Map<String, String[]> params = getQueryParameters();
+ if (params != null)
+ {
+ params.clear();
+ }
+ }
+
+ /**
* Returns the query parameters. Null can be returned.
*
* @return the query parameters
Modified:
portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/performance/Standalone.java
===================================================================
---
portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/performance/Standalone.java 2011-11-15
09:22:58 UTC (rev 8071)
+++
portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/performance/Standalone.java 2011-11-15
12:21:46 UTC (rev 8072)
@@ -21,9 +21,6 @@
private static final QualifiedName HANDLER =
QualifiedName.parse("gtn:handler");
/** . */
- private static final QualifiedName LANG = QualifiedName.parse("gtn:lang");
-
- /** . */
private static final QualifiedName SITETYPE =
QualifiedName.parse("gtn:sitetype");
/** . */
@@ -32,15 +29,6 @@
/** . */
private static final QualifiedName PATH = QualifiedName.parse("gtn:path");
- /** . */
- private static final QualifiedName COMPONENT_ID =
QualifiedName.parse("gtn:componentid");
-
- /** . */
- private static final QualifiedName ACTION =
QualifiedName.parse("gtn:action");
-
- /** . */
- private static final QualifiedName OBJECT_ID =
QualifiedName.parse("gtn:objectid");
-
public void testFoo() throws Exception
{
Modified:
portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/Names.java
===================================================================
---
portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/Names.java 2011-11-15
09:22:58 UTC (rev 8071)
+++
portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/Names.java 2011-11-15
12:21:46 UTC (rev 8072)
@@ -42,6 +42,4 @@
QualifiedName GTN_SITETYPE = QualifiedName.parse("gtn:sitetype");
QualifiedName GTN_ACCESS = QualifiedName.parse("gtn:access");
QualifiedName GTN_PATH = QualifiedName.parse("gtn:path");
- QualifiedName GTN_COMPONENTID = QualifiedName.parse("gtn:componentid");
-
}
Modified:
portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java
===================================================================
---
portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java 2011-11-15
09:22:58 UTC (rev 8071)
+++
portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java 2011-11-15
12:21:46 UTC (rev 8072)
@@ -23,7 +23,6 @@
import org.exoplatform.web.controller.QualifiedName;
import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -43,10 +42,7 @@
this.router = router().
add(route("/").
with(
- routeParam("gtn:handler").withValue("portal"),
-
requestParam("gtn:componentid").named("portal:componentId"),
- requestParam("gtn:action").named("portal:action"),
-
requestParam("gtn:objectid").named("portal:objectId")).
+ routeParam("gtn:handler").withValue("portal")).
sub(route("/public/{gtn:sitename}{gtn:path}").
with(
routeParam("gtn:access").withValue("public"),
@@ -65,11 +61,10 @@
expectedParameters.put(Names.GTN_SITENAME, "classic");
expectedParameters.put(Names.GTN_ACCESS, "private");
expectedParameters.put(Names.GTN_PATH, "");
- expectedParameters.put(Names.GTN_COMPONENTID, "foo");
//
- assertEquals(expectedParameters, router.route("/private/classic",
Collections.singletonMap("portal:componentId", new
String[]{"foo"})));
- assertEquals("/private/classic?portal:componentId=foo",
router.render(expectedParameters));
+ assertEquals(expectedParameters, router.route("/private/classic"));
+ assertEquals("/private/classic", router.render(expectedParameters));
}
public void testPrivateClassic() throws Exception
@@ -105,11 +100,10 @@
expectedParameters.put(Names.GTN_SITENAME, "classic");
expectedParameters.put(Names.GTN_ACCESS, "private");
expectedParameters.put(Names.GTN_PATH, "/");
- expectedParameters.put(Names.GTN_COMPONENTID, "foo");
//
- assertEquals(expectedParameters, router.route("/private/classic/",
Collections.singletonMap("portal:componentId", new
String[]{"foo"})));
- assertEquals("/private/classic/?portal:componentId=foo",
router.render(expectedParameters));
+ assertEquals(expectedParameters, router.route("/private/classic/"));
+ assertEquals("/private/classic/", router.render(expectedParameters));
}
public void testPrivateClassicHome() throws Exception
@@ -132,10 +126,9 @@
expectedParameters.put(Names.GTN_SITENAME, "classic");
expectedParameters.put(Names.GTN_ACCESS, "private");
expectedParameters.put(Names.GTN_PATH, "/home");
- expectedParameters.put(Names.GTN_COMPONENTID, "foo");
//
- assertEquals(expectedParameters, router.route("/private/classic/home",
Collections.singletonMap("portal:componentId", new
String[]{"foo"})));
- assertEquals("/private/classic/home?portal:componentId=foo",
router.render(expectedParameters));
+ assertEquals(expectedParameters, router.route("/private/classic/home"));
+ assertEquals("/private/classic/home",
router.render(expectedParameters));
}
}
Modified:
portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java
===================================================================
---
portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java 2011-11-15
09:22:58 UTC (rev 8071)
+++
portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java 2011-11-15
12:21:46 UTC (rev 8072)
@@ -22,7 +22,6 @@
import org.exoplatform.web.controller.QualifiedName;
import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -45,7 +44,6 @@
with(
routeParam("gtn:handler").withValue("site"),
routeParam("gtn:handler").withValue("site"),
-
requestParam("gtn:componentid").named("portal:componentId"),
pathParam("gtn:path").matchedBy(".*").preservePath()),
route("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
with(
@@ -69,11 +67,10 @@
expectedParameters.put(Names.GTN_SITENAME, "classic");
expectedParameters.put(Names.GTN_SITETYPE, "portal");
expectedParameters.put(Names.GTN_PATH, "/");
- expectedParameters.put(Names.GTN_COMPONENTID, "foo");
//
- assertEquals(expectedParameters, router.route("/private/portal/classic/",
Collections.singletonMap("portal:componentId", new
String[]{"foo"})));
- assertEquals("/private/portal/classic/?portal:componentId=foo",
router.render(expectedParameters));
+ assertEquals(expectedParameters,
router.route("/private/portal/classic/"));
+ assertEquals("/private/portal/classic/",
router.render(expectedParameters));
}
public void testPrivateClassic() throws Exception
Modified:
portal/trunk/component/web/controller/src/test/resources/org/exoplatform/web/controller/performance/controller.xml
===================================================================
---
portal/trunk/component/web/controller/src/test/resources/org/exoplatform/web/controller/performance/controller.xml 2011-11-15
09:22:58 UTC (rev 8071)
+++
portal/trunk/component/web/controller/src/test/resources/org/exoplatform/web/controller/performance/controller.xml 2011-11-15
12:21:46 UTC (rev 8072)
@@ -83,11 +83,6 @@
<value>portal</value>
</route-param>
- <!-- Webui parameters -->
- <request-param qname="gtn:componentid"
name="portal:componentId"/>
- <request-param qname="gtn:action" name="portal:action"/>
- <request-param qname="gtn:objectid" name="objectId"/>
-
<!-- The group access -->
<route path="/groups/{gtn:sitename}/{gtn:path}">
<request-param qname="gtn:lang" name="lang"
value-mapping="never-empty">
Modified:
portal/trunk/packaging/jboss-as5/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml
===================================================================
---
portal/trunk/packaging/jboss-as5/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml 2011-11-15
09:22:58 UTC (rev 8071)
+++
portal/trunk/packaging/jboss-as5/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml 2011-11-15
12:21:46 UTC (rev 8072)
@@ -74,11 +74,6 @@
<value>portal</value>
</route-param>
- <!-- Webui parameters -->
- <request-param qname="gtn:componentid"
name="portal:componentId"/>
- <request-param qname="gtn:action" name="portal:action"/>
- <request-param qname="gtn:objectid" name="objectId"/>
-
<!-- The group access -->
<route path="/g/{gtn:sitename}/{gtn:path}">
<request-param qname="gtn:lang" name="lang"
value-mapping="never-empty">
Modified:
portal/trunk/packaging/jboss-as6/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml
===================================================================
---
portal/trunk/packaging/jboss-as6/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml 2011-11-15
09:22:58 UTC (rev 8071)
+++
portal/trunk/packaging/jboss-as6/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml 2011-11-15
12:21:46 UTC (rev 8072)
@@ -74,11 +74,6 @@
<value>portal</value>
</route-param>
- <!-- Webui parameters -->
- <request-param qname="gtn:componentid"
name="portal:componentId"/>
- <request-param qname="gtn:action" name="portal:action"/>
- <request-param qname="gtn:objectid" name="objectId"/>
-
<!-- The group access -->
<route path="/g/{gtn:sitename}/{gtn:path}">
<request-param qname="gtn:lang" name="lang"
value-mapping="never-empty">
Modified:
portal/trunk/packaging/jboss-as7/pkg/src/main/resources/jboss/standalone/configuration/gatein/controller.xml
===================================================================
---
portal/trunk/packaging/jboss-as7/pkg/src/main/resources/jboss/standalone/configuration/gatein/controller.xml 2011-11-15
09:22:58 UTC (rev 8071)
+++
portal/trunk/packaging/jboss-as7/pkg/src/main/resources/jboss/standalone/configuration/gatein/controller.xml 2011-11-15
12:21:46 UTC (rev 8072)
@@ -74,11 +74,6 @@
<value>portal</value>
</route-param>
- <!-- Webui parameters -->
- <request-param qname="gtn:componentid"
name="portal:componentId"/>
- <request-param qname="gtn:action" name="portal:action"/>
- <request-param qname="gtn:objectid" name="objectId"/>
-
<!-- The group access -->
<route path="/g/{gtn:sitename}/{gtn:path}">
<request-param qname="gtn:lang" name="lang"
value-mapping="never-empty">
Modified:
portal/trunk/packaging/jetty/pkg/src/main/resources/jetty/gatein/conf/controller.xml
===================================================================
---
portal/trunk/packaging/jetty/pkg/src/main/resources/jetty/gatein/conf/controller.xml 2011-11-15
09:22:58 UTC (rev 8071)
+++
portal/trunk/packaging/jetty/pkg/src/main/resources/jetty/gatein/conf/controller.xml 2011-11-15
12:21:46 UTC (rev 8072)
@@ -74,11 +74,6 @@
<value>portal</value>
</route-param>
- <!-- Webui parameters -->
- <request-param qname="gtn:componentid"
name="portal:componentId"/>
- <request-param qname="gtn:action" name="portal:action"/>
- <request-param qname="gtn:objectid" name="objectId"/>
-
<!-- The group access -->
<route path="/g/{gtn:sitename}/{gtn:path}">
<request-param qname="gtn:lang" name="lang"
value-mapping="never-empty">
Modified:
portal/trunk/packaging/tomcat/pkg/src/main/resources/tomcat/gatein/conf/controller.xml
===================================================================
---
portal/trunk/packaging/tomcat/pkg/src/main/resources/tomcat/gatein/conf/controller.xml 2011-11-15
09:22:58 UTC (rev 8071)
+++
portal/trunk/packaging/tomcat/pkg/src/main/resources/tomcat/gatein/conf/controller.xml 2011-11-15
12:21:46 UTC (rev 8072)
@@ -74,11 +74,6 @@
<value>portal</value>
</route-param>
- <!-- Webui parameters -->
- <request-param qname="gtn:componentid"
name="portal:componentId"/>
- <request-param qname="gtn:action" name="portal:action"/>
- <request-param qname="gtn:objectid" name="objectId"/>
-
<!-- The group access -->
<route path="/g/{gtn:sitename}/{gtn:path}">
<request-param qname="gtn:lang" name="lang"
value-mapping="never-empty">
Modified:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentURL.java
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentURL.java 2011-11-15
09:22:58 UTC (rev 8071)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentURL.java 2011-11-15
12:21:46 UTC (rev 8072)
@@ -35,24 +35,18 @@
*/
public class ComponentURL extends PortalURL<UIComponent, ComponentURL>
{
+ public static final String PORTAL_COMPONENT_ID = "portal:componentId";
+ public static final String PORTAL_COMPONENT_ACTION = "portal:action";
+
/** . */
public static final ResourceType<UIComponent, ComponentURL> TYPE = new
ResourceType<UIComponent, ComponentURL>() {};
/** . */
- public static final QualifiedName COMPONENT = QualifiedName.create("gtn",
"componentid");
-
- /** . */
- public static final QualifiedName ACTION = QualifiedName.create("gtn",
"action");
-
- /** . */
- public static final QualifiedName TARGET = QualifiedName.create("gtn",
"objectid");
-
- /** . */
public static final QualifiedName PATH = QualifiedName.create("gtn",
"path");
/** . */
- private static final Set<QualifiedName> NAMES =
Collections.unmodifiableSet(Tools.toSet(COMPONENT, ACTION, TARGET, PATH));
+ private static final Set<QualifiedName> NAMES =
Collections.unmodifiableSet(Tools.toSet(PATH));
/** . */
private UIComponent resource;
@@ -61,9 +55,6 @@
private String action;
/** . */
- private String targetBeanId;
-
- /** . */
private String path;
public ComponentURL(URLContext context) throws NullPointerException
@@ -79,9 +70,27 @@
public ComponentURL setResource(UIComponent resource)
{
this.resource = resource;
+
+ if (resource != null)
+ {
+ setQueryParameterValue(PORTAL_COMPONENT_ID, resource.getId());
+ }
+
return this;
}
+ public void reset()
+ {
+ super.reset();
+
+ //
+ if (resource != null)
+ {
+ setQueryParameterValue(PORTAL_COMPONENT_ID, resource.getId());
+ }
+ setQueryParameterValue(PORTAL_COMPONENT_ACTION, action);
+ }
+
public Set<QualifiedName> getParameterNames()
{
return NAMES;
@@ -89,20 +98,8 @@
public String getParameterValue(QualifiedName parameterName)
{
- if (COMPONENT.equals(parameterName))
+ if (PATH.equals(parameterName))
{
- return resource != null ? resource.getId() : null;
- }
- else if (ACTION.equals(parameterName))
- {
- return action;
- }
- else if (TARGET.equals(parameterName))
- {
- return targetBeanId;
- }
- else if (PATH.equals(parameterName))
- {
return path;
}
else
@@ -111,26 +108,12 @@
}
}
- public String getAction()
- {
- return action;
- }
-
public void setAction(String action)
{
this.action = action;
+ setQueryParameterValue(PORTAL_COMPONENT_ACTION, action);
}
- public String getTargetBeanId()
- {
- return targetBeanId;
- }
-
- public void setTargetBeanId(String targetBeanId)
- {
- this.targetBeanId = targetBeanId;
- }
-
public String getPath()
{
return path;
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2011-11-15
09:22:58 UTC (rev 8071)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2011-11-15
12:21:46 UTC (rev 8072)
@@ -89,9 +89,9 @@
final static public int PRIVATE_ACCESS = 1;
- final static public String UI_COMPONENT_ACTION = "portal:action";
+ final static public String UI_COMPONENT_ACTION =
ComponentURL.PORTAL_COMPONENT_ACTION;
- final static public String UI_COMPONENT_ID = "portal:componentId";
+ final static public String UI_COMPONENT_ID = ComponentURL.PORTAL_COMPONENT_ID;
final static public String TARGET_NODE = "portal:targetNode";
@@ -475,7 +475,7 @@
public String getUIComponentIdParameterName()
{
- return PortalRequestContext.UI_COMPONENT_ID;
+ return ComponentURL.PORTAL_COMPONENT_ID;
}
public SiteType getSiteType()
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalURLBuilder.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalURLBuilder.java 2011-11-15
09:22:58 UTC (rev 8071)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalURLBuilder.java 2011-11-15
12:21:46 UTC (rev 8072)
@@ -59,11 +59,7 @@
private String createURL(boolean ajax, UIComponent targetComponent, String action,
String confirm, String targetBeanId, Parameter[] params)
{
- Map<String,String[]> queryParameters = url.getQueryParameters();
- if (queryParameters != null)
- {
- queryParameters.clear();
- }
+ url.reset();
//
url.setAjax(ajax);
@@ -72,7 +68,7 @@
//
url.setAction(action);
- url.setTargetBeanId(targetBeanId);
+ url.setQueryParameterValue(UIComponent.OBJECTID, targetBeanId);
//
if (params != null)
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java 2011-11-15
09:22:58 UTC (rev 8071)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java 2011-11-15
12:21:46 UTC (rev 8072)
@@ -116,12 +116,8 @@
.append(PortalRequestContext.UI_COMPONENT_ID).append("=").append(this.portletId);
*/
- //Clear URL parameters
- Map<String, String[]> queryParameters = url.getQueryParameters();
- if (queryParameters != null)
- {
- queryParameters.clear();
- }
+ //Reset query parameters
+ url.reset();
String type;
if (containerURL instanceof RenderURL)
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/login/UIForgetPassword.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/login/UIForgetPassword.java 2011-11-15
09:22:58 UTC (rev 8071)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/login/UIForgetPassword.java 2011-11-15
12:21:46 UTC (rev 8072)
@@ -39,6 +39,7 @@
import org.exoplatform.webui.form.UIFormStringInput;
import org.exoplatform.webui.form.validator.EmailAddressValidator;
import org.exoplatform.webui.form.validator.MandatoryValidator;
+import org.exoplatform.webui.url.ComponentURL;
import org.gatein.wci.security.Credentials;
import java.net.URLEncoder;
@@ -145,7 +146,7 @@
HttpServletRequest request = portalContext.getRequest();
String host = request.getScheme() + "://" + request.getServerName() +
":" + request.getServerPort();
String activeLink = host + requestContext.getRequestContextPath() +
"/public/" + portalName
- +
"?portal:componentId=UIPortal&portal:action=RecoveryPasswordAndUsername&tokenId="
+ + "?" + ComponentURL.PORTAL_COMPONENT_ID +
"=UIPortal&portal:action=RecoveryPasswordAndUsername&tokenId="
+ tokenId;
String mailText = headerMail + "\n" + activeLink + footerMail;
try