Browse Source

去掉登录日志备份,去掉消息邮件通知,策略配置去掉系统配置和审计配置,将初始重置密码动态输出改为固定88888888

xusl 9 tháng trước cách đây
mục cha
commit
d171cf8b84

+ 4 - 4
console/src/main/java/com/jiayue/ssi/constant/CacheConstants.java

@@ -83,10 +83,10 @@ public class CacheConstants {
      * 用户名对应明文密码缓存
      */
     public static ConcurrentMap<String, String> usernamePasswordMap = new ConcurrentHashMap<>();
-    /**
-     * 当前服务端访问的IP集合<IP,用户名>
-     */
-    public static ConcurrentMap<String, String> IP_USER_MAP = new ConcurrentHashMap<>();
+//    /**
+//     * 当前服务端访问的IP集合<IP,用户名>
+//     */
+//    public static ConcurrentMap<String, String> IP_USER_MAP = new ConcurrentHashMap<>();
 //    /**
 //     * 用于用户心跳
 //     */

+ 0 - 22
console/src/main/java/com/jiayue/ssi/controller/SysPolicyController.java

@@ -219,28 +219,6 @@ public class SysPolicyController {
             operLog.setAuditType(AuditType.SYS.ordinal());
             // 保存数据库
             OperateLogFactory.recordOper(operLog);
-            SysPolicy sysPolicy = sysPolicyService.getOne(new QueryWrapper<>());
-            String noticeWay = "";
-            if ("0".equals(sysPolicy.getExcLevelLogin())){
-                noticeWay = sysPolicy.getExcNoticeWayA();
-            } else if ("1".equals(sysPolicy.getExcLevelLogin())){
-                noticeWay = sysPolicy.getExcNoticeWayB();
-            }
-
-            // 通知系统管理员
-            if ("0".equals(noticeWay)){
-                log.info("发送邮箱越权访问告警\r\n" +
-                        "↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓邮箱内容↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓"+
-                        "\r\n  账号:"+username+"越权访问"+openUrl+" \r\n"     +
-                        "↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑邮箱内容↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑");
-//                log.info("发送邮箱通知系统管理员后台输出======> "+"账号【"+username+"】越权访问"+openUrl);
-            }
-            else if ("1".equals(noticeWay)){
-                // 告警先不用了,系统里只用一种邮箱告警
-            }
-
-
-
             return ResponseVO.success();
         } catch (Exception e) {
             throw new CustomException("越权访问记录异常", e);

+ 1 - 17
console/src/main/java/com/jiayue/ssi/controller/SysUserController.java

@@ -458,17 +458,8 @@ public class SysUserController {
         if (sysUser == null) {
             return ResponseVO.fail("重置密码失败!");
         }
-
-        SysPolicy sysPolicy = sysPolicyService.getOne(new QueryWrapper<>());
-        // 生成8位初始密码
-        String randomPwd = RandomRulePwd.createPwd(sysPolicy.getPasswordRule(),8);
-        log.info("发送邮箱初始/重置密码\r\n" +
-                "↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓邮箱内容↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓"+
-                "\r\n  账号:"+sysUser.getUsername()+"  初始/重置密码:"+randomPwd+" \r\n"     +
-                "↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑邮箱内容↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑");
-//        log.info("发送邮箱重置密码后台输出======> 用户名:"+sysUser.getUsername()+" 初始/重置密码:"+randomPwd);
         // SM3加密密码
-        String sm3password = SmUtil.sm3(randomPwd).toUpperCase();
+        String sm3password = SmUtil.sm3("88888888").toUpperCase();
         // 再对密码sm2
         String sm2password = SM2CryptUtils.encrypt(sm3password,SecretKeyConstants.SERVER_PUBLIC_KEY);
 
@@ -476,13 +467,6 @@ public class SysUserController {
         if (!bo) {
             return ResponseVO.fail("密码生成失败!");
         }
-        try {
-//            String[] mailArray = {AesUtils.decryptStr(sysUser.getMailbox())};
-//            sendMailUtil.executeSendMail(mailArray, "系统登录密码", "密码:" + randomPwd);
-        } catch (Exception e) {
-//            log.error("用户名:"+sysUser.getUsername()+",邮箱验证码发送失败!",e);
-            return ResponseVO.fail("发送邮箱失败");
-        }
         return ResponseVO.success();
     }
 

+ 1 - 47
console/src/main/java/com/jiayue/ssi/controller/UserLoginController.java

@@ -1,15 +1,10 @@
 package com.jiayue.ssi.controller;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.jiayue.ssi.annotation.OperateLog;
-import com.jiayue.ssi.backenum.AuditType;
-import com.jiayue.ssi.backenum.BusinessType;
+
 import com.jiayue.ssi.config.SendMailUtil;
 import com.jiayue.ssi.constant.CacheConstants;
 import com.jiayue.ssi.constant.CustomException;
 import com.jiayue.ssi.entity.SysMenu;
-import com.jiayue.ssi.entity.SysPolicy;
-import com.jiayue.ssi.entity.SysUser;
 import com.jiayue.ssi.service.SysMenuService;
 import com.jiayue.ssi.service.SysPolicyService;
 import com.jiayue.ssi.service.SysUserService;
@@ -108,47 +103,6 @@ public class UserLoginController {
             throw new CustomException("生成验证码异常", e);
         }
     }
-
-    /**
-     * 获取邮箱口令
-     *
-     * @param httpServletRequest
-     * @param httpServletResponse
-     * @throws IOException
-     */
-    @GetMapping("/getMailCode")
-    public ResponseVO getMailCode(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws CustomException {
-        try {
-            String username = httpServletRequest.getParameter("username");
-            // 暂存1分钟,防止频繁访问
-            LocalCache.set(CacheConstants.PREVENT_MAIL_CODE + username, username, 60000);
-            // 口令保存到服务器
-            String mailKey = CacheConstants.MAIL_CODE_KEY + username;
-            SysUser sysUser = sysUserService.queryUserName(username);
-            if (sysUser != null) {
-                // 生成6位邮箱口令
-                SysPolicy sysPolicy = sysPolicyService.getOne(new QueryWrapper<>());
-                String mailRandom = RandomRulePwd.createPwd(sysPolicy.getPasswordRule(),6);
-                // uuid存入缓存,失效时间4分钟
-                LocalCache.set(mailKey, mailRandom, 60000 * 4);
-                log.info("发送邮箱动态口令\r\n" +
-                  "↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓邮箱内容↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓"+
-                 "\r\n  用户名:"+username+"  动态口令:"+mailRandom+"  \r\n"     +
-                  "↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑邮箱内容↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑");
-                try {
-//                    String[] mailArray = {AesUtils.decryptStr(sysUser.getMailbox())};
-//                    sendMailUtil.executeSendMail(mailArray, "邮箱验证码", "口令:" + mailRandom + ",有效期4分钟。");
-                } catch (Exception e) {
-//                    log.error("用户名:"+username+",邮箱验证码发送失败!",e);
-                    return ResponseVO.fail("邮箱验证码发送失败!");
-                }
-            }
-            return ResponseVO.success();
-        } catch (Exception e) {
-            throw new CustomException("获取邮箱口令异常", e);
-        }
-    }
-
     /**
      * 刷新token
      *

+ 0 - 9
console/src/main/java/com/jiayue/ssi/filter/InterfaceLimitFilter.java

@@ -102,11 +102,6 @@ public class InterfaceLimitFilter extends OncePerRequestFilter {
                     // 保存数据库
                     OperateLogFactory.recordOper(operLog);
 
-                    log.info("发送邮箱IP异常访问\r\n" +
-                            "↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓邮箱内容↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓"+
-                            "\r\n  IP:"+remoteIp+"异常访问系统 \r\n"     +
-                            "↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑邮箱内容↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑");
-//                    log.info("发送邮箱通知系统管理员后台输出======> "+"IP【"+remoteIp+"】异常访问");
                     response.setHeader("Access-Control-Allow-Origin", "*");
                     response.setStatus(410);
                     response.setContentType("text/html;charset=utf-8");
@@ -147,10 +142,6 @@ public class InterfaceLimitFilter extends OncePerRequestFilter {
                 // 保存数据库
                 OperateLogFactory.recordOper(operLog);
 
-                log.info("发送邮箱IP异常访问\r\n" +
-                        "↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓邮箱内容↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓"+
-                        "\r\n  IP:"+remoteIp+"异常访问系统 \r\n"     +
-                        "↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑邮箱内容↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑");
                 response.setHeader("Access-Control-Allow-Origin", "*");
                 response.setStatus(410);
                 response.setContentType("text/html;charset=utf-8");

+ 10 - 18
console/src/main/java/com/jiayue/ssi/filter/JwtAuthenticationTokenFilter.java

@@ -85,7 +85,7 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
                     if (username != null) {
                         if (CacheConstants.LOGIN_TOKEN_MAP.get(username) == null) {
                             String killIp = IPUtils.getIpAddr(request);
-                            CacheConstants.IP_USER_MAP.remove(killIp);
+//                            CacheConstants.IP_USER_MAP.remove(killIp);
                             ResponseInfo.doResponse(response, "令牌无效,请重新登录!", 406);
                             return;
                         } else {
@@ -93,7 +93,7 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
                             //内存token和当前token一致  说明是当前登陆用户访问
                             if (!token.equals(cacheToken)) {
                                 String killIp = IPUtils.getIpAddr(request);
-                                CacheConstants.IP_USER_MAP.remove(killIp);
+//                                CacheConstants.IP_USER_MAP.remove(killIp);
                                 ResponseInfo.doResponse(response, "账号已在另一台机器登录,请重新登录!", 406);
                                 return;
                             }
@@ -212,14 +212,14 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
                         sysUserService.updateUser(sysUser);
                         CacheConstants.LOGIN_TOKEN_MAP.remove(sysUser.getUsername());
                         LoginConstants.sessionMap.remove(sysUser.getUsername());
-                        Iterator<Map.Entry<String, String>> countMap = CacheConstants.IP_USER_MAP.entrySet().iterator();
-                        while (countMap.hasNext()) {
-                            Map.Entry<String, String> entry1 = countMap.next();
-                            String cacheusername = entry1.getValue();
-                            if (cacheusername.equals(sysUser.getUsername())) {
-                                countMap.remove();
-                            }
-                        }
+//                        Iterator<Map.Entry<String, String>> countMap = CacheConstants.IP_USER_MAP.entrySet().iterator();
+//                        while (countMap.hasNext()) {
+//                            Map.Entry<String, String> entry1 = countMap.next();
+//                            String cacheusername = entry1.getValue();
+//                            if (cacheusername.equals(sysUser.getUsername())) {
+//                                countMap.remove();
+//                            }
+//                        }
                         LocalCache.remove(CacheConstants.REACTIVE_KEY + token);
                         // 超出配置设定值则退出
                         ResponseInfo.doResponse(response, "超出非活动时长退出!", 406);
@@ -230,14 +230,6 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
                 }
             } else {
                 if ("POST".equalsIgnoreCase(request.getMethod()) && defaultFilterProcessUrl.equals(request.getServletPath())) {
-                    String currentIp = IPUtils.getIpAddr();
-                    String ip = CacheConstants.IP_USER_MAP.get(currentIp);
-                    if (ip != null && !"".equals(ip)) {
-                        // 判断当前访问的ip是否已经存在,如果存在则不让任何用户访问
-                        ResponseInfo.doResponse(response, "您的客户端用户正在使用,请等待一小会登录系统!", 405);
-                        return;
-                    }
-
                     // 判断并发会话数是否满足
                     SysPolicy sysPolicy = sysPolicyService.getOne(new QueryWrapper<>());
                     if (LoginConstants.sessionMap.size() + 1 > sysPolicy.getBfhhs()) {

+ 0 - 10
console/src/main/java/com/jiayue/ssi/filter/VerifySmFilter.java

@@ -40,16 +40,6 @@ public class VerifySmFilter extends OncePerRequestFilter {
     @Override
     protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) {
         try {
-            if (request.getRequestURI().equals(defaultFilterProcessUrl)){
-                String currentIp = IPUtils.getIpAddr();
-                String ip = CacheConstants.IP_USER_MAP.get(currentIp);
-                if (ip!=null && !"".equals(ip)){
-                    // 判断当前访问的ip是否已经存在,如果存在则不让任何用户访问
-                    ResponseInfo.doResponse(response, "您的客户端用户正在使用,请等待一小会登录系统!", 405);
-                    return;
-                }
-            }
-
             Map<String, Object> stringToMap = new HashMap(16);
             ParameterRequestWrapper initWrapper = new ParameterRequestWrapper(request);
             // 不是登录操作

+ 0 - 36
console/src/main/java/com/jiayue/ssi/handler/CustomAuthenticationFailureHandler.java

@@ -95,42 +95,6 @@ public class CustomAuthenticationFailureHandler extends SimpleUrlAuthenticationF
                     user.setStatus("1");
                     user.setLockTime(System.currentTimeMillis());
                     sysUserService.updateUser(user);
-                    String noticeWay = "";
-                    if ("0".equals(sysPolicy.getExcLevelLogin())){
-                        noticeWay = sysPolicy.getExcNoticeWayA();
-                    } else if ("1".equals(sysPolicy.getExcLevelLogin())){
-                        noticeWay = sysPolicy.getExcNoticeWayB();
-                    }
-
-                    // 通知系统管理员
-                    if ("0".equals(noticeWay)){
-                        log.info("发送邮箱连续登录失败\r\n" +
-                                "↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓邮箱内容↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓"+
-                                "\r\n  账号:"+user.getUsername()+"  连续登录失败:"+errCount+"次,锁定账号! \r\n"     +
-                                "↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑邮箱内容↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑");
-//                        log.info("发送邮箱通知系统管理员后台输出======> "+"账号【"+user.getUsername()+"】登录失败"+errCount+"次,锁定账号!");
-//                        List<SysUser> sysUserList = sysUserService.selectUserByRole("1");
-//                        if (sysUserList.size()>0){
-//                            String[] mailArray = new String[sysUserList.size()];
-//                            for (int i=0;i<sysUserList.size();i++){
-//                                mailArray[i] = AesUtils.decryptStr(sysUserList.get(i).getMailbox());
-//                            }
-//                            try {
-//                                // 发送邮件
-//                                sendMailUtil.executeSendMail(mailArray,"账号【"+user.getUsername()+"】登录失败","账号【"+user.getUsername()+"】登录失败"+errCount+"次,锁定账号!");
-//                            } catch (Exception ex) {
-//                                System.out.println("邮箱验证码发送失败!");
-//                            }
-//                        }
-                    }
-                    else if ("1".equals(noticeWay)){
-                        // 告警
-                        SysAlarm sysAlarm = new SysAlarm();
-                        sysAlarm.setAlarmContent("账号【"+user.getUsername()+"】登录失败"+errCount+"次,锁定账号!");
-                        sysAlarm.setReadSign("0");
-                        // 低于策略设定值则告警
-                        sysAlarmService.save(sysAlarm);
-                    }
                 }
             }
         }

+ 0 - 79
console/src/main/java/com/jiayue/ssi/handler/CustomAuthenticationSuccessHandler.java

@@ -97,88 +97,9 @@ public class CustomAuthenticationSuccessHandler extends SavedRequestAwareAuthent
         userVisitInfoDto.setOs(os);
         LoginConstants.sessionMap.put(username,userVisitInfoDto);
 
-        // 将token存储内存中,便于重复登录比对
-        if (CacheConstants.LOGIN_TOKEN_MAP.get(username)!=null){
-            // 将之前用户登录过的ip删除掉
-            Iterator<Map.Entry<String, String>> countMap = CacheConstants.IP_USER_MAP.entrySet().iterator();
-            String kickedIp = "";
-            while (countMap.hasNext()) {
-                Map.Entry<String, String> entry = countMap.next();
-                String cacheusername = entry.getValue();
-                if (cacheusername.equals(username)){
-                    kickedIp = entry.getKey();
-                    countMap.remove();
-                }
-            }
-            // 之前有用户登录过,本次将上次用户踢出下线。并通知管理员
-            String noticeWay = "";
-            SysPolicy sysPolicy = sysPolicyService.getOne(new QueryWrapper<>());
-            if ("0".equals(sysPolicy.getExcLevelSameUser())){
-                noticeWay = sysPolicy.getExcNoticeWayA();
-            } else if ("1".equals(sysPolicy.getExcLevelSameUser())){
-                noticeWay = sysPolicy.getExcNoticeWayB();
-            }
-
-            // 通知系统管理员
-            if ("0".equals(noticeWay)){
-                log.info("发送邮箱多点登录\r\n" +
-                        "↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓邮箱内容↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓"+
-                        "\r\n  账号:"+sysUser.getUsername()+"多点登录,本次登录时间:"+DateUtils.getTime()+",登录IP:"+IPUtils.getIpAddr(request)+" \r\n"     +
-                        "↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑邮箱内容↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑");
-//                log.info("发送邮箱通知系统管理员后台输出======> "+"账号【"+sysUser.getUsername()+"】多点登录","本次登录时间:"+DateUtils.getTime()+",登录IP:"+IPUtils.getIpAddr(request));
-//                List<SysUser> sysUserList = sysUserService.selectUserByRole("1");
-//                if (sysUserList.size()>0){
-////                    String[] mailArray = new String[sysUserList.size()];
-//                    for (int i=0;i<sysUserList.size();i++){
-//
-//                        // 邮箱解密
-////                        mailArray[i] = AesUtils.decryptStr(sysUserList.get(i).getMailbox());
-//                    }
-//                    try {
-//                        // 发送邮件
-////                        sendMailUtil.executeSendMail(mailArray,"账号【"+sysUser.getUsername()+"】多点登录","本次登录时间:"+DateUtils.getTime()+",登录IP:"+IPUtils.getIpAddr(request));
-//
-//                    } catch (Exception ex) {
-//                        System.out.println("邮箱验证码发送失败!");
-//                    }
-//                }
-            }
-            else if ("1".equals(noticeWay)){
-                log.info("发送邮箱多点登录\r\n" +
-                        "↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓邮箱内容↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓"+
-                        "\r\n  账号:"+sysUser.getUsername()+"多点登录,本次登录时间:"+DateUtils.getTime()+",登录IP:"+IPUtils.getIpAddr(request)+" \r\n"     +
-                        "↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑邮箱内容↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑");
-//                log.info("发送邮箱通知系统管理员后台输出======> "+"账号【"+sysUser.getUsername()+"】多点登录","本次登录时间:"+DateUtils.getTime()+",登录IP:"+IPUtils.getIpAddr(request));
-            }
-
-            // 封装被下线的对象退出信息
-            SysLogininfor logininfor = new SysLogininfor();
-            logininfor.setUserName(sysUser.getUsername());
-            logininfor.setIpaddr(kickedIp);
-            String address = AddressUtils.getRealAddressByIP(kickedIp);
-            logininfor.setLoginLocation(address);
-            HttpServletRequest kickedRequest = CacheConstants.KICKED_USER_MAP.get(sysUser.getUsername());
-            // 获取被踢用户的request
-            final UserAgent kickedUserAgent = UserAgent.parseUserAgentString(kickedRequest.getHeader("User-Agent"));
-            logininfor.setBrowser(kickedUserAgent.getBrowser().getName());
-            logininfor.setOs(kickedUserAgent.getOperatingSystem().getName());
-            logininfor.setMsg("退出成功");
-            logininfor.setLoginTime(new Date());
-            logininfor.setCreateBy(sysUser.getUsername());
-            // 日志状态
-            logininfor.setStatus(Constants.SUCCESS);
-            // 插入数据
-            SpringUtils.getBean(SysLogininforService.class).insertLogininfor(logininfor);
-
-//            System.out.println(CacheConstants.SESSIONID_USER_MAP.toString());
-//            System.out.println("被踢用户的sessionid:"+kickedRequest.getSession().getId());
-//            CacheConstants.SESSIONID_USER_MAP.put(kickedRequest.getSession().getId(),sysUser.getUsername());
-        }
         CacheConstants.LOGIN_TOKEN_MAP.put(username,token);
         // 登录成功后将用户本次操作时间存入缓存,为了判断非活动退出时应用,60分钟自动失效
         LocalCache.set(CacheConstants.REACTIVE_KEY + token,vtime,1000*60*60);
-        // 将登录成功的用户ip加入缓存中
-        CacheConstants.IP_USER_MAP.put(ip,username);
         ActiveUserDto activeUserDto = new ActiveUserDto();
         activeUserDto.setSysUser(sysUser);
         activeUserDto.setHttpServletRequest(request);

+ 0 - 34
console/src/main/java/com/jiayue/ssi/handler/RestAccessDeniedHandler.java

@@ -72,40 +72,6 @@ public class RestAccessDeniedHandler implements AccessDeniedHandler {
         operLog.setAuditType(AuditType.SYS.ordinal());
         // 保存数据库
         OperateLogFactory.recordOper(operLog);
-        SysPolicy sysPolicy = sysPolicyService.getOne(new QueryWrapper<>());
-        String noticeWay = "";
-        if ("0".equals(sysPolicy.getExcLevelLogin())){
-            noticeWay = sysPolicy.getExcNoticeWayA();
-        } else if ("1".equals(sysPolicy.getExcLevelLogin())){
-            noticeWay = sysPolicy.getExcNoticeWayB();
-        }
-
-        // 通知系统管理员
-        if ("0".equals(noticeWay)){
-            log.info("发送邮箱越权访问\r\n" +
-                    "↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓邮箱内容↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓"+
-                    "\r\n  账号:"+username+"  越权访问:"+ org.apache.commons.lang3.StringUtils.substring(ServletUtils.getRequest().getRequestURI(), 0, 255)+" \r\n"     +
-                    "↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑邮箱内容↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑");
-//            log.info("发送邮箱通知系统管理员后台输出======> "+"账号【"+username+"】越权访问"+org.apache.commons.lang3.StringUtils.substring(ServletUtils.getRequest().getRequestURI(), 0, 255));
-//                        List<SysUser> sysUserList = sysUserService.selectUserByRole("1");
-//                        if (sysUserList.size()>0){
-//                            String[] mailArray = new String[sysUserList.size()];
-//                            for (int i=0;i<sysUserList.size();i++){
-//                                mailArray[i] = AesUtils.decryptStr(sysUserList.get(i).getMailbox());
-//                            }
-//                            try {
-//                                // 发送邮件
-//                                sendMailUtil.executeSendMail(mailArray,"账号【"+user.getUsername()+"】登录失败","账号【"+user.getUsername()+"】登录失败"+errCount+"次,锁定账号!");
-//                            } catch (Exception ex) {
-//                                System.out.println("邮箱验证码发送失败!");
-//                            }
-//                        }
-        }
-        else if ("1".equals(noticeWay)){
-            // 告警先不用了,系统里只用一种邮箱告警
-        }
-
-
 
         response.setHeader("Access-Control-Allow-Origin", "*");
         response.setStatus(402);

+ 0 - 117
console/src/main/java/com/jiayue/ssi/job/AuditBakPathCapCheck.java

@@ -1,117 +0,0 @@
-package com.jiayue.ssi.job;
-
-import cn.hutool.core.convert.Convert;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.jiayue.ssi.entity.SysPolicy;
-import com.jiayue.ssi.service.SysPolicyService;
-import com.jiayue.ssi.util.FileUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.io.FileUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Service;
-
-import java.io.File;
-import java.math.BigDecimal;
-import java.text.DecimalFormat;
-/**
-* 自动备份审计日志
-*
-* @author xsl
-* @since 2023/04/06
-*/
-@Service
-@EnableScheduling
-@Slf4j
-public class AuditBakPathCapCheck {
-    @Autowired
-    SysPolicyService sysPolicyService;
-
-    /**
-     * 每5分钟执行执行一次
-     */
-    @Scheduled(cron = "5 0/5 * * * ?")
-    public void auditCheck() throws Exception {
-
-        DecimalFormat df = new DecimalFormat("#.00");//设置保留两位小数
-        SysPolicy sysPolicy = sysPolicyService.getOne(new QueryWrapper<>());
-        float logSpaceWarnCap = sysPolicy.getAuditLogBakCapAlarm() *  Convert.toFloat(txfloat(sysPolicy.getLogSpaceWarn(),100));
-//        log.debug("日志容量阈值:{} GB参数设置:磁盘上限:{} GB,预警阈值百分比:{}%",df.format(logSpaceWarnCap),sysPolicy.getAuditLogBakCapAlarm(),sysPolicy.getLogSpaceWarn());
-        long size = FileUtils.sizeOfDirectory(new File(FileUtil.getAuditBackUpPath()));
-//        log.debug("审查日志备份路径大小:{} ,转换后大小:{} GB",size,getSizeToGb(size));
-
-        if(Convert.toFloat((Convert.toFloat(sysPolicy.getAuditLogBakCapAlarm(),0f) - Convert.toFloat(getSizeToGb(size),0f)))< logSpaceWarnCap){
-            log.info("发送邮箱日志存储告警\r\n" +
-                    "↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓邮箱内容↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓"+
-                    "\r\n  审计日志存储剩余容量低于额定容量"+sysPolicy.getLogSpaceWarn()+"%,邮箱告警! \r\n"     +
-                    "↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑邮箱内容↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑");
-//            log.info("发送邮箱通知系统管理员后台输出======> 审计日志存储剩余容量低于额定容量"+sysPolicy.getLogSpaceWarn()+"%,邮箱告警!");
-        }else{
-//            log.info("检测审计日志备份目录大小正常。");
-        }
-    }
-
-    /**
-     * 传入一个字符串类型的数字大小,实现文件大小的转化,如 B - KB - MB - GB
-     * @param
-     * @return
-     */
-    public static String getSizeToGb(long i){
-        String result = "";
-        long kb = 1024;
-        long mb = kb * 1024;
-        long gb = mb * 1024;
-
-        /*实现保留小数点两位*/
-        DecimalFormat df = new DecimalFormat("#.00");
-
-        result =  df.format((float) i / gb) + "GB";
-
-        return result;
-    }
-    /**
-     *  除法运算,保留小数
-     * @param a 被除数
-     * @param b 除数
-     * @return 商
-     */
-    public static String txfloat(int a,int b) {
-        // TODO 自动生成的方法存根
-
-        DecimalFormat df=new DecimalFormat("0.00");//设置保留位数
-
-        return df.format((float)a/b);
-
-    }
-    /**
-     * 传入一个字符串类型的数字大小,实现文件大小的转化,如 B - KB - MB - GB
-     * @param
-     * @return
-     */
-    public static String getSize(long i){
-        String result = "";
-        long kb = 1024;
-        long mb = kb * 1024;
-        long gb = mb * 1024;
-
-        /*实现保留小数点两位*/
-        DecimalFormat df = new DecimalFormat("#.00");
-
-        if (i >= gb){
-            result =  df.format((float) i / gb) + "GB";
-        }else if(i >= mb){
-            result =  df.format((float) i / mb) + "MB";
-        }else if(i >= kb){
-            result = String.format("%.2f", (float) i / kb) + "KB";
-        }else {
-            result =  i + "B";
-        }
-        return result;
-    }
-
-
-
-
-
-}

+ 0 - 288
console/src/main/java/com/jiayue/ssi/job/AutoAuditBak.java

@@ -1,288 +0,0 @@
-package com.jiayue.ssi.job;
-
-import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.text.csv.CsvUtil;
-import cn.hutool.core.text.csv.CsvWriter;
-import cn.hutool.core.util.CharsetUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.jiayue.ssi.constant.SecretKeyConstants;
-import com.jiayue.ssi.entity.*;
-import com.jiayue.ssi.entity.server.Jvm;
-import com.jiayue.ssi.service.SysAlarmService;
-import com.jiayue.ssi.service.SysLogininforService;
-import com.jiayue.ssi.service.SysOperLogService;
-import com.jiayue.ssi.service.SysPolicyService;
-import com.jiayue.ssi.util.DateUtils;
-import com.jiayue.ssi.util.FileUtil;
-import com.jiayue.ssi.util.ResponseVO;
-import com.jiayue.ssi.util.SM2CryptUtils;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Service;
-
-import java.io.File;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
-* 自动备份审计日志
-*
-* @author xsl
-* @since 2023/04/06
-*/
-@Service
-@EnableScheduling
-@Slf4j
-public class AutoAuditBak {
-    @Autowired
-    SysLogininforService sysLogininforService;
-    @Autowired
-    SysPolicyService sysPolicyService;
-    @Autowired
-    SysOperLogService sysOperLogService;
-
-
-    /**
-     * 每天凌晨1点执行
-     */
-    @Scheduled(cron = "15 0/5 * * * ?")
-    public void auditBak() throws Exception{
-
-
-        try {
-            // 登录日志备份
-            createSysLogininforCsvFile();
-        }
-        catch (Exception e){
-            log.error("登录日志备份出错",e);
-        }
-        try {
-            // 操作日志备份
-            createSysOperCsvFile();
-        }
-        catch (Exception e){
-            log.error("操作日志备份出错",e);
-        }
-    }
-
-
-    public Calendar getYesterday(){
-        Calendar calendar = Calendar.getInstance(); //创建Calendar 的实例
-        //前一天开始的时间
-        calendar.setTime(DateUtil.parse(DateUtil.format(DateUtil.yesterday(),"yyyy-MM-dd 00:00:00")));
-        return calendar;
-    }
-    /**
-     * 生成登录日志csv文件
-     *
-     */
-    public void createSysLogininforCsvFile() throws Exception{
-        Calendar calendar = getYesterday();
-        QueryWrapper<SysLogininfor> sysLogininforQueryWrapper = new QueryWrapper<>();
-        sysLogininforQueryWrapper.ge("create_time", calendar.getTime());
-        // 备份文件名
-        String fileName = DateUtil.format(calendar.getTime(),"yyyy-MM-dd") + "-" + "SysLogininfor" + ".csv";
-        calendar.add(Calendar.DAY_OF_MONTH,1);
-        sysLogininforQueryWrapper.lt("create_time",calendar.getTime() );
-        List<SysLogininfor> sysLogininforList = sysLogininforService.list(sysLogininforQueryWrapper);
-        // 生成csv备份
-        if (sysLogininforList.size()>0){
-
-            //第一行
-            String[] listName = new String[15];
-            listName[0] = "infoId";
-            listName[1] = "userName";
-            listName[2] = "status";
-            listName[3] = "ipaddr";
-            listName[4] = "loginLocation";
-            listName[5] = "browser";
-            listName[6] = "os";
-            listName[7] = "msg";
-            listName[8] = "loginTime";
-            listName[9] = "delFlag";
-            listName[10] = "createBy";
-            listName[11] = "createTime";
-            listName[12] = "updateBy";
-            listName[13] = "updateTime";
-            listName[14] = "remark";
-            //获取String[]类型的数据至result中
-            List<String> result = new ArrayList<>();
-            String listNameStr = "";
-            for (int i=0;i<listName.length;i++){
-                listNameStr = listNameStr + listName[i]+"|";
-            }
-//            String headEncrypt = SM2CryptUtils.encrypt(listNameStr.substring(0,listNameStr.length()-1), SecretKeyConstants.SERVER_PUBLIC_KEY);
-//            System.out.println("加密:"+headEncrypt);
-//            String headText = SM2CryptUtils.decrypt(headEncrypt,SecretKeyConstants.CLIENT_PRIVATE_KEY);
-//            System.out.println("解密:"+headText);
-            //将listName添加到result中
-            result.add(listNameStr.substring(0,listNameStr.length()-1));
-            Long delIds[] = new Long[sysLogininforList.size()];
-            for (int j=0;j<sysLogininforList.size();j++) {
-                SysLogininfor sysLogininfor = sysLogininforList.get(j);
-                String[] listValue = new String[15];
-                listValue[0] = String.valueOf(sysLogininfor.getInfoId());
-                delIds[j] = sysLogininfor.getInfoId();
-                listValue[1] = String.valueOf(sysLogininfor.getUserName());
-                listValue[2] = String.valueOf(sysLogininfor.getStatus());
-                listValue[3] = String.valueOf(sysLogininfor.getIpaddr());
-                listValue[4] = String.valueOf(sysLogininfor.getLoginLocation());
-                listValue[5] = String.valueOf(sysLogininfor.getBrowser());
-                listValue[6] = String.valueOf(sysLogininfor.getOs());
-                listValue[7] = String.valueOf(sysLogininfor.getMsg());
-                listValue[8] = String.valueOf(DateUtil.format(sysLogininfor.getLoginTime(),"yyyy-MM-dd HH:mm:ss"));
-                listValue[9] = String.valueOf(sysLogininfor.getDelFlag());
-                listValue[10] = String.valueOf(sysLogininfor.getCreateBy());
-                listValue[11] = String.valueOf(DateUtil.format(sysLogininfor.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
-                listValue[12] = String.valueOf(sysLogininfor.getUpdateBy());
-                listValue[13] = String.valueOf(DateUtil.format(sysLogininfor.getUpdateTime(),"yyyy-MM-dd HH:mm:ss"));
-                listValue[14] = String.valueOf(sysLogininfor.getRemark());
-
-                String listValueStr = "";
-                for (int k=0;k<listValue.length;k++){
-                    listValueStr = listValueStr + listValue[k]+"|";
-                }
-//                String encrypt = SM2CryptUtils.encrypt(listValueStr.substring(0,listValueStr.length()-1), SecretKeyConstants.SERVER_PUBLIC_KEY);
-//                System.out.println("加密:"+encrypt);
-//                String text = SM2CryptUtils.decrypt(encrypt,SecretKeyConstants.CLIENT_PRIVATE_KEY);
-//                System.out.println("解密:"+text);
-                result.add(listValueStr.substring(0,listValueStr.length()-1));
-            }
-            //导入HuTool中CSV工具包的CsvWriter类
-            //设置导出字符类型, CHARSET_UTF_8
-            File csvFile = new File(fileName);
-            File destDir = new File(FileUtil.getAuditBackUpPath()+ File.separator +DateUtils.dateTime());
-            if (!destDir.exists()) {// 如果目录不存在则创建目录
-                boolean b = destDir.mkdirs();
-                if (!b) {
-                    throw new RuntimeException(destDir.getPath() + " 目录创建失败");
-                }
-            }
-            CsvWriter writer = CsvUtil.getWriter(destDir + File.separator + csvFile.getName(), CharsetUtil.CHARSET_UTF_8);
-            writer.write(result);  //通过CsvWriter中的write方法写入数据
-            writer.close();   //关闭CsvWriter
-        }
-        log.info("执行登录日志备份:{}",calendar.getTime());
-    }
-
-    /**
-     * 生成操作日志csv文件
-     *
-     */
-    public void createSysOperCsvFile() throws Exception{
-        Calendar calendar = getYesterday();
-        QueryWrapper<SysOperLog> sysOperLogQueryWrapper = new QueryWrapper<>();
-        sysOperLogQueryWrapper.ge("create_time", calendar.getTime());
-        // 备份文件名
-        String fileName = DateUtil.format(calendar.getTime(),"yyyy-MM-dd") + "-" + "SysOperLog" + ".csv";
-        calendar.add(Calendar.DAY_OF_MONTH,1);
-        sysOperLogQueryWrapper.lt("create_time",calendar.getTime() );
-        List<SysOperLog> sysOperLogList = sysOperLogService.list(sysOperLogQueryWrapper);
-        // 生成csv备份
-        if (sysOperLogList.size()>0){
-
-            //第一行
-            String[] listName = new String[25];
-            listName[0] = "operId";
-            listName[1] = "title";
-            listName[2] = "businessType";
-            listName[3] = "auditType";
-            listName[4] = "businessTypes";
-            listName[5] = "method";
-            listName[6] = "requestMethod";
-            listName[7] = "operatorType";
-            listName[8] = "operName";
-            listName[9] = "deptName";
-            listName[10] = "operUrl";
-            listName[11] = "operIp";
-            listName[12] = "operLocation";
-            listName[13] = "operParam";
-//            listName[14] = "jsonResult";
-            listName[14] = "status";
-            listName[15] = "errorMsg";
-            listName[16] = "operTime";
-            listName[17] = "costTime";
-            listName[18] = "delFlag";
-            listName[19] = "createBy";
-            listName[20] = "createTime";
-            listName[21] = "updateBy";
-            listName[22] = "updateTime";
-            listName[23] = "remark";
-            //获取String[]类型的数据至result中
-            List<String> result = new ArrayList<>();
-            String listNameStr = "";
-            for (int i=0;i<listName.length;i++){
-                listNameStr = listNameStr + listName[i]+"|";
-            }
-//            String headEncrypt = SM2CryptUtils.encrypt(listNameStr.substring(0,listNameStr.length()-1), SecretKeyConstants.CLIENT_PUBLIC_KEY);
-//            System.out.println("加密:"+headEncrypt);
-//            String headText = SM2CryptUtils.decrypt(headEncrypt,SecretKeyConstants.CLIENT_PRIVATE_KEY);
-//            System.out.println("解密:"+headText);
-            //将listName添加到result中
-            result.add(listNameStr.substring(0,listNameStr.length()-1));
-            Long delIds[] = new Long[sysOperLogList.size()];
-            for (int j=0;j<sysOperLogList.size();j++) {
-                SysOperLog sysOperLog = sysOperLogList.get(j);
-                String[] listValue = new String[25];
-                listValue[0] = String.valueOf(sysOperLog.getOperId());
-                delIds[j] = sysOperLog.getOperId();
-                listValue[1] = String.valueOf(sysOperLog.getTitle());
-                listValue[2] = String.valueOf(sysOperLog.getBusinessType());
-                listValue[3] = String.valueOf(sysOperLog.getAuditType());
-                listValue[4] = String.valueOf(sysOperLog.getBusinessTypes());
-                listValue[5] = String.valueOf(sysOperLog.getMethod());
-                listValue[6] = String.valueOf(sysOperLog.getRequestMethod());
-                listValue[7] = String.valueOf(sysOperLog.getOperatorType());
-                listValue[8] = String.valueOf(sysOperLog.getOperName());
-                listValue[9] = String.valueOf(sysOperLog.getDeptName());
-                listValue[10] = String.valueOf(sysOperLog.getOperUrl());
-                listValue[11] = String.valueOf(sysOperLog.getOperIp());
-                listValue[12] = String.valueOf(sysOperLog.getOperLocation());
-                listValue[13] = String.valueOf(sysOperLog.getOperParam());
-//                listValue[14] = String.valueOf(sysOperLog.getJsonResult());
-                listValue[14] = String.valueOf(sysOperLog.getStatus());
-                listValue[15] = String.valueOf(sysOperLog.getErrorMsg());
-                listValue[16] = String.valueOf(DateUtil.format(sysOperLog.getOperTime(),"yyyy-MM-dd HH:mm:ss"));
-                listValue[17] = String.valueOf(sysOperLog.getCostTime());
-                listValue[18] = String.valueOf(sysOperLog.getDelFlag());
-                listValue[19] = String.valueOf(sysOperLog.getCreateBy());
-                listValue[20] = String.valueOf(DateUtil.format(sysOperLog.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
-                listValue[21] = String.valueOf(sysOperLog.getUpdateBy());
-                listValue[22] = String.valueOf(DateUtil.format(sysOperLog.getUpdateTime(),"yyyy-MM-dd HH:mm:ss"));
-                listValue[23] = String.valueOf(sysOperLog.getRemark());
-
-                String listValueStr = "";
-                for (int k=0;k<listValue.length;k++){
-                    listValueStr = listValueStr + listValue[k]+"|";
-                }
-//                String encrypt = SM2CryptUtils.encrypt(listValueStr.substring(0,listValueStr.length()-1), SecretKeyConstants.CLIENT_PUBLIC_KEY);
-//                System.out.println("加密:"+encrypt);
-//                String text = SM2CryptUtils.decrypt(encrypt,SecretKeyConstants.CLIENT_PRIVATE_KEY);
-//                System.out.println("解密:"+text);
-                result.add(listValueStr.substring(0,listValueStr.length()-1));
-            }
-            //导入HuTool中CSV工具包的CsvWriter类
-            //设置导出字符类型, CHARSET_UTF_8
-            File csvFile = new File(fileName);
-            File destDir = new File(FileUtil.getAuditBackUpPath()+ File.separator +DateUtils.dateTime());
-            if (!destDir.exists()) {// 如果目录不存在则创建目录
-                boolean b = destDir.mkdirs();
-                if (!b) {
-                    throw new RuntimeException(destDir.getPath() + " 目录创建失败");
-                }
-            }
-            CsvWriter writer = CsvUtil.getWriter(destDir + File.separator + csvFile.getName(), CharsetUtil.CHARSET_UTF_8);
-            writer.write(result);  //通过CsvWriter中的write方法写入数据
-            writer.close();   //关闭CsvWriter
-        }
-        log.info("执行操作日志备份:{}",calendar.getTime());
-    }
-}

+ 0 - 57
console/src/main/java/com/jiayue/ssi/job/AutoCheckSessionMap.java

@@ -1,57 +0,0 @@
-package com.jiayue.ssi.job;
-
-
-import com.jiayue.ssi.service.SysPolicyService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Service;
-
-/**
-* 自动检测并发会话数是否存在超时
-*
-* @author xsl
-* @since 2023/06/28
-*/
-//@Service
-//@EnableScheduling
-//@Slf4j
-public class AutoCheckSessionMap {
-//    @Autowired
-//    SysPolicyService sysPolicyService;
-
-    /**
-     * 每分钟执行
-     */
-//    @Scheduled(cron = "0 0/1 * * * ?")
-    public void auditBak() throws Exception{
-//        SysPolicy sysPolicy = sysPolicyService.getOne(new QueryWrapper<>());
-//        // 非活动登出时间(分钟)
-//        int inactiveLogout = sysPolicy.getInactiveLogout();
-//
-//        long iil = inactiveLogout * 1000 * 60;
-//
-//        Iterator<Map.Entry<String, UserVisitInfoDto>> entries = LoginConstants.sessionMap.entrySet().iterator();
-//        while (entries.hasNext()) {
-//            Map.Entry<String, UserVisitInfoDto> entry = entries.next();
-//            // 判断会话连接里失效的用户
-//            UserVisitInfoDto userVisitInfoDto = entry.getValue();
-//            Long userTime = userVisitInfoDto.getVtime();
-//            if (System.currentTimeMillis()> userTime + iil){
-//                // 踢用户
-//                LoginConstants.sessionMap.remove(entry.getKey());
-//                Iterator<Map.Entry<String, String>> countMap = CacheConstants.IP_USER_MAP.entrySet().iterator();
-//                while (countMap.hasNext()) {
-//                    Map.Entry<String, String> entry1 = countMap.next();
-//                    String cacheusername = entry1.getValue();
-//                    if (cacheusername.equals(userVisitInfoDto.getUsername())){
-//                        countMap.remove();
-//                    }
-//                }
-//                // 记录用户退出日志
-//                LoginFactory.autoRecordLogininfor(userVisitInfoDto, Constants.LOGIN_SUCCESS, "超时登出");
-//            }
-//        }
-    }
-}

+ 0 - 82
console/src/main/java/com/jiayue/ssi/job/AutoScanMemory.java

@@ -1,82 +0,0 @@
-package com.jiayue.ssi.job;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.jiayue.ssi.entity.SysAlarm;
-import com.jiayue.ssi.entity.SysPolicy;
-import com.jiayue.ssi.entity.server.Jvm;
-import com.jiayue.ssi.service.SysAlarmService;
-import com.jiayue.ssi.service.SysPolicyService;
-import com.jiayue.ssi.util.FileUtil;
-import com.jiayue.ssi.util.ServletUtils;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Service;
-
-import java.io.File;
-
-/**
-* 检测内存告警
-*
-* @author xsl
-* @since 2023/04/06
-*/
-@Service
-@EnableScheduling
-@Slf4j
-public class AutoScanMemory {
-    @Autowired
-    SysPolicyService sysPolicyService;
-    @Autowired
-    SysAlarmService sysAlarmService;
-
-    /**
-     * 每30分钟执行一次扫描
-     */
-    @Scheduled(cron = "9 0/5 * * * ?")
-    public void scanMemory() throws Exception{
-        SysPolicy sysPolicy = sysPolicyService.getOne(new QueryWrapper<>());
-        try {
-            int memoryWarn = sysPolicy.getMemoryWarn();
-            Jvm jvm = new Jvm();
-            jvm.setTotal(Runtime.getRuntime().totalMemory());
-            jvm.setMax(Runtime.getRuntime().maxMemory());
-            jvm.setFree(Runtime.getRuntime().freeMemory());
-            if ((100 - jvm.getUsage()) < memoryWarn) {
-//                SysAlarm sysAlarm = new SysAlarm();
-//                sysAlarm.setAlarmContent("当前JVM使用率:" + jvm.getUsage() + "%,低于阈值" + memoryWarn + "%");
-//                sysAlarm.setReadSign("0");
-//                // 低于策略设定值则告警
-//                sysAlarmService.save(sysAlarm);
-                log.info("发送邮箱内存过低告警\r\n" +
-                        "↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓邮箱内容↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓"+
-                        "\r\n  系统剩余内存低于总内存"+memoryWarn+"%,邮箱告警! \r\n"     +
-                        "↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑邮箱内容↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑");
-//                log.info("发送邮箱通知系统管理员后台输出======> "+"系统剩余内存低于总内存"+memoryWarn + "%,邮箱告警!");
-            }
-        }
-        catch (Exception e){
-            log.error("检测内存阈值出错",e);
-        }
-//        try {
-//            // 检测日志存储低于阈值告警
-//            File file = new File(FileUtil.getLogsPath());
-//            // 最低阈值数值
-//            double percentValue = Double.parseDouble(sysPolicy.getLogSpaceWarn().toString()) / (double) 100;
-//            double lowValue = (file.getTotalSpace() / 1024 / 1024 / 1024) * percentValue;
-//            // 可用剩余空间
-//            double ableSpaceValue = Double.parseDouble((file.getUsableSpace() / 1024 / 1024 / 1024) + "");
-//            if (ableSpaceValue < lowValue) {
-//                SysAlarm sysAlarm = new SysAlarm();
-//                sysAlarm.setAlarmContent("当前剩余空间:" + ableSpaceValue + "G,低于阈值" + sysPolicy.getLogSpaceWarn() + "%");
-//                sysAlarm.setReadSign("0");
-//                // 低于策略设定值则告警
-//                sysAlarmService.save(sysAlarm);
-//            }
-//        }
-//        catch (Exception e){
-//            log.error("检测日志空间阈值出错",e);
-//        }
-    }
-}

+ 89 - 92
ui/src/views/sysManager/sysPolicy/index.vue

@@ -29,101 +29,98 @@
           <span style="font-weight: bold;color: #606266;">  月数内未使用锁定。</span>
         </el-form-item>
       </fieldset>
-      <fieldset>
-        <legend>审计策略配置</legend>
-<!--        <el-form-item label="审计日志保留月数" prop="auditLog">-->
-<!--          <el-input v-model="form.auditLog" style="width: 240px"></el-input>-->
+<!--      <fieldset>-->
+<!--        <legend>审计策略配置</legend>-->
+<!--        <el-form-item label="审计策略配置" prop="auditableEvent">-->
+<!--          <el-checkbox-group v-model="form.auditableEvent">-->
+<!--            <el-checkbox v-for="(item,index) in auditableEventList" :key="index" :label="item.value">{{ item.label }}-->
+<!--            </el-checkbox>-->
+<!--          </el-checkbox-group>-->
 <!--        </el-form-item>-->
-        <el-form-item label="审计策略配置" prop="auditableEvent">
-          <el-checkbox-group v-model="form.auditableEvent">
-            <el-checkbox v-for="(item,index) in auditableEventList" :key="index" :label="item.value">{{ item.label }}
-            </el-checkbox>
-          </el-checkbox-group>
-        </el-form-item>
-        <el-form-item label="审计日志存储额定容量上限(GB)" prop="auditLogBakCapAlarm" type="number">
-          <el-input v-model="form.auditLogBakCapAlarm" style="width: 240px"></el-input>
-        </el-form-item>
-        <el-form-item label="审计日志存储剩余容量低于额定容量" prop="logSpaceWarn">
-          <el-input v-model="form.logSpaceWarn" style="width: 60px"></el-input>
-          <span style="font-weight: bold;color: #606266;">  (%)时,邮箱告警。</span>
-        </el-form-item>
-      </fieldset>
-      <fieldset>
-        <legend>系统策略配置</legend>
-        <el-form-item label="剩余内存低于总内存" prop="memoryWarn">
-          <el-input v-model="form.memoryWarn" style="width: 60px"></el-input>
-          <span style="font-weight: bold;color: #606266">  (%)时,邮箱告警。</span>
-        </el-form-item>
-        <el-divider></el-divider>
-        <el-row>
-          <el-col :span="12">
-            <el-form-item label="A级别异常通知方式" prop="excNoticeWayA">
-              <el-select v-model="form.excNoticeWayA" placeholder="请选择通知方式" style="width: 240px">
-                <el-option
-                  v-for="item in excNoticeOptions"
-                  :key="item.value"
-                  :label="item.label"
-                  :value="item.value"
-                ></el-option>
-              </el-select>
-            </el-form-item>
-            <el-form-item label="B级别异常通知方式" prop="excNoticeWayB">
-              <el-select v-model="form.excNoticeWayB" placeholder="请选择通知方式" style="width: 240px">
-                <el-option
-                  v-for="item in excNoticeOptions"
-                  :key="item.value"
-                  :label="item.label"
-                  :value="item.value"
-                ></el-option>
-              </el-select>
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="连续登录失败异常级别" prop="excLevelLogin">
-              <el-select v-model="form.excLevelLogin" placeholder="请选择异常级别" style="width: 240px">
-                <el-option
-                  v-for="item in excLevelOptions"
-                  :key="item.value"
-                  :label="item.label"
-                  :value="item.value"
-                ></el-option>
-              </el-select>
-            </el-form-item>
-            <el-form-item label="同一用户多点登录异常级别" prop="excLevelSameUser">
-              <el-select v-model="form.excLevelSameUser" placeholder="请选择异常级别" style="width: 240px">
-                <el-option
-                  v-for="item in excLevelOptions"
-                  :key="item.value"
-                  :label="item.label"
-                  :value="item.value"
-                ></el-option>
-              </el-select>
-            </el-form-item>
-            <el-form-item label="越权访问异常级别" prop="excLevelLogin">
-              <el-select v-model="form.unauthorizedAccessExceptionLevel" placeholder="请选择异常级别" style="width: 240px">
-                <el-option
-                  v-for="item in excLevelOptions"
-                  :key="item.value"
-                  :label="item.label"
-                  :value="item.value"
-                ></el-option>
-              </el-select>
-            </el-form-item>
-            <el-form-item label="IP地址异常级别" prop="excLevelSameUser">
-              <el-select v-model="form.ipAddressExceptionLevel" placeholder="请选择异常级别" style="width: 240px">
-                <el-option
-                  v-for="item in excLevelOptions"
-                  :key="item.value"
-                  :label="item.label"
-                  :value="item.value"
-                ></el-option>
-              </el-select>
-            </el-form-item>
-          </el-col>
+<!--        <el-form-item label="审计日志存储额定容量上限(GB)" prop="auditLogBakCapAlarm" type="number">-->
+<!--          <el-input v-model="form.auditLogBakCapAlarm" style="width: 240px"></el-input>-->
+<!--        </el-form-item>-->
+<!--        <el-form-item label="审计日志存储剩余容量低于额定容量" prop="logSpaceWarn">-->
+<!--          <el-input v-model="form.logSpaceWarn" style="width: 60px"></el-input>-->
+<!--          <span style="font-weight: bold;color: #606266;">  (%)时,邮箱告警。</span>-->
+<!--        </el-form-item>-->
+<!--      </fieldset>-->
+<!--      <fieldset>-->
+<!--        <legend>系统策略配置</legend>-->
+<!--        <el-form-item label="剩余内存低于总内存" prop="memoryWarn">-->
+<!--          <el-input v-model="form.memoryWarn" style="width: 60px"></el-input>-->
+<!--          <span style="font-weight: bold;color: #606266">  (%)时,邮箱告警。</span>-->
+<!--        </el-form-item>-->
+<!--        <el-divider></el-divider>-->
+<!--        <el-row>-->
+<!--          <el-col :span="12">-->
+<!--            <el-form-item label="A级别异常通知方式" prop="excNoticeWayA">-->
+<!--              <el-select v-model="form.excNoticeWayA" placeholder="请选择通知方式" style="width: 240px">-->
+<!--                <el-option-->
+<!--                  v-for="item in excNoticeOptions"-->
+<!--                  :key="item.value"-->
+<!--                  :label="item.label"-->
+<!--                  :value="item.value"-->
+<!--                ></el-option>-->
+<!--              </el-select>-->
+<!--            </el-form-item>-->
+<!--            <el-form-item label="B级别异常通知方式" prop="excNoticeWayB">-->
+<!--              <el-select v-model="form.excNoticeWayB" placeholder="请选择通知方式" style="width: 240px">-->
+<!--                <el-option-->
+<!--                  v-for="item in excNoticeOptions"-->
+<!--                  :key="item.value"-->
+<!--                  :label="item.label"-->
+<!--                  :value="item.value"-->
+<!--                ></el-option>-->
+<!--              </el-select>-->
+<!--            </el-form-item>-->
+<!--          </el-col>-->
+<!--          <el-col :span="12">-->
+<!--            <el-form-item label="连续登录失败异常级别" prop="excLevelLogin">-->
+<!--              <el-select v-model="form.excLevelLogin" placeholder="请选择异常级别" style="width: 240px">-->
+<!--                <el-option-->
+<!--                  v-for="item in excLevelOptions"-->
+<!--                  :key="item.value"-->
+<!--                  :label="item.label"-->
+<!--                  :value="item.value"-->
+<!--                ></el-option>-->
+<!--              </el-select>-->
+<!--            </el-form-item>-->
+<!--            <el-form-item label="同一用户多点登录异常级别" prop="excLevelSameUser">-->
+<!--              <el-select v-model="form.excLevelSameUser" placeholder="请选择异常级别" style="width: 240px">-->
+<!--                <el-option-->
+<!--                  v-for="item in excLevelOptions"-->
+<!--                  :key="item.value"-->
+<!--                  :label="item.label"-->
+<!--                  :value="item.value"-->
+<!--                ></el-option>-->
+<!--              </el-select>-->
+<!--            </el-form-item>-->
+<!--            <el-form-item label="越权访问异常级别" prop="excLevelLogin">-->
+<!--              <el-select v-model="form.unauthorizedAccessExceptionLevel" placeholder="请选择异常级别" style="width: 240px">-->
+<!--                <el-option-->
+<!--                  v-for="item in excLevelOptions"-->
+<!--                  :key="item.value"-->
+<!--                  :label="item.label"-->
+<!--                  :value="item.value"-->
+<!--                ></el-option>-->
+<!--              </el-select>-->
+<!--            </el-form-item>-->
+<!--            <el-form-item label="IP地址异常级别" prop="excLevelSameUser">-->
+<!--              <el-select v-model="form.ipAddressExceptionLevel" placeholder="请选择异常级别" style="width: 240px">-->
+<!--                <el-option-->
+<!--                  v-for="item in excLevelOptions"-->
+<!--                  :key="item.value"-->
+<!--                  :label="item.label"-->
+<!--                  :value="item.value"-->
+<!--                ></el-option>-->
+<!--              </el-select>-->
+<!--            </el-form-item>-->
+<!--          </el-col>-->
 
-        </el-row>
+<!--        </el-row>-->
 
-      </fieldset>
+<!--      </fieldset>-->
       <el-form-item>
         <el-button type="primary" @click="onSubmit">保存</el-button>
       </el-form-item>