update 优化同步数据时的验证逻辑
This commit is contained in:
+21
-5
@@ -1,5 +1,9 @@
|
||||
package com.jero.config.shiro.filters;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.jero.common.system.util.JwtUtil;
|
||||
import com.jero.common.util.AuthenticationUtils;
|
||||
import com.jero.common.util.SpringContextUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter;
|
||||
@@ -9,6 +13,7 @@ import com.jero.config.shiro.JwtToken;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -28,6 +33,8 @@ public class JwtFilter extends BasicHttpAuthenticationFilter {
|
||||
public JwtFilter(boolean allowOrigin){
|
||||
this.allowOrigin = allowOrigin;
|
||||
}
|
||||
@Resource
|
||||
private AuthenticationUtils authenticationUtils;
|
||||
|
||||
/**
|
||||
* 执行登录认证
|
||||
@@ -58,12 +65,21 @@ public class JwtFilter extends BasicHttpAuthenticationFilter {
|
||||
if(token == null){
|
||||
token = httpServletRequest.getParameter("token");
|
||||
}
|
||||
// update-end--Author:lvdandan Date:20210105 for:JT-355 OA聊天添加token验证,获取token参数
|
||||
String pushToken = httpServletRequest.getParameter("pushToken");
|
||||
if (StrUtil.isNotBlank(pushToken)){
|
||||
String publicKey = httpServletRequest.getParameter("publicKey");
|
||||
if (authenticationUtils ==null ){
|
||||
authenticationUtils = (AuthenticationUtils) SpringContextUtil.getBean("authenticationUtils");
|
||||
}
|
||||
authenticationUtils.check(pushToken,publicKey);
|
||||
}else {
|
||||
// update-end--Author:lvdandan Date:20210105 for:JT-355 OA聊天添加token验证,获取token参数
|
||||
|
||||
JwtToken jwtToken = new JwtToken(token);
|
||||
// 提交给realm进行登入,如果错误他会抛出异常并被捕获
|
||||
getSubject(request, response).login(jwtToken);
|
||||
// 如果没有抛出异常则代表登入成功,返回true
|
||||
JwtToken jwtToken = new JwtToken(token);
|
||||
// 提交给realm进行登入,如果错误他会抛出异常并被捕获
|
||||
getSubject(request, response).login(jwtToken);
|
||||
// 如果没有抛出异常则代表登入成功,返回true
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user