use of org.springframework.security.oauth2.provider.token.DefaultUserAuthenticationConverter in project cloud-sea-towerman by huadahuang1983.
the class WebSecurityConfig method remoteTokenServices.
@Bean
public RemoteTokenServices remoteTokenServices() {
RemoteTokenServices services = new RemoteTokenServices();
services.setCheckTokenEndpointUrl(this.resource.getTokenInfoUri());
services.setClientId(this.resource.getClientId());
services.setClientSecret(this.resource.getClientSecret());
DefaultUserAuthenticationConverter userTokenConverter = new DefaultUserAuthenticationConverter();
userTokenConverter.setUserDetailsService(userDetailsService());
DefaultAccessTokenConverter tokenConverter = new DefaultAccessTokenConverter();
tokenConverter.setUserTokenConverter(userTokenConverter);
services.setAccessTokenConverter(tokenConverter);
return services;
}
use of org.springframework.security.oauth2.provider.token.DefaultUserAuthenticationConverter in project spring-security-oauth2-google by skate056.
the class GoogleTokenServicesTest method shouldLoadAuthenticationAndTransformValuesToStandardValuesAndAddDomainRole.
@Test
public void shouldLoadAuthenticationAndTransformValuesToStandardValuesAndAddDomainRole() throws Exception {
Map<String, String> body = new HashMap<>();
body.put("issued_to", "blh");
body.put("user_id", "user@domain.google.com");
body.put("email", "user@domain.google.com");
given(response.getBody()).willReturn(body);
given(restTemplate.exchange(anyString(), any(HttpMethod.class), any(HttpEntity.class), any(ParameterizedTypeReference.class))).willReturn(response);
googleTokenServices.setRestTemplate(restTemplate);
googleTokenServices.setCheckTokenEndpointUrl("//");
DefaultUserAuthenticationConverter defaultUserAuthenticationConverter = new DefaultUserAuthenticationConverter();
defaultUserAuthenticationConverter.setAuthorityGranter(authorityGranter);
GoogleAccessTokenConverter realAccessTokenConverter = new GoogleAccessTokenConverter();
realAccessTokenConverter.setUserTokenConverter(defaultUserAuthenticationConverter);
googleTokenServices.setAccessTokenConverter(realAccessTokenConverter);
OAuth2Authentication authentication = googleTokenServices.loadAuthentication(null);
assertThat(authentication, notNullValue());
verify(authorityGranter).getAuthorities(anyMap());
}
Aggregations