Author: alain_defrance
Date: 2010-09-30 10:05:42 -0400 (Thu, 30 Sep 2010)
New Revision: 4444
Added:
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/LogoutControl.java
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/application/PortalLogoutLifecycle.java
Modified:
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java
portal/branches/wci/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java
portal/branches/wci/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalActionListener.java
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
Log:
WCI authentication in progress
Modified:
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java
===================================================================
---
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java 2010-09-30
14:01:44 UTC (rev 4443)
+++
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java 2010-09-30
14:05:42 UTC (rev 4444)
@@ -122,7 +122,10 @@
req.getSession().removeAttribute(InitiateLoginServlet.CREDENTIALS);
sendAuth(resp, credentials.getUsername(),
genericAuthentication.getTicket());
}
- resp.sendRedirect(resp.encodeRedirectURL(""));
+ else
+ {
+ resp.sendRedirect(resp.encodeRedirectURL(""));
+ }
}
}
Added:
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/LogoutControl.java
===================================================================
---
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/LogoutControl.java
(rev 0)
+++
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/LogoutControl.java 2010-09-30
14:05:42 UTC (rev 4444)
@@ -0,0 +1,44 @@
+/*
+* Copyright (C) 2003-2009 eXo Platform SAS.
+*
+* 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.exoplatform.web.login;
+
+/**
+ * @author <a href="mailto:alain.defrance@exoplatform.com">Alain
Defrance</a>
+ * @version $Revision$
+ */
+public class LogoutControl
+{
+ private static final ThreadLocal<Boolean> wantLogout = new
ThreadLocal<Boolean>();
+
+ public static void cancelLogout()
+ {
+ wantLogout.set(false);
+ }
+
+ public static void wantLogout()
+ {
+ wantLogout.set(true);
+ }
+
+ public static boolean isLogoutRequired()
+ {
+ return wantLogout.get();
+ }
+}
Modified:
portal/branches/wci/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java
===================================================================
---
portal/branches/wci/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java 2010-09-30
14:01:44 UTC (rev 4443)
+++
portal/branches/wci/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java 2010-09-30
14:05:42 UTC (rev 4444)
@@ -44,6 +44,7 @@
import org.exoplatform.portal.webui.workspace.UIWorkingWorkspace;
import org.exoplatform.util.ReflectionUtil;
import org.exoplatform.web.application.ApplicationMessage;
+import org.exoplatform.web.login.LogoutControl;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.ComponentConfigs;
@@ -252,7 +253,7 @@
if (config == null || Util.getUIPortal().getName().equals(portalName))
{
HttpServletRequest request = prContext.getRequest();
- request.getSession().invalidate();
+ LogoutControl.wantLogout();
prContext.setResponseComplete(true);
prContext.getResponse().sendRedirect(request.getContextPath());
return;
Modified: portal/branches/wci/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml
===================================================================
---
portal/branches/wci/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml 2010-09-30
14:01:44 UTC (rev 4443)
+++
portal/branches/wci/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml 2010-09-30
14:05:42 UTC (rev 4444)
@@ -33,6 +33,7 @@
<application-lifecycle-listeners>
<listener>org.exoplatform.portal.application.UserSiteLifeCycle</listener>
+
<listener>org.exoplatform.portal.application.PortalLogoutLifecycle</listener>
<listener>org.exoplatform.portal.application.PortalStatisticLifecycle</listener>
<listener>org.exoplatform.portal.application.PortalApplicationLifecycle</listener>
<listener>org.exoplatform.webui.application.MonitorApplicationLifecycle</listener>
Added:
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/application/PortalLogoutLifecycle.java
===================================================================
---
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/application/PortalLogoutLifecycle.java
(rev 0)
+++
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/application/PortalLogoutLifecycle.java 2010-09-30
14:05:42 UTC (rev 4444)
@@ -0,0 +1,67 @@
+/*
+* Copyright (C) 2003-2009 eXo Platform SAS.
+*
+* 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.exoplatform.portal.application;
+
+import org.exoplatform.portal.webui.util.Util;
+import org.exoplatform.web.application.Application;
+import org.exoplatform.web.application.ApplicationLifecycle;
+import org.exoplatform.web.application.RequestFailure;
+import org.exoplatform.web.login.LogoutControl;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.gatein.wci.impl.DefaultServletContainerFactory;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:alain.defrance@exoplatform.com">Alain
Defrance</a>
+ * @version $Revision$
+ */
+public class PortalLogoutLifecycle implements
ApplicationLifecycle<WebuiRequestContext>
+{
+
+ public void onInit(Application app) throws Exception
+ {
+ }
+
+ public void onStartRequest(Application app, WebuiRequestContext context) throws
Exception
+ {
+ LogoutControl.cancelLogout();
+ }
+
+ public void onFailRequest(Application app, WebuiRequestContext context, RequestFailure
failureType) throws Exception
+ {
+ }
+
+ public void onEndRequest(Application app, WebuiRequestContext context) throws
Exception
+ {
+ if (LogoutControl.isLogoutRequired())
+ {
+ PortalRequestContext prContext = Util.getPortalRequestContext();
+ HttpServletRequest request = prContext.getRequest();
+ HttpServletResponse response = prContext.getResponse();
+
DefaultServletContainerFactory.getInstance().getServletContainer().logout(request,
response);
+ }
+ }
+
+ public void onDestroy(Application app) throws Exception
+ {
+ }
+}
Modified:
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
===================================================================
---
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2010-09-30
14:01:44 UTC (rev 4443)
+++
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2010-09-30
14:05:42 UTC (rev 4444)
@@ -45,6 +45,7 @@
import org.exoplatform.services.organization.User;
import org.exoplatform.services.resources.ResourceBundleManager;
import org.exoplatform.web.login.InitiateLoginServlet;
+import org.exoplatform.web.login.LogoutControl;
import org.exoplatform.web.security.security.AbstractTokenService;
import org.exoplatform.web.security.security.CookieTokenService;
import org.exoplatform.webui.application.WebuiRequestContext;
@@ -413,8 +414,8 @@
AbstractTokenService tokenService =
AbstractTokenService.getInstance(CookieTokenService.class);
tokenService.deleteToken(token);
}
-
- req.getSession().invalidate();
+
+ LogoutControl.wantLogout();
Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, "");
cookie.setPath(req.getContextPath());
cookie.setMaxAge(0);
Modified:
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalActionListener.java
===================================================================
---
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalActionListener.java 2010-09-30
14:01:44 UTC (rev 4443)
+++
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalActionListener.java 2010-09-30
14:05:42 UTC (rev 4444)
@@ -22,6 +22,7 @@
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.webui.application.UIPortlet;
import org.exoplatform.portal.webui.util.Util;
+import org.exoplatform.web.login.LogoutControl;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.core.UIComponent;
import org.exoplatform.webui.event.Event;
@@ -45,7 +46,7 @@
public void execute(Event<UIComponent> event) throws Exception
{
PortalRequestContext prContext = Util.getPortalRequestContext();
- prContext.getRequest().getSession().invalidate();
+ LogoutControl.wantLogout();
HttpServletRequest request = prContext.getRequest();
String portalName = URLEncoder.encode(Util.getUIPortal().getName(),
"UTF-8");
String redirect = request.getContextPath() + "/public/" + portalName +
"/";
Modified:
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
===================================================================
---
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java 2010-09-30
14:01:44 UTC (rev 4443)
+++
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java 2010-09-30
14:05:42 UTC (rev 4444)
@@ -46,6 +46,7 @@
import org.exoplatform.services.resources.LocaleConfigService;
import org.exoplatform.web.application.ApplicationMessage;
import org.exoplatform.web.application.JavascriptManager;
+import org.exoplatform.web.login.LogoutControl;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.ComponentConfigs;
@@ -497,7 +498,7 @@
if (editPortal.getOwner().equals(prContext.getPortalOwner()))
{
HttpServletRequest request = prContext.getRequest();
- request.getSession().invalidate();
+ LogoutControl.wantLogout();
prContext.setResponseComplete(true);
prContext.getResponse().sendRedirect(request.getContextPath());
return;