XiaoRuby
2023-08-03 fbba4ea24430b14eee18b190b7e08f1a58a8e504
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
package com.yuanchu.limslaboratory.shiro;
 
import com.yuanchu.limslaboratory.shiro.utils.JwtUtils;
import org.apache.shiro.authc.AuthenticationToken;
 
public class JwtToken implements AuthenticationToken {
    private static final long serialVersionUID = 1L;
 
    // 加密后的 JWT token串
    private String token;
 
    private String account;
 
    public JwtToken(String token) {
        this.token = token;
        this.account = JwtUtils.getClaimFiled(token, "account");
    }
 
    @Override
    public Object getPrincipal() {
        return this.account;
    }
 
    @Override
    public Object getCredentials() {
        return token;
    }
}