Search in sources :

Example 1 with JdbcTokenStore

use of org.springframework.security.oauth2.provider.token.store.JdbcTokenStore in project spring-security-oauth by spring-projects.

the class AbstractIntegrationTests method clear.

private void clear(TokenStore tokenStore) throws Exception {
    if (tokenStore instanceof Advised) {
        Advised advised = (Advised) tokenStore;
        TokenStore target = (TokenStore) advised.getTargetSource().getTarget();
        clear(target);
        return;
    }
    if (tokenStore instanceof InMemoryTokenStore) {
        ((InMemoryTokenStore) tokenStore).clear();
    }
    if (tokenStore instanceof JdbcTokenStore) {
        JdbcTemplate template = new JdbcTemplate(dataSource);
        template.execute("delete from oauth_access_token");
        template.execute("delete from oauth_refresh_token");
        template.execute("delete from oauth_client_token");
        template.execute("delete from oauth_code");
    }
}
Also used : InMemoryTokenStore(org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore) JdbcTokenStore(org.springframework.security.oauth2.provider.token.store.JdbcTokenStore) Advised(org.springframework.aop.framework.Advised) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) TokenStore(org.springframework.security.oauth2.provider.token.TokenStore) InMemoryTokenStore(org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore) JdbcTokenStore(org.springframework.security.oauth2.provider.token.store.JdbcTokenStore)

Example 2 with JdbcTokenStore

use of org.springframework.security.oauth2.provider.token.store.JdbcTokenStore in project spring-security-oauth by spring-projects.

the class Application method tokenStore.

@Bean
public JwtTokenStore tokenStore() throws Exception {
    JwtAccessTokenConverter enhancer = new JwtAccessTokenConverter();
    // N.B. in a real system you would have to configure the verifierKey (or use JdbcTokenStore)
    enhancer.afterPropertiesSet();
    return new JwtTokenStore(enhancer);
}
Also used : JwtTokenStore(org.springframework.security.oauth2.provider.token.store.JwtTokenStore) JwtAccessTokenConverter(org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter) Bean(org.springframework.context.annotation.Bean)

Aggregations

Advised (org.springframework.aop.framework.Advised)1 Bean (org.springframework.context.annotation.Bean)1 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)1 TokenStore (org.springframework.security.oauth2.provider.token.TokenStore)1 InMemoryTokenStore (org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore)1 JdbcTokenStore (org.springframework.security.oauth2.provider.token.store.JdbcTokenStore)1 JwtAccessTokenConverter (org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter)1 JwtTokenStore (org.springframework.security.oauth2.provider.token.store.JwtTokenStore)1