List of usage examples for org.springframework.security.oauth2.client.token.grant.client ClientCredentialsAccessTokenProvider ClientCredentialsAccessTokenProvider
ClientCredentialsAccessTokenProvider
From source file:cloud.api.gateway.ApiGatewayApplication.java
@Bean
UserInfoRestTemplateCustomizer userInfoRestTemplateCustomizer(SpringClientFactory springClientFactory) {
return template -> {
AccessTokenProviderChain accessTokenProviderChain = Stream
.of(new AuthorizationCodeAccessTokenProvider(), new ImplicitAccessTokenProvider(),
new ResourceOwnerPasswordAccessTokenProvider(),
new ClientCredentialsAccessTokenProvider())
.peek(tp -> tp.setRequestFactory(new RibbonClientHttpRequestFactory(springClientFactory)))
.collect(Collectors.collectingAndThen(Collectors.toList(), AccessTokenProviderChain::new));
template.setAccessTokenProvider(accessTokenProviderChain);
};//from w w w . ja v a 2 s .c o m
}
From source file:org.trustedanalytics.h2oscoringengine.publisher.ApplicationConfiguration.java
@Bean public OAuth2RestTemplate oAuth2RestTemplate(OAuth2ProtectedResourceDetails clientCredentials, OAuth2ClientContext clientContext) { OAuth2RestTemplate template = new OAuth2RestTemplate(clientCredentials, clientContext); ClientCredentialsAccessTokenProvider tokenProvider = new ClientCredentialsAccessTokenProvider(); template.setAccessTokenProvider(tokenProvider); return template; }
From source file:org.trustedanalytics.platformoperations.ApplicationConfiguration.java
@Bean public OAuth2RestTemplate clientRestTemplate() { OAuth2RestTemplate template = new OAuth2RestTemplate(clientCredentials()); ClientCredentialsAccessTokenProvider provider = new ClientCredentialsAccessTokenProvider(); template.setAccessTokenProvider(provider); return template; }
From source file:sample.jsp.WelcomeController.java
@Bean public AccessTokenProvider accessTokenProviderChain() { return new AccessTokenProviderChain(Arrays.<AccessTokenProvider>asList(new OpenIDTokenProvider(), new AuthorizationCodeAccessTokenProvider(), new ImplicitAccessTokenProvider(), new ResourceOwnerPasswordAccessTokenProvider(), new ClientCredentialsAccessTokenProvider())); }
From source file:org.trustedanalytics.user.common.RestTemplatesConfiguration.java
@Bean public OAuth2RestTemplate clientRestTemplate(OAuth2ClientContext oauth2ClientContext, OAuth2ProtectedResourceDetails clientCredentials) { OAuth2RestTemplate template = new OAuth2RestTemplate(clientCredentials, oauth2ClientContext); ClientCredentialsAccessTokenProvider provider = new ClientCredentialsAccessTokenProvider(); template.setAccessTokenProvider(provider); return template; }
From source file:org.trustedanalytics.servicecatalog.service.ServiceConfig.java
@Bean @Scope(value = SCOPE_REQUEST, proxyMode = TARGET_CLASS) public OAuth2RestTemplate clientRestTemplate(OAuth2ClientContext clientContext, ClientCredentialsResourceDetails clientCredentials) { OAuth2RestTemplate template = new OAuth2RestTemplate(clientCredentials, clientContext); ClientCredentialsAccessTokenProvider provider = new ClientCredentialsAccessTokenProvider(); template.setAccessTokenProvider(provider); return template; }
From source file:org.cloudfoundry.identity.client.UaaContextFactory.java
/** * If the {@link TokenRequest#isSkipSslValidation()} returns true, the rest template * will be configured//from w w w . j a v a 2s . co m * @param tokenRequest * @param template */ protected void skipSslValidation(TokenRequest tokenRequest, OAuth2RestTemplate template, List<OAuth2AccessTokenSupport> existingProviders) { ClientHttpRequestFactory requestFactory = null; if (tokenRequest.isSkipSslValidation()) { requestFactory = getNoValidatingClientHttpRequestFactory(); } List<OAuth2AccessTokenSupport> accessTokenProviders = existingProviders != null ? existingProviders : Arrays.<OAuth2AccessTokenSupport>asList(new AuthorizationCodeAccessTokenProvider(), new ImplicitAccessTokenProvider(), new ResourceOwnerPasswordAccessTokenProvider(), new ClientCredentialsAccessTokenProvider()); List<AccessTokenProvider> providers = new ArrayList<>(); for (OAuth2AccessTokenSupport provider : accessTokenProviders) { if (requestFactory != null) { provider.setRequestFactory(requestFactory); } providers.add((AccessTokenProvider) provider); } AccessTokenProviderChain chain = new AccessTokenProviderChain(providers); template.setAccessTokenProvider(chain); }