List of usage examples for javax.servlet.http HttpSession invalidate
public void invalidate();
From source file:cn.vlabs.duckling.api.umt.sso.configable.servlet.LogoutServlet.java
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { String defaultRetoLocalAppUrl = SSOProperties.getInstance().getProperty(ILoginHandle.LOCALAPP_LOGIN_RETURN); if (StringUtils.isBlank(defaultRetoLocalAppUrl)) { defaultRetoLocalAppUrl = getRootUrlWithContextPath(request); }/*from w w w . j a va 2 s . c o m*/ String umtSsoLogout = request.getParameter("umtSsoLogout"); UserPrincipalV7 context = (UserPrincipalV7) SessionUtil.getObj(request, SessionUtil.USER_CONTEXT); if (context != null) { ILoginHandle handle = getHandle(); handle.onLogOut(request, response, context); if (umtSsoLogout == null) { String sid = request.getSession().getId(); String logoutURL = buildLogoutURL(defaultRetoLocalAppUrl, sid); response.sendRedirect(logoutURL); } } else { if (umtSsoLogout == null) { response.sendRedirect(defaultRetoLocalAppUrl); } } HttpSession session = request.getSession(false); if (session != null) { session.invalidate(); } }
From source file:org.apache.struts.scaffold.RecreateSessionAction.java
/** * Creates a new session, perserving any prior Locale attribute. * * @param mapping The ActionMapping used to select this instance * @param actionForm The optional ActionForm bean for this request * @param request The HTTP request we are processing * @param response The response we are creating * @todo Add support for multiple attributes * @fixme Needs to be tested.//from w w w . j ava2s . c o m */ protected ActionForward findSuccess(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(); Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY); session.invalidate(); session = request.getSession(true); session.setAttribute(Action.LOCALE_KEY, locale); return mapping.findForward(Tokens.SUCCESS); }
From source file:com.xpn.xwiki.web.LogoutAction.java
@Override public boolean action(XWikiContext context) throws XWikiException { XWikiRequest request = context.getRequest(); XWikiResponse response = context.getResponse(); // Destroy the current session, if any, so that any private data stored in the session won't be accessible by // the next user on the same computer HttpSession currentSession = request.getSession(false); if (currentSession != null) { synchronized (currentSession) { currentSession.invalidate(); // Early registration of a new session, so that the client gets to know the new session identifier early // A new session is going to be needed after the redirect anyway request.getSession(true);/* w w w .j av a 2 s . c o m*/ } } // Process redirect String redirect; redirect = context.getRequest().getParameter("xredirect"); if (StringUtils.isEmpty(redirect)) { ModelConfiguration modelDefaults = Utils.getComponent(ModelConfiguration.class); DocumentReference doc = new DocumentReference(context.getDatabase(), modelDefaults.getDefaultReferenceValue(EntityType.SPACE), modelDefaults.getDefaultReferenceValue(EntityType.DOCUMENT)); redirect = context.getWiki().getURL(doc, "view", context); } sendRedirect(response, redirect); return false; }
From source file:org.sharetask.controller.UserController.java
@RequestMapping(value = "/logout", method = RequestMethod.GET) public void performLogout(final HttpServletRequest request, final HttpServletResponse response) { SecurityContextHolder.clearContext(); final HttpSession session = request.getSession(false); if (session != null) { session.invalidate(); }/*from w w w.ja va 2s . c o m*/ }
From source file:com.asociate.managedbean.DatosSesion.java
/** * *///w w w . j a v a2 s.co m public void logout() { FacesContext context = FacesContext.getCurrentInstance(); ExternalContext externalContext = context.getExternalContext(); Object session = externalContext.getSession(false); HttpSession httpSession = (HttpSession) session; httpSession.invalidate(); HttpServletRequest origRequest = (HttpServletRequest) context.getExternalContext().getRequest(); String contextPath = origRequest.getContextPath(); try { FacesContext.getCurrentInstance().getExternalContext().redirect(contextPath + "/faces/index.xhtml"); } catch (IOException e) { e.printStackTrace(); } }
From source file:controller.CasoDeUsoController.java
@Override public void index() { HttpSession session = request.getSession(); session.invalidate(); cadastrar(); }
From source file:Controllers.CompteController.java
@RequestMapping(value = "deconnexion", method = RequestMethod.GET) public ModelAndView deconnexion(HttpServletRequest request, HttpServletResponse response) throws Exception { ModelAndView mv = new ModelAndView("connexion"); // Cration de la session HttpSession session = request.getSession(); if (session != null) { session.invalidate(); mv.addObject("inscriptionMessage", "Dconnexion russie"); } else {/*from w ww . ja v a 2s . com*/ // Ne doit pas arriver mv.addObject("inscriptionMessage", "Veuillez vous connecter pour accder cette page"); } return mv; }
From source file:com.liferay.portal.action.LogoutAction.java
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception { try {/*from w ww. j a va 2s .c o m*/ HttpSession ses = req.getSession(); try { // Logger.info(this, "User " + // PortalUtil.getUser(req).getFullName() + " (" + // PortalUtil.getUser(req).getUserId() + // ") has logged out from IP: " + req.getRemoteAddr()); SecurityLogger.logInfo(this.getClass(), "User " + PortalUtil.getUser(req).getFullName() + " (" + PortalUtil.getUser(req).getUserId() + ") has logged out from IP: " + req.getRemoteAddr()); } catch (Exception e) { //Logger.info(this, "User has logged out from IP: " + req.getRemoteAddr()); SecurityLogger.logInfo(this.getClass(), "User has logged out from IP: " + req.getRemoteAddr()); } EventsProcessor.process(PropsUtil.getArray(PropsUtil.LOGOUT_EVENTS_PRE), req, res); ArrayList<Cookie> al = new ArrayList<Cookie>(); Cookie[] cookies = req.getCookies(); if (cookies != null) { for (int i = 0; i < cookies.length; i++) { Cookie cookie = cookies[i]; al.add(cookie); cookie.setMaxAge(0); cookie.setPath("/"); res.addCookie(cookie); } } Map sessions = PortletSessionPool.remove(ses.getId()); if (sessions != null) { Iterator itr = sessions.entrySet().iterator(); while (itr.hasNext()) { Map.Entry entry = (Map.Entry) itr.next(); HttpSession portletSession = (HttpSession) entry.getValue(); portletSession.invalidate(); } } try { ses.invalidate(); } catch (Exception e) { } EventsProcessor.process(PropsUtil.getArray(PropsUtil.LOGOUT_EVENTS_POST), req, res); // ActionForward af = mapping.findForward("referer"); // return af; return mapping.findForward(Constants.COMMON_REFERER); } catch (Exception e) { req.setAttribute(PageContext.EXCEPTION, e); return mapping.findForward(Constants.COMMON_REFERER); } }
From source file:it.unica.djestit.recording.controllers.RecordController.java
@RequestMapping(value = "logout.json", method = RequestMethod.GET, produces = "application/json; charset=utf-8") public @ResponseBody String logout(HttpSession session) { session.invalidate(); CommandMsg msg = new CommandMsg(); msg.setStatus(0);//from w w w .j a va 2 s. c o m Gson gson = new GsonBuilder().setPrettyPrinting().create(); return gson.toJson(msg); }
From source file:nl.ctrlaltdev.harbinger.response.InvalidateSessionAction.java
@Override public boolean perform(HarbingerContext ctx) { ServletRequestAttributes sra = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); if (sra != null) { HttpSession session = sra.getRequest().getSession(false); if (session != null) { LoggerFactory.getLogger(getClass()).warn("Invalidated session '{}'", session.getId()); session.invalidate(); }// w ww . ja v a 2 s . c o m } return true; }