use of org.springframework.security.authentication.dao.DaoAuthenticationProvider in project spring-security by spring-projects.
the class JdbcUserServiceBeanDefinitionParserTests method cacheIsInjectedIntoAuthenticationProvider.
@Test
public void cacheIsInjectedIntoAuthenticationProvider() {
setContext("<authentication-manager>" + " <authentication-provider>" + " <jdbc-user-service cache-ref='userCache' data-source-ref='dataSource'/>" + " </authentication-provider>" + "</authentication-manager>" + DATA_SOURCE + USER_CACHE_XML);
ProviderManager mgr = (ProviderManager) appContext.getBean(BeanIds.AUTHENTICATION_MANAGER);
DaoAuthenticationProvider provider = (DaoAuthenticationProvider) mgr.getProviders().get(0);
assertThat(appContext.getBean("userCache")).isSameAs(provider.getUserCache());
provider.authenticate(new UsernamePasswordAuthenticationToken("rod", "koala"));
assertThat(provider.getUserCache().getUserFromCache("rod")).isNotNull().withFailMessage("Cache should contain user after authentication");
}
use of org.springframework.security.authentication.dao.DaoAuthenticationProvider in project spring-boot by spring-projects.
the class ManagementWebSecurityAutoConfigurationTests method getUser.
private UserDetails getUser() {
ProviderManager parent = (ProviderManager) this.context.getBean(AuthenticationManager.class);
DaoAuthenticationProvider provider = (DaoAuthenticationProvider) parent.getProviders().get(0);
UserDetailsService service = (UserDetailsService) ReflectionTestUtils.getField(provider, "userDetailsService");
UserDetails user = service.loadUserByUsername("user");
return user;
}
Aggregations