[jboss-svn-commits] JBoss Portal SVN: r5486 - in branches/JBoss_Portal_Branch_2_4/wsrp: . src/main/org/jboss/portal/test/wsrp/portlet src/main/org/jboss/portal/test/wsrp/v1/producer src/main/org/jboss/portal/wsrp src/main/org/jboss/portal/wsrp/producer src/resources src/resources/test-usercontext-portlet-war src/resources/test-usercontext-portlet-war/WEB-INF
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Oct 19 18:04:09 EDT 2006
Author: chris.laprun at jboss.com
Date: 2006-10-19 18:04:06 -0400 (Thu, 19 Oct 2006)
New Revision: 5486
Added:
branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/UserContextPortlet.java
branches/JBoss_Portal_Branch_2_4/wsrp/src/resources/test-usercontext-portlet-war/
branches/JBoss_Portal_Branch_2_4/wsrp/src/resources/test-usercontext-portlet-war/WEB-INF/
branches/JBoss_Portal_Branch_2_4/wsrp/src/resources/test-usercontext-portlet-war/WEB-INF/portlet.xml
branches/JBoss_Portal_Branch_2_4/wsrp/src/resources/test-usercontext-portlet-war/WEB-INF/web.xml
Modified:
branches/JBoss_Portal_Branch_2_4/wsrp/build.xml
branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java
branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/UserContextConverter.java
branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
Log:
JBPORTAL-1086:
- Now should correctly propagate userContextKey.
- Added test.
Modified: branches/JBoss_Portal_Branch_2_4/wsrp/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/wsrp/build.xml 2006-10-19 09:23:01 UTC (rev 5485)
+++ branches/JBoss_Portal_Branch_2_4/wsrp/build.xml 2006-10-19 22:04:06 UTC (rev 5486)
@@ -462,6 +462,9 @@
<!-- Encode URL test portlet -->
<package-test-portlet archiveName="encodeurl" portletName="EncodeURL"/>
+
+ <!-- UserContext test portlet -->
+ <package-test-portlet archiveName="usercontext" portletName="UserContext"/>
</target>
<!-- Packages all the test related artifacts. Note that compilation should have be-->
Added: branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/UserContextPortlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/UserContextPortlet.java 2006-10-19 09:23:01 UTC (rev 5485)
+++ branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/UserContextPortlet.java 2006-10-19 22:04:06 UTC (rev 5486)
@@ -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.portal.test.wsrp.portlet;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision: 5440 $
+ * @since 2.4
+ */
+public class UserContextPortlet extends GenericPortlet
+{
+
+ protected void doView(RenderRequest request, RenderResponse response) throws PortletException, PortletSecurityException, IOException
+ {
+ response.setContentType("text/html");
+ Writer writer = response.getWriter();
+ writer.write("user: " + request.getRemoteUser());
+ }
+
+}
Modified: branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java 2006-10-19 09:23:01 UTC (rev 5485)
+++ branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java 2006-10-19 22:04:06 UTC (rev 5486)
@@ -405,6 +405,21 @@
undeploy(encodeURLPortletArchive);
}
+ public void testGetMarkupWithUserContext() throws Exception
+ {
+ undeploy(DEFAULT_MARKUP_PORTLET_WAR);
+ String userContextPortletArchive = "test-usercontext-portlet.war";
+ deploy(userContextPortletArchive);
+
+ GetMarkup getMarkup = createMarkupRequest(userContextPortletArchive);
+ getMarkup.setUserContext(WSRPTypeFactory.createUserContext("johndoe"));
+
+ MarkupResponse response = markupService.getMarkup(getMarkup);
+ checkMarkupResponse(response, "user: johndoe");
+
+ undeploy(userContextPortletArchive);
+ }
+
private MarkupContext checkMarkupResponse(MarkupResponse response, String markupString)
{
assertNotNull(response);
Modified: branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/UserContextConverter.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/UserContextConverter.java 2006-10-19 09:23:01 UTC (rev 5485)
+++ branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/UserContextConverter.java 2006-10-19 22:04:06 UTC (rev 5486)
@@ -170,6 +170,7 @@
private Map infos;
private String[] desiredLocales;
private Locale locale;
+ private String id;
public WSRPMappedUserContext(org.jboss.portal.wsrp.core.UserContext userContext, String[] desiredLocales, String preferredLocale)
{
@@ -213,6 +214,13 @@
infos.put(P3PConstants.INFO_USER_JOB_TITLE, employerInfo.getJobtitle());
}
}
+
+ String key = userContext.getUserContextKey();
+ if (key == null)
+ {
+ throw new IllegalArgumentException("Missing required userContextKey in UserContext!");
+ }
+ id = key;
}
else
{
@@ -222,7 +230,7 @@
public String getId()
{
- return null;
+ return id;
}
public Map getInformations()
Modified: branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2006-10-19 09:23:01 UTC (rev 5485)
+++ branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2006-10-19 22:04:06 UTC (rev 5486)
@@ -91,7 +91,6 @@
import org.jboss.portal.wsrp.core.WSRP_v1_Markup_PortType;
import org.jboss.portal.wsrp.invocation.WSRPActionContext;
import org.jboss.portal.wsrp.invocation.WSRPRenderContext;
-import org.jboss.portal.wsrp.servlet.ServletAccess;
import javax.activation.MimeTypeParseException;
import javax.portlet.PortletModeException;
@@ -657,7 +656,11 @@
public String getRemoteUser()
{
- return ServletAccess.getRequest().getRemoteUser(); // todo: check if this is correct
+ if (wsrpUserContext != null)
+ {
+ return wsrpUserContext.getUserContextKey();
+ }
+ return null;
}
public Principal getUserPrincipal()
@@ -667,13 +670,17 @@
public boolean isUserInRole(String roleName)
{
- List userCategories = Arrays.asList(wsrpUserContext.getUserCategories());
- return userCategories.contains(roleName);
+ if (wsrpUserContext != null)
+ {
+ List userCategories = Arrays.asList(wsrpUserContext.getUserCategories());
+ return userCategories.contains(roleName);
+ }
+ return false;
}
public boolean isAuthenticated()
{
- return false;
+ return wsrpUserContext != null;
}
};
}
Added: branches/JBoss_Portal_Branch_2_4/wsrp/src/resources/test-usercontext-portlet-war/WEB-INF/portlet.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/wsrp/src/resources/test-usercontext-portlet-war/WEB-INF/portlet.xml 2006-10-19 09:23:01 UTC (rev 5485)
+++ branches/JBoss_Portal_Branch_2_4/wsrp/src/resources/test-usercontext-portlet-war/WEB-INF/portlet.xml 2006-10-19 22:04:06 UTC (rev 5486)
@@ -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_1_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0">
+ <portlet>
+ <portlet-name>UserContext Test Portlet</portlet-name>
+ <portlet-class>org.jboss.portal.test.wsrp.portlet.UserContextPortlet</portlet-class>
+
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>view</portlet-mode>
+ </supports>
+
+ <portlet-info>
+ <title>title</title>
+ </portlet-info>
+ </portlet>
+
+</portlet-app>
\ No newline at end of file
Added: branches/JBoss_Portal_Branch_2_4/wsrp/src/resources/test-usercontext-portlet-war/WEB-INF/web.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/wsrp/src/resources/test-usercontext-portlet-war/WEB-INF/web.xml 2006-10-19 09:23:01 UTC (rev 5485)
+++ branches/JBoss_Portal_Branch_2_4/wsrp/src/resources/test-usercontext-portlet-war/WEB-INF/web.xml 2006-10-19 22:04:06 UTC (rev 5486)
@@ -0,0 +1,30 @@
+<?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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<web-app version="2.4"
+ xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+</web-app>
\ No newline at end of file
More information about the jboss-svn-commits
mailing list