package com.hx.util;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import io.jsonwebtoken.Claims;
|
|
/**
|
* JWT 具备配置
|
* @author chenjiahe
|
* @Data 2020-06-09
|
*/
|
public class JwtConstant {
|
|
public static void main(String[] args) {
|
//每新开一个项目就重新生成JWT_SECERT秘钥
|
//String s = BASE64.encryptBASE64("hx-haoqi168".getBytes());
|
//System.out.println("s:"+s);
|
JSONObject obj = new JSONObject();
|
obj.put("id", "111");
|
obj.put("adminRoleId", "22");
|
String token = JwtTool.createJWT("111", obj.toString(), 300);
|
System.out.println("token:"+token);
|
//eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxMTEiLCJzdWIiOiLkuprpurvot4wiLCJpc3MiOiJ1c2VyIiwiaWF0IjoxNTkxODY4NjAxLCJleHAiOjE1OTE4Njg5MDF9.8m_TgK8m49r35-qQRQ0cGjL4r_jBlaVqb318vM00qrE
|
}
|
|
public static String JWT_ERRCODE_EXPIRE = "登录有效期已过!";
|
public static String JWT_ERRCODE_FAIL = "登录无效,请重新登录!";
|
public static String JWT_SECERT = "aGFvcWkxNjg=";//生成JWT的秘钥
|
|
private Claims claims;
|
private boolean success;
|
private String errCode;
|
|
|
/*************************************************************************/
|
public Claims getClaims() {
|
return claims;
|
}
|
public void setClaims(Claims claims) {
|
this.claims = claims;
|
}
|
public boolean isSuccess() {
|
return success;
|
}
|
public void setSuccess(boolean success) {
|
this.success = success;
|
}
|
public String getErrCode() {
|
return errCode;
|
}
|
public void setErrCode(String errCode) {
|
this.errCode = errCode;
|
}
|
}
|