Source:
<code>public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { <START> try { <END> HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse resp = (HttpServletResponse) response; boolean persistentAuth = "persistent-auth".equals(req.getHeader("Prefer")); if (persistentAuth && (req.getHeader("Authorization") != null || !containsJessionId(req))) { if (req.getSession(false) != null) { req.getSession().removeAttribute(FiltersHelper.Constants.AUTHENTICATED_KEY); } } chain.doFilter(request, response); HttpSession session = req.getSession(false); if (session != null && Boolean.TRUE.equals(session.getAttribute(FiltersHelper.Constants.AUTHENTICATED_KEY))) { String engineSessionId = (String) session.getAttribute(FiltersHelper.Constants.ENGINE_SESSION_ID_KEY); if (!persistentAuth) { InitialContext ctx = new InitialContext(); try { VdcActionParametersBase params = new VdcActionParametersBase(); params.setSessionId(engineSessionId); FiltersHelper.getBackend(ctx).runAction(VdcActionType.LogoutBySession, params); session.invalidate(); } finally { FiltersHelper.closeContext(ctx); } } else { Cookie cookie = new Cookie("JESSIONID", engineSessionId); cookie.setPath("/api"); resp.addCookie(cookie); } } } catch (Exception ex) { log.error(String.format("Error in REST-API session management. Message is: %1$s", ex.getMessage())); if (log.isDebugEnabled()) { log.debug("", ex); } } }</code><technical_language>in if authenticated do nothing...</technical_language>

Target:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { try { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse resp = (HttpServletResponse) response; boolean persistentAuth = "persistent-auth".equals(req.getHeader("Prefer")); HttpSession session = req.getSession(false); if (persistentAuth && (req.getHeader("Authorization") != null || !containsJsessionId(req))) { if (session != null) { session.removeAttribute(FiltersHelper.Constants.SESSION_AUTHENTICATED_KEY); } } else if (persistentAuth) { if (session != null) { try { int ttlValue = Integer.parseInt(req.getHeader("Session-TTL")) * SECONDS_IN_MINUTE; if (ttlValue >= MINIMAL_SESSION_TTL) { session.setMaxInactiveInterval(ttlValue); } } catch (NumberFormatException ex) { log.error("Session-TTL header was not passed. Not setting TTL value"); } } } chain.doFilter(request, response); if (session != null && Boolean.TRUE.equals(session.getAttribute(FiltersHelper.Constants.SESSION_AUTHENTICATED_KEY))) { String engineSessionId = (String) session.getAttribute(FiltersHelper.Constants.SESSION_ENGINE_SESSION_ID_KEY); if (!persistentAuth && !Boolean.valueOf((Boolean) session.getAttribute(FiltersHelper.Constants.SESSION_ALREADY_LOGGED_OUT_KEY))) { InitialContext ctx = new InitialContext(); try { VdcActionParametersBase params = new VdcActionParametersBase(); params.setSessionId(engineSessionId); FiltersHelper.getBackend(ctx).runAction(VdcActionType.LogoutBySession, params); session.invalidate(); } finally { ctx.close(); } } else { Cookie cookie = new Cookie("JSESSIONID", engineSessionId); cookie.setPath("/api"); resp.addCookie(cookie); } } } catch (Exception ex) { log.error(String.format("Error in REST-API session management. Message is: %1$s", ex.getMessage())); if (log.isDebugEnabled()) { log.debug("", ex); } } }