Search in sources :

Example 1 with UserInfoRestTemplateCustomizer

use of org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoRestTemplateCustomizer in project spring-boot by spring-projects.

the class DefaultUserInfoRestTemplateFactory method getUserInfoRestTemplate.

@Override
public OAuth2RestTemplate getUserInfoRestTemplate() {
    if (this.oauth2RestTemplate == null) {
        this.oauth2RestTemplate = createOAuth2RestTemplate(this.details == null ? DEFAULT_RESOURCE_DETAILS : this.details);
        this.oauth2RestTemplate.getInterceptors().add(new AcceptJsonRequestInterceptor());
        AuthorizationCodeAccessTokenProvider accessTokenProvider = new AuthorizationCodeAccessTokenProvider();
        accessTokenProvider.setTokenRequestEnhancer(new AcceptJsonRequestEnhancer());
        this.oauth2RestTemplate.setAccessTokenProvider(accessTokenProvider);
        if (!CollectionUtils.isEmpty(this.customizers)) {
            AnnotationAwareOrderComparator.sort(this.customizers);
            for (UserInfoRestTemplateCustomizer customizer : this.customizers) {
                customizer.customize(this.oauth2RestTemplate);
            }
        }
    }
    return this.oauth2RestTemplate;
}
Also used : AcceptJsonRequestEnhancer(org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration.AcceptJsonRequestEnhancer) AuthorizationCodeAccessTokenProvider(org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeAccessTokenProvider) AcceptJsonRequestInterceptor(org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration.AcceptJsonRequestInterceptor)

Example 2 with UserInfoRestTemplateCustomizer

use of org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoRestTemplateCustomizer in project spring-cloud-sleuth by spring-cloud.

the class TraceUserInfoRestTemplateCustomizer method customize.

@Override
public void customize(OAuth2RestTemplate template) {
    final TracingClientHttpRequestInterceptor interceptor = this.beanFactory.getBean(TracingClientHttpRequestInterceptor.class);
    new RestTemplateInterceptorInjector(interceptor).inject(template);
    if (this.delegate != null) {
        ((UserInfoRestTemplateCustomizer) this.delegate).customize(template);
    }
}
Also used : TracingClientHttpRequestInterceptor(brave.spring.web.TracingClientHttpRequestInterceptor) UserInfoRestTemplateCustomizer(org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoRestTemplateCustomizer)

Aggregations

TracingClientHttpRequestInterceptor (brave.spring.web.TracingClientHttpRequestInterceptor)1 AcceptJsonRequestEnhancer (org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration.AcceptJsonRequestEnhancer)1 AcceptJsonRequestInterceptor (org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration.AcceptJsonRequestInterceptor)1 UserInfoRestTemplateCustomizer (org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoRestTemplateCustomizer)1 AuthorizationCodeAccessTokenProvider (org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeAccessTokenProvider)1