Package jeeves.config.springutil

Source Code of jeeves.config.springutil.LogoutUserSessionHandler

package jeeves.config.springutil;

import jeeves.server.UserSession;
import jeeves.server.sources.http.JeevesServlet;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutHandler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
* Clears the UserSession
*
* @author jeichar
*/
public class LogoutUserSessionHandler implements LogoutHandler {

  @Override
  public void logout(HttpServletRequest request,
      HttpServletResponse response, Authentication authentication) {
    HttpSession httpSession = request.getSession(false);
    if(httpSession != null) {
      Object tmp = httpSession.getAttribute(JeevesServlet.USER_SESSION_ATTRIBUTE_KEY);
      if (tmp instanceof UserSession) {
        UserSession userSession = (UserSession) tmp;
        userSession.clear();
      }
    }

  }

}
TOP

Related Classes of jeeves.config.springutil.LogoutUserSessionHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.