|
@@ -1,48 +0,0 @@
|
|
|
-package com.diagbot.config;
|
|
|
-
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
-import org.springframework.context.annotation.Bean;
|
|
|
-import org.springframework.context.annotation.Configuration;
|
|
|
-import org.springframework.core.io.ClassPathResource;
|
|
|
-import org.springframework.core.io.Resource;
|
|
|
-import org.springframework.security.oauth2.provider.token.TokenStore;
|
|
|
-import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
|
|
|
-import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
|
|
|
-import org.springframework.util.FileCopyUtils;
|
|
|
-
|
|
|
-import java.io.IOException;
|
|
|
-
|
|
|
-/**
|
|
|
- * @Description: JWT配置类
|
|
|
- * @author: gaodm
|
|
|
- * @time: 2018/8/2 13:38
|
|
|
- */
|
|
|
-@Configuration
|
|
|
-public class JwtConfiguration {
|
|
|
- @Autowired
|
|
|
- private CustomAccessTokenConverter customAccessTokenConverter;
|
|
|
-
|
|
|
- @Bean
|
|
|
- @Qualifier("tokenStore")
|
|
|
- public TokenStore tokenStore() {
|
|
|
-
|
|
|
- System.out.println("Created JwtTokenStore");
|
|
|
- return new JwtTokenStore(jwtTokenEnhancer());
|
|
|
- }
|
|
|
-
|
|
|
- @Bean
|
|
|
- protected JwtAccessTokenConverter jwtTokenEnhancer() {
|
|
|
- JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
|
|
|
- Resource resource = new ClassPathResource("public.cert");
|
|
|
- String publicKey ;
|
|
|
- try {
|
|
|
- publicKey = new String(FileCopyUtils.copyToByteArray(resource.getInputStream()));
|
|
|
- } catch (IOException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
- converter.setVerifierKey(publicKey);
|
|
|
- converter.setAccessTokenConverter(customAccessTokenConverter);
|
|
|
- return converter;
|
|
|
- }
|
|
|
-}
|