|
@@ -1,9 +1,13 @@
|
|
|
package com.gis.common.shiro;
|
|
|
|
|
|
+import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.gis.common.constant.ConfigConstant;
|
|
|
import com.gis.common.exception.JwtAuthenticationException;
|
|
|
+import com.gis.common.util.RedisUtil;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
@@ -21,7 +25,6 @@ import java.io.PrintWriter;
|
|
|
*/
|
|
|
@Log4j2
|
|
|
public class JWTFilter extends BasicHttpAuthenticationFilter {
|
|
|
-
|
|
|
/**
|
|
|
* 执行登录验证
|
|
|
*/
|
|
@@ -33,9 +36,10 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
|
|
|
|
|
|
// 提交给realm进行登入,如果错误他会抛出异常并被捕获
|
|
|
getSubject(request, response).login(token);
|
|
|
-
|
|
|
- // 如果没有抛出异常则代表登入成功,返回true
|
|
|
- return true;
|
|
|
+ RedisUtil redisUtil = SpringUtil.getBean(RedisUtil.class);
|
|
|
+ ConfigConstant configConstant = SpringUtil.getBean(ConfigConstant.class);
|
|
|
+ Boolean hasKey = redisUtil.hasKey(configConstant.redisTokenPrefix + token);
|
|
|
+ return hasKey;
|
|
|
}
|
|
|
|
|
|
/**
|