Replies: 1 comment
-
private static Optional<Payload> parseToken(String jwtToken, JWTSigner jwtSigner, Boolean isVerifyExpireTime) {
try {
System.out.println("jwtToken = " + jwtToken);
var jwt = JWTUtil.parseToken(jwtToken);
var verify = false;
if (isVerifyExpireTime) {
verify = jwt.setSigner(jwtSigner).validate(0);
System.out.println("verify = " + verify);
} else {
verify = jwt.setSigner(jwtSigner).verify();
}
if (!verify) {
return Optional.empty();
}
var payload = (NumberWithFormat) jwt.getPayload(SystemConstant.TOKEN_PAYLOAD_ID);
return Optional.of(new Payload(payload.longValue()));
} catch (Exception e) {
e.printStackTrace();
return Optional.empty();
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
这是我工具类中的方法:
private static Optional parseToken(String jwtToken, JWTSigner jwtSigner, Boolean isVerifyExpireTime) {
try {
System.out.println("jwtToken = " + jwtToken);
var jwt = JWTUtil.parseToken(jwtToken);
var verify = false;
}
日志:
jwtToken = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpZCI6MTY0NzUyMTgxOTM0MDU3MDYyNCwiZXhwIjoxNjg5MDYzOTY4fQ.M3OokEKI3x72TqR5baxiHfcvm3kmQmUsMa3ote2jGmPcpk3wBMrMknEMyFYXQ4aEXFs_xabwR2z2o_FPubjqxA
jwtToken = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpZCI6MTY0NzUyMTgxOTM0MDU3MDYyNCwiZXhwIjoxNjg5MDYzOTY4fQ.M3OokEKI3x72TqR5baxiHfcvm3kmQmUsMa3ote2jGmPcpk3wBMrMknEMyFYXQ4aEXFs_xabwR2z2o_FPubjqxA
verify = false
verify = false
jwtToken = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpZCI6MTY0NzUyMTgxOTM0MDU3MDYyNCwiZXhwIjoxNjg5MDYzOTY4fQ.M3OokEKI3x72TqR5baxiHfcvm3kmQmUsMa3ote2jGmPcpk3wBMrMknEMyFYXQ4aEXFs_xabwR2z2o_FPubjqxA
jwtToken = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpZCI6MTY0NzUyMTgxOTM0MDU3MDYyNCwiZXhwIjoxNjg5MDYzOTY4fQ.M3OokEKI3x72TqR5baxiHfcvm3kmQmUsMa3ote2jGmPcpk3wBMrMknEMyFYXQ4aEXFs_xabwR2z2o_FPubjqxA
verify = true
verify = true
jwtToken = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpZCI6MTY0NzUyMTgxOTM0MDU3MDYyNCwiZXhwIjoxNjg5MDYzOTY4fQ.M3OokEKI3x72TqR5baxiHfcvm3kmQmUsMa3ote2jGmPcpk3wBMrMknEMyFYXQ4aEXFs_xabwR2z2o_FPubjqxA
jwtToken = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpZCI6MTY0NzUyMTgxOTM0MDU3MDYyNCwiZXhwIjoxNjg5MDYzOTY4fQ.M3OokEKI3x72TqR5baxiHfcvm3kmQmUsMa3ote2jGmPcpk3wBMrMknEMyFYXQ4aEXFs_xabwR2z2o_FPubjqxA
verify = false
verify = false
jwtToken = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpZCI6MTY0NzUyMTgxOTM0MDU3MDYyNCwiZXhwIjoxNjg5MDYzOTY4fQ.M3OokEKI3x72TqR5baxiHfcvm3kmQmUsMa3ote2jGmPcpk3wBMrMknEMyFYXQ4aEXFs_xabwR2z2o_FPubjqxA
jwtToken = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpZCI6MTY0NzUyMTgxOTM0MDU3MDYyNCwiZXhwIjoxNjg5MDYzOTY4fQ.M3OokEKI3x72TqR5baxiHfcvm3kmQmUsMa3ote2jGmPcpk3wBMrMknEMyFYXQ4aEXFs_xabwR2z2o_FPubjqxA
verify = true
verify = true
jwtToken = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpZCI6MTY0NzUyMTgxOTM0MDU3MDYyNCwiZXhwIjoxNjg5MDYzOTY4fQ.M3OokEKI3x72TqR5baxiHfcvm3kmQmUsMa3ote2jGmPcpk3wBMrMknEMyFYXQ4aEXFs_xabwR2z2o_FPubjqxA
jwtToken = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpZCI6MTY0NzUyMTgxOTM0MDU3MDYyNCwiZXhwIjoxNjg5MDYzOTY4fQ.M3OokEKI3x72TqR5baxiHfcvm3kmQmUsMa3ote2jGmPcpk3wBMrMknEMyFYXQ4aEXFs_xabwR2z2o_FPubjqxA
verify = false
verify = false
jwtToken = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpZCI6MTY0NzUyMTgxOTM0MDU3MDYyNCwiZXhwIjoxNjg5MDYzOTY4fQ.M3OokEKI3x72TqR5baxiHfcvm3kmQmUsMa3ote2jGmPcpk3wBMrMknEMyFYXQ4aEXFs_xabwR2z2o_FPubjqxA
jwtToken = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpZCI6MTY0NzUyMTgxOTM0MDU3MDYyNCwiZXhwIjoxNjg5MDYzOTY4fQ.M3OokEKI3x72TqR5baxiHfcvm3kmQmUsMa3ote2jGmPcpk3wBMrMknEMyFYXQ4aEXFs_xabwR2z2o_FPubjqxA
verify = false
verify = false
Beta Was this translation helpful? Give feedback.
All reactions