Search in sources :

Example 6 with TokenStore

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

the class AbstractIntegrationTests method clear.

private void clear(ApprovalStore approvalStore) throws Exception {
    if (approvalStore instanceof Advised) {
        Advised advised = (Advised) tokenStore;
        ApprovalStore target = (ApprovalStore) advised.getTargetSource().getTarget();
        clear(target);
        return;
    }
    if (approvalStore instanceof InMemoryApprovalStore) {
        ((InMemoryApprovalStore) approvalStore).clear();
    }
    if (approvalStore instanceof JdbcApprovalStore) {
        JdbcTemplate template = new JdbcTemplate(dataSource);
        template.execute("delete from oauth_approvals");
    }
}
Also used : InMemoryApprovalStore(org.springframework.security.oauth2.provider.approval.InMemoryApprovalStore) Advised(org.springframework.aop.framework.Advised) InMemoryApprovalStore(org.springframework.security.oauth2.provider.approval.InMemoryApprovalStore) ApprovalStore(org.springframework.security.oauth2.provider.approval.ApprovalStore) JdbcApprovalStore(org.springframework.security.oauth2.provider.approval.JdbcApprovalStore) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) JdbcApprovalStore(org.springframework.security.oauth2.provider.approval.JdbcApprovalStore)

Example 7 with TokenStore

use of org.springframework.security.oauth2.provider.token.TokenStore in project paascloud-master by paascloud.

the class PcAuthorizationServerConfig method configure.

/**
 * Configure.
 *
 * @param endpoints the endpoints
 *
 * @throws Exception the exception
 */
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
    endpoints.tokenStore(tokenStore).authenticationManager(authenticationManager).userDetailsService(userDetailsService);
    if (jwtAccessTokenConverter != null && jwtTokenEnhancer != null) {
        TokenEnhancerChain enhancerChain = new TokenEnhancerChain();
        List<TokenEnhancer> enhancers = new ArrayList<>();
        enhancers.add(jwtTokenEnhancer);
        enhancers.add(jwtAccessTokenConverter);
        enhancerChain.setTokenEnhancers(enhancers);
        endpoints.tokenEnhancer(enhancerChain).accessTokenConverter(jwtAccessTokenConverter);
    }
}
Also used : TokenEnhancer(org.springframework.security.oauth2.provider.token.TokenEnhancer) TokenEnhancerChain(org.springframework.security.oauth2.provider.token.TokenEnhancerChain) ArrayList(java.util.ArrayList)

Example 8 with TokenStore

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

the class AuthorizationServerEndpointsConfigurer method createDefaultTokenServices.

private DefaultTokenServices createDefaultTokenServices() {
    DefaultTokenServices tokenServices = new DefaultTokenServices();
    tokenServices.setTokenStore(tokenStore());
    tokenServices.setSupportRefreshToken(true);
    tokenServices.setReuseRefreshToken(reuseRefreshToken);
    tokenServices.setClientDetailsService(clientDetailsService());
    tokenServices.setTokenEnhancer(tokenEnhancer());
    addUserDetailsService(tokenServices, this.userDetailsService);
    return tokenServices;
}
Also used : DefaultTokenServices(org.springframework.security.oauth2.provider.token.DefaultTokenServices)

Example 9 with TokenStore

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

the class AuthorizationServerEndpointsConfigurer method approvalStore.

private ApprovalStore approvalStore() {
    if (approvalStore == null && tokenStore() != null && !isApprovalStoreDisabled()) {
        TokenApprovalStore tokenApprovalStore = new TokenApprovalStore();
        tokenApprovalStore.setTokenStore(tokenStore());
        this.approvalStore = tokenApprovalStore;
    }
    return this.approvalStore;
}
Also used : TokenApprovalStore(org.springframework.security.oauth2.provider.approval.TokenApprovalStore)

Example 10 with TokenStore

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

the class AuthorizationServerEndpointsConfigurer method userApprovalHandler.

private UserApprovalHandler userApprovalHandler() {
    if (userApprovalHandler == null) {
        if (approvalStore() != null) {
            ApprovalStoreUserApprovalHandler handler = new ApprovalStoreUserApprovalHandler();
            handler.setApprovalStore(approvalStore());
            handler.setRequestFactory(requestFactory());
            handler.setClientDetailsService(clientDetailsService);
            this.userApprovalHandler = handler;
        } else if (tokenStore() != null) {
            TokenStoreUserApprovalHandler userApprovalHandler = new TokenStoreUserApprovalHandler();
            userApprovalHandler.setTokenStore(tokenStore());
            userApprovalHandler.setClientDetailsService(clientDetailsService());
            userApprovalHandler.setRequestFactory(requestFactory());
            this.userApprovalHandler = userApprovalHandler;
        } else {
            throw new IllegalStateException("Either a TokenStore or an ApprovalStore must be provided");
        }
    }
    return this.userApprovalHandler;
}
Also used : TokenStoreUserApprovalHandler(org.springframework.security.oauth2.provider.approval.TokenStoreUserApprovalHandler) ApprovalStoreUserApprovalHandler(org.springframework.security.oauth2.provider.approval.ApprovalStoreUserApprovalHandler)

Aggregations

OAuth2AccessToken (org.springframework.security.oauth2.common.OAuth2AccessToken)3 InMemoryTokenStore (org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore)3 Test (org.junit.Test)2 Advised (org.springframework.aop.framework.Advised)2 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)2 DefaultOAuth2AccessToken (org.springframework.security.oauth2.common.DefaultOAuth2AccessToken)2 DefaultTokenServices (org.springframework.security.oauth2.provider.token.DefaultTokenServices)2 JwtTokenStore (org.springframework.security.oauth2.provider.token.store.JwtTokenStore)2 ArrayList (java.util.ArrayList)1 AbstractBeanDefinition (org.springframework.beans.factory.support.AbstractBeanDefinition)1 BeanDefinitionBuilder (org.springframework.beans.factory.support.BeanDefinitionBuilder)1 Bean (org.springframework.context.annotation.Bean)1 AnonymousAuthenticationProvider (org.springframework.security.authentication.AnonymousAuthenticationProvider)1 OAuth2RefreshToken (org.springframework.security.oauth2.common.OAuth2RefreshToken)1 ResourceServerSecurityConfigurer (org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer)1 TokenRequest (org.springframework.security.oauth2.provider.TokenRequest)1 ApprovalStore (org.springframework.security.oauth2.provider.approval.ApprovalStore)1 ApprovalStoreUserApprovalHandler (org.springframework.security.oauth2.provider.approval.ApprovalStoreUserApprovalHandler)1 InMemoryApprovalStore (org.springframework.security.oauth2.provider.approval.InMemoryApprovalStore)1 JdbcApprovalStore (org.springframework.security.oauth2.provider.approval.JdbcApprovalStore)1