Example usage for org.springframework.security.core.session SessionRegistry getSessionInformation

List of usage examples for org.springframework.security.core.session SessionRegistry getSessionInformation

Introduction

In this page you can find the example usage for org.springframework.security.core.session SessionRegistry getSessionInformation.

Prototype

SessionInformation getSessionInformation(String sessionId);

Source Link

Document

Obtains the session information for the specified sessionId.

Usage

From source file:com.hazelcast.wm.test.spring.SpringAwareWebFilterTest.java

@Test
public void test_issue_3049() throws Exception {
    Set<ApplicationContext> applicationContextSet = SpringApplicationContextProvider.getApplicationContextSet();
    Iterator<ApplicationContext> i = applicationContextSet.iterator();
    ApplicationContext applicationContext1 = i.next();
    ApplicationContext applicationContext2 = i.next();
    SessionRegistry sessionRegistry1 = applicationContext1.getBean(SessionRegistry.class);
    SessionRegistry sessionRegistry2 = applicationContext2.getBean(SessionRegistry.class);

    SpringSecuritySession sss = login(null, false);

    request("hello.jsp", serverPort1, sss.cookieStore);

    String sessionId = sss.getSessionId();
    String hazelcastSessionId = sss.getHazelcastSessionId();

    assertTrue("Native session must not exist in both Spring session registry of Node-1 and Node-2 after login",
            sessionRegistry1.getSessionInformation(sessionId) == null
                    && sessionRegistry2.getSessionInformation(sessionId) == null);

    assertTrue(//w  ww . j  a  va  2 s.c om
            "Hazelcast session must exist locally in one of the Spring session registry of Node-1 and Node-2 after login",
            sessionRegistry1.getSessionInformation(hazelcastSessionId) != null
                    || sessionRegistry2.getSessionInformation(hazelcastSessionId) != null);

    logout(sss);

    assertTrue(
            "Native session must not exist in both Spring session registry of Node-1 and Node-2 after logout",
            sessionRegistry1.getSessionInformation(sessionId) == null
                    && sessionRegistry2.getSessionInformation(sessionId) == null);

    assertTrue(
            "Hazelcast session must not exist in both Spring session registry of Node-1 and Node-2 after logout",
            sessionRegistry1.getSessionInformation(hazelcastSessionId) == null
                    && sessionRegistry2.getSessionInformation(hazelcastSessionId) == null);
}