|
@@ -1,9 +1,15 @@
|
|
package com.jiayue.ssi.filter;
|
|
package com.jiayue.ssi.filter;
|
|
|
|
|
|
|
|
+import com.jiayue.ssi.backenum.AuditType;
|
|
|
|
+import com.jiayue.ssi.backenum.BusinessStatus;
|
|
|
|
+import com.jiayue.ssi.backenum.BusinessType;
|
|
import com.jiayue.ssi.constant.CacheConstants;
|
|
import com.jiayue.ssi.constant.CacheConstants;
|
|
import com.jiayue.ssi.entity.SysBlacklist;
|
|
import com.jiayue.ssi.entity.SysBlacklist;
|
|
|
|
+import com.jiayue.ssi.entity.SysOperLog;
|
|
|
|
+import com.jiayue.ssi.factory.OperateLogFactory;
|
|
import com.jiayue.ssi.service.SysBlacklistService;
|
|
import com.jiayue.ssi.service.SysBlacklistService;
|
|
import com.jiayue.ssi.util.*;
|
|
import com.jiayue.ssi.util.*;
|
|
|
|
+import io.jsonwebtoken.Claims;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.core.annotation.Order;
|
|
import org.springframework.core.annotation.Order;
|
|
@@ -64,6 +70,38 @@ public class InterfaceLimitFilter extends OncePerRequestFilter {
|
|
// 当前时间
|
|
// 当前时间
|
|
Date currentDate = new Date();
|
|
Date currentDate = new Date();
|
|
if (currentDate.after(startDate) && currentDate.before(endDate)){
|
|
if (currentDate.after(startDate) && currentDate.before(endDate)){
|
|
|
|
+ String token = request.getHeader("Authorization");
|
|
|
|
+ JwtTokenUtil jwtTokenUtil = new JwtTokenUtil();
|
|
|
|
+ Claims claims = jwtTokenUtil.getClaimsFromToken(token);
|
|
|
|
+ String username="";
|
|
|
|
+ if (claims==null){
|
|
|
|
+ username = "未知用户";
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ username = claims.getSubject();
|
|
|
|
+ }
|
|
|
|
+ String openUrl = request.getParameter("accessUrl");
|
|
|
|
+ SysOperLog operLog = new SysOperLog();
|
|
|
|
+ operLog.setStatus(BusinessStatus.FAIL.ordinal());
|
|
|
|
+ // 请求的地址
|
|
|
|
+ String ip = IPUtils.getIpAddr();
|
|
|
|
+ operLog.setOperIp(ip);
|
|
|
|
+ operLog.setOperUrl(openUrl);
|
|
|
|
+ operLog.setOperName(username);
|
|
|
|
+ // 设置请求方式
|
|
|
|
+ operLog.setRequestMethod("");
|
|
|
|
+ operLog.setCreateBy(username);
|
|
|
|
+ // 设置action动作
|
|
|
|
+ operLog.setBusinessType(BusinessType.IPYC.ordinal());
|
|
|
|
+ // 设置标题
|
|
|
|
+ operLog.setTitle("IP异常");
|
|
|
|
+ // 操作描述
|
|
|
|
+ operLog.setOperdesc("IP异常");
|
|
|
|
+ // 审计类型
|
|
|
|
+ operLog.setAuditType(AuditType.SYS.ordinal());
|
|
|
|
+ // 保存数据库
|
|
|
|
+ OperateLogFactory.recordOper(operLog);
|
|
|
|
+
|
|
log.info("发送邮箱IP异常访问\r\n" +
|
|
log.info("发送邮箱IP异常访问\r\n" +
|
|
"↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓邮箱内容↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓"+
|
|
"↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓邮箱内容↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓"+
|
|
"\r\n IP:"+remoteIp+"异常访问系统 \r\n" +
|
|
"\r\n IP:"+remoteIp+"异常访问系统 \r\n" +
|
|
@@ -77,6 +115,38 @@ public class InterfaceLimitFilter extends OncePerRequestFilter {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else{
|
|
else{
|
|
|
|
+ String token = request.getHeader("Authorization");
|
|
|
|
+ JwtTokenUtil jwtTokenUtil = new JwtTokenUtil();
|
|
|
|
+ Claims claims = jwtTokenUtil.getClaimsFromToken(token);
|
|
|
|
+ String username="";
|
|
|
|
+ if (claims==null){
|
|
|
|
+ username = "未知用户";
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ username = claims.getSubject();
|
|
|
|
+ }
|
|
|
|
+ String openUrl = request.getParameter("accessUrl");
|
|
|
|
+ SysOperLog operLog = new SysOperLog();
|
|
|
|
+ operLog.setStatus(BusinessStatus.FAIL.ordinal());
|
|
|
|
+ // 请求的地址
|
|
|
|
+ String ip = IPUtils.getIpAddr();
|
|
|
|
+ operLog.setOperIp(ip);
|
|
|
|
+ operLog.setOperUrl(openUrl);
|
|
|
|
+ operLog.setOperName(username);
|
|
|
|
+ // 设置请求方式
|
|
|
|
+ operLog.setRequestMethod("");
|
|
|
|
+ operLog.setCreateBy(username);
|
|
|
|
+ // 设置action动作
|
|
|
|
+ operLog.setBusinessType(BusinessType.IPYC.ordinal());
|
|
|
|
+ // 设置标题
|
|
|
|
+ operLog.setTitle("IP异常");
|
|
|
|
+ // 操作描述
|
|
|
|
+ operLog.setOperdesc("IP异常");
|
|
|
|
+ // 审计类型
|
|
|
|
+ operLog.setAuditType(AuditType.SYS.ordinal());
|
|
|
|
+ // 保存数据库
|
|
|
|
+ OperateLogFactory.recordOper(operLog);
|
|
|
|
+
|
|
log.info("发送邮箱IP异常访问\r\n" +
|
|
log.info("发送邮箱IP异常访问\r\n" +
|
|
"↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓邮箱内容↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓"+
|
|
"↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓邮箱内容↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓"+
|
|
"\r\n IP:"+remoteIp+"异常访问系统 \r\n" +
|
|
"\r\n IP:"+remoteIp+"异常访问系统 \r\n" +
|