本文整理了Java中org.springframework.security.oauth2.client.OAuth2RestTemplate.setAccessTokenProvider()
方法的一些代码示例,展示了OAuth2RestTemplate.setAccessTokenProvider()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OAuth2RestTemplate.setAccessTokenProvider()
方法的具体详情如下:
包路径:org.springframework.security.oauth2.client.OAuth2RestTemplate
类名称:OAuth2RestTemplate
方法名:setAccessTokenProvider
暂无
代码示例来源:origin: spring-projects/spring-security-oauth
client.setAccessTokenProvider(accessTokenProvider);
代码示例来源:origin: spring-projects/spring-security-oauth
private OAuth2RestTemplate createRestTemplate(
OAuth2ProtectedResourceDetails resource, AccessTokenRequest request) {
OAuth2ClientContext context = new DefaultOAuth2ClientContext(request);
OAuth2RestTemplate client = new OAuth2RestTemplate(resource, context);
setupConnectionFactory(client);
client.setErrorHandler(new DefaultResponseErrorHandler() {
// Pass errors through in response entity for status code analysis
public boolean hasError(ClientHttpResponse response) throws IOException {
return false;
}
});
if (accessTokenProvider != null) {
client.setAccessTokenProvider(accessTokenProvider);
}
return client;
}
代码示例来源:origin: stackoverflow.com
@Component
public class AzureRequestEnhancerCustomizer {
@Autowired
private OAuth2RestTemplate userInfoRestTemplate;
@Autowired
private AzureRequestEnhancer azureRequestEnhancer;
@PostConstruct
public void testWiring() {
AuthorizationCodeAccessTokenProvider authorizationCodeAccessTokenProvider = new AuthorizationCodeAccessTokenProvider();
authorizationCodeAccessTokenProvider.setTokenRequestEnhancer(azureRequestEnhancer);
userInfoRestTemplate.setAccessTokenProvider(authorizationCodeAccessTokenProvider);
}
}
代码示例来源:origin: org.cloudfoundry/cloudfoundry-client-spring
private static void setRequestFactory(OAuth2RestTemplate restTemplate, HostnameVerifier hostnameVerifier, SSLContext sslContext) {
if (hostnameVerifier != null && sslContext != null) {
CustomSslSimpleClientHttpRequestFactory requestFactory = new CustomSslSimpleClientHttpRequestFactory(hostnameVerifier, sslContext);
restTemplate.setRequestFactory(requestFactory);
restTemplate.setAccessTokenProvider(getAccessTokenProvider(requestFactory));
}
}
代码示例来源:origin: PacktPublishing/OAuth-2.0-Cookbook
@Bean
public OAuth2RestTemplate restTemplate(OAuth2ClientContext context) {
OAuth2RestTemplate rest = new OAuth2RestTemplate(resourceDetails(), context);
AccessTokenProviderChain providerChain = new AccessTokenProviderChain(
Arrays.asList(new AuthorizationCodeAccessTokenProvider()));
rest.setAccessTokenProvider(providerChain);
return rest;
}
代码示例来源:origin: PacktPublishing/OAuth-2.0-Cookbook
@Bean
public OAuth2RestTemplate restTemplate(OAuth2ClientContext context) {
OAuth2RestTemplate rest = new OAuth2RestTemplate(resourceDetails(), context);
AccessTokenProviderChain providerChain = new AccessTokenProviderChain(
Arrays.asList(new AuthorizationCodeAccessTokenProvider()));
rest.setAccessTokenProvider(providerChain);
return rest;
}
代码示例来源:origin: PacktPublishing/OAuth-2.0-Cookbook
@Bean
public OAuth2RestTemplate restTemplate(OAuth2ClientContext context) {
OAuth2RestTemplate rest = new OAuth2RestTemplate(resourceDetails(), context);
rest.setAccessTokenProvider(
new AccessTokenProviderChain(
Arrays.asList(new AuthorizationCodeAccessTokenProvider())));
return rest;
}
代码示例来源:origin: org.springframework.security.oauth/spring-security-oauth2
client.setAccessTokenProvider(accessTokenProvider);
代码示例来源:origin: PacktPublishing/OAuth-2.0-Cookbook
@Bean
public OAuth2RestTemplate oauth2RestTemplate() {
OAuth2ProtectedResourceDetails resourceDetails = implicitResourceDetails();
OAuth2RestTemplate template = new OAuth2RestTemplate(resourceDetails,
oauth2ClientContext);
AccessTokenProviderChain provider = new AccessTokenProviderChain(
Arrays.asList(new CustomImplicitAccessTokenProvider()));
provider.setClientTokenServices(clientTokenServices);
template.setAccessTokenProvider(provider);
return template;
}
代码示例来源:origin: PacktPublishing/OAuth-2.0-Cookbook
@Bean
public OAuth2RestTemplate oauth2RestTemplate() {
OAuth2ProtectedResourceDetails resourceDetails = passwordResourceDetails();
OAuth2RestTemplate template = new OAuth2RestTemplate(resourceDetails,
oauth2ClientContext);
AccessTokenProviderChain provider = new AccessTokenProviderChain(
Arrays.asList(new ResourceOwnerPasswordAccessTokenProvider()));
provider.setClientTokenServices(clientTokenServices);
template.setAccessTokenProvider(provider);
return template;
}
代码示例来源:origin: PacktPublishing/OAuth-2.0-Cookbook
@Bean
public OAuth2RestTemplate oauth2RestTemplate() {
OAuth2ProtectedResourceDetails resourceDetails = authorizationCode();
OAuth2RestTemplate template = new OAuth2RestTemplate(resourceDetails,
oauth2ClientContext);
AccessTokenProviderChain provider = new AccessTokenProviderChain(
Arrays.asList(new AuthorizationCodeAccessTokenProvider()));
provider.setClientTokenServices(clientTokenServices);
template.setAccessTokenProvider(provider);
return template;
}
代码示例来源:origin: PacktPublishing/OAuth-2.0-Cookbook
@Bean
public OAuth2RestTemplate oauth2RestTemplate() {
OAuth2ProtectedResourceDetails resourceDetails = authorizationCode();
OAuth2RestTemplate template = new OAuth2RestTemplate(resourceDetails,
oauth2ClientContext);
AccessTokenProviderChain provider = new AccessTokenProviderChain(
Arrays.asList(new AuthorizationCodeAccessTokenProvider()));
provider.setClientTokenServices(clientTokenServices);
template.setAccessTokenProvider(provider);
return template;
}
代码示例来源:origin: PacktPublishing/OAuth-2.0-Cookbook
@Bean
public OAuth2RestTemplate oauth2RestTemplate() {
OAuth2ProtectedResourceDetails resourceDetails = passwordResourceDetails();
OAuth2RestTemplate template = new OAuth2RestTemplate(resourceDetails,
oauth2ClientContext);
AccessTokenProviderChain provider = new AccessTokenProviderChain(
Arrays.asList(new ClientCredentialsAccessTokenProvider()));
provider.setClientTokenServices(clientTokenServices);
template.setAccessTokenProvider(provider);
return template;
}
代码示例来源:origin: org.springframework.security.oauth/spring-security-oauth2
private OAuth2RestTemplate createRestTemplate(
OAuth2ProtectedResourceDetails resource, AccessTokenRequest request) {
OAuth2ClientContext context = new DefaultOAuth2ClientContext(request);
OAuth2RestTemplate client = new OAuth2RestTemplate(resource, context);
setupConnectionFactory(client);
client.setErrorHandler(new DefaultResponseErrorHandler() {
// Pass errors through in response entity for status code analysis
public boolean hasError(ClientHttpResponse response) throws IOException {
return false;
}
});
if (accessTokenProvider != null) {
client.setAccessTokenProvider(accessTokenProvider);
}
return client;
}
代码示例来源:origin: org.springframework.security.oauth.boot/spring-security-oauth2-autoconfigure
@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;
}
代码示例来源:origin: spring-projects/spring-security-oauth2-boot
@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;
}
代码示例来源:origin: org.eclipse.vorto/repository-server-config
private Filter newSsoFilter(String defaultFilterProcessesUrl, UserInfoTokenServices tokenService, AccessTokenProvider accessTokenProvider,
OAuth2RestTemplate restTemplate, AuthoritiesExtractor authoritiesExtractor ) {
restTemplate.setAccessTokenProvider(accessTokenProvider);
OAuth2ClientAuthenticationProcessingFilter filter = new OAuth2ClientAuthenticationProcessingFilter(defaultFilterProcessesUrl);
filter.setAuthenticationSuccessHandler(successHandler);
tokenService.setRestTemplate(restTemplate);
tokenService.setAuthoritiesExtractor(authoritiesExtractor);
filter.setRestTemplate(restTemplate);
filter.setTokenServices(tokenService);
return filter;
}
代码示例来源:origin: spring-cloud/spring-cloud-dataflow
template.setAccessTokenProvider(userAccessTokenProvider());
代码示例来源:origin: org.springframework.cloud/spring-cloud-dataflow-server-core
template.setAccessTokenProvider(userAccessTokenProvider());
代码示例来源:origin: org.springframework.cloud/spring-cloud-common-security-config-web
template.setAccessTokenProvider(userAccessTokenProvider());
内容来源于网络,如有侵权,请联系作者删除!