org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoRestTemplateFactory Java Examples

The following examples show how to use org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoRestTemplateFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OAuth2LoadBalancerClientAutoConfigurationTests.java    From spring-cloud-security with Apache License 2.0 6 votes vote down vote up
@Test
public void userInfoLoadBalancedNoRetry() throws Exception {
	this.context = new SpringApplicationBuilder(ClientConfiguration.class)
			.properties("spring.config.name=test", "server.port=0",
					"spring.cloud.gateway.enabled=false",
					"security.oauth2.resource.userInfoUri:https://nosuchservice",
					"security.oauth2.resource.loadBalanced=true")
			.run();

	assertThat(
			this.context.containsBean("loadBalancedUserInfoRestTemplateCustomizer"))
					.isTrue();
	assertThat(this.context
			.containsBean("retryLoadBalancedUserInfoRestTemplateCustomizer"))
					.isFalse();

	OAuth2RestTemplate template = this.context
			.getBean(UserInfoRestTemplateFactory.class).getUserInfoRestTemplate();
	ClientHttpRequest request = template.getRequestFactory()
			.createRequest(new URI("https://nosuchservice"), HttpMethod.GET);
	expected.expectMessage("No instances available for nosuchservice");
	request.execute();
}
 
Example #2
Source File: SsoSecurityConfigurer.java    From spring-security-oauth2-boot with Apache License 2.0 5 votes vote down vote up
private OAuth2ClientAuthenticationProcessingFilter oauth2SsoFilter(OAuth2SsoProperties sso) {
	OAuth2RestOperations restTemplate = this.applicationContext.getBean(UserInfoRestTemplateFactory.class)
			.getUserInfoRestTemplate();
	ResourceServerTokenServices tokenServices = this.applicationContext.getBean(ResourceServerTokenServices.class);
	OAuth2ClientAuthenticationProcessingFilter filter = new OAuth2ClientAuthenticationProcessingFilter(
			sso.getLoginPath());
	filter.setRestTemplate(restTemplate);
	filter.setTokenServices(tokenServices);
	filter.setApplicationEventPublisher(this.applicationContext);
	return filter;
}
 
Example #3
Source File: EdgeServiceApplication.java    From building-microservices with Apache License 2.0 4 votes vote down vote up
@Bean
OAuth2RestTemplate restTemplate(UserInfoRestTemplateFactory templateFactory) {
    return templateFactory.getUserInfoRestTemplate();
}