forked from kidgrow-microservices-platform

克 刘
2020-03-16 549148d90d41a3320bd36d469fd690354c78de58
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.kidgrow.jwt.client.utils;
 
import com.kidgrow.common.exception.BizException;
import com.kidgrow.jwt.client.properties.AuthClientProperties;
import com.kidgrow.jwt.utils.JwtHelper;
import com.kidgrow.jwt.utils.JwtUserInfo;
import lombok.AllArgsConstructor;
 
/**
 * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br>
 *
 * @Description: JwtToken 客户端工具<br>
 * @Project: <br>
 * @CreateDate: Created in 2020/2/11 14:04 <br>
 * @Author: <a href="4345453@kidgrow.com">liuke</a>
 */
@AllArgsConstructor
public class JwtTokenClientUtils {
    /**
     * 用于 认证服务的 客户端使用(如 网关) , 在网关获取到token后,
     * 调用此工具类进行token 解析。
     * 客户端一般只需要解析token 即可
     */
    private AuthClientProperties authClientProperties;
 
    /**
     * 解析token
     *
     * @param token
     * @return
     * @throws BizException
     */
    public JwtUserInfo getUserInfo(String token) throws BizException {
        AuthClientProperties.TokenInfo userTokenInfo = authClientProperties.getUser();
        return JwtHelper.getJwtFromToken(token, userTokenInfo.getPubKey());
    }
}