Package org.springframework.security.core.session

Examples of org.springframework.security.core.session.SessionRegistry


        // Setup our test fixture and registry to want this session to be expired
        ConcurrentSessionFilter filter = new ConcurrentSessionFilter();
        filter.setRedirectStrategy(new DefaultRedirectStrategy());
        filter.setLogoutHandlers(new LogoutHandler[] {new SecurityContextLogoutHandler()});

        SessionRegistry registry = new SessionRegistryImpl();
        registry.registerNewSession(session.getId(), "principal");
        registry.getSessionInformation(session.getId()).expireNow();
        filter.setSessionRegistry(registry);
        filter.setExpiredUrl("/expired.jsp");
        filter.afterPropertiesSet();

        FilterChain fc = mock(FilterChain.class);
View Full Code Here


        request.setSession(session);

        MockHttpServletResponse response = new MockHttpServletResponse();

        ConcurrentSessionFilter filter = new ConcurrentSessionFilter();
        SessionRegistry registry = new SessionRegistryImpl();
        registry.registerNewSession(session.getId(), "principal");
        registry.getSessionInformation(session.getId()).expireNow();
        filter.setSessionRegistry(registry);

        FilterChain fc = mock(FilterChain.class);
        filter.doFilter(request, response, fc);
        verifyZeroInteractions(fc);
View Full Code Here

        MockHttpServletResponse response = new MockHttpServletResponse();
        FilterChain fc = mock(FilterChain.class);

        // Setup our test fixture
        ConcurrentSessionFilter filter = new ConcurrentSessionFilter();
        SessionRegistry registry = new SessionRegistryImpl();
        registry.registerNewSession(session.getId(), "principal");

        Date lastRequest = registry.getSessionInformation(session.getId()).getLastRequest();
        filter.setSessionRegistry(registry);
        filter.setExpiredUrl("/expired.jsp");

        Thread.sleep(1000);

        filter.doFilter(request, response, fc);

        verify(fc).doFilter(request, response);
        assertTrue(registry.getSessionInformation(session.getId()).getLastRequest().after(lastRequest));
    }
View Full Code Here

    @Test
    public void logoutClearsSessionRegistryAndAllowsSecondLogin() throws Exception {
        beginAt("secure/index.html");
        login("bessie", "bessiespassword");
        SessionRegistry reg = getAppContext().getBean(SessionRegistry.class);

        tester.gotoPage("/j_spring_security_logout");

        // Login again
        System.out.println("Client: ******* Second login ******* ");
 
View Full Code Here

    public void usingPrototypeDoesNotParsePointcutOnEachCall() {
        StopWatch sw = new StopWatch();
        sw.start();
        for (int i = 0; i < 1000; i++) {
            try {
                SessionRegistry reg = (SessionRegistry) ctx.getBean("sessionRegistryPrototype");
                reg.getAllPrincipals();
                fail("Expected AuthenticationCredentialsNotFoundException");
            } catch (AuthenticationCredentialsNotFoundException expected) {
            }
        }
        sw.stop();
View Full Code Here

    return SUCCESS;
  }
 
  public String getNumberOfUsers(){
    resultInfo = new OperResult();
    SessionRegistry sessionRegistry = (SessionRegistry)StorageService.ctx.getBean("sessionRegistry");
    resultInfo.setSucceed();
    resultInfo.setData(sessionRegistry.getAllPrincipals().size());
    return SUCCESS;
  }
View Full Code Here

    @BeforeClass
    public void setUp() {

        statisticsService = mock(ForumStatisticsService.class);

        SessionRegistry sessionRegistry = mock(SessionRegistry.class);
        users = Collections.nCopies(userCount , (Object) new JCUser("","",""));
        when(sessionRegistry.getAllPrincipals()).thenReturn(users);

        SessionStatisticListener listener = mock(SessionStatisticListener.class);
        when(listener.getTotalActiveSessions()).thenReturn(sessionCount);

        forumStaticsProvider = new ForumStatisticsProvider(sessionRegistry, listener, statisticsService);
View Full Code Here

        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);

        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(
            "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);
    }
View Full Code Here

TOP

Related Classes of org.springframework.security.core.session.SessionRegistry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.