Package org.geoserver.security

Examples of org.geoserver.security.LogoutFilterChain


        // check for sign out request from cas server
        if (handler.isLogoutRequest(httpReq)) {
            if (singleSignOut) { // do we participate
                LOGGER.info("Single Sign Out received from CAS server --> starting log out");
                handler.destroySession(httpReq);               
                LogoutFilterChain logOutChain = (LogoutFilterChain)
                        getSecurityManager().getSecurityConfig().getFilterChain().getRequestChainByName("webLogout");
                logOutChain.doLogout(getSecurityManager(), httpReq, httpRes,getName());
            } else
                LOGGER.info("Single Sign Out received from CAS server --> ignoring");
            return;
        }
       
View Full Code Here


    }

    @Test
    public void testLogout() throws Exception {

        LogoutFilterChain logoutchain =
                (LogoutFilterChain) getSecurityManager().getSecurityConfig().getFilterChain().getRequestChainByName("webLogout");
       
        String casFilterName = "testCasFilter2";
        CasAuthenticationFilterConfig config = new CasAuthenticationFilterConfig();
        config.setClassName(GeoServerCasAuthenticationFilter.class.getName());
        config.setCasServerUrlPrefix(casServerURLPrefix.toString());
        config.setName(casFilterName);
        config.setRoleSource(PreAuthenticatedUserNameRoleSource.UserGroupService);
        config.setUserGroupServiceName("ug1");
        config.setSingleSignOut(true);
        getSecurityManager().saveFilter(config);               
       
        // put a CAS filter on an active chain      
        prepareFilterChain(pattern,casFilterName);
        modifyChain(pattern, false, true, null);

        SecurityContextHolder.getContext().setAuthentication(null);
        getCache().removeAll();
       
        // login
        String username = "castest";
        String password = username;
        CasFormAuthenticationHelper helper = new CasFormAuthenticationHelper(casServerURLPrefix,
                username, password);
        helper.ssoLogin();
       
        MockHttpServletRequest request = createRequest(pattern);
        MockHttpServletResponse response = new MockHttpServletResponse();
        MockFilterChain  chain = new MockFilterChain();
        loginUsingTicket(helper, request, response, chain);
        assertEquals(HttpServletResponse.SC_OK, response.getErrorCode());
        assertFalse(response.wasRedirectSent());


        SecurityContext ctx = (SecurityContext) request.getSession(false).getAttribute(
                HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY);
        assertNotNull(ctx);
        Authentication auth = ctx.getAuthentication();
        assertNotNull(auth);
        assertNull(SecurityContextHolder.getContext().getAuthentication());
        MockHttpSession session = (MockHttpSession) request.getSession(false);
        assertNotNull(session);
        assertTrue(session.isValid());



        // logout triggered by geoserver
        request = createRequest(logoutchain.getPatterns().get(0));
        //request.getSession().setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, ctx);
        SecurityContextHolder.setContext(ctx);
        response = new MockHttpServletResponse();
        chain = new MockFilterChain();
        //getProxy().doFilter(request, response, chain);
View Full Code Here

TOP

Related Classes of org.geoserver.security.LogoutFilterChain

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.