package com.css.simulation.oauth.server.cofiguration.oauth;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.AccessTokenConverter;
import org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter;

@Configuration
public class MyAccessTokenConverter {

    @Autowired
    MyUserAuthenticationConverter myUserAuthenticationConverter;

    /**
     * redis 存储需使用
     */
    @Bean
    public AccessTokenConverter accessTokenConverter() {
        DefaultAccessTokenConverter defaultAccessTokenConverter = new DefaultAccessTokenConverter();
        defaultAccessTokenConverter.setUserTokenConverter(myUserAuthenticationConverter);
        return defaultAccessTokenConverter;
    }

//    /**
//     * jwt 令牌存储需使用
//     */
//    @Bean
//    public AccessTokenConverter accessTokenConverter() {
//        JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter();
//        jwtAccessTokenConverter.setSigningKey("project");
//        return jwtAccessTokenConverter;
//    }
}
