Package org.springframework.security.cas

Examples of org.springframework.security.cas.ServiceProperties


        return new User("user", "password", true, true, true, true,
                AuthorityUtils.createAuthorityList("ROLE_A", "ROLE_B"));
    }

    private ServiceProperties makeServiceProperties() {
        final ServiceProperties serviceProperties = new ServiceProperties();
        serviceProperties.setSendRenew(false);
        serviceProperties.setService("http://test.com");

        return serviceProperties;
    }
View Full Code Here


        ServiceAuthenticationDetails details = mock(ServiceAuthenticationDetails.class);
        when(details.getServiceUrl()).thenReturn(serviceUrl);
        TicketValidator validator = mock(TicketValidator.class);
        when(validator.validate(any(String.class),any(String.class))).thenReturn(new AssertionImpl("rod"));

        ServiceProperties serviceProperties = makeServiceProperties();
        serviceProperties.setAuthenticateAllArtifacts(true);

        CasAuthenticationProvider cap = new CasAuthenticationProvider();
        cap.setAuthenticationUserDetailsService(new MockAuthoritiesPopulator());
        cap.setKey("qwerty");
View Full Code Here

        ServiceAuthenticationDetails details = mock(ServiceAuthenticationDetails.class);
        when(details.getServiceUrl()).thenReturn(serviceUrl);
        TicketValidator validator = mock(TicketValidator.class);
        when(validator.validate(any(String.class),any(String.class))).thenReturn(new AssertionImpl("rod"));

        ServiceProperties serviceProperties = makeServiceProperties();
        serviceProperties.setAuthenticateAllArtifacts(true);

        CasAuthenticationProvider cap = new CasAuthenticationProvider();
        cap.setAuthenticationUserDetailsService(new MockAuthoritiesPopulator());
        cap.setKey("qwerty");

        cap.setTicketValidator(validator);
        cap.setServiceProperties(serviceProperties);
        cap.afterPropertiesSet();

        String ticket = "ST-456";
        UsernamePasswordAuthenticationToken token =
            new UsernamePasswordAuthenticationToken(CasAuthenticationFilter.CAS_STATELESS_IDENTIFIER, ticket);

        Authentication result = cap.authenticate(token);
        verify(validator).validate(ticket, serviceProperties.getService());

        serviceProperties.setAuthenticateAllArtifacts(true);
        result = cap.authenticate(token);
        verify(validator,times(2)).validate(ticket, serviceProperties.getService());

        token.setDetails(details);
        result = cap.authenticate(token);
        verify(validator).validate(ticket, serviceUrl);

        serviceProperties.setAuthenticateAllArtifacts(false);
        serviceProperties.setService(null);
        cap.setServiceProperties(serviceProperties);
        cap.afterPropertiesSet();
        result = cap.authenticate(token);
        verify(validator,times(2)).validate(ticket, serviceUrl);
View Full Code Here

    public void testGettersSetters() {
        CasAuthenticationFilter filter = new CasAuthenticationFilter();
        assertEquals("/j_spring_cas_security_check", filter.getFilterProcessesUrl());
        filter.setProxyGrantingTicketStorage(mock(ProxyGrantingTicketStorage.class));
        filter.setProxyReceptorUrl("/someurl");
        filter.setServiceProperties(new ServiceProperties());
    }
View Full Code Here

        assertFalse(filter.requiresAuthentication(request, response));
    }

    @Test
    public void testRequiresAuthenticationAuthAll() {
        ServiceProperties properties = new ServiceProperties();
        properties.setAuthenticateAllArtifacts(true);

        CasAuthenticationFilter filter = new CasAuthenticationFilter();
        filter.setServiceProperties(properties);
        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpServletResponse response = new MockHttpServletResponse();

        request.setRequestURI(filter.getFilterProcessesUrl());
        assertTrue(filter.requiresAuthentication(request, response));

        request.setRequestURI("/other");
        assertFalse(filter.requiresAuthentication(request, response));
        request.setParameter(properties.getArtifactParameter(), "value");
        assertTrue(filter.requiresAuthentication(request, response));
        SecurityContextHolder.getContext().setAuthentication(new AnonymousAuthenticationToken("key", "principal", AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS")));
        assertTrue(filter.requiresAuthentication(request, response));
        SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken("un", "principal", AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS")));
        assertTrue(filter.requiresAuthentication(request, response));
View Full Code Here

    public void testDoFilterAuthenticateAll() throws Exception {
        AuthenticationSuccessHandler successHandler = mock(AuthenticationSuccessHandler.class);
        AuthenticationManager manager = mock(AuthenticationManager.class);
        Authentication authentication = new TestingAuthenticationToken("un", "pwd","ROLE_USER");
        when(manager.authenticate(any(Authentication.class))).thenReturn(authentication);
        ServiceProperties serviceProperties = new ServiceProperties();
        serviceProperties.setAuthenticateAllArtifacts(true);
        MockHttpServletRequest request = new MockHttpServletRequest();
        request.setParameter("ticket", "ST-1-123");
        request.setRequestURI("/authenticate");
        MockHttpServletResponse response = new MockHttpServletResponse();
        FilterChain chain = mock(FilterChain.class);
View Full Code Here

public class ServicePropertiesTests {
    //~ Methods ========================================================================================================

    @Test(expected=IllegalArgumentException.class)
    public void detectsMissingService() throws Exception {
        ServiceProperties sp = new ServiceProperties();
        sp.afterPropertiesSet();
    }
View Full Code Here

        sp.afterPropertiesSet();
    }

    @Test
    public void nullServiceWhenAuthenticateAllTokens() throws Exception {
        ServiceProperties sp = new ServiceProperties();
        sp.setAuthenticateAllArtifacts(true);
        try {
            sp.afterPropertiesSet();
            fail("Expected Exception");
        }catch(IllegalArgumentException success) {}
        sp.setAuthenticateAllArtifacts(false);
        try {
            sp.afterPropertiesSet();
            fail("Expected Exception");
        }catch(IllegalArgumentException success) {}
    }
View Full Code Here

        }catch(IllegalArgumentException success) {}
    }

    @Test
    public void testGettersSetters() throws Exception {
        ServiceProperties[] sps = {new ServiceProperties(), new SamlServiceProperties()};
        for(ServiceProperties sp : sps) {
            sp.setSendRenew(false);
            assertFalse(sp.isSendRenew());
            sp.setSendRenew(true);
            assertTrue(sp.isSendRenew());
View Full Code Here

public class CasAuthenticationEntryPointTests extends TestCase {
    //~ Methods ========================================================================================================

    public void testDetectsMissingLoginFormUrl() throws Exception {
        CasAuthenticationEntryPoint ep = new CasAuthenticationEntryPoint();
        ep.setServiceProperties(new ServiceProperties());

        try {
            ep.afterPropertiesSet();
            fail("Should have thrown IllegalArgumentException");
        } catch (IllegalArgumentException expected) {
View Full Code Here

TOP

Related Classes of org.springframework.security.cas.ServiceProperties

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.