@Test public void testAuthenticate() { final UsernamePasswordAuthenticationToken auth = context.mock(UsernamePasswordAuthenticationToken.class); final UserDetailsService uds = context.mock(UserDetailsService.class); final UserDetails ud = context.mock(UserDetails.class); final UserDetailsChecker checker = context.mock(UserDetailsChecker.class); context.checking(new Expectations() { { oneOf(auth).getName(); will(returnValue("homers")); oneOf(uds).loadUserByUsername("homers"); will(returnValue(ud)); oneOf(auth).getCredentials(); will(returnValue(null)); oneOf(ud).getAuthorities(); oneOf(checker).check(ud); } }); OpenAccessAuthenticationProvider sut = new OpenAccessAuthenticationProvider(uds, checker); assertEquals("User details are not correct for passed in authentication", ud, sut.authenticate(auth).getPrincipal()); context.assertIsSatisfied(); }
public Authentication authenticate(final Authentication authentication) { UsernamePasswordAuthenticationToken userToken = (UsernamePasswordAuthenticationToken) authentication; UserDetails currentUserDets = userDetailsService.loadUserByUsername(userToken.getName()); userDetailsChecker.check(currentUserDets); return new UsernamePasswordAuthenticationToken(currentUserDets, userToken.getCredentials(), currentUserDets.getAuthorities()); }
OpenAccessAuthenticationProvider implements AuthenticationProvider { public Authentication authenticate(final Authentication authentication) { UsernamePasswordAuthenticationToken userToken = (UsernamePasswordAuthenticationToken) authentication; UserDetails currentUserDets = userDetailsService.loadUserByUsername(userToken.getName()); userDetailsChecker.check(currentUserDets); return new UsernamePasswordAuthenticationToken(currentUserDets, userToken.getCredentials(), currentUserDets.getAuthorities()); } }
OpenAccessAuthenticationProvider implements AuthenticationProvider { public Authentication authenticate(final Authentication authentication) { UsernamePasswordAuthenticationToken userToken = (UsernamePasswordAuthenticationToken) authentication; UserDetails currentUserDets = userDetailsService.loadUserByUsername(userToken.getName()); userDetailsChecker.check(currentUserDets); return new UsernamePasswordAuthenticationToken(currentUserDets, userToken.getCredentials(), currentUserDets.getAuthorities()); } OpenAccessAuthenticationProvider(final UserDetailsService inUserDetailsService,
            final UserDetailsChecker inUserDetailsChecker); }
OpenAccessAuthenticationProvider implements AuthenticationProvider { public Authentication authenticate(final Authentication authentication) { UsernamePasswordAuthenticationToken userToken = (UsernamePasswordAuthenticationToken) authentication; UserDetails currentUserDets = userDetailsService.loadUserByUsername(userToken.getName()); userDetailsChecker.check(currentUserDets); return new UsernamePasswordAuthenticationToken(currentUserDets, userToken.getCredentials(), currentUserDets.getAuthorities()); } OpenAccessAuthenticationProvider(final UserDetailsService inUserDetailsService,
            final UserDetailsChecker inUserDetailsChecker); Authentication authenticate(final Authentication authentication); boolean supports(final Class authentication); }
OpenAccessAuthenticationProvider implements AuthenticationProvider { public Authentication authenticate(final Authentication authentication) { UsernamePasswordAuthenticationToken userToken = (UsernamePasswordAuthenticationToken) authentication; UserDetails currentUserDets = userDetailsService.loadUserByUsername(userToken.getName()); userDetailsChecker.check(currentUserDets); return new UsernamePasswordAuthenticationToken(currentUserDets, userToken.getCredentials(), currentUserDets.getAuthorities()); } OpenAccessAuthenticationProvider(final UserDetailsService inUserDetailsService,
            final UserDetailsChecker inUserDetailsChecker); Authentication authenticate(final Authentication authentication); boolean supports(final Class authentication);  }