/**
需要搭配WebUtil JWT Autor2
*/
public static DecodedJWT verify() {
String s = WebUtil.getRequest().getHeader("Authorization");
//截取token请求头前的
String token = s.substring(7);
//密匙
JWTVerifier JwtPass = JWT.require(Algorithm.HMAC256("***")).build();
DecodedJWT verify =null;
try{
verify = JwtPass.verify(token);
}catch (Exception e){
throw new RuntimeException(e);
}
return verify;
}
使用WebUtil实现一个反编译Author+security安全框架的Authorization请求头。
注意 需要进行字符串截取,被去除的内容为"bearer "注意有空格
"bearer "