From portal-commits at lists.jboss.org Wed Jan 17 16:32:25 2007 Content-Type: multipart/mixed; boundary="===============3184608240773515968==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r6022 - in trunk: core/src/main/org/jboss/portal/core/controller/classic and 6 other directories. Date: Wed, 17 Jan 2007 16:32:25 -0500 Message-ID: --===============3184608240773515968== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: julien(a)jboss.com Date: 2007-01-17 16:32:24 -0500 (Wed, 17 Jan 2007) New Revision: 6022 Added: trunk/server/src/main/org/jboss/portal/test/server/request/ trunk/server/src/main/org/jboss/portal/test/server/request/URLContextTes= tCase.java Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomi= zerInterceptor.java trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicCont= roller.java trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResp= onseHandler.java trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvo= cationFactory.java trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResp= onseHandler.java trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPor= tletWindowCommand.java trunk/server/build.xml trunk/server/src/main/org/jboss/portal/server/request/URLContext.java Log: - added URLContext test cases - on the tab logout URL, do not use the authenticated servlet Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/Page= CustomizerInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustom= izerInterceptor.java 2007-01-17 20:54:46 UTC (rev 6021) +++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustom= izerInterceptor.java 2007-01-17 21:32:24 UTC (rev 6022) @@ -157,7 +157,7 @@ if (controllerCtx.getServerInvocation().getServerContext().getClient= Request().getRemoteUser() =3D=3D null) { URLContext ctx =3D controllerCtx.getServerInvocation().getServerC= ontext().getURLContext(); - ctx =3D URLContext.newInstance(ctx.getSecure(), true); + ctx =3D URLContext.newInstance(ctx.isSecure(), true); String loginURL =3D controllerCtx.renderURL(cc, ctx, null); sb.append("Login"); } @@ -253,7 +253,8 @@ } = SignOutCommand cmd =3D new SignOutCommand(); - String logoutURL =3D controllerCtx.renderURL(cmd, null, null); + URLContext urlContext =3D controllerCtx.getServerInvocation().get= ServerContext().getURLContext(); + String logoutURL =3D controllerCtx.renderURL(cmd, urlContext.asNo= nAuthenticated(), null); = // if (user !=3D null) Modified: trunk/core/src/main/org/jboss/portal/core/controller/classic/Clas= sicController.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicCon= troller.java 2007-01-17 20:54:46 UTC (rev 6021) +++ trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicCon= troller.java 2007-01-17 21:32:24 UTC (rev 6022) @@ -134,7 +134,7 @@ } else { - urlContext =3D URLContext.newInstance(urlContext.getSecure(), = true); + urlContext =3D URLContext.newInstance(urlContext.isSecure(), t= rue); ServerURL serverURL =3D getURLFactory().doMapping(invocation, = cmd); String url =3D invocation.getResponse().renderURL(serverURL, u= rlContext, null); AbstractResponseHandler.sendRedirect(invocation, url); @@ -200,8 +200,8 @@ } else { - boolean currentSecure =3D currentURLCtx.getSecure(); - if (nextURLCtx !=3D null && nextURLCtx.getSecure() && !current= Secure) + boolean currentSecure =3D currentURLCtx.isSecure(); + if (nextURLCtx !=3D null && nextURLCtx.isSecure() && !currentS= ecure) { return true; } Modified: trunk/core/src/main/org/jboss/portal/core/controller/classic/Clas= sicResponseHandler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicRes= ponseHandler.java 2007-01-17 20:54:46 UTC (rev 6021) +++ trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicRes= ponseHandler.java 2007-01-17 21:32:24 UTC (rev 6022) @@ -74,9 +74,8 @@ PortalObjectContainer portalObjectContainer =3D ctx.getControl= ler().getPortalObjectContainer(); Portal portal =3D (Portal)portalObjectContainer.getObject(defa= ultPortalPath); RenderPageCommand renderCmd =3D new RenderPageCommand(portal.g= etId()); - boolean secure =3D invocation.getServerContext().getURLContext= ().getSecure(); - URLContext urlContext =3D URLContext.newInstance(secure, false= ); - location =3D ctx.renderURL(renderCmd, urlContext, null); + URLContext urlContext =3D invocation.getServerContext().getURL= Context(); + location =3D ctx.renderURL(renderCmd, urlContext.asNonAuthenti= cated(), null); } = // Modified: trunk/core/src/main/org/jboss/portal/core/controller/portlet/Port= letInvocationFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletInv= ocationFactory.java 2007-01-17 20:54:46 UTC (rev 6021) +++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletInv= ocationFactory.java 2007-01-17 21:32:24 UTC (rev 6022) @@ -245,7 +245,7 @@ } = // - boolean secure =3D controllerContext.getServerInvocation().getServer= Context().getURLContext().getSecure(); + boolean secure =3D controllerContext.getServerInvocation().getServer= Context().getURLContext().isSecure(); if (wantSecure !=3D null) { secure =3D wantSecure.booleanValue(); Modified: trunk/core/src/main/org/jboss/portal/core/controller/portlet/Port= letResponseHandler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletRes= ponseHandler.java 2007-01-17 20:54:46 UTC (rev 6021) +++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletRes= ponseHandler.java 2007-01-17 21:32:24 UTC (rev 6022) @@ -118,7 +118,7 @@ InvokePortletWindowActionCommand iwac =3D (InvokePortletWin= dowActionCommand)cmd; Page page =3D iwac.getPage(); RenderPageCommand renderCmd =3D new RenderPageCommand(page.= getId()); - boolean secure =3D invocation.getServerContext().getURLCont= ext().getSecure(); + boolean secure =3D invocation.getServerContext().getURLCont= ext().isSecure(); URLContext urlContext =3D URLContext.newInstance(secure, fa= lse); location =3D ctx.renderURL(renderCmd, urlContext, null); } Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/Re= nderPortletWindowCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPo= rtletWindowCommand.java 2007-01-17 20:54:46 UTC (rev 6021) +++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPo= rtletWindowCommand.java 2007-01-17 21:32:24 UTC (rev 6022) @@ -353,7 +353,7 @@ InvokePortletWindowRenderCommand cmd =3D new InvokePortletWindowRend= erCommand(window.getId(), mode, windowState); ControllerContext controllerContext =3D getControllerContext(); ServerInvocationContext serverContext =3D controllerContext.getServe= rInvocation().getServerContext(); - boolean secure =3D serverContext.getURLContext().getSecure(); + boolean secure =3D serverContext.getURLContext().isSecure(); boolean authenticated =3D serverContext.getURLContext().isAuthentica= ted(); URLContext urlContext =3D URLContext.newInstance(secure, authenticat= ed); return controllerContext.renderURL(cmd, urlContext, URLFormat.newIns= tance(true, true)); Modified: trunk/server/build.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/server/build.xml 2007-01-17 20:54:46 UTC (rev 6021) +++ trunk/server/build.xml 2007-01-17 21:32:24 UTC (rev 6022) @@ -310,10 +310,11 @@ - - - + + + + Modified: trunk/server/src/main/org/jboss/portal/server/request/URLContext.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/server/src/main/org/jboss/portal/server/request/URLContext.java 2= 007-01-17 20:54:46 UTC (rev 6021) +++ trunk/server/src/main/org/jboss/portal/server/request/URLContext.java 2= 007-01-17 21:32:24 UTC (rev 6022) @@ -31,10 +31,10 @@ public final class URLContext { = - /** . */ + /** Mask for secure bit. */ public static final int SEC_MASK =3D 0x01; = - /** . */ + /** Mask for authenticated bit. */ public static final int AUTH_MASK =3D 0x02; = /** . */ @@ -62,7 +62,7 @@ this.authenticated =3D authenticated; } = - public boolean getSecure() + public boolean isSecure() { return secure; } @@ -72,6 +72,30 @@ return authenticated; } = + public URLContext asSecured() + { + int newMask =3D mask | SEC_MASK; + return contexts[newMask]; + } + + public URLContext asNonSecured() + { + int newMask =3D mask & ~SEC_MASK; + return contexts[newMask]; + } + + public URLContext asAuthenticated() + { + int newMask =3D mask | AUTH_MASK; + return contexts[newMask]; + } + + public URLContext asNonAuthenticated() + { + int newMask =3D mask & ~AUTH_MASK; + return contexts[newMask]; + } + public int getMask() { return mask; Added: trunk/server/src/main/org/jboss/portal/test/server/request/URLContex= tTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/server/src/main/org/jboss/portal/test/server/request/URLContextTe= stCase.java (rev 0) +++ trunk/server/src/main/org/jboss/portal/test/server/request/URLContextTe= stCase.java 2007-01-17 21:32:24 UTC (rev 6022) @@ -0,0 +1,88 @@ +/*************************************************************************= ***** + * 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.server.request; + +import junit.framework.TestCase; +import org.jboss.portal.server.request.URLContext; + +/** + * @author Julien Viet + * @version $Revision: 1.1 $ + */ +public class URLContextTestCase extends TestCase +{ + + URLContext a =3D URLContext.newInstance(false, false); + URLContext b =3D URLContext.newInstance(true, false); + URLContext c =3D URLContext.newInstance(false, true); + URLContext d =3D URLContext.newInstance(true, true); + + public void testFactory() + { + assertFalse(a.isSecure()); + assertFalse(a.isAuthenticated()); + assertEquals(0, a.getMask()); + + // + assertTrue(b.isSecure()); + assertFalse(b.isAuthenticated()); + assertEquals(URLContext.SEC_MASK, b.getMask()); + + // + assertFalse(c.isSecure()); + assertTrue(c.isAuthenticated()); + assertEquals(URLContext.AUTH_MASK, c.getMask()); + + // + assertTrue(d.isSecure()); + assertTrue(d.isAuthenticated()); + assertEquals(URLContext.AUTH_MASK | URLContext.SEC_MASK, d.getMask()= ); + } + + public void testTransformation() + { + assertEquals(a, a.asNonSecured()); + assertEquals(a, a.asNonAuthenticated()); + assertEquals(b, a.asSecured()); + assertEquals(c, a.asAuthenticated()); + + // + assertEquals(a, b.asNonSecured()); + assertEquals(b, b.asNonAuthenticated()); + assertEquals(b, b.asSecured()); + assertEquals(d, b.asAuthenticated()); + + // + assertEquals(c, c.asNonSecured()); + assertEquals(a, c.asNonAuthenticated()); + assertEquals(d, c.asSecured()); + assertEquals(c, c.asAuthenticated()); + + // + assertEquals(c, d.asNonSecured()); + assertEquals(b, d.asNonAuthenticated()); + assertEquals(d, d.asSecured()); + assertEquals(d, d.asAuthenticated()); + } + +} --===============3184608240773515968==--