Java Code Examples for org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer#tokenServices()

The following examples show how to use org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer#tokenServices() . 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: OAuth2ResourceServerConfig.java    From spring-boot-demo with MIT License 5 votes vote down vote up
@Override
  public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
    DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
    defaultTokenServices.setTokenStore(tokenStore());
    resources.tokenServices(defaultTokenServices);
//    resources.tokenStore(tokenStore());
  }
 
Example 2
Source File: ResourceServerConfig.java    From springcloud-oauth2 with MIT License 5 votes vote down vote up
/**
 * 这个是跟服务绑定的,注意要跟client配置一致,如果客户端没有,则不能访问
 * @param resources
 * @throws Exception
 */
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
    resources.resourceId(RESOURCE_ID).stateless(true);
    userInfoTokenServices.setPrincipalExtractor(principalExtractor());
    // 配置了user-info-uri默认使用的就是userInfoTokenServices,这个这么配置只是为了设置principalExtractor
    resources.tokenServices(userInfoTokenServices);
}
 
Example 3
Source File: ResourceServerConfiguration.java    From demo-spring-boot-security-oauth2 with MIT License 5 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources) {
	// @formatter:off
	resources.resourceId(resourceId);
	resources.tokenServices(defaultTokenServices());
	// @formatter:on
}
 
Example 4
Source File: ResourceServerConfig.java    From microservice-integration with MIT License 5 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
    CustomRemoteTokenServices resourceServerTokenServices = new CustomRemoteTokenServices();
    resourceServerTokenServices.setCheckTokenEndpointUrl(resource.getTokenInfoUri());
    resourceServerTokenServices.setClientId(resource.getClientId());
    resourceServerTokenServices.setClientSecret(resource.getClientSecret());
    resourceServerTokenServices.setLoadBalancerClient(loadBalancerClient);
    resources.tokenServices(resourceServerTokenServices);

}
 
Example 5
Source File: SecurityConfiguration.java    From nakadi with MIT License 5 votes vote down vote up
@Override
public void configure(final ResourceServerSecurityConfigurer resources) throws Exception {
    final OAuth2AuthenticationEntryPoint oAuth2AuthenticationEntryPoint = new OAuth2AuthenticationEntryPoint();
    oAuth2AuthenticationEntryPoint.setExceptionRenderer(new ProblemOauthExceptionRenderer());
    resources.authenticationEntryPoint(oAuth2AuthenticationEntryPoint);
    resources.tokenServices(tokenServices);
    resources.expressionHandler(new ExtendedOAuth2WebSecurityExpressionHandler());
    final OAuth2AccessDeniedHandler oAuth2AccessDeniedHandler = new OAuth2AccessDeniedHandler();
    oAuth2AccessDeniedHandler.setExceptionRenderer(new ProblemOauthExceptionRenderer());
    resources.accessDeniedHandler(oAuth2AccessDeniedHandler);
}
 
Example 6
Source File: ResourceServerConfiguration.java    From open-cloud with MIT License 4 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
    // 构建redis获取token服务类
    resources.tokenServices(OpenHelper.buildRedisTokenServices(redisConnectionFactory));
}
 
Example 7
Source File: ResourceServerConfiguration.java    From open-cloud with MIT License 4 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
    // 构建redis获取token服务类
    resources.tokenServices(OpenHelper.buildRedisTokenServices(redisConnectionFactory));
    resources.expressionHandler(expressionHandler);
}
 
Example 8
Source File: ResourceServerConfiguration.java    From open-cloud with MIT License 4 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
    // 构建redis获取token服务类
    resources.tokenServices(OpenHelper.buildRedisTokenServices(redisConnectionFactory));
}
 
Example 9
Source File: ResourceServerConfiguration.java    From open-cloud with MIT License 4 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
    // 构建redis获取token服务类
    resources.tokenServices(OpenHelper.buildRedisTokenServices(redisConnectionFactory));
}
 
Example 10
Source File: ResourceServerConfiguration.java    From open-cloud with MIT License 4 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
    // 构建redis获取token服务类
    resources.tokenServices(OpenHelper.buildRedisTokenServices(redisConnectionFactory));
}
 
Example 11
Source File: ResourceServerConfiguration.java    From open-cloud with MIT License 4 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
    // 构建redis获取token服务类
    resources.tokenServices(OpenHelper.buildRedisTokenServices(redisConnectionFactory));
}
 
Example 12
Source File: ResourceServerConfig.java    From java8-spring-cloud-microservice-demo with MIT License 4 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer config) {
    config.resourceId("default-resources"); // this matches the resourceId in OAuth2JwtConfig
    config.tokenServices(this.getTokenService());
}
 
Example 13
Source File: ResourceServerOAuth2Config.java    From Building-Web-Apps-with-Spring-5-and-Angular with MIT License 4 votes vote down vote up
@Override
public void configure(final ResourceServerSecurityConfigurer config) {
	final DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
    defaultTokenServices.setTokenStore(this.tokenStore);        
    config.tokenServices(defaultTokenServices);
}
 
Example 14
Source File: OAuth2ResourceServerConfig.java    From spring-security-oauth with MIT License 4 votes vote down vote up
@Override
public void configure(final ResourceServerSecurityConfigurer config) {
    config.tokenServices(tokenServices());
}
 
Example 15
Source File: OAuth2ResourceServerConfigJwt.java    From spring-security-oauth with MIT License 4 votes vote down vote up
@Override
public void configure(final ResourceServerSecurityConfigurer config) {
    config.tokenServices(tokenServices());
}
 
Example 16
Source File: OAuth2ResourceServerConfig.java    From spring-security-oauth with MIT License 4 votes vote down vote up
@Override
public void configure(final ResourceServerSecurityConfigurer config) {
    config.tokenServices(tokenServices());
}