cziegeler 2003/05/28 00:14:41
Modified: src/blocks/portal/samples/skins/common/styles header.xsl tab.xsl src/blocks/portal/samples sitemap.xmap src/blocks/portal/java/org/apache/cocoon/portal/profile/impl AuthenticationProfileManager.java Added: src/blocks/portal/java/org/apache/cocoon/portal/acting LogoutAction.java LoginAction.java src/blocks/portal/samples/skins/common/images logout-door.gif src/blocks/portal/conf actions.xmap Log: Implementing login and logout Revision Changes Path 1.4 +1 -2 cocoon-2.1/src/blocks/portal/samples/skins/common/styles/header.xsl Index: header.xsl =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/samples/skins/common/styles/header.xsl,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- header.xsl 27 May 2003 14:30:45 -0000 1.3 +++ header.xsl 28 May 2003 07:14:40 -0000 1.4 @@ -23,9 +23,8 @@ </td> </tr> <tr> - <td align="right" height="1%" noWrap="" bgcolor="#294563" width="1%"> + <td align="center" height="1%" noWrap="" bgcolor="#294563" width="1%"> <img src="space.gif" width="300" height="10"/> - <a href="logout">LOGOUT</a> </td> </tr> </tbody> 1.3 +10 -4 cocoon-2.1/src/blocks/portal/samples/skins/common/styles/tab.xsl Index: tab.xsl =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/samples/skins/common/styles/tab.xsl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- tab.xsl 27 May 2003 11:10:20 -0000 1.2 +++ tab.xsl 28 May 2003 07:14:40 -0000 1.3 @@ -89,15 +89,21 @@ </xsl:choose> </xsl:for-each> <td width="99%" bgcolor="#294563"> - <!-- ~~~~~ last "blank" tab, filling the rest of the tab row ~~~~~ --> + <!-- ~~~~~ last "blank" tab, contains logout button ~~~~~ --> <table style="height: 2.0em" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> - <td height="99%" bgcolor="#294563" width="100%"> - <img height="5" src="space.gif" width="1"/> + <td height="99%" bgcolor="#294563" width="99%" align="right" valign="center"> + <a href="logout"><img src="logout-door.gif" width="18" height="22" border="0"/></a><img height="10" src="sunspotdemoimg-space.gif" width="5"/> + </td> + <td height="99%" bgcolor="#294563" width="1%" align="right" valign="center"> + <a href="logout" style="color:#4C6C8F;font-size:75%;">Logout</a> </td> </tr> <tr> - <td height="1" bgcolor="#4C6C8F" width="100%"> + <td height="1" bgcolor="#4C6C8F" width="99%"> + <img height="10" src="space.gif" width="1"/> + </td> + <td height="1" bgcolor="#4C6C8F" width="1%"> <img height="10" src="space.gif" width="1"/> </td> </tr> 1.1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/acting/LogoutAction.java Index: LogoutAction.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.portal.acting; import java.util.Map; import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.parameters.ParameterException; import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.framework.thread.ThreadSafe; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.acting.ComposerAction; import org.apache.cocoon.environment.Redirector; import org.apache.cocoon.environment.SourceResolver; import org.apache.cocoon.portal.PortalService; import org.apache.cocoon.portal.profile.ProfileManager; /** * This action logs the current user out of the portal * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @version CVS $Id: LogoutAction.java,v 1.1 2003/05/28 07:14:41 cziegeler Exp $ */ public final class LogoutAction extends ComposerAction implements ThreadSafe { public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters par) throws Exception { if (this.getLogger().isDebugEnabled() ) { this.getLogger().debug("BEGIN act resolver="+resolver+ ", objectModel="+objectModel+ ", source="+source+ ", par="+par); } PortalService service = null; try { service = (PortalService)this.manager.lookup(PortalService.ROLE); service.setPortalName(par.getParameter("portal-name")); } catch (ParameterException pe) { throw new ProcessingException("Parameter portal-name is required."); } catch (ComponentException ce) { throw new ProcessingException("Unable to lookup portal service.", ce); } finally { this.manager.release(service); } // logout ProfileManager profileManager = null; try { profileManager = (ProfileManager) this.manager.lookup(ProfileManager.ROLE); profileManager.logout(); } finally { this.manager.release( (Component)profileManager ); } if (this.getLogger().isDebugEnabled() ) { this.getLogger().debug("END act map={}"); } return EMPTY_MAP; } } 1.1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/acting/LoginAction.java Index: LoginAction.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.portal.acting; import java.util.Map; import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.parameters.ParameterException; import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.framework.thread.ThreadSafe; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.acting.ComposerAction; import org.apache.cocoon.environment.Redirector; import org.apache.cocoon.environment.SourceResolver; import org.apache.cocoon.portal.PortalService; import org.apache.cocoon.portal.profile.ProfileManager; /** * This action logs the user into the portal * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @version CVS $Id: LoginAction.java,v 1.1 2003/05/28 07:14:41 cziegeler Exp $ */ public final class LoginAction extends ComposerAction implements ThreadSafe { public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters par) throws Exception { if (this.getLogger().isDebugEnabled() ) { this.getLogger().debug("BEGIN act resolver="+resolver+ ", objectModel="+objectModel+ ", source="+source+ ", par="+par); } PortalService service = null; try { service = (PortalService)this.manager.lookup(PortalService.ROLE); service.setPortalName(par.getParameter("portal-name")); } catch (ParameterException pe) { throw new ProcessingException("Parameter portal-name is required."); } catch (ComponentException ce) { throw new ProcessingException("Unable to lookup portal service.", ce); } finally { this.manager.release(service); } // login ProfileManager profileManager = null; try { profileManager = (ProfileManager) this.manager.lookup(ProfileManager.ROLE); profileManager.login(); } finally { this.manager.release( (Component)profileManager ); } if (this.getLogger().isDebugEnabled() ) { this.getLogger().debug("END act map={}"); } return EMPTY_MAP; } } 1.9 +11 -1 cocoon-2.1/src/blocks/portal/samples/sitemap.xmap Index: sitemap.xmap =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/samples/sitemap.xmap,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- sitemap.xmap 27 May 2003 14:30:45 -0000 1.8 +++ sitemap.xmap 28 May 2003 07:14:41 -0000 1.9 @@ -113,6 +113,12 @@ <map:match pattern="login"> <map:act type="auth-loggedIn"> <map:parameter name="handler" value="portalhandler"/> + <map:parameter name="application" value="portal"/> + + <map:act type="portal-login"> + <map:parameter name="portal-name" value="portal"/> + </map:act> + <map:redirect-to uri="portal"/> </map:act> <map:generate src="resources/login.xml"/> @@ -155,10 +161,14 @@ <map:match pattern="logout"> <map:act type="auth-protect"> <map:parameter name="handler" value="portalhandler"/> + <map:parameter name="application" value="portal"/> + <map:act type="portal-logout"> + <map:parameter name="portal-name" value="portal"/> + </map:act> <map:act type="auth-logout"/> </map:act> -<!-- TODO logout??? --> + <!-- TODO logout page --> <map:redirect-to uri="login"/> </map:match> 1.4 +29 -28 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java Index: AuthenticationProfileManager.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- AuthenticationProfileManager.java 27 May 2003 14:07:16 -0000 1.3 +++ AuthenticationProfileManager.java 28 May 2003 07:14:41 -0000 1.4 @@ -208,14 +208,15 @@ layout = (Layout)service.getAttribute(portalPrefix+"/Layout"); if (layout == null) { this.lock.readLock(); + HashMap map = new HashMap(); + HashMap keyMap = new HashMap(); + CopletDataManager copletDataManager = null; try { - HashMap map = new HashMap(); map.put("portalname", service.getPortalName()); // TODO Change to KeyManager usage RequestState state = this.getRequestState(); UserHandler handler = state.getHandler(); - HashMap keyMap = new HashMap(); keyMap.put("user", handler.getUserId()); keyMap.put("role", handler.getContext().getContextInfo().get("role")); keyMap.put("config", state.getApplicationConfiguration().getConfiguration("portal")); @@ -229,33 +230,33 @@ // load coplet data map.put("profile", "copletdata"); map.put("objectmap", copletBaseDataManager.getCopletBaseData()); - CopletDataManager copletDataManager = (CopletDataManager)this.getDeltaProfile(keyMap, map, portalPrefix+"/CopletData", service, copletFactory, ((Boolean)result[1]).booleanValue()); + copletDataManager = (CopletDataManager)this.getDeltaProfile(keyMap, map, portalPrefix+"/CopletData", service, copletFactory, ((Boolean)result[1]).booleanValue()); - // load coplet instance data - map.put("profile", "copletinstancedata"); - map.put("objectmap", copletDataManager.getCopletData()); - CopletInstanceDataManager copletInstanceDataManager = (CopletInstanceDataManager)this.getOrCreateProfile(keyMap, map, portalPrefix+"/CopletInstanceData", service, copletFactory); - - // load layout - map.put("profile", "layout"); - map.put("objectmap", copletInstanceDataManager.getCopletInstanceData()); - layout = (Layout)this.getOrCreateProfile(keyMap, map, portalPrefix+"/Layout", service, factory); - - // now invoke login on each instance - Iterator iter = copletInstanceDataManager.getCopletInstanceData().values().iterator(); - while ( iter.hasNext() ) { - CopletInstanceData cid = (CopletInstanceData) iter.next(); - CopletAdapter adapter = null; - try { - adapter = (CopletAdapter) adapterSelector.select(cid.getCopletData().getCopletBaseData().getCopletAdapterName()); - adapter.login( cid ); - } finally { - adapterSelector.release( adapter ); - } + } finally { + this.lock.releaseLocks(); + } + // load coplet instance data + map.put("profile", "copletinstancedata"); + map.put("objectmap", copletDataManager.getCopletData()); + CopletInstanceDataManager copletInstanceDataManager = (CopletInstanceDataManager)this.getOrCreateProfile(keyMap, map, portalPrefix+"/CopletInstanceData", service, copletFactory); + + // load layout + map.put("profile", "layout"); + map.put("objectmap", copletInstanceDataManager.getCopletInstanceData()); + layout = (Layout)this.getOrCreateProfile(keyMap, map, portalPrefix+"/Layout", service, factory); + + // now invoke login on each instance + Iterator iter = copletInstanceDataManager.getCopletInstanceData().values().iterator(); + while ( iter.hasNext() ) { + CopletInstanceData cid = (CopletInstanceData) iter.next(); + CopletAdapter adapter = null; + try { + adapter = (CopletAdapter) adapterSelector.select(cid.getCopletData().getCopletBaseData().getCopletAdapterName()); + adapter.login( cid ); + } finally { + adapterSelector.release( adapter ); } - } finally { - this.lock.releaseLocks(); - } + } } return layout; 1.1 cocoon-2.1/src/blocks/portal/samples/skins/common/images/logout-door.gif <<Binary file>> 1.1 cocoon-2.1/src/blocks/portal/conf/actions.xmap Index: actions.xmap =================================================================== <?xml version="1.0"?> <xmap xpath="/sitemap/components/actions" unless="[EMAIL PROTECTED]'portal-login']"> <map:action name="portal-login" src="org.apache.cocoon.portal.acting.LoginAction"/> <map:action name="portal-logout" src="org.apache.cocoon.portal.acting.LogoutAction"/> <map:action name="portal-object-model" src="org.apache.cocoon.portal.acting.ObjectModelAction"/> </xmap>