Java Code Examples for org.springframework.security.oauth2.provider.token.TokenStore

The following examples show how to use org.springframework.security.oauth2.provider.token.TokenStore. These examples are extracted from open source projects.
Example 1
Project: oauth-boot   File: OAuth2AuthorizationServerConfig.java    License: MIT License 6 votes vote down vote up
@Autowired(required = false)
public OAuth2AuthorizationServerConfig(AuthenticationManager authenticationManager,
                                       BootClientDetailsService clientDetailsService,
                                       TokenStore tokenStore, JwtAccessTokenConverter converter,
                                       AuthenticationEntryPoint authenticationEntryPoint,
                                       BootOAuth2WebResponseExceptionTranslator bootWebResponseExceptionTranslator,
                                       PasswordEncoder passwordEncoder, BootUserDetailService userDetailsService) {
    this.authenticationManager = authenticationManager;
    this.clientDetailsService = clientDetailsService;
    this.tokenStore = tokenStore;
    this.converter = converter;
    this.authenticationEntryPoint = authenticationEntryPoint;
    this.bootWebResponseExceptionTranslator = bootWebResponseExceptionTranslator;
    this.passwordEncoder = passwordEncoder;
    this.userDetailsService = userDetailsService;
}
 
Example 2
Project: open-cloud   File: OpenHelper.java    License: MIT License 6 votes vote down vote up
/**
 * 更新OpenUser
 *
 * @param openUser
 */
public static void updateOpenUser(TokenStore tokenStore, OpenUserDetails openUser) {
    if (openUser == null) {
        return;
    }
    Assert.notNull(openUser.getClientId(), "客户端ID不能为空");
    Assert.notNull(openUser.getUsername(), "用户名不能为空");
    // 动态更新客户端生成的token
    Collection<OAuth2AccessToken> accessTokens = tokenStore.findTokensByClientIdAndUserName(openUser.getClientId(), openUser.getUsername());
    if (accessTokens != null && !accessTokens.isEmpty()) {
        for (OAuth2AccessToken accessToken : accessTokens) {
            // 由于没有set方法,使用反射机制强制赋值
            OAuth2Authentication oAuth2Authentication = tokenStore.readAuthentication(accessToken);
            if (oAuth2Authentication != null) {
                Authentication authentication = oAuth2Authentication.getUserAuthentication();
                ReflectionUtils.setFieldValue(authentication, "principal", openUser);
                // 重新保存
                tokenStore.storeAccessToken(accessToken, oAuth2Authentication);
            }
        }
    }
}
 
Example 3
Project: Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud   File: AuthorizationServerConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean
public TokenStore tokenStore() {
	if (this.jwtEnabled) {
		return new JwtTokenStore(accessTokenConverter());
	} else {
		return new InMemoryTokenStore();
	}
}
 
Example 4
Project: spring-cloud-sso-connector   File: IssuerCheckConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public TokenStore jwkTokenStore() throws MalformedURLException {
    ProviderDiscoveryClient discoveryClient = new ProviderDiscoveryClient(ssoServiceUrl);
    ProviderConfiguration providerConfiguration = discoveryClient.discover();

    IssuerClaimVerifier issuerClaimVerifier = new IssuerClaimVerifier(providerConfiguration.getIssuer());

    return new JwkTokenStore(
        keySetUri,
        issuerClaimVerifier
    );
}
 
Example 5
Project: spring-security-oauth2-boot   File: OAuth2AuthorizationServerConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
public AuthorizationSecurityConfigurer(BaseClientDetails details,
		AuthenticationConfiguration authenticationConfiguration, ObjectProvider<TokenStore> tokenStore,
		ObjectProvider<AccessTokenConverter> tokenConverter, AuthorizationServerProperties properties)
		throws Exception {

	this.details = details;
	this.authenticationManager = authenticationConfiguration.getAuthenticationManager();
	this.tokenStore = tokenStore.getIfAvailable();
	this.tokenConverter = tokenConverter.getIfAvailable();
	this.properties = properties;
}
 
Example 6
Project: Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud   File: AuthorizationServerConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean
public TokenStore tokenStore() {
	if (this.jwtEnabled) {
		return new JwtTokenStore(accessTokenConverter());
	} else {
		return new InMemoryTokenStore();
	}
}
 
Example 7
Project: Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud   File: AuthorizationServerConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean
public TokenStore tokenStore() {
	if (this.jwtEnabled) {
		return new JwtTokenStore(accessTokenConverter());
	} else {
		return new InMemoryTokenStore();
	}
}
 
Example 8
Project: OAuth-2.0-Cookbook   File: JweTokenStore.java    License: MIT License 5 votes vote down vote up
public JweTokenStore(String encodedSigningKey, TokenStore delegate,
                     JwtAccessTokenConverter converter, JweTokenSerializer crypto) {
    this.encodedSigningKey = encodedSigningKey;
    this.delegate = delegate;
    this.converter = converter;
    this.crypto = crypto;
}
 
Example 9
Project: Learning-Path-Spring-5-End-to-End-Programming   File: OAuth2AuthServer.java    License: MIT License 5 votes vote down vote up
@Autowired
public OAuth2AuthServer(AuthenticationManager authenticationManager, TokenStore tokenStore,
    JwtAccessTokenConverter jwtAccessTokenConverter) {
  this.authenticationManager = authenticationManager;
  this.tokenStore = tokenStore;
  this.jwtAccessTokenConverter = jwtAccessTokenConverter;
}
 
Example 10
Project: osiam   File: TokenService.java    License: MIT License 5 votes vote down vote up
@Autowired
public TokenService(TokenStore tokenStore,
                    SCIMUserProvisioning userProvisioning,
                    ClientRepository clientRepository) {
    this.tokenStore = tokenStore;
    this.userProvisioning = userProvisioning;
    this.clientRepository = clientRepository;
}
 
Example 11
Project: spring-security-oauth2-boot   File: ResourceServerTokenServicesConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(ResourceServerTokenServices.class)
public DefaultTokenServices jwtTokenServices(TokenStore jwtTokenStore) {
	DefaultTokenServices services = new DefaultTokenServices();
	services.setTokenStore(jwtTokenStore);
	return services;
}
 
Example 12
Project: spring-security-oauth2-boot   File: AuthorizationServerTokenServicesConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(AuthorizationServerTokenServices.class)
public DefaultTokenServices jwtTokenServices(TokenStore jwtTokenStore) {
	DefaultTokenServices services = new DefaultTokenServices();
	services.setTokenStore(jwtTokenStore);
	return services;
}
 
Example 13
Project: swagger-aem   File: OAuth2SecurityConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@Autowired
public TokenStoreUserApprovalHandler userApprovalHandler(TokenStore tokenStore){
    TokenStoreUserApprovalHandler handler = new TokenStoreUserApprovalHandler();
    handler.setTokenStore(tokenStore);
    handler.setRequestFactory(new DefaultOAuth2RequestFactory(clientDetailsService));
    handler.setClientDetailsService(clientDetailsService);
    return handler;
}
 
Example 14
Project: Building-Web-Apps-with-Spring-5-and-Angular   File: AuthServerOAuth2Config.java    License: MIT License 4 votes vote down vote up
@Bean(name="tokenStore")
public TokenStore tokenStore() {
	return new JdbcTokenStore(this.dataSource);
}
 
Example 15
Project: training   File: AuthServiceApplication.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
TokenStore tokenStore() {
	return new JwtTokenStore(this.jwtAccessTokenConverter());
}
 
Example 16
Project: codeway_service   File: OauthAuthorizationServerConfig.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Bean
@Autowired
public TokenStore tokenStore(JwtAccessTokenConverter jwtAccessTokenConverter) {
	return new JwtTokenStore(jwtAccessTokenConverter);
}
 
Example 17
Project: camunda-bpm-identity-keycloak   File: RestApiSecurityConfig.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Configures the JWKS bases TokenStore.
 */
@Bean
public TokenStore tokenStore() {
	return new JwkTokenStore(configProps.getJwkSetUrl());
}
 
Example 18
Project: Mastering-Microservices-with-Java-Third-Edition   File: WebSecurityConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
  return new InMemoryTokenStore();
}
 
Example 19
Project: incubator-wikift   File: SecurityConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JwtTokenStore(accessTokenConverter());
}
 
Example 20
Project: swaggy-jenkins   File: OAuth2SecurityConfiguration.java    License: MIT License 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new InMemoryTokenStore();
}
 
Example 21
Project: Spring-5.0-Projects   File: CustomAuthorizationConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
	return new JwtTokenStore(accessTokenConverter());
}
 
Example 22
Project: lolibox   File: OauthConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public TokenStore tokenStore(DataSource ds){
    return new JdbcTokenStore(ds);
}
 
Example 23
Project: cubeai   File: SecurityBeanOverrideConfiguration.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
@Primary
public TokenStore tokenStore() {
    return null;
}
 
Example 24
Project: spring-security-oauth2-boot   File: OAuth2AutoConfigurationTests.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
	return new InMemoryTokenStore();
}
 
Example 25
Project: SpringAll   File: SsoAuthorizationServerConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public TokenStore jwtTokenStore() {
    return new JwtTokenStore(jwtAccessTokenConverter());
}
 
Example 26
Project: spring-boot-demo   File: AuthorizationServerConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new InMemoryTokenStore();
    // redis配置
    // return new RedisTokenStore(redisConnectionFactory);
}
 
Example 27
Project: Auth-service   File: OAuth2Config.java    License: MIT License 4 votes vote down vote up
@Bean
public TokenStore tokenStore(RedisConnectionFactory redisConnectionFactory) {
    return new CustomRedisTokenStore(redisConnectionFactory);
}
 
Example 28
Project: spring-security-oauth2-boot   File: ResourceServerTokenServicesConfiguration.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(TokenStore.class)
public TokenStore jwtTokenStore() {
	return new JwtTokenStore(jwtTokenEnhancer());
}
 
Example 29
Project: openapi-generator   File: OAuth2SecurityConfiguration.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new InMemoryTokenStore();
}
 
Example 30
Project: tutorials   File: SecurityBeanOverrideConfiguration.java    License: MIT License 4 votes vote down vote up
@Bean
@Primary
public TokenStore tokenStore() {
    return null;
}
 
Example 31
Project: microservices-platform   File: AuthJwtTokenStore.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public TokenStore tokenStore(JwtAccessTokenConverter jwtAccessTokenConverter) {
    return new JwtTokenStore(jwtAccessTokenConverter);
}
 
Example 32
Project: pacbot   File: AuthorizationServerConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JdbcTokenStore(dataSource);
}
 
Example 33
Project: codeway_service   File: ResourceServerConfig.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JwtTokenStore(jwtAccessTokenConverter());
}
 
Example 34
Project: spring-cloud-study   File: RedisTokenStoreConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public TokenStore redisTokenStore (){
    return new RedisTokenStore(redisConnectionFactory);
}
 
Example 35
Project: SpringAll   File: JWTokenConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public TokenStore jwtTokenStore() {
    return new JwtTokenStore(jwtAccessTokenConverter());
}
 
Example 36
Project: Spring5Tutorial   File: AcctApplication.java    License: GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JwtTokenStore(accessTokenConverter());
}
 
Example 37
Project: spring-cloud-study   File: RedisTokenStoreConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public TokenStore redisTokenStore (){
    return new RedisTokenStore(redisConnectionFactory);
}
 
Example 38
Project: spring-cloud-study   File: ResourceServerConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public TokenStore jwtTokenStore() {
    return new JwtTokenStore(jwtAccessTokenConverter());
}
 
Example 39
Project: oauth-boot   File: OAuth2ResourceServerConfig.java    License: MIT License 4 votes vote down vote up
public OAuth2ResourceServerConfig(AuthenticationEntryPoint point, BootAccessDeniedHandler handler, TokenStore tokenStore, BootSecurityProperties properties) {
    this.point = point;
    this.handler = handler;
    this.tokenStore = tokenStore;
    this.properties = properties;
}
 
Example 40
Project: cloud-template   File: AuthorizationServerConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JdbcTokenStore(dataSource());
}