Examples of PreAuthenticatedAuthenticationProvider


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

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

     *
     * @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

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

*/
public class PreAuthenticatedAuthenticationProviderTests {

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

        provider.afterPropertiesSet();
    }
View Full Code Here

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

    }

    @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

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

        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

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

    }

    @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

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

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

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

    }

    @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

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

    }

    @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

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

        provider.authenticate(request);
    }

    @Test
    public final void supportsArbitraryObject() throws Exception {
        PreAuthenticatedAuthenticationProvider provider = getProvider(null);
        assertFalse(provider.supports(Authentication.class));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.