Package org.springframework.security.web.authentication.preauth

Examples of org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider


        return this;
    }

    @Override
    public void init(H http) throws Exception {
        PreAuthenticatedAuthenticationProvider authenticationProvider = new PreAuthenticatedAuthenticationProvider();
        authenticationProvider.setPreAuthenticatedUserDetailsService(getAuthenticationUserDetailsService(http));

        http
            .authenticationProvider(authenticationProvider)
            .setSharedObject(AuthenticationEntryPoint.class,new Http403ForbiddenEntryPoint());
    }
View Full Code Here


     *
     * @see org.springframework.security.config.annotation.SecurityConfigurerAdapter#init(org.springframework.security.config.annotation.SecurityBuilder)
     */
    @Override
    public void init(H http) throws Exception {
        PreAuthenticatedAuthenticationProvider authenticationProvider = new PreAuthenticatedAuthenticationProvider();
        authenticationProvider.setPreAuthenticatedUserDetailsService(getUserDetailsService());
        authenticationProvider = postProcess(authenticationProvider);

        http
            .authenticationProvider(authenticationProvider)
            .setSharedObject(AuthenticationEntryPoint.class,new Http403ForbiddenEntryPoint());
View Full Code Here

*/
public class PreAuthenticatedAuthenticationProviderTests {

    @Test(expected = IllegalArgumentException.class)
    public final void afterPropertiesSet() {
        PreAuthenticatedAuthenticationProvider provider = new PreAuthenticatedAuthenticationProvider();

        provider.afterPropertiesSet();
    }
View Full Code Here

    }

    @Test
    public final void authenticateInvalidToken() throws Exception {
        UserDetails ud = new User("dummyUser", "dummyPwd", true, true, true, true, AuthorityUtils.NO_AUTHORITIES );
        PreAuthenticatedAuthenticationProvider provider = getProvider(ud);
        Authentication request = new UsernamePasswordAuthenticationToken("dummyUser", "dummyPwd");
        Authentication result = provider.authenticate(request);
        assertNull(result);
    }
View Full Code Here

        assertNull(result);
    }

    @Test
    public final void nullPrincipalReturnsNullAuthentication() throws Exception {
        PreAuthenticatedAuthenticationProvider provider = new PreAuthenticatedAuthenticationProvider();
        Authentication request = new PreAuthenticatedAuthenticationToken(null, "dummyPwd");
        Authentication result = provider.authenticate(request);
        assertNull(result);
    }
View Full Code Here

    }

    @Test
    public final void authenticateKnownUser() throws Exception {
        UserDetails ud = new User("dummyUser", "dummyPwd", true, true, true, true, AuthorityUtils.NO_AUTHORITIES );
        PreAuthenticatedAuthenticationProvider provider = getProvider(ud);
        Authentication request = new PreAuthenticatedAuthenticationToken("dummyUser", "dummyPwd");
        Authentication result = provider.authenticate(request);
        assertNotNull(result);
        assertEquals(result.getPrincipal(), ud);
        // @TODO: Add more asserts?
    }
View Full Code Here

            }
        });
        interceptor.setAuthenticationDetailsSource(mock(AuthenticationDetailsSource.class));
        interceptor.invoke(mock(MethodInvocation.class));

        PreAuthenticatedAuthenticationProvider provider = new PreAuthenticatedAuthenticationProvider();
        AuthenticationUserDetailsService uds = mock(AuthenticationUserDetailsService.class);
        UserDetails user = mock(UserDetails.class);
        List authorities = AuthorityUtils.createAuthorityList("SOME_ROLE");
        when(user.getAuthorities()).thenReturn(authorities);
        when(uds.loadUserDetails(any(Authentication.class))).thenReturn(user);
        provider.setPreAuthenticatedUserDetailsService(uds);
        provider.setUserDetailsChecker(mock(UserDetailsChecker.class));

        assertNotNull(provider.authenticate(context.getAuthentication()));
    }
View Full Code Here

    }

    @Test
    public final void authenticateIgnoreCredentials() throws Exception {
        UserDetails ud = new User("dummyUser1", "dummyPwd1", true, true, true, true, AuthorityUtils.NO_AUTHORITIES );
        PreAuthenticatedAuthenticationProvider provider = getProvider(ud);
        Authentication request = new PreAuthenticatedAuthenticationToken("dummyUser1", "dummyPwd2");
        Authentication result = provider.authenticate(request);
        assertNotNull(result);
        assertEquals(result.getPrincipal(), ud);
        // @TODO: Add more asserts?
    }
View Full Code Here

    }

    @Test(expected=UsernameNotFoundException.class)
    public final void authenticateUnknownUserThrowsException() throws Exception {
        UserDetails ud = new User("dummyUser1", "dummyPwd", true, true, true, true, AuthorityUtils.NO_AUTHORITIES );
        PreAuthenticatedAuthenticationProvider provider = getProvider(ud);
        Authentication request = new PreAuthenticatedAuthenticationToken("dummyUser2", "dummyPwd");
        provider.authenticate(request);
    }
View Full Code Here

        provider.authenticate(request);
    }

    @Test
    public final void supportsArbitraryObject() throws Exception {
        PreAuthenticatedAuthenticationProvider provider = getProvider(null);
        assertFalse(provider.supports(Authentication.class));
    }
View Full Code Here

TOP

Related Classes of org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider

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.