use of org.springframework.security.oauth2.provider.client.ClientDetailsUserDetailsService in project spring-security-oauth by spring-projects.
the class ClientDetailsUserDetailsServiceTests method shouldConductOriginalException.
@SuppressWarnings("unchecked")
@Test(expected = ClientRegistrationException.class)
public void shouldConductOriginalException() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put(UserAuthenticationConverter.USERNAME, "test_user");
ClientDetailsService clientDetailsService = Mockito.mock(ClientDetailsService.class);
Mockito.when(clientDetailsService.loadClientByClientId("test_user")).thenThrow(ClientRegistrationException.class);
ClientDetailsUserDetailsService testee = new ClientDetailsUserDetailsService(clientDetailsService);
testee.loadUserByUsername("test_user");
}
use of org.springframework.security.oauth2.provider.client.ClientDetailsUserDetailsService in project spring-security-oauth by spring-projects.
the class AuthorizationServerSecurityConfigurer method init.
@Override
public void init(HttpSecurity http) throws Exception {
registerDefaultAuthenticationEntryPoint(http);
if (passwordEncoder != null) {
ClientDetailsUserDetailsService clientDetailsUserDetailsService = new ClientDetailsUserDetailsService(clientDetailsService());
clientDetailsUserDetailsService.setPasswordEncoder(passwordEncoder());
http.getSharedObject(AuthenticationManagerBuilder.class).userDetailsService(clientDetailsUserDetailsService).passwordEncoder(passwordEncoder());
} else {
http.userDetailsService(new ClientDetailsUserDetailsService(clientDetailsService()));
}
http.securityContext().securityContextRepository(new NullSecurityContextRepository()).and().csrf().disable().httpBasic().realmName(realm);
}
use of org.springframework.security.oauth2.provider.client.ClientDetailsUserDetailsService in project spring-security-oauth by spring-projects.
the class ClientDetailsUserDetailsServiceTests method shouldThrowUsernameNotFoundExceptionWhenNoSuchClient.
@SuppressWarnings("unchecked")
@Test(expected = UsernameNotFoundException.class)
public void shouldThrowUsernameNotFoundExceptionWhenNoSuchClient() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put(UserAuthenticationConverter.USERNAME, "test_user");
ClientDetailsService clientDetailsService = Mockito.mock(ClientDetailsService.class);
Mockito.when(clientDetailsService.loadClientByClientId("test_user")).thenThrow(NoSuchClientException.class);
ClientDetailsUserDetailsService testee = new ClientDetailsUserDetailsService(clientDetailsService);
testee.loadUserByUsername("test_user");
}
Aggregations