Form logout does not log out the user
 Technote (troubleshooting)
 
Problem(Abstract)
You click on the form logout link in your application and nothing happens. You are not logged out, and you either receive no error messages or a "page not found" message.
 
Cause
What is probably causing the problem is that Global Security is not enabled, and therefore your application is not using Form Login. Form logout is an extension of form login and was never intended to be used when security was disabled. The key is the call to the SecurityContext class. If SecurityContext.isSecurityEnabled() returns false, the ibm_security_logout call fails.
 
Resolving the problem
A possible work around for this problem is to use the following code:

Struts configuration entry for logout action:

<action path="/logout" type="com._360.office.central.web.login.LogoutAction">
   <forward name="ibmlogout" path="ibm_security_logout?logoutExitPage=/home.do"/>
   <forward name="success" path="/home.do" redirect="true"/>
</action>

LogoutAction class:

// This is in the security.jar -

import com.ibm.ws.security.core.SecurityContext;

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)

throws Exception
{
  HttpSession httpsession = request.getSession();
  httpsession.invalidate();

  ActionForward forward = null;

  // Must check for security enable/disabled - will get error
  // on ibm_security_logout is security is not enabled

  if (SecurityContext.isSecurityEnabled())
  {
     forward = mapping.findForward("ibmlogout");
  }
  else
  {
     forward = mapping.findForward("success");
  }
  return forward;
}

 
 
Cross Reference information
Segment Product Component Platform Version Edition
Application Servers Runtimes for Java Technology Java SDK
 
 


Document Information


Product categories: Software > Application Servers > Distributed Application & Web Servers > WebSphere Application Server > Security
Operating system(s): Windows
Software version: 6.1
Software edition:
Reference #: 1114756
IBM Group: Software Group
Modified date: Sep 15, 2004