TokenConfig.java 990 B

123456789101112131415161718192021222324252627282930313233
  1. package com.artist.config;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.context.annotation.Bean;
  4. import org.springframework.context.annotation.Configuration;
  5. import org.springframework.security.oauth2.provider.token.TokenStore;
  6. import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
  7. import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
  8. /**
  9. * @author Administrator
  10. * @version 1.0
  11. **/
  12. @Configuration
  13. public class TokenConfig {
  14. String SIGNING_KEY = "wy_music_token";
  15. @Autowired
  16. private JwtAccessTokenConverter accessTokenConverter;
  17. @Bean
  18. public TokenStore tokenStore() {
  19. return new JwtTokenStore(accessTokenConverter());
  20. }
  21. @Bean
  22. public JwtAccessTokenConverter accessTokenConverter() {
  23. JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
  24. converter.setSigningKey(SIGNING_KEY);
  25. return converter;
  26. }
  27. }