Author: julien(a)jboss.com
Date: 2008-03-03 04:51:51 -0500 (Mon, 03 Mar 2008)
New Revision: 10177
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/userinformation/
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/userinformation/NullProfileForUnauthenticatedIdentityTestCase.java
modules/portlet/trunk/test/src/test/resources/jsr286/tck/userinformation-war/
modules/portlet/trunk/test/src/test/resources/jsr286/tck/userinformation-war/WEB-INF/
modules/portlet/trunk/test/src/test/resources/jsr286/tck/userinformation-war/WEB-INF/portlet.xml
modules/portlet/trunk/test/src/test/resources/jsr286/tck/userinformation-war/WEB-INF/web.xml
Modified:
modules/portlet/trunk/pom.xml
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
modules/portlet/trunk/test/src/test/build.xml
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
- added test case to assert that the user profile is not present when the user is not
authenticated
- added maven profiles for portlet module
Modified: modules/portlet/trunk/pom.xml
===================================================================
--- modules/portlet/trunk/pom.xml 2008-03-02 23:21:50 UTC (rev 10176)
+++ modules/portlet/trunk/pom.xml 2008-03-03 09:51:51 UTC (rev 10177)
@@ -32,6 +32,39 @@
<module>docs</module>
</modules>
</profile>
+ <profile>
+ <id>test</id>
+ <modules>
+ <module>build</module>
+ <module>portlet</module>
+ <module>controller</module>
+ <module>mc</module>
+ <module>test</module>
+ </modules>
+ </profile>
+ <profile>
+ <id>simple-portal</id>
+ <modules>
+ <module>build</module>
+ <module>portlet</module>
+ <module>controller</module>
+ <module>mc</module>
+ <module>portal</module>
+ <module>samples</module>
+ </modules>
+ </profile>
+ <profile>
+ <id>release</id>
+ <modules>
+ <module>build</module>
+ <module>portlet</module>
+ <module>controller</module>
+ <module>mc</module>
+ <module>portal</module>
+ <module>samples</module>
+ <module>docs</module>
+ </modules>
+ </profile>
</profiles>
<modules>
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java 2008-03-02
23:21:50 UTC (rev 10176)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestAttributes.java 2008-03-03
09:51:51 UTC (rev 10177)
@@ -23,7 +23,9 @@
package org.jboss.portal.portlet.impl.jsr168;
import org.jboss.portal.portlet.impl.info.ContainerUserInfo;
+import org.jboss.portal.portlet.impl.jsr168.api.PortletRequestImpl;
import org.jboss.portal.portlet.spi.UserContext;
+import org.jboss.portal.portlet.spi.SecurityContext;
import org.jboss.portal.portlet.container.PortletContainer;
import javax.portlet.PortletRequest;
@@ -56,6 +58,9 @@
protected static final Object REMOVED_ATTRIBUTE = new Object();
/** . */
+ private final SecurityContext securityContext;
+
+ /** . */
private final PortletContainer container;
/** . */
@@ -68,10 +73,15 @@
private Map<String, Object> attributes;
public PortletRequestAttributes(
+ SecurityContext securityContext,
PortletContainer container,
UserContext userContext,
HttpServletRequestWrapper wreq)
{
+ if (securityContext == null)
+ {
+ throw new IllegalArgumentException("No null portlet request
allowed");
+ }
if (container == null)
{
throw new IllegalArgumentException("No null container allowed");
@@ -85,6 +95,8 @@
throw new IllegalArgumentException("No null wrapped request
allowed");
}
+ //
+ this.securityContext = securityContext;
this.container = container;
this.userContext = userContext;
this.wreq = wreq;
@@ -98,6 +110,12 @@
}
if (PortletRequest.USER_INFO.equals(name))
{
+ if (!securityContext.isAuthenticated())
+ {
+ return null;
+ }
+
+ //
Map<String, String> infos = userContext.getInformations();
//
@@ -116,6 +134,10 @@
// Make it immutable
infos = Collections.unmodifiableMap(infos);
}
+ else
+ {
+ infos = Collections.emptyMap();
+ }
//
return infos;
@@ -170,9 +192,14 @@
}
}
}
- names.add(PortletRequest.USER_INFO);
//
+ if (securityContext.isAuthenticated())
+ {
+ names.add(PortletRequest.USER_INFO);
+ }
+
+ //
return names.iterator();
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-03-02
23:21:50 UTC (rev 10176)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-03-03
09:51:51 UTC (rev 10177)
@@ -149,7 +149,7 @@
HttpServletRequestWrapper realReq = new
HttpServletRequestWrapper(invocation.getDispatchedRequest());
//
- PortletRequestAttributes attributes = new PortletRequestAttributes(container,
userContext, realReq);
+ PortletRequestAttributes attributes = new
PortletRequestAttributes(invocation.getSecurityContext(), container, userContext,
realReq);
if (invocation.getAttributes() != null)
{
attributes.setAttributeMap(invocation.getAttributes());
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/userinformation/NullProfileForUnauthenticatedIdentityTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/userinformation/NullProfileForUnauthenticatedIdentityTestCase.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/userinformation/NullProfileForUnauthenticatedIdentityTestCase.java 2008-03-03
09:51:51 UTC (rev 10177)
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.portal.test.portlet.jsr286.tck.userinformation;
+
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.Assertion;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.*;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+import java.io.IOException;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase(/*Assertion.JSR286_302*/)
+public class NullProfileForUnauthenticatedIdentityTestCase
+{
+
+ public NullProfileForUnauthenticatedIdentityTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertNull(request.getUserPrincipal());
+
+ //
+ Object info = request.getAttribute(PortletRequest.USER_INFO);
+ assertNull("Was not expecting a profile", info);
+
+ //
+ Set<String> names = Tools.toSet(request.getAttributeNames());
+ assertFalse(names.contains(PortletRequest.USER_INFO));
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-03-02 23:21:50 UTC (rev 10176)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-03-03 09:51:51 UTC (rev 10177)
@@ -79,15 +79,7 @@
<pathelement path="${dependency.jbossxb.jar}"/>
</path>
<path id="mc.jboss_aop">
- <!--<pathelement
path="${dependency.jboss-aop-as4-deployer.jar}"/>-->
- <!--<pathelement
path="${dependency.jboss-aop-deployer-jdk50.jar}"/>-->
- <!--<pathelement
path="${dependency.jboss-aop-jdk50.jar}"/>-->
- <!--<pathelement
path="${dependency.jboss-aop-jdk50-client.jar}"/>-->
- <!--<pathelement
path="${dependency.jboss-standalone-aspect-library-jdk50.jar}"/>-->
- <!--<pathelement
path="${dependency.jrockit-pluggable-instrumentor.jar}"/>-->
- <!--<pathelement
path="${dependency.pluggable-instrumentor.jar}"/>-->
<pathelement path="${dependency.jboss-aop.jar}"/>
-
</path>
<path id="mc.jboss_microcontainer">
<pathelement path="${dependency.jboss-aop-mc-int.jar}"/>
@@ -377,6 +369,7 @@
<package-jsr286-tck-test test="portleturl"/>
<package-jsr286-tck-test test="portletfilter"/>
<package-jsr286-tck-test test="taglib"/>
+ <package-jsr286-tck-test test="userinformation"/>
<package-jsr286-api-test test="event"/>
<package-jsr286-api-test test="portleturl"/>
<package-jsr286-ext-test test="portletrequests"/>
@@ -848,69 +841,4 @@
</target>
-<!--
- <target name="__package-demo-portlets"
depends="prepare_env">
-
- <property name="samples.target.dir"
value="${portal.dir}/samples"/>
- <property name="samples.tmp.dir"
value="${test.temp.dir}/portal"/>
-
- <mkdir dir="${samples.tmp.dir}"/>
- <mkdir dir="${samples.target.dir}"/>
-
- <copy todir="${samples.tmp.dir}/samples-google-map-portlet-war">
- <fileset
dir="src/test/resources/portal/samples/google-map-portlet-war"/>
- </copy>
- <copy
todir="${samples.tmp.dir}/samples-google-map-portlet-war/WEB-INF/classes">
- <fileset dir="${target}/classes"
-
includes="org/jboss/portal/portlet/portal/samples/GoogleClippingPortlet.class"/>
- </copy>
- <jar
jarfile="${samples.target.dir}/samples-google-map-portlet.war">
- <fileset
dir="${samples.tmp.dir}/samples-google-map-portlet-war"/>
- </jar>
-
- <copy
todir="${samples.tmp.dir}/samples-google-weather-portlet-war">
- <fileset
dir="src/test/resources/portal/samples/google-weather-portlet-war"/>
- </copy>
- <copy
todir="${samples.tmp.dir}/samples-google-weather-portlet-war/WEB-INF/classes">
- <fileset dir="${target}/classes"
includes="org/jboss/portal/portlet/portal/samples/*.class"
-
excludes="org/jboss/portal/portlet/portal/samples/RemoteControlResourcePortlet.class"/>
- </copy>
- <jar
jarfile="${samples.target.dir}/samples-google-weather-portlet.war">
- <fileset
dir="${samples.tmp.dir}/samples-google-weather-portlet-war"/>
- </jar>
-
- <copy
todir="${samples.tmp.dir}/samples-remotecontrol-portlet-war">
- <fileset
dir="src/test/resources/portal/samples/remotecontrol-portlet-war"/>
- </copy>
- <copy
todir="${samples.tmp.dir}/samples-remotecontrol-portlet-war/WEB-INF/classes">
- <fileset dir="${target}/classes"
-
includes="org/jboss/portal/portlet/portal/samples/RemoteControlResourcePortlet.class"/>
- </copy>
- <jar
jarfile="${samples.target.dir}/samples-remotecontrol-portlet.war">
- <fileset
dir="${samples.tmp.dir}/samples-remotecontrol-portlet-war"/>
- </jar>
-
- <copy todir="${samples.tmp.dir}/samples-cart-event-portlet-war">
- <fileset
dir="src/test/resources/portal/samples/cart-event-portlet-war"/>
- </copy>
- <copy
todir="${samples.tmp.dir}/samples-cart-event-portlet-war/WEB-INF/classes">
- <fileset dir="${target}/classes"
includes="org/jboss/portal/portlet/portal/samples/event/*.class"/>
- </copy>
- <jar
jarfile="${samples.target.dir}/samples-cart-event-portlet.war">
- <fileset
dir="${samples.tmp.dir}/samples-cart-event-portlet-war"/>
- </jar>
-
- <copy todir="${samples.tmp.dir}/samples-basic-war">
- <fileset dir="src/test/resources/portal/samples/basic-war"/>
- </copy>
- <copy
todir="${samples.tmp.dir}/samples-basic-war/WEB-INF/classes">
- <fileset dir="${target}/classes"
includes="org/jboss/portal/portlet/portal/samples/basic/**"/>
- </copy>
- <jar jarfile="${samples.target.dir}/samples-basic.war">
- <fileset dir="${samples.tmp.dir}/samples-basic-war"/>
- </jar>
-
- </target>
--->
-
</project>
\ No newline at end of file
Added:
modules/portlet/trunk/test/src/test/resources/jsr286/tck/userinformation-war/WEB-INF/portlet.xml
===================================================================
---
modules/portlet/trunk/test/src/test/resources/jsr286/tck/userinformation-war/WEB-INF/portlet.xml
(rev 0)
+++
modules/portlet/trunk/test/src/test/resources/jsr286/tck/userinformation-war/WEB-INF/portlet.xml 2008-03-03
09:51:51 UTC (rev 10177)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<portlet-app
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2...
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ version="2.0">
+
+ <portlet>
+ <portlet-name>UniversalTestPortletA</portlet-name>
+
<portlet-class>org.jboss.portal.test.portlet.framework.UTP1</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ </portlet>
+
+ <user-attribute>
+ <name>user.name.given</name>
+ </user-attribute>
+
+</portlet-app>
Added:
modules/portlet/trunk/test/src/test/resources/jsr286/tck/userinformation-war/WEB-INF/web.xml
===================================================================
---
modules/portlet/trunk/test/src/test/resources/jsr286/tck/userinformation-war/WEB-INF/web.xml
(rev 0)
+++
modules/portlet/trunk/test/src/test/resources/jsr286/tck/userinformation-war/WEB-INF/web.xml 2008-03-03
09:51:51 UTC (rev 10177)
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <listener>
+
<listener-class>org.jboss.portal.unit.PortletTestSuite</listener-class>
+ </listener>
+</web-app>
Modified: modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-03-02
23:21:50 UTC (rev 10176)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-03-03
09:51:51 UTC (rev 10177)
@@ -191,6 +191,10 @@
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr286-tck-taglib.war"/>
</generic>
+ <generic>
+ <class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
+ <property name="archiveId"
value="test-jsr286-tck-userinformation.war"/>
+ </generic>
<!--Spec API Assertions tests-->
<generic>