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; }
protected HazelcastHttpSession createNewSession(HazelcastRequestWrapper requestWrapper, boolean create, String existingSessionId) { // use existing hazelcast session id for the new session only if the session info exists in the cluster boolean sessionExistsInTheCluster = sessionExistsInTheCluster(existingSessionId); if (!create && !sessionExistsInTheCluster) { return null; } String id = sessionExistsInTheCluster ? existingSessionId : generateSessionId(); if (requestWrapper.getOriginalSession(false) != null) { LOGGER.finest("Original session exists!!!"); } HttpSession originalSession = requestWrapper.getOriginalSession(true); HazelcastHttpSession hazelcastSession = createHazelcastHttpSession(id, originalSession); if (existingSessionId == null) { hazelcastSession.setClusterWideNew(true); // If the session is being created for the first time, add its initial reference in the cluster-wide map. } updateSessionMaps(originalSession.getId(), hazelcastSession); addSessionCookie(requestWrapper, id); return hazelcastSession; }
protected HazelcastHttpSession createNewSession(HazelcastRequestWrapper requestWrapper, boolean create, String existingSessionId) { // use existing hazelcast session id for the new session only if the session info exists in the cluster boolean sessionExistsInTheCluster = sessionExistsInTheCluster(existingSessionId); if (!create && !sessionExistsInTheCluster) { return null; } String id = sessionExistsInTheCluster ? existingSessionId : generateSessionId(); if (requestWrapper.getOriginalSession(false) != null) { LOGGER.finest("Original session exists!!!"); } HttpSession originalSession = requestWrapper.getOriginalSession(true); HazelcastHttpSession hazelcastSession = createHazelcastHttpSession(id, originalSession); if (existingSessionId == null) { hazelcastSession.setClusterWideNew(true); // If the session is being created for the first time, add its initial reference in the cluster-wide map. } updateSessionMaps(id, originalSession, hazelcastSession); addSessionCookie(requestWrapper, id); return hazelcastSession; }