Java Code Examples for org.springframework.security.oauth2.provider.token.store.JdbcTokenStore

The following examples show how to use org.springframework.security.oauth2.provider.token.store.JdbcTokenStore. These examples are extracted from open source projects. 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 Project: auth-server   Source File: TokenServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void revokeTokens(String username) {
  log.debug("Revoking tokens for {}", username);

  if (!(tokenStore instanceof JdbcTokenStore)) {
    log.debug("Token store is not instance of JdbcTokenStore. Cannot revoke tokens!");

    return;
  }

  Collection<OAuth2AccessToken> tokens = ((JdbcTokenStore) tokenStore).findTokensByUserName(username);

  for (OAuth2AccessToken token : tokens) {
    log.debug("Revoking access token {}", token);
    tokenStore.removeAccessToken(token);

    log.debug("Revoking refresh token {}", token.getRefreshToken());
    tokenStore.removeRefreshToken(token.getRefreshToken());
  }

}
 
Example 2
Source Project: open-capacity-platform   Source File: TokenStoreConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
	@ConditionalOnProperty(prefix="security.oauth2.token.store",name="type" ,havingValue="jdbc" ,matchIfMissing=false)
	public JdbcTokenStore jdbcTokenStore(){
 
//		oauth_access_token oauth_refresh_token 创建两张表
//		return new JdbcTokenStore( dataSource ) ;
		return new JdbcTokenStore( dataSource ) ;

	}
 
Example 3
Source Project: open-capacity-platform   Source File: TokenStoreConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
	@ConditionalOnProperty(prefix="security.oauth2.token.store",name="type" ,havingValue="jdbc" ,matchIfMissing=false)
	public JdbcTokenStore jdbcTokenStore(){
 
//		oauth_access_token oauth_refresh_token 创建两张表
//		return new JdbcTokenStore( dataSource ) ;
		return new JdbcTokenStore( dataSource ) ;

	}
 
Example 4
Source Project: pacbot   Source File: ApiService.java    License: Apache License 2.0 5 votes vote down vote up
public void logout(Principal principal) {
	 JdbcTokenStore jdbcTokenStore = tokenStore();
	 OAuth2Authentication oAuth2Authentication = (OAuth2Authentication) principal;
	 OAuth2AccessToken accessToken = jdbcTokenStore.getAccessToken(oAuth2Authentication);
	 jdbcTokenStore.removeAccessToken(accessToken.getValue());
	 jdbcTokenStore.removeRefreshToken(accessToken.getRefreshToken());
}
 
Example 5
Source Project: pacbot   Source File: LdapAuthServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void logout(Principal principal) {
	 JdbcTokenStore jdbcTokenStore = tokenStore();
	 OAuth2Authentication oAuth2Authentication = (OAuth2Authentication) principal;
	 OAuth2AccessToken accessToken = jdbcTokenStore.getAccessToken(oAuth2Authentication);
	 jdbcTokenStore.removeAccessToken(accessToken.getValue());
	 jdbcTokenStore.removeRefreshToken(accessToken.getRefreshToken());
}
 
Example 6
Source Project: oauth2lab   Source File: TokenController.java    License: MIT License 5 votes vote down vote up
@RequestMapping(method = RequestMethod.POST, value = "/tokens/revokeRefreshToken/{tokenId:.*}")
@ResponseBody
public String revokeRefreshToken(@PathVariable String tokenId) {
    if (tokenStore instanceof JdbcTokenStore) {
        ((JdbcTokenStore) tokenStore).removeRefreshToken(tokenId);
    }
    return tokenId;
}
 
Example 7
Source Project: OAuth-2.0-Cookbook   Source File: RefreshTokenRevocationService.java    License: MIT License 5 votes vote down vote up
@Override
public void revoke(String token) {
    if (tokenStore instanceof JdbcTokenStore) {
        JdbcTokenStore store = (JdbcTokenStore) tokenStore;
        store.removeRefreshToken(token);
    }
}
 
Example 8
Source Project: spring-security-oauth   Source File: TokenController.java    License: MIT License 5 votes vote down vote up
@RequestMapping(method = RequestMethod.POST, value = "/tokens/revokeRefreshToken/{tokenId:.*}")
@ResponseBody
public String revokeRefreshToken(@PathVariable String tokenId) {
    if (tokenStore instanceof JdbcTokenStore) {
        ((JdbcTokenStore) tokenStore).removeRefreshToken(tokenId);
    }
    return tokenId;
}
 
Example 9
@Primary
@Bean
public AuthorizationServerTokenServices tokenServices()
{
    DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
    defaultTokenServices.setTokenStore( new JdbcTokenStore( dataSource ) );
    defaultTokenServices.setSupportRefreshToken( true );
    return defaultTokenServices;
}
 
Example 10
Source Project: microservices-platform   Source File: AuthDbTokenStore.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public TokenStore tokenStore(){
    return new JdbcTokenStore(dataSource);
}
 
Example 11
Source Project: cloud-template   Source File: AuthorizationServerConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JdbcTokenStore(dataSource());
}
 
Example 12
@Bean
public TokenStore tokenStore() {
    // 基于 JDBC 实现,令牌保存到数据
    return new JdbcTokenStore(dataSource());
}
 
Example 13
Source Project: Spring   Source File: OauthResourceApplication.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public TokenStore tokenStore(){
	return new JdbcTokenStore(dataSource());
}
 
Example 14
Source Project: Spring   Source File: AuthorizationServerConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
	return new JdbcTokenStore(dataSource());
}
 
Example 15
@Bean
public TokenStore tokenStore() {
    return new JdbcTokenStore(dataSource);
}
 
Example 16
Source Project: pacbot   Source File: ApiService.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public JdbcTokenStore tokenStore() {
    return new JdbcTokenStore(dataSource);
}
 
Example 17
Source Project: pacbot   Source File: LdapAuthServiceImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public JdbcTokenStore tokenStore() {
    return new JdbcTokenStore(dataSource);
}
 
Example 18
Source Project: pacbot   Source File: AuthorizationServerConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JdbcTokenStore(dataSource);
}
 
Example 19
Source Project: oauth2lab   Source File: OAuth2AuthorizationServerConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JdbcTokenStore(dataSource());
}
 
Example 20
Source Project: oauth2lab   Source File: OAuth2Configuration.java    License: MIT License 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JdbcTokenStore(dataSource);
}
 
Example 21
Source Project: java-tutorial   Source File: AuthorizationServerConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public TokenStore jdbcTokenStore() {
    return new JdbcTokenStore(dataSource);
}
 
Example 22
Source Project: oauth2-blog   Source File: TokenStoreConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JdbcTokenStore(dataSource);
}
 
Example 23
@Bean
public JdbcTokenStore tokenStore() {
	return new JdbcTokenStore(dataSource);
}
 
Example 24
Source Project: microservices-oauth   Source File: OAuth2Configuration.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
	return new JdbcTokenStore(dataSource);
}
 
Example 25
Source Project: auth-server   Source File: JDBCTokenStoreConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
  return new JdbcTokenStore(dataSource);
}
 
Example 26
Source Project: OAuth-2.0-Cookbook   Source File: OAuth2AuthorizationServer.java    License: MIT License 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JdbcTokenStore(dataSource);
}
 
Example 27
Source Project: OAuth-2.0-Cookbook   Source File: OAuth2AuthorizationServer.java    License: MIT License 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JdbcTokenStore(dataSource);
}
 
Example 28
Source Project: OAuth-2.0-Cookbook   Source File: OAuth2AuthorizationServer.java    License: MIT License 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JdbcTokenStore(dataSource);
}
 
Example 29
Source Project: OAuth-2.0-Cookbook   Source File: OAuth2AuthorizationServer.java    License: MIT License 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JdbcTokenStore(dataSource);
}
 
Example 30
Source Project: OAuth-2.0-Cookbook   Source File: OAuth2AuthorizationServer.java    License: MIT License 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JdbcTokenStore(dataSource);
}