/** * Destroys a session, determining if it should be destroyed clusterwide automatically or via expiry. * * @param session the session to be destroyed <i>locally</i> * @param invalidate {@code true} if the session has been invalidated and should be destroyed on all nodes * in the cluster; otherwise, {@code false} to only remove the session globally if this * node was the final node referencing it */ protected void destroySession(HazelcastHttpSession session, boolean invalidate) { if (LOGGER.isFinestEnabled()) { LOGGER.finest("Destroying local session: " + session.getId()); } sessions.remove(session.getId()); originalSessions.remove(session.getOriginalSession().getId()); session.destroy(invalidate); }
/** * Destroys a session, determining if it should be destroyed clusterwide automatically or via expiry. * * @param session the session to be destroyed <i>locally</i> * @param invalidate {@code true} if the session has been invalidated and should be destroyed on all nodes * in the cluster; otherwise, {@code false} to only remove the session globally if this * node was the final node referencing it */ protected void destroySession(HazelcastHttpSession session, boolean invalidate) { if (LOGGER.isFinestEnabled()) { LOGGER.finest("Destroying local session: " + session.getId()); } sessions.remove(session.getId()); originalSessions.remove(session.getOriginalSession().getId()); session.destroy(invalidate); }
public String changeSessionId() { Method changeSessionIdMethod = getChangeSessionIdMethod(); if (changeSessionIdMethod == null) { return ""; } HttpServletRequest nonWrappedHttpServletRequest = getNonWrappedHttpServletRequest(); if (nonWrappedHttpServletRequest.getSession() == null) { throw new IllegalStateException("changeSessionId requested for request with no session"); } originalSessions.remove(nonWrappedHttpServletRequest.getSession().getId()); HazelcastHttpSession hazelcastHttpSession = getSession(false); sessions.remove(hazelcastHttpSession.getId()); hazelcastHttpSession.destroy(true); String newHazelcastSessionId = generateSessionId(); String newJSessionId = invokeChangeSessionId(nonWrappedHttpServletRequest, changeSessionIdMethod); HttpSession originalSession = nonWrappedHttpServletRequest.getSession(); HazelcastHttpSession hazelcastSession = createHazelcastHttpSession(newHazelcastSessionId, originalSession); hazelcastSession.setClusterWideNew(true); updateSessionMaps(newJSessionId, hazelcastSession); addSessionCookie(this, newHazelcastSessionId); return newJSessionId; }