@Test public void testAuthenticateParentAuthenticateReturnsNull() { final JaasAuthenticationProvider provider = context.mock(JaasAuthenticationProvider.class); final UsernamePasswordAuthenticationToken auth = context.mock(UsernamePasswordAuthenticationToken.class); final UserDetailsService uds = context.mock(UserDetailsService.class); context.checking(new Expectations() { { oneOf(provider).authenticate(auth); will(returnValue(null)); } }); JaasAuthenticationProviderWrapper sut = new JaasAuthenticationProviderWrapper(provider, uds); assertNull("authenticate() should return null if wrapped provider returns null", sut.authenticate(auth)); context.assertIsSatisfied(); }
public Authentication authenticate(final Authentication authentication) { Authentication parentAuthResult = authProvider.authenticate(authentication); if (parentAuthResult == null) { log.debug("Parent authentication provider returned null Authentication object."); return null; } log.debug("loading userDetails for user: " + parentAuthResult.getName()); UserDetails details = userDetailsService .loadUserByUsername((String) parentAuthResult.getName()); detailsChecker.check(details); return new UsernamePasswordAuthenticationToken(details, parentAuthResult.getCredentials(), parentAuthResult.getAuthorities()); }
JaasAuthenticationProviderWrapper implements
        AuthenticationProvider { public Authentication authenticate(final Authentication authentication) { Authentication parentAuthResult = authProvider.authenticate(authentication); if (parentAuthResult == null) { log.debug("Parent authentication provider returned null Authentication object."); return null; } log.debug("loading userDetails for user: " + parentAuthResult.getName()); UserDetails details = userDetailsService .loadUserByUsername((String) parentAuthResult.getName()); detailsChecker.check(details); return new UsernamePasswordAuthenticationToken(details, parentAuthResult.getCredentials(), parentAuthResult.getAuthorities()); } }
JaasAuthenticationProviderWrapper implements
        AuthenticationProvider { public Authentication authenticate(final Authentication authentication) { Authentication parentAuthResult = authProvider.authenticate(authentication); if (parentAuthResult == null) { log.debug("Parent authentication provider returned null Authentication object."); return null; } log.debug("loading userDetails for user: " + parentAuthResult.getName()); UserDetails details = userDetailsService .loadUserByUsername((String) parentAuthResult.getName()); detailsChecker.check(details); return new UsernamePasswordAuthenticationToken(details, parentAuthResult.getCredentials(), parentAuthResult.getAuthorities()); } JaasAuthenticationProviderWrapper(final JaasAuthenticationProvider inAuthProvider,
            final UserDetailsService inUserDetailsService); }
JaasAuthenticationProviderWrapper implements
        AuthenticationProvider { public Authentication authenticate(final Authentication authentication) { Authentication parentAuthResult = authProvider.authenticate(authentication); if (parentAuthResult == null) { log.debug("Parent authentication provider returned null Authentication object."); return null; } log.debug("loading userDetails for user: " + parentAuthResult.getName()); UserDetails details = userDetailsService .loadUserByUsername((String) parentAuthResult.getName()); detailsChecker.check(details); return new UsernamePasswordAuthenticationToken(details, parentAuthResult.getCredentials(), parentAuthResult.getAuthorities()); } JaasAuthenticationProviderWrapper(final JaasAuthenticationProvider inAuthProvider,
            final UserDetailsService inUserDetailsService); Authentication authenticate(final Authentication authentication); @SuppressWarnings("unchecked") boolean supports(final Class authentication); }
JaasAuthenticationProviderWrapper implements
        AuthenticationProvider { public Authentication authenticate(final Authentication authentication) { Authentication parentAuthResult = authProvider.authenticate(authentication); if (parentAuthResult == null) { log.debug("Parent authentication provider returned null Authentication object."); return null; } log.debug("loading userDetails for user: " + parentAuthResult.getName()); UserDetails details = userDetailsService .loadUserByUsername((String) parentAuthResult.getName()); detailsChecker.check(details); return new UsernamePasswordAuthenticationToken(details, parentAuthResult.getCredentials(), parentAuthResult.getAuthorities()); } JaasAuthenticationProviderWrapper(final JaasAuthenticationProvider inAuthProvider,
            final UserDetailsService inUserDetailsService); Authentication authenticate(final Authentication authentication); @SuppressWarnings("unchecked") boolean supports(final Class authentication);  }