chenjiahe
2022-03-31 b5bfe58beeeeb8343bdea6a9412f8f6704b67633
提交 | 用户 | age
5c5945 1 package com.hx.util;
E 2
3 import com.alibaba.fastjson.JSONObject;
4
5 import io.jsonwebtoken.Claims;
6
7 /**
8  * JWT 具备配置
9  * @author chenjiahe
10  * @Data 2020-06-09
11  */
12 public class JwtConstant {
13     
14     public static void main(String[] args) {
15         //每新开一个项目就重新生成JWT_SECERT秘钥
16         //String s = BASE64.encryptBASE64("hx-haoqi168".getBytes());
17         //System.out.println("s:"+s);
18         JSONObject obj = new JSONObject();
19         obj.put("id", "111");
20         obj.put("adminRoleId", "22");
21          String token = JwtTool.createJWT("111", obj.toString(), 300);
22          System.out.println("token:"+token);
23          //eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxMTEiLCJzdWIiOiLkuprpurvot4wiLCJpc3MiOiJ1c2VyIiwiaWF0IjoxNTkxODY4NjAxLCJleHAiOjE1OTE4Njg5MDF9.8m_TgK8m49r35-qQRQ0cGjL4r_jBlaVqb318vM00qrE
24     }
25     
26     public static String JWT_ERRCODE_EXPIRE = "登录有效期已过!";
27     public static String JWT_ERRCODE_FAIL = "登录无效,请重新登录!";
28     public static String JWT_SECERT = "aGFvcWkxNjg=";//生成JWT的秘钥
29     
30     private Claims claims;
31     private boolean success;
32     private String errCode;
33     
34     
35     /*************************************************************************/
36     public Claims getClaims() {
37         return claims;
38     }
39     public void setClaims(Claims claims) {
40         this.claims = claims;
41     }
42     public boolean isSuccess() {
43         return success;
44     }
45     public void setSuccess(boolean success) {
46         this.success = success;
47     }
48     public String getErrCode() {
49         return errCode;
50     }
51     public void setErrCode(String errCode) {
52         this.errCode = errCode;
53     }
54 }