use of org.springframework.security.oauth2.client.userinfo.CustomUserTypesOAuth2UserService in project spring-security by spring-projects.
the class OAuth2LoginConfigurer method getOAuth2UserService.
private OAuth2UserService<OAuth2UserRequest, OAuth2User> getOAuth2UserService() {
if (this.userInfoEndpointConfig.userService != null) {
return this.userInfoEndpointConfig.userService;
}
ResolvableType type = ResolvableType.forClassWithGenerics(OAuth2UserService.class, OAuth2UserRequest.class, OAuth2User.class);
OAuth2UserService<OAuth2UserRequest, OAuth2User> bean = getBeanOrNull(type);
if (bean != null) {
return bean;
}
if (this.userInfoEndpointConfig.customUserTypes.isEmpty()) {
return new DefaultOAuth2UserService();
}
List<OAuth2UserService<OAuth2UserRequest, OAuth2User>> userServices = new ArrayList<>();
userServices.add(new CustomUserTypesOAuth2UserService(this.userInfoEndpointConfig.customUserTypes));
userServices.add(new DefaultOAuth2UserService());
return new DelegatingOAuth2UserService<>(userServices);
}
use of org.springframework.security.oauth2.client.userinfo.CustomUserTypesOAuth2UserService in project spring-security by spring-projects.
the class CustomUserTypesOAuth2UserServiceTests method setUp.
@BeforeEach
public void setUp() throws Exception {
this.server = new MockWebServer();
this.server.start();
String registrationId = "client-registration-id-1";
// @formatter:off
this.clientRegistrationBuilder = TestClientRegistrations.clientRegistration().registrationId(registrationId);
// @formatter:on
this.accessToken = TestOAuth2AccessTokens.noScopes();
Map<String, Class<? extends OAuth2User>> customUserTypes = new HashMap<>();
customUserTypes.put(registrationId, CustomOAuth2User.class);
this.userService = new CustomUserTypesOAuth2UserService(customUserTypes);
}
Aggregations