org.springframework.security.oauth2.provider.token.RemoteTokenServices Java Examples

The following examples show how to use org.springframework.security.oauth2.provider.token.RemoteTokenServices. 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: ResourceServerTokenServicesConfiguration.java    From spring-security-oauth2-boot with Apache License 2.0 6 votes vote down vote up
@Bean
@ConditionalOnMissingBean(ResourceServerTokenServices.class)
public RemoteTokenServices remoteTokenServices() {
	RemoteTokenServices services = new RemoteTokenServices();
	services.setCheckTokenEndpointUrl(this.resource.getTokenInfoUri());
	services.setClientId(this.resource.getClientId());
	services.setClientSecret(this.resource.getClientSecret());
	return services;
}
 
Example #2
Source File: OpenHelper.java    From open-cloud with MIT License 5 votes vote down vote up
/**
 * 构建自定义远程Token服务类
 *
 * @param properties
 * @return
 */
public static RemoteTokenServices buildRemoteTokenServices(OpenCommonProperties properties) {
    // 使用自定义系统用户凭证转换器
    DefaultAccessTokenConverter accessTokenConverter = buildAccessTokenConverter();
    RemoteTokenServices tokenServices = new RemoteTokenServices();
    tokenServices.setCheckTokenEndpointUrl(properties.getTokenInfoUri());
    tokenServices.setClientId(properties.getClientId());
    tokenServices.setClientSecret(properties.getClientSecret());
    tokenServices.setAccessTokenConverter(accessTokenConverter);
    log.info("buildRemoteTokenServices[{}]", tokenServices);
    return tokenServices;
}
 
Example #3
Source File: OauthResourceApplication.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Bean
public RemoteTokenServices remoteTokenServices() {
	final RemoteTokenServices tokenServices = new RemoteTokenServices();
	tokenServices.setCheckTokenEndpointUrl("http://localhost:9090/oauth/check_token");
	tokenServices.setClientId("resource1");
	tokenServices.setClientSecret("secret");
	return tokenServices;
}
 
Example #4
Source File: OAuth2ResourceServerConfigRemoteTokenService.java    From oauth2lab with MIT License 5 votes vote down vote up
@Primary
@Bean
public RemoteTokenServices tokenServices() {
    final RemoteTokenServices tokenService = new RemoteTokenServices();
    tokenService.setCheckTokenEndpointUrl("http://localhost:8081/oauth/check_token");
    tokenService.setClientId("fooClientIdPassword");
    tokenService.setClientSecret("secret");
    return tokenService;
}
 
Example #5
Source File: ResourceServerConfiguration.java    From microservices-oauth with Apache License 2.0 5 votes vote down vote up
@Bean
public ResourceServerTokenServices tokenService() {
	RemoteTokenServices tokenServices = new RemoteTokenServices();
	tokenServices.setClientId("adminapp");
	tokenServices.setClientSecret("password");
	tokenServices.setCheckTokenEndpointUrl(authEndpoint + "/uaa/oauth/check_token");
	return tokenServices;
}
 
Example #6
Source File: ResourceServerTokenServicesConfigurationTests.java    From spring-security-oauth2-boot with Apache License 2.0 5 votes vote down vote up
@Test
public void useRemoteTokenServices() {
	TestPropertyValues.of("security.oauth2.resource.tokenInfoUri:https://example.com").applyTo(this.environment);
	this.context = new SpringApplicationBuilder(ResourceConfiguration.class).environment(this.environment)
			.web(WebApplicationType.NONE).run();
	RemoteTokenServices services = this.context.getBean(RemoteTokenServices.class);
	assertThat(services).isNotNull();
}
 
Example #7
Source File: ResourceServerTokenServicesConfigurationTests.java    From spring-security-oauth2-boot with Apache License 2.0 5 votes vote down vote up
@Test
public void overrideRemoteTokenServices() {
	TestPropertyValues.of("security.oauth2.resource.tokenInfoUri:https://example.com").applyTo(this.environment);
	this.context = new SpringApplicationBuilder(CustomRemoteTokenService.class, ResourceConfiguration.class)
			.environment(this.environment).web(WebApplicationType.NONE).run();
	CustomRemoteTokenService services = this.context.getBean(CustomRemoteTokenService.class);
	assertThat(services).isNotNull();
	this.thrown.expect(NoSuchBeanDefinitionException.class);
	this.context.getBean(RemoteTokenServices.class);
}
 
Example #8
Source File: ResourceServerTokenServicesConfigurationTests.java    From spring-security-oauth2-boot with Apache License 2.0 5 votes vote down vote up
@Test
public void switchToJwt() {
	TestPropertyValues.of("security.oauth2.resource.jwt.keyValue=FOOBAR").applyTo(this.environment);
	this.context = new SpringApplicationBuilder(ResourceConfiguration.class).environment(this.environment)
			.web(WebApplicationType.NONE).run();
	DefaultTokenServices services = this.context.getBean(DefaultTokenServices.class);
	assertThat(services).isNotNull();
	this.thrown.expect(NoSuchBeanDefinitionException.class);
	this.context.getBean(RemoteTokenServices.class);
}
 
Example #9
Source File: ResourceServerTokenServicesConfigurationTests.java    From spring-security-oauth2-boot with Apache License 2.0 5 votes vote down vote up
@Test
public void jwkConfiguration() throws Exception {
	TestPropertyValues.of("security.oauth2.resource.jwk.key-set-uri=https://idp.example.com/token_keys")
			.applyTo(this.environment);
	this.context = new SpringApplicationBuilder(ResourceConfiguration.class).environment(this.environment)
			.web(WebApplicationType.NONE).run();
	DefaultTokenServices services = this.context.getBean(DefaultTokenServices.class);
	assertThat(services).isNotNull();
	this.thrown.expect(NoSuchBeanDefinitionException.class);
	this.context.getBean(RemoteTokenServices.class);
}
 
Example #10
Source File: OAuth2ResourceServer.java    From OAuth-2.0-Cookbook with MIT License 5 votes vote down vote up
@Bean
public RemoteTokenServices remoteTokenServices() {

    RemoteTokenServices tokenServices = new RemoteTokenServices();
    tokenServices.setClientId("resource_server");
    tokenServices.setClientSecret("abc123");
    tokenServices.setCheckTokenEndpointUrl("http://localhost:8080/oauth/check_token");
    tokenServices.setAccessTokenConverter(accessTokenConverter());

    return new CustomRemoteTokenServices(tokenServices);
}
 
Example #11
Source File: OAuth2ResourceServer.java    From OAuth-2.0-Cookbook with MIT License 5 votes vote down vote up
@Bean
public RemoteTokenServices remoteTokenServices() {
    RemoteTokenServices tokenServices = new RemoteTokenServices();
    tokenServices.setClientId("resource_server");
    tokenServices.setClientSecret("abc123");
    tokenServices.setCheckTokenEndpointUrl("http://localhost:8080/oauth/check_token");
    tokenServices.setAccessTokenConverter(accessTokenConverter());
    return tokenServices;
}
 
Example #12
Source File: ResourceServerConfig.java    From multi-tenant-rest-api with MIT License 5 votes vote down vote up
@Bean
public RemoteTokenServices LocalTokenService() {
     final RemoteTokenServices tokenService = new RemoteTokenServices();
     tokenService.setCheckTokenEndpointUrl("http://localhost:8081/oauth/check_token");
     tokenService.setClientId("my-client-with-secret");
     tokenService.setClientSecret("secret");
     return tokenService;
 }
 
Example #13
Source File: OAuth2ResourceServerConfigRemoteTokenService.java    From spring-security-oauth with MIT License 5 votes vote down vote up
@Primary
@Bean
public RemoteTokenServices tokenServices() {
    final RemoteTokenServices tokenService = new RemoteTokenServices();
    tokenService.setCheckTokenEndpointUrl("http://localhost:8081/spring-security-oauth-server/oauth/check_token");
    tokenService.setClientId("fooClientIdPassword");
    tokenService.setClientSecret("secret");
    return tokenService;
}
 
Example #14
Source File: CustomRemoteTokenServices.java    From OAuth-2.0-Cookbook with MIT License 4 votes vote down vote up
public CustomRemoteTokenServices(RemoteTokenServices remoteTokenServices) {
    this.remoteTokenServices = remoteTokenServices;
}