Source:
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) { if (session == null) { try { int ttlValue = Integer.parseInt(req.getHeader("Session-TTL")) * SECONDS_IN_MINUTE; if (ttlValue >= MINIMAL_SESSION_TTL) { session = req.getSession(true); session.setMaxInactiveInterval(ttlValue); } } catch (NumberFormatException ex) { log.error("Session-TTL header was not passed. Not setting TTL value"); } } if ((req.getHeader("Authorization") != null || !containsJsessionId(req))) { if (session != null) { session.removeAttribute(FiltersHelper.Constants.SESSION_ENGINE_SESSION_ID_KEY); } } } chain.doFilter(request, response); if (FiltersHelper.isAuthenticated(req)) { session = req.getSession(false); String engineSessionId = (String) session.getAttribute(FiltersHelper.Constants.SESSION_ENGINE_SESSION_ID_KEY); if (!persistentAuth && (req.getAttribute(FiltersHelper.Constants.REQUEST_ALREADY_LOGGED_OUT_KEY) == null || !Boolean.valueOf((Boolean) req.getAttribute(FiltersHelper.Constants.REQUEST_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(); } } } } 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); } } }

Target:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { try { HttpServletRequest req = (HttpServletRequest) request; boolean persistentAuth = "persistent-auth".equals(req.getHeader("Prefer")); HttpSession session = req.getSession(false); if (persistentAuth) { if (session == null) { try { int ttlValue = Integer.parseInt(req.getHeader("Session-TTL")) * SECONDS_IN_MINUTE; if (ttlValue >= MINIMAL_SESSION_TTL) { session = req.getSession(true); session.setMaxInactiveInterval(ttlValue); } } catch (NumberFormatException ex) { log.error("Session-TTL header was not passed. Not setting TTL value"); } } if ((req.getHeader("Authorization") != null)) { if (session != null) { session.removeAttribute(FiltersHelper.Constants.HTTP_SESSION_ENGINE_SESSION_ID_KEY); } } } chain.doFilter(request, response); if (FiltersHelper.isAuthenticated(req)) { session = req.getSession(); String engineSessionId = (String) session.getAttribute(FiltersHelper.Constants.HTTP_SESSION_ENGINE_SESSION_ID_KEY); if (!persistentAuth) { InitialContext ctx = new InitialContext(); try { VdcActionParametersBase params = new VdcActionParametersBase(engineSessionId); FiltersHelper.getBackend(ctx).runAction(VdcActionType.LogoutBySession, params); session.invalidate(); } finally { ctx.close(); } } } } 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); } } }