Package org.springframework.security.web.session

Examples of org.springframework.security.web.session.HttpSessionEventPublisher


    /**
     * It's not that complicated so we'll just run it straight through here.
     */
    @Test
    public void publishedEventIsReceivedbyListener() {
        HttpSessionEventPublisher publisher = new HttpSessionEventPublisher();

        StaticWebApplicationContext context = new StaticWebApplicationContext();

        MockServletContext servletContext = new MockServletContext();
        servletContext.setAttribute(StaticWebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context);

        context.setServletContext(servletContext);
        context.registerSingleton("listener", MockApplicationListener.class, null);
        context.refresh();

        MockHttpSession session = new MockHttpSession(servletContext);
        MockApplicationListener listener = (MockApplicationListener) context.getBean("listener");

        HttpSessionEvent event = new HttpSessionEvent(session);

        publisher.sessionCreated(event);

        assertNotNull(listener.getCreatedEvent());
        assertNull(listener.getDestroyedEvent());
        assertEquals(session, listener.getCreatedEvent().getSession());

        listener.setCreatedEvent(null);
        listener.setDestroyedEvent(null);

        publisher.sessionDestroyed(event);
        assertNotNull(listener.getDestroyedEvent());
        assertNull(listener.getCreatedEvent());
        assertEquals(session, listener.getDestroyedEvent().getSession());
    }
View Full Code Here


    }

    // SEC-2599
    @Test(expected=IllegalStateException.class)
    public void sessionCreatedNullApplicationContext() {
        HttpSessionEventPublisher publisher = new HttpSessionEventPublisher();
        MockServletContext servletContext = new MockServletContext();
        MockHttpSession session = new MockHttpSession(servletContext);
        HttpSessionEvent event = new HttpSessionEvent(session);

        publisher.sessionCreated(event);
    }
View Full Code Here

    }

    // SEC-2599
    @Test(expected=IllegalStateException.class)
    public void sessionDestroyedNullApplicationContext() {
        HttpSessionEventPublisher publisher = new HttpSessionEventPublisher();
        MockServletContext servletContext = new MockServletContext();
        MockHttpSession session = new MockHttpSession(servletContext);
        HttpSessionEvent event = new HttpSessionEvent(session);

        publisher.sessionDestroyed(event);
    }
View Full Code Here

        WebAppContext webCtx = new WebAppContext(webappDir == null ? "src/main/webapp" : webappDir, getContextPath());

        if (StringUtils.hasText(getContextConfigLocations())) {
            webCtx.addEventListener(new ContextLoaderListener());
            webCtx.addEventListener(new HttpSessionEventPublisher());
            webCtx.getInitParams().put("contextConfigLocation", getContextConfigLocations());
        }

        ServletHolder servlet = new ServletHolder();
        servlet.setName("testapp");
View Full Code Here

        FilterRegistration.Dynamic springSecurityFilterChain =
                servletContext.addFilter("springSecurityFilterChain", DelegatingFilterProxy.class);
        springSecurityFilterChain.addMappingForUrlPatterns(null, false, "/*");

        // Enable SessionDestroyedEvent for the LogOutListener
        servletContext.addListener(new HttpSessionEventPublisher());

        // Make RequestContextHolder available in filters
        servletContext.addListener(new RequestContextListener());

        // Register UTF-8 Encoding Filter, see http://developers-blog.org/blog/default/2010/08/17/Spring-MVC-and-UTF-8-Encoding-with-CharacterEncodingFilter
View Full Code Here

TOP

Related Classes of org.springframework.security.web.session.HttpSessionEventPublisher

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.