|
@@ -1,5 +1,6 @@
|
|
|
package com.gis.common.shiro;
|
|
|
|
|
|
+import com.gis.common.constant.ErrorEnum;
|
|
|
import com.gis.common.exception.JwtAuthenticationException;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -74,19 +75,17 @@ public class MyRealm extends AuthorizingRealm {
|
|
|
|
|
|
if (StringUtils.isBlank(token)) {
|
|
|
log.error("header token is null ");
|
|
|
- throw new JwtAuthenticationException(5001, "header token is null");
|
|
|
+ throw new JwtAuthenticationException(ErrorEnum.FAILURE_SYS_5001.code(), "header token is null");
|
|
|
}
|
|
|
|
|
|
|
|
|
// 这里redis的key是token, value是用户信息,所以只要有返回结果,就算是验证通过
|
|
|
String tokenKey = "token#" + token;
|
|
|
- // String redisToken = redisTemplate.opsForValue().get(tokenKey);
|
|
|
-// Boolean aBoolean = redisTemplate.hasKey(tokenKey);
|
|
|
|
|
|
// 2022-11-04 四维看看v4 用户登录key:token#token , value: 用户信息jsonStr
|
|
|
if (!redisTemplate.hasKey(tokenKey)) {
|
|
|
log.error("redis token is null");
|
|
|
- throw new JwtAuthenticationException(5001, "redis token is null");
|
|
|
+ throw new JwtAuthenticationException(ErrorEnum.FAILURE_SYS_5002.code(), ErrorEnum.FAILURE_SYS_5002.message());
|
|
|
|
|
|
}
|
|
|
|
|
@@ -95,7 +94,7 @@ public class MyRealm extends AuthorizingRealm {
|
|
|
String username = JwtUtil.getUsername(token);
|
|
|
if (username == null) {
|
|
|
log.error("error token username");
|
|
|
- throw new JwtAuthenticationException(5001, "token invalid");
|
|
|
+ throw new JwtAuthenticationException(ErrorEnum.FAILURE_SYS_5003.code(), "token invalid");
|
|
|
}
|
|
|
|
|
|
|