白名单增加各个操作的定时任务处理
各种批量操作增加定时任务的处理
This commit is contained in:
@@ -64,7 +64,6 @@ import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.configuration.ComplexStringCfgTemplate;
|
||||
import com.nis.domain.configuration.ComplexkeywordCfg;
|
||||
import com.nis.domain.configuration.DdosIpCfg;
|
||||
import com.nis.domain.configuration.DnsIpCfg;
|
||||
@@ -75,7 +74,6 @@ import com.nis.domain.configuration.PxyObjKeyring;
|
||||
import com.nis.domain.configuration.PxyObjTrustedCaCert;
|
||||
import com.nis.domain.configuration.PxyObjTrustedCaCrl;
|
||||
import com.nis.domain.configuration.RequestInfo;
|
||||
import com.nis.domain.configuration.StringCfgTemplate;
|
||||
import com.nis.domain.configuration.template.AppDomainTemplate;
|
||||
import com.nis.domain.configuration.template.AppPayloadTemplate;
|
||||
import com.nis.domain.configuration.template.AsnIpTemplate;
|
||||
@@ -100,7 +98,6 @@ import com.nis.domain.configuration.template.HttpsReplaceIpTemplate;
|
||||
import com.nis.domain.configuration.template.HttpsReplaceTemplate;
|
||||
import com.nis.domain.configuration.template.IpAllNotDoLogTemplate;
|
||||
import com.nis.domain.configuration.template.IpAllTemplate;
|
||||
import com.nis.domain.configuration.template.IpCfgTemplate;
|
||||
import com.nis.domain.configuration.template.IpPayloadTemplate;
|
||||
import com.nis.domain.configuration.template.IpRateLimitTemplate;
|
||||
import com.nis.domain.configuration.template.IpSpoofingTemplate;
|
||||
@@ -771,75 +768,6 @@ public class BaseController {
|
||||
}
|
||||
return msgProp;
|
||||
}
|
||||
@Deprecated
|
||||
public void importCfgTemplate(HttpServletRequest request, HttpServletResponse response,
|
||||
RedirectAttributes redirectAttributes, Integer functionId, Integer cfgRegionCode) {
|
||||
Properties msgProp = getMsgProp();
|
||||
try {
|
||||
List<FunctionRegionDict> dictList = DictUtils.getFunctionRegionDictList(functionId);
|
||||
for (FunctionRegionDict dict : dictList) {
|
||||
if (dict.getConfigRegionCode() == cfgRegionCode) {
|
||||
String fileName = dict.getConfigRegionValue() + ".xlsx";
|
||||
if (dict.getRegionType() == 1) {
|
||||
List<IpCfgTemplate> list = Lists.newArrayList();
|
||||
list.add(new IpCfgTemplate());
|
||||
new ExportExcel(new FunctionServiceDict(), new FunctionRegionDict(), msgProp, null,
|
||||
IpCfgTemplate.class, 2).setDataList(msgProp, list, null)
|
||||
.write(request, response, fileName).dispose();
|
||||
} else if (dict.getRegionType() == 2) {
|
||||
List<StringCfgTemplate> list = Lists.newArrayList();
|
||||
list.add(new StringCfgTemplate());
|
||||
new ExportExcel(new FunctionServiceDict(), new FunctionRegionDict(), msgProp, null,
|
||||
StringCfgTemplate.class, 2).setDataList(msgProp, list, null)
|
||||
.write(request, response, fileName).dispose();
|
||||
} else if (dict.getRegionType() == 3) {
|
||||
List<ComplexStringCfgTemplate> list = Lists.newArrayList();
|
||||
list.add(new ComplexStringCfgTemplate());
|
||||
new ExportExcel(new FunctionServiceDict(), new FunctionRegionDict(), msgProp, null,
|
||||
ComplexStringCfgTemplate.class, 2).setDataList(msgProp, list, null)
|
||||
.write(request, response, fileName).dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
msgProp = null;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@Deprecated
|
||||
public void importCfgTemplate(HttpServletRequest request, HttpServletResponse response,
|
||||
RedirectAttributes redirectAttributes, Integer functionId, Integer cfgRegionCode, Class clazz) {
|
||||
Properties msgProp = getMsgProp();
|
||||
try {
|
||||
List<FunctionRegionDict> dictList = DictUtils.getFunctionRegionDictList(functionId);
|
||||
for (FunctionRegionDict dict : dictList) {
|
||||
if (dict.getConfigRegionCode() == cfgRegionCode) {
|
||||
String fileName = dict.getConfigRegionValue() + ".xlsx";
|
||||
if (dict.getRegionType() == 1) {
|
||||
List<IpCfgTemplate> list = Lists.newArrayList();
|
||||
list.add((IpCfgTemplate) clazz.newInstance());
|
||||
new ExportExcel(new FunctionServiceDict(), new FunctionRegionDict(), msgProp, null, clazz, 2)
|
||||
.setDataList(msgProp, list, null).write(request, response, fileName).dispose();
|
||||
} else if (dict.getRegionType() == 2) {
|
||||
List<StringCfgTemplate> list = Lists.newArrayList();
|
||||
list.add(new StringCfgTemplate());
|
||||
new ExportExcel(new FunctionServiceDict(), new FunctionRegionDict(), msgProp, null, clazz, 2)
|
||||
.setDataList(msgProp, list, null).write(request, response, fileName).dispose();
|
||||
} else if (dict.getRegionType() == 3) {
|
||||
List<ComplexStringCfgTemplate> list = Lists.newArrayList();
|
||||
list.add(new ComplexStringCfgTemplate());
|
||||
new ExportExcel(new FunctionServiceDict(), new FunctionRegionDict(), msgProp, null, clazz, 2)
|
||||
.setDataList(msgProp, list, null).write(request, response, fileName).dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
msgProp = null;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setLogAction(BaseLogEntity log, List<FunctionServiceDict> serviceList) {
|
||||
if (!StringUtil.isEmpty(serviceList)) {
|
||||
@@ -3869,7 +3797,8 @@ public class BaseController {
|
||||
maatBean = new ToMaatBean();
|
||||
configCompileList = new ArrayList();
|
||||
List list = new ArrayList();
|
||||
List newList = new ArrayList();
|
||||
List notAuditList = new ArrayList();
|
||||
List auditList = new ArrayList();
|
||||
List ids = new ArrayList();
|
||||
List<Integer> compileIds = Lists.newArrayList();
|
||||
if(entity.getServiceId().equals(3)){//ip drop回调类配置用了主表和子表关系
|
||||
@@ -3882,9 +3811,21 @@ public class BaseController {
|
||||
List subList = commonPolicyService.getIpDropList("ip_port_cfg", compileIds);
|
||||
for(int i=0;i<subList.size();i++){
|
||||
IpPortCfg cfg = (IpPortCfg) subList.get(i);
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
newList.add(BaseService.convertCallBackIp(cfg,cfg.getGroupId()));
|
||||
if(cfg.getIsValid()==1) {
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
|
||||
auditList.add(BaseService.convertCallBackIp(cfg,cfg.getGroupId()));
|
||||
}else {
|
||||
//定时任务审核通过,配置已经失效,则
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
notAuditList.add(BaseService.convertCallBackIp(cfg,cfg.getGroupId()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3893,47 +3834,102 @@ public class BaseController {
|
||||
list = avCfgService.getAvFileSampleList(page,searchFileSampleCfg).getList();
|
||||
for(int i=0;i<list.size();i++){
|
||||
BaseCfg cfg = (BaseCfg) list.get(i);
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
ids.add(cfg.getCompileId());
|
||||
newList.add(cfg);
|
||||
if(cfg.getIsValid()==1) {
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
auditList.add(cfg);
|
||||
}else {
|
||||
//定时任务审核通过,配置已经失效,则
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
notAuditList.add(cfg);
|
||||
}
|
||||
|
||||
}
|
||||
}else if(className.equals("AvSignSampleCfg")){
|
||||
list = avCfgService.getSignSampleList(searchSignSampleCfg);
|
||||
for(int i=0;i<list.size();i++){
|
||||
BaseCfg cfg = (BaseCfg) list.get(i);
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
ids.add(cfg.getCompileId());
|
||||
newList.add(cfg);
|
||||
if(cfg.getIsValid()==1) {
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
auditList.add(cfg);
|
||||
}else {
|
||||
//定时任务审核通过,配置已经失效,则
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
notAuditList.add(cfg);
|
||||
}
|
||||
}
|
||||
}else if(className.equals("PxyObjKeyring")){
|
||||
list = pxyObjKeyringService.findPage(page, searchObjKeyringCfg).getList();
|
||||
for(int i=0;i<list.size();i++){
|
||||
PxyObjKeyring cfg = (PxyObjKeyring) list.get(i);
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
newList.add(BaseService.convertCallBackProxyObjKeyring(cfg));
|
||||
ids.add(cfg.getCompileId());
|
||||
/*newList.add(cfg);*/
|
||||
if(cfg.getIsValid()==1) {
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
auditList.add(BaseService.convertCallBackProxyObjKeyring(cfg));
|
||||
}else {
|
||||
//定时任务审核通过,配置已经失效,则
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
notAuditList.add(BaseService.convertCallBackProxyObjKeyring(cfg));
|
||||
}
|
||||
}
|
||||
}else if(className.equals("PxyObjTrustedCaCert")){
|
||||
list = pxyObjKeyringService.findTrustedCertPage(page,searchTrustedCaCertCfg).getList();
|
||||
for(int i=0;i<list.size();i++){
|
||||
PxyObjTrustedCaCert cfg = (PxyObjTrustedCaCert) list.get(i);
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
newList.addAll(BaseService.convertCallBackProxyObjTrustedCa(cfg,null));
|
||||
ids.add(cfg.getCompileId());
|
||||
if(cfg.getIsValid()==1) {
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
auditList.addAll(BaseService.convertCallBackProxyObjTrustedCa(cfg,null));
|
||||
}else {
|
||||
//定时任务审核通过,配置已经失效,则
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
notAuditList.addAll(BaseService.convertCallBackProxyObjTrustedCa(cfg,null));
|
||||
}
|
||||
}
|
||||
if(!StringUtil.isEmpty(ids)) {
|
||||
list=new ArrayList<>();
|
||||
list=commonPolicyService.getPxyObjTrustedCrlCfgListByCertId(ids);
|
||||
for(int i=0;i<list.size();i++){
|
||||
PxyObjTrustedCaCrl cfg = (PxyObjTrustedCaCrl) list.get(i);
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
newList.addAll(BaseService.convertCallBackProxyObjTrustedCa(null,cfg));
|
||||
if(cfg.getIsValid()==1) {
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
auditList.addAll(BaseService.convertCallBackProxyObjTrustedCa(null,cfg));
|
||||
}else {
|
||||
//定时任务审核通过,配置已经失效,则
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
notAuditList.addAll(BaseService.convertCallBackProxyObjTrustedCa(null,cfg));
|
||||
}
|
||||
}
|
||||
}
|
||||
}/*//批量下发时不需要单独下发CRL
|
||||
@@ -3948,28 +3944,61 @@ public class BaseController {
|
||||
list = dnsResStrategyService.findPage(page,searchDnsResStrategy).getList();
|
||||
for(int i=0;i<list.size();i++){
|
||||
DnsResStrategy cfg = (DnsResStrategy) list.get(i);
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
newList.add(BaseService.convertCallBackDnsResStrategy(cfg));
|
||||
ids.add(cfg.getCompileId());
|
||||
if(cfg.getIsValid()==1) {
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
auditList.add(BaseService.convertCallBackDnsResStrategy(cfg));
|
||||
}else {
|
||||
//定时任务审核通过,配置已经失效,则
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
notAuditList.add(BaseService.convertCallBackDnsResStrategy(cfg));
|
||||
}
|
||||
}
|
||||
}else if(className.equals("DnsIpCfg")){
|
||||
list = dnsIpCfgService.findPage(page,searchDnsIpCfg).getList();
|
||||
for(int i=0;i<list.size();i++){
|
||||
DnsIpCfg cfg = (DnsIpCfg) list.get(i);
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
newList.add(BaseService.convertCallBackIp(cfg,cfg.getDnsStrategyId()));
|
||||
ids.add(cfg.getCompileId());
|
||||
if(cfg.getIsValid()==1) {
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
auditList.add(BaseService.convertCallBackIp(cfg,cfg.getDnsStrategyId()));
|
||||
}else {
|
||||
//定时任务审核通过,配置已经失效,则
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
notAuditList.add(BaseService.convertCallBackIp(cfg,cfg.getDnsStrategyId()));
|
||||
}
|
||||
}
|
||||
}else if(className.equals("IpPortCfg")){
|
||||
list = commonPolicyService.getIpPortList(searchIpPortCfg);
|
||||
for(int i=0;i<list.size();i++){
|
||||
IpPortCfg cfg = (IpPortCfg) list.get(i);
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
newList.add(BaseService.convertCallBackIp(cfg,cfg.getGroupId()));
|
||||
ids.add(cfg.getCompileId());
|
||||
if(cfg.getIsValid()==1) {
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
auditList.add(BaseService.convertCallBackIp(cfg,cfg.getGroupId()));
|
||||
}else {
|
||||
//定时任务审核通过,配置已经失效,则
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
notAuditList.add(BaseService.convertCallBackIp(cfg,cfg.getGroupId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3978,9 +4007,9 @@ public class BaseController {
|
||||
hasData = false;
|
||||
}
|
||||
|
||||
if(!StringUtil.isEmpty(newList)) {
|
||||
if(!StringUtil.isEmpty(auditList) || !StringUtil.isEmpty(notAuditList)) {
|
||||
//批量修改和下发回调配置
|
||||
commonPolicyService.auditCallBackData(newList, compileIds, ids, entity);
|
||||
commonPolicyService.auditCallBackData(auditList,notAuditList, compileIds, ids, entity);
|
||||
}else {
|
||||
hasData = false;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.nis.web.controller.configuration.ntc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -26,12 +25,10 @@ import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.configuration.HttpUrlCfg;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.configuration.NtcSubscribeIdCfg;
|
||||
import com.nis.domain.configuration.template.WhiteListIpTemplate;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.configuration.CommonController;
|
||||
import com.nis.web.security.UserUtils;
|
||||
|
||||
/**
|
||||
* 白名单
|
||||
@@ -386,24 +383,6 @@ public class WhiteListController extends CommonController {
|
||||
return "redirect:" + adminPath + "/ntc/whitelist/domain/list?functionId=" + functionId;
|
||||
}
|
||||
|
||||
// ip配置导入
|
||||
/*
|
||||
* @RequestMapping(value = "ip/import", method=RequestMethod.POST) public
|
||||
* String importIp(String cfgName,RedirectAttributes redirectAttributes,
|
||||
*
|
||||
* @RequestParam("file") MultipartFile file,IpPortCfg cfg) {
|
||||
* this._importIp(cfgName,redirectAttributes,
|
||||
* file,cfg,WhiteListIpTemplate.class); return "redirect:" + adminPath
|
||||
* +"/ntc/whitelist/ip/list?functionId="+cfg.getFunctionId(); }
|
||||
*/
|
||||
// ip模板下载
|
||||
@RequestMapping(value = "ip/import/template")
|
||||
public void importFileTemplate(HttpServletRequest request, HttpServletResponse response,
|
||||
RedirectAttributes redirectAttributes, Integer functionId, Integer cfgRegionCode) {
|
||||
this._importFileTemplate(request, response, redirectAttributes, functionId, cfgRegionCode,
|
||||
WhiteListIpTemplate.class);
|
||||
}
|
||||
|
||||
// ip配置导出
|
||||
@RequestMapping(value = "ip/export")
|
||||
public void exportIp(String columns, Model model, HttpServletRequest request, HttpServletResponse response,
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Type;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.Charset;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -14,6 +17,9 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.ibatis.executor.Executor;
|
||||
import org.apache.ibatis.mapping.MappedStatement;
|
||||
import org.apache.ibatis.session.Configuration;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
@@ -40,6 +46,7 @@ import com.googlecode.ipv6.IPv6Address;
|
||||
import com.googlecode.ipv6.IPv6Network;
|
||||
import com.nis.domain.FunctionRegionDict;
|
||||
import com.nis.domain.FunctionServiceDict;
|
||||
import com.nis.domain.ScheduleCfg;
|
||||
import com.nis.domain.SysRole;
|
||||
import com.nis.domain.SysUser;
|
||||
import com.nis.domain.basics.AsnGroupInfo;
|
||||
@@ -95,6 +102,7 @@ import com.nis.util.IpUtil;
|
||||
import com.nis.util.Reflections;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.web.dao.SchedulerDao;
|
||||
import com.nis.web.dao.basics.AsnGroupInfoDao;
|
||||
import com.nis.web.dao.basics.AsnIpCfgDao;
|
||||
import com.nis.web.dao.configuration.AppCfgDao;
|
||||
@@ -110,6 +118,7 @@ import com.nis.web.dao.specific.SpecificServiceCfgDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
import com.nis.web.service.basics.AsnGroupInfoService;
|
||||
import com.nis.web.service.basics.SysDictInfoService;
|
||||
import com.sun.org.apache.bcel.internal.generic.NEW;
|
||||
|
||||
/**
|
||||
* Service基类
|
||||
@@ -1044,31 +1053,45 @@ public abstract class BaseService {
|
||||
*/
|
||||
public static List<IpCfg> ipConvert(IpCfg dstIp, BaseIpCfg srcIp) {
|
||||
List<IpCfg> ipConvertList = Lists.newArrayList();
|
||||
boolean isRange = ((srcIp.getIpPattern() != null && srcIp.getIpPattern() == 2)
|
||||
|| (srcIp.getSrcIpAddress() != null && srcIp.getSrcIpAddress().indexOf("-") > -1)
|
||||
|| (srcIp.getDestIpAddress() != null && srcIp.getDestIpAddress().indexOf("-") > -1));
|
||||
if (isRange) {
|
||||
List<IpCfg> tempList = Lists.newArrayList();
|
||||
List<IpCfg> tempList1 = Lists.newArrayList();
|
||||
if (srcIp.getIpType().intValue() == 4) {
|
||||
if (srcIp.getSrcIpAddress() != null) {
|
||||
String startIpPart = srcIp.getSrcIpAddress().split("-")[0];
|
||||
String endIpPart = srcIp.getSrcIpAddress().split("-")[1];
|
||||
Integer startNum = Integer.parseInt(startIpPart.split("\\.")[3]);
|
||||
Integer endNum = Integer.parseInt(endIpPart.split("\\.")[3]);
|
||||
for (int i = startNum; i <= endNum; i++) {
|
||||
IpCfg tempIp = new IpCfg();
|
||||
BeanUtils.copyProperties(dstIp, tempIp);
|
||||
tempIp.setSrcIp(startIpPart.substring(0, startIpPart.lastIndexOf(".") + 1) + i);
|
||||
tempIp.setSrcIpMask("255.255.255.255");
|
||||
tempList.add(tempIp);
|
||||
List<IpCfg> tempList = Lists.newArrayList();
|
||||
List<IpCfg> tempList1 = Lists.newArrayList();
|
||||
if (srcIp.getIpType().equals(4)) {// IP V4
|
||||
if(srcIp.getSrcIpPattern().equals(2)) {//源IP范围
|
||||
if (srcIp.getSrcIpAddress() != null) {
|
||||
String startIpPart = srcIp.getSrcIpAddress().split("-")[0];
|
||||
String endIpPart = srcIp.getSrcIpAddress().split("-")[1];
|
||||
Integer startNum = Integer.parseInt(startIpPart.split("\\.")[3]);
|
||||
Integer endNum = Integer.parseInt(endIpPart.split("\\.")[3]);
|
||||
for (int i = startNum; i <= endNum; i++) {
|
||||
IpCfg tempIp = new IpCfg();
|
||||
BeanUtils.copyProperties(dstIp, tempIp);
|
||||
tempIp.setSrcIp(startIpPart.substring(0, startIpPart.lastIndexOf(".") + 1) + i);
|
||||
tempIp.setSrcIpMask("255.255.255.255");
|
||||
tempList.add(tempIp);
|
||||
}
|
||||
}else {
|
||||
dstIp.setSrcIp("0.0.0.0");
|
||||
dstIp.setSrcIpMask("255.255.255.255");
|
||||
tempList.add(dstIp);
|
||||
}
|
||||
}else if(srcIp.getSrcIpPattern().equals(1)){
|
||||
Integer srcMaskNum = Integer.parseInt(srcIp.getSrcIpAddress().split("/")[1]);
|
||||
if (srcMaskNum == 0) {
|
||||
dstIp.setSrcIpMask("0.0.0.0");
|
||||
} else {
|
||||
dstIp.setSrcIp("0.0.0.0");
|
||||
dstIp.setSrcIpMask("255.255.255.255");
|
||||
tempList.add(dstIp);
|
||||
dstIp.setSrcIpMask(IpUtil.convertMask(srcMaskNum));
|
||||
}
|
||||
if (srcIp.getDestIpAddress() != null) {
|
||||
dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]);
|
||||
tempList.add(dstIp);
|
||||
}else if(srcIp.getSrcIpPattern().equals(3)){
|
||||
dstIp.setSrcIp(srcIp.getSrcIpAddress());
|
||||
dstIp.setSrcIpMask("255.255.255.255");
|
||||
tempList.add(dstIp);
|
||||
}else {
|
||||
throw new RuntimeException("Unsupported IP Pattern " + srcIp.getSrcIpPattern());
|
||||
}
|
||||
if (srcIp.getDestIpAddress() != null) {
|
||||
if(srcIp.getDestIpPattern().equals(2)) {
|
||||
String startIpPart = srcIp.getDestIpAddress().split("-")[0];
|
||||
String endIpPart = srcIp.getDestIpAddress().split("-")[1];
|
||||
Integer startNum = Integer.parseInt(startIpPart.split("\\.")[3]);
|
||||
@@ -1088,217 +1111,93 @@ public abstract class BaseService {
|
||||
}
|
||||
}
|
||||
tempList.clear();
|
||||
} else {
|
||||
}else if(srcIp.getDestIpPattern().equals(1)) {
|
||||
Integer dstMaskNum = Integer.parseInt(srcIp.getDestIpAddress().split("/")[1]);
|
||||
for (IpCfg _cfg : tempList) {
|
||||
_cfg.setDstIp("0.0.0.0");
|
||||
_cfg.setSrcIpMask("255.255.255.255");
|
||||
convertPortValues(_cfg, srcIp);
|
||||
IpCfg tempIp = new IpCfg();
|
||||
BeanUtils.copyProperties(_cfg, tempIp);
|
||||
if (dstMaskNum == 0) {
|
||||
tempIp.setDstIpMask("0.0.0.0");
|
||||
} else {
|
||||
tempIp.setDstIpMask(IpUtil.convertMask(dstMaskNum));
|
||||
}
|
||||
tempIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]);
|
||||
if (!tempIp.getSrcIp().equals(tempIp.getDstIp())) {
|
||||
// 处理
|
||||
convertPortValues(tempIp, srcIp);
|
||||
tempList1.add(tempIp);
|
||||
}
|
||||
}
|
||||
tempList.clear();
|
||||
}else {
|
||||
for (IpCfg _cfg : tempList) {
|
||||
IpCfg tempIp = new IpCfg();
|
||||
BeanUtils.copyProperties(_cfg, tempIp);
|
||||
tempIp.setDstIp(srcIp.getDestIpAddress());
|
||||
if (!tempIp.getSrcIp().equals(tempIp.getDstIp())) {
|
||||
tempIp.setDstIpMask("255.255.255.255");
|
||||
// 处理
|
||||
convertPortValues(tempIp, srcIp);
|
||||
tempList1.add(tempIp);
|
||||
}
|
||||
}
|
||||
tempList.clear();
|
||||
}
|
||||
if (tempList1.size() > 0) {
|
||||
ipConvertList.addAll(tempList1);
|
||||
} else {
|
||||
ipConvertList.addAll(tempList);
|
||||
}else {
|
||||
for (IpCfg _cfg : tempList) {
|
||||
_cfg.setDstIp("0.0.0.0");
|
||||
_cfg.setSrcIpMask("255.255.255.255");
|
||||
convertPortValues(_cfg, srcIp);
|
||||
}
|
||||
} else if (srcIp.getIpType().intValue() == 6) {
|
||||
if (srcIp.getSrcIpAddress() != null) {
|
||||
}
|
||||
if (tempList1.size() > 0) {
|
||||
ipConvertList.addAll(tempList1);
|
||||
} else {
|
||||
ipConvertList.addAll(tempList);
|
||||
}
|
||||
}else if(srcIp.getIpType().equals(6)){// IP V6
|
||||
if (srcIp.getSrcIpAddress() != null) {
|
||||
if(srcIp.getSrcIpPattern().equals(2)) {
|
||||
IPv6Address address1 = IPv6Address.fromString(srcIp.getSrcIpAddress().split("-")[0]);
|
||||
IPv6Address address2 = IPv6Address.fromString(srcIp.getSrcIpAddress().split("-")[1]);
|
||||
IPv6Network network = IPv6Network.fromTwoAddresses(address1, address2);
|
||||
dstIp.setSrcIp(address1.toString());
|
||||
dstIp.setSrcIpMask(network.getNetmask().asAddress().toString());
|
||||
} else {
|
||||
dstIp.setSrcIp("::");
|
||||
}else if(srcIp.getSrcIpPattern().equals(1)){// IP/掩码
|
||||
IPv6Network strangeNetwork = IPv6Network.fromString(srcIp.getSrcIpAddress());
|
||||
dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]);
|
||||
dstIp.setSrcIpMask(strangeNetwork.getNetmask().asAddress().toString());
|
||||
}else {// IP
|
||||
dstIp.setSrcIp(srcIp.getSrcIpAddress());
|
||||
dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
|
||||
}
|
||||
if (srcIp.getDestIpAddress() != null) {
|
||||
} else {
|
||||
dstIp.setSrcIp("::");
|
||||
dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
|
||||
}
|
||||
if (srcIp.getDestIpAddress() != null) {
|
||||
if(srcIp.getDestIpPattern().equals(2)) {
|
||||
IPv6Address address1 = IPv6Address.fromString(srcIp.getDestIpAddress().split("-")[0]);
|
||||
IPv6Address address2 = IPv6Address.fromString(srcIp.getDestIpAddress().split("-")[1]);
|
||||
IPv6Network network = IPv6Network.fromTwoAddresses(address1, address2);
|
||||
dstIp.setDstIp(address1.toString());
|
||||
dstIp.setDstIpMask(network.getNetmask().asAddress().toString());
|
||||
} else {
|
||||
dstIp.setDstIp("::");
|
||||
dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
|
||||
}
|
||||
|
||||
ipConvertList.add(dstIp);
|
||||
} else {
|
||||
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
|
||||
}
|
||||
} else {
|
||||
if (srcIp.getSrcIpAddress() != null) {
|
||||
if (srcIp.getSrcIpAddress().indexOf("/") != -1) {
|
||||
if (srcIp.getIpType() == 4 /* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4,目的ip为ipv6
|
||||
Integer srcMaskNum = Integer.parseInt(srcIp.getSrcIpAddress().split("/")[1]);
|
||||
if (srcMaskNum == 0) {
|
||||
dstIp.setSrcIpMask("0.0.0.0");
|
||||
} else {
|
||||
dstIp.setSrcIpMask(IpUtil.convertMask(srcMaskNum));
|
||||
}
|
||||
|
||||
dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]);
|
||||
} else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6,目的ip为ipv4
|
||||
IPv6Network strangeNetwork = IPv6Network.fromString(srcIp.getSrcIpAddress());
|
||||
dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]);
|
||||
dstIp.setSrcIpMask(strangeNetwork.getNetmask().asAddress().toString());
|
||||
} /*
|
||||
* else { Pattern
|
||||
* patternV4Subnet=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP); Pattern
|
||||
* patternV6Subnet=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP); Matcher
|
||||
* matchernV4Subnet=patternV4Subnet.matcher(srcIp.getSrcIpAddress()); Matcher
|
||||
* matcherV6Subnet=patternV6Subnet.matcher(srcIp.getSrcIpAddress());
|
||||
* if(matchernV4Subnet.matches()) { Integer srcMaskNum =
|
||||
* Integer.parseInt(srcIp.getSrcIpAddress().split("/")[1]); if(srcMaskNum==0){
|
||||
* dstIp.setSrcIpMask("0.0.0.0"); }else{
|
||||
* dstIp.setSrcIpMask(IpUtil.convertMask(srcMaskNum)); }
|
||||
* dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]); }else
|
||||
* if(matcherV6Subnet.matches()){ IPv6Network strangeNetwork =
|
||||
* IPv6Network.fromString(srcIp.getSrcIpAddress());
|
||||
* dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]);
|
||||
* dstIp.setSrcIpMask(strangeNetwork.getNetmask().asAddress().toString()); }else
|
||||
* { throw new RuntimeException("Invalid IP/subnet mask format"); } }
|
||||
*/
|
||||
else {
|
||||
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
|
||||
}
|
||||
} else {
|
||||
if (srcIp.getIpType() == 4/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4,目的ip为ipv6
|
||||
dstIp.setSrcIp(srcIp.getSrcIpAddress());
|
||||
dstIp.setSrcIpMask("255.255.255.255");
|
||||
} else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6,目的ip为ipv4
|
||||
dstIp.setSrcIp(srcIp.getSrcIpAddress());
|
||||
dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
|
||||
} /*
|
||||
* else {//all Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
|
||||
* Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP); Matcher
|
||||
* matcherV4=patternV4.matcher(srcIp.getSrcIpAddress()); Matcher
|
||||
* matcherV6=patternV6.matcher(srcIp.getSrcIpAddress()); if(matcherV4.matches())
|
||||
* { dstIp.setSrcIp(srcIp.getSrcIpAddress());
|
||||
* dstIp.setSrcIpMask("255.255.255.255"); }else if(matcherV6.matches()) {
|
||||
* dstIp.setSrcIp(srcIp.getSrcIpAddress());
|
||||
* dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); }else { throw
|
||||
* new RuntimeException("Invalid IP format"); } }
|
||||
*/
|
||||
else {
|
||||
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (srcIp.getIpType() == 4/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4,目的ip为ipv6
|
||||
dstIp.setSrcIp(srcIp.getSrcIpAddress());
|
||||
dstIp.setSrcIpMask("255.255.255.255");
|
||||
} else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6,目的ip为ipv4
|
||||
dstIp.setSrcIp(srcIp.getSrcIpAddress());
|
||||
dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
|
||||
} /*
|
||||
* else {//all dstIp.setSrcIp(srcIp.getSrcIpAddress());
|
||||
* dstIp.setSrcIpMask("255.255.255.255"); }
|
||||
*/
|
||||
else {
|
||||
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
|
||||
}
|
||||
}
|
||||
if (srcIp.getDestIpAddress() != null) {
|
||||
if (srcIp.getDestIpAddress().indexOf("/") != -1) {
|
||||
if (srcIp.getIpType() == 4/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6,目的ip为ipv4
|
||||
Integer dstMaskNum = Integer.parseInt(srcIp.getDestIpAddress().split("/")[1]);
|
||||
if (dstMaskNum == 0) {
|
||||
dstIp.setDstIpMask("0.0.0.0");
|
||||
} else {
|
||||
dstIp.setDstIpMask(IpUtil.convertMask(dstMaskNum));
|
||||
;
|
||||
}
|
||||
dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]);
|
||||
} else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4,目的ip为ipv6
|
||||
IPv6Network strangeNetwork = IPv6Network.fromString(srcIp.getDestIpAddress());
|
||||
dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]);
|
||||
dstIp.setDstIpMask(strangeNetwork.getNetmask().asAddress().toString());
|
||||
} /*
|
||||
* else { Pattern
|
||||
* patternV4Subnet=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP); Pattern
|
||||
* patternV6Subnet=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP); Matcher
|
||||
* matchernV4Subnet=patternV4Subnet.matcher(srcIp.getDestIpAddress()); Matcher
|
||||
* matcherV6Subnet=patternV6Subnet.matcher(srcIp.getDestIpAddress());
|
||||
* if(matchernV4Subnet.matches()) { Integer dstMaskNum =
|
||||
* Integer.parseInt(srcIp.getDestIpAddress().split("/")[1]); if(dstMaskNum==0){
|
||||
* dstIp.setDstIpMask("0.0.0.0"); }else{
|
||||
* dstIp.setDstIpMask(IpUtil.convertMask(dstMaskNum));; }
|
||||
* dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]); }else
|
||||
* if(matcherV6Subnet.matches()){ IPv6Network strangeNetwork =
|
||||
* IPv6Network.fromString(srcIp.getDestIpAddress());
|
||||
* dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]);
|
||||
* dstIp.setDstIpMask(strangeNetwork.getNetmask().asAddress().toString()); }else
|
||||
* { throw new RuntimeException("Invalid IP/subnet mask format"); } }
|
||||
*/
|
||||
else {
|
||||
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
|
||||
}
|
||||
|
||||
} else {
|
||||
if (srcIp.getIpType() == 4/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6,目的ip为ipv4
|
||||
dstIp.setDstIp(srcIp.getDestIpAddress());
|
||||
dstIp.setDstIpMask("255.255.255.255");
|
||||
} else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4,目的ip为ipv6
|
||||
dstIp.setDstIp(srcIp.getDestIpAddress());
|
||||
dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
|
||||
} /*
|
||||
* else {//all Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
|
||||
* Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP); Matcher
|
||||
* matcherV4=patternV4.matcher(srcIp.getDestIpAddress()); Matcher
|
||||
* matcherV6=patternV6.matcher(srcIp.getDestIpAddress());
|
||||
* if(matcherV4.matches()) { dstIp.setDstIp(srcIp.getDestIpAddress());
|
||||
* dstIp.setDstIpMask("255.255.255.255"); }else if(matcherV6.matches()) {
|
||||
* dstIp.setDstIp(srcIp.getDestIpAddress());
|
||||
* dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); }else { throw
|
||||
* new RuntimeException("invalid ip format"); } }
|
||||
*/
|
||||
else {
|
||||
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (srcIp.getIpType() == 4/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6,目的ip为ipv4
|
||||
dstIp.setDstIp(srcIp.getDestIpAddress());
|
||||
dstIp.setDstIpMask("255.255.255.255");
|
||||
} else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4,目的ip为ipv6
|
||||
}else if(srcIp.getDestIpPattern().equals(1)) {// IP/掩码
|
||||
IPv6Network strangeNetwork = IPv6Network.fromString(srcIp.getDestIpAddress());
|
||||
dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]);
|
||||
dstIp.setDstIpMask(strangeNetwork.getNetmask().asAddress().toString());
|
||||
}else {// IP
|
||||
dstIp.setDstIp(srcIp.getDestIpAddress());
|
||||
dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
|
||||
} /*
|
||||
* else {//all dstIp.setDstIp(srcIp.getDestIpAddress());
|
||||
* dstIp.setDstIpMask("255.255.255.255"); }
|
||||
*/
|
||||
else {
|
||||
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
|
||||
}
|
||||
}
|
||||
if (srcIp.getSrcPort() != null) {
|
||||
if (srcIp.getSrcPort().indexOf("/") != -1) {
|
||||
String srcMaskNum = srcIp.getSrcPort().split("/")[1];
|
||||
dstIp.setSrcPortMask(srcMaskNum);
|
||||
dstIp.setSrcPort(srcIp.getSrcPort().split("/")[0]);
|
||||
} else {
|
||||
dstIp.setSrcPort(srcIp.getSrcPort());
|
||||
dstIp.setSrcPortMask("65535");
|
||||
}
|
||||
} else {
|
||||
dstIp.setSrcPort("0");
|
||||
dstIp.setSrcPortMask("65535");
|
||||
}
|
||||
if (srcIp.getDestPort() != null) {
|
||||
if (srcIp.getDestPort().indexOf("/") != -1) {
|
||||
String dstMaskNum = srcIp.getDestPort().split("/")[1];
|
||||
dstIp.setDstPortMask(dstMaskNum);
|
||||
dstIp.setDstPort(srcIp.getDestPort().split("/")[0]);
|
||||
} else {
|
||||
dstIp.setDstPort(srcIp.getDestPort());
|
||||
dstIp.setDstPortMask("65535");
|
||||
}
|
||||
} else {
|
||||
dstIp.setDstPort("0");
|
||||
dstIp.setDstPortMask("65535");
|
||||
dstIp.setDstIp("::");
|
||||
dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
|
||||
}
|
||||
convertPortValues(dstIp, srcIp);
|
||||
ipConvertList.add(dstIp);
|
||||
}else {
|
||||
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
|
||||
}
|
||||
return ipConvertList;
|
||||
}
|
||||
@@ -2596,7 +2495,15 @@ public abstract class BaseService {
|
||||
if(_cfg.getAction().equals(Constants.MONIT_ACTION)) {
|
||||
maatCfg.setUserRegion(Constants.INTERCEPT_IP_MONIT_USER_REGION_KEY+"="+Constants.USER_REGION_PLACEHOLDER);
|
||||
}*/
|
||||
maatCfg.setUserRegion(Constants.INTERCEPT_IP_RATELIMIT_DROPRATE_USER_REGION_KEY+"="+_cfg.getUserRegion2());
|
||||
if(serviceDict!=null&&serviceDict.getAction().equals(Constants.MONIT_ACTION)) {// 监测 需要发keyring_id、拦截强度
|
||||
_cfg.setUserRegion1(StringUtil.isEmpty(_cfg.getUserRegion1()) ? "0":_cfg.getUserRegion1());
|
||||
_cfg.setUserRegion5(StringUtil.isEmpty(_cfg.getUserRegion5()) ? "1":_cfg.getUserRegion5());
|
||||
maatCfg.setUserRegion(Constants.INTERCEPT_IP_MONIT_USER_REGION_KEY+"=0"+";"+Constants.INTERCEPT_DOMAN_INTENSITY_USER_REGION_KEY+"="+_cfg.getUserRegion5());
|
||||
}
|
||||
if(serviceDict!=null&&serviceDict.getAction().equals(64)) {
|
||||
maatCfg.setUserRegion(Constants.INTERCEPT_IP_RATELIMIT_DROPRATE_USER_REGION_KEY+"="+_cfg.getUserRegion2());
|
||||
}
|
||||
|
||||
}else if(regionDict.getFunctionId()==207 || regionDict.getFunctionId()==208 || regionDict.getFunctionId()==209) {// HTTP(s)阻断、重定向、替换
|
||||
String userRegion = Constants.USER_REGION_PLACEHOLDER;
|
||||
if(_cfg.getAction().equals(Constants.REJECT_ACTION)) {// 阻断
|
||||
@@ -3033,6 +2940,140 @@ public abstract class BaseService {
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 新增:修改旧的定时任务为无效(实际不需要)--》新增sche(1)用于生成新的定时任务trigger(清理旧定时任务的trigger)
|
||||
* 修改:修改旧的定时任务为无效--》新增sche(1)用于生成新的定时任务trigger(清理旧定时任务的trigger)
|
||||
* 审核通过:不需要操作
|
||||
* 审核不通过:修改旧的定时任务为无效--》新增sche(0)用于清理旧定时任务的trigger
|
||||
* 配置取消:修改旧的定时任务为无效--》新增sche(0)用于清理旧定时任务的trigger
|
||||
* 删除:修改旧的定时任务为无效--》新增sche(0)用于清理旧定时任务的trigger
|
||||
* @param parameterObject
|
||||
* @param tableName
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void handelScheduleCfg(Object parameterObject,String tableName){
|
||||
logger.info("handelScheduleCfg==》开始处理定时任务");
|
||||
List<BaseCfg> cfgList = Lists.newArrayList();
|
||||
//确保 单个,批量都适用
|
||||
if(parameterObject instanceof BaseCfg<?>) {//单个添加
|
||||
BaseCfg<?> baseCfg = (BaseCfg<?>)parameterObject;
|
||||
cfgList.add(baseCfg);
|
||||
}else if(parameterObject instanceof Collection) {
|
||||
Collection<BaseCfg<?>> bcCollection = (Collection<BaseCfg<?>>)parameterObject;
|
||||
cfgList.addAll(bcCollection);
|
||||
}else if(parameterObject.getClass().isArray()) {
|
||||
int length = Array.getLength(parameterObject);
|
||||
for(int i = 0;i< length;i++) {
|
||||
BaseCfg<?> baseCfg = (BaseCfg<?>)Array.get(parameterObject, i);
|
||||
cfgList.add(baseCfg);
|
||||
}
|
||||
}
|
||||
|
||||
//存放需要删除的定时任务(根据compileId删除之前所有的定时任务)
|
||||
String compileIds="";
|
||||
//存放需要删除的定时任务trigger的sche
|
||||
List<ScheduleCfg> delScheduleList = Lists.newArrayList();
|
||||
//存放需要新增的定时任务
|
||||
List<ScheduleCfg> addScheduleList = Lists.newArrayList();
|
||||
|
||||
for(BaseCfg<?> baseCfg : cfgList) {
|
||||
//定时任务删除需要新增一条无效的sche用来清理旧的trigger
|
||||
if(baseCfg.getIsValid()==-1 || baseCfg.getIsAudit()==2 || baseCfg.getIsAudit()==3) {
|
||||
ScheduleCfg scheduleCfgdel =new ScheduleCfg();
|
||||
scheduleCfgdel.setDelFlag(0);
|
||||
scheduleCfgdel.setType(1);
|
||||
scheduleCfgdel.setTableName(tableName);
|
||||
scheduleCfgdel.setName("DELETE TRIGGER SCHE");
|
||||
scheduleCfgdel.setCompileId(baseCfg.getCompileId());
|
||||
scheduleCfgdel.setFunctionId(baseCfg.getFunctionId());
|
||||
scheduleCfgdel.setIsValid(baseCfg.getIsValid());
|
||||
scheduleCfgdel.setIsAudit(baseCfg.getIsAudit());
|
||||
scheduleCfgdel.setCfgId(baseCfg.getCfgId());
|
||||
scheduleCfgdel.setCreateTime(new Date());
|
||||
scheduleCfgdel.setCreatorId(UserUtils.getUser().getId());
|
||||
scheduleCfgdel.setServiceId(baseCfg.getServiceId());
|
||||
delScheduleList.add(scheduleCfgdel);
|
||||
}else {
|
||||
//有新的定时任务时,不需要在新增无效sche来清理旧的trigger,扫描到新增的sche时,也会有清理操作
|
||||
ScheduleCfg scheduleCfgAdd = copyScheduleCfgFromBaseCfg(baseCfg, tableName);
|
||||
if(scheduleCfgAdd!=null){
|
||||
scheduleCfgAdd.setIsValid(0);
|
||||
scheduleCfgAdd.setIsAudit(0);
|
||||
scheduleCfgAdd.setDelFlag(1);
|
||||
addScheduleList.add(scheduleCfgAdd);
|
||||
}
|
||||
}
|
||||
compileIds+=baseCfg.getCompileId()+",";
|
||||
|
||||
}
|
||||
|
||||
//将之前的定时任务置为无效
|
||||
if(!StringUtil.isEmpty(compileIds)) {
|
||||
compileIds=compileIds.substring(0,compileIds.length()-1);
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try {
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
((SchedulerDao) batchSqlSession.getMapper(SchedulerDao.class)).deleteByCompileIds(compileIds.toString());
|
||||
batchSqlSession.commit();
|
||||
} finally {
|
||||
if(batchSqlSession != null) {
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
//新增sche,用于删除旧的定时任务
|
||||
if(!StringUtil.isEmpty(delScheduleList)) {
|
||||
compileIds=compileIds.substring(0,compileIds.length()-1);
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try {
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for(ScheduleCfg entity : delScheduleList) {
|
||||
((SchedulerDao) batchSqlSession.getMapper(SchedulerDao.class)).insert(entity);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
} finally {
|
||||
if(batchSqlSession != null) {
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//新增sche,用于新增新定时任务
|
||||
if(!StringUtil.isEmpty(addScheduleList)) {
|
||||
compileIds=compileIds.substring(0,compileIds.length()-1);
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try {
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for(ScheduleCfg entity : addScheduleList) {
|
||||
((SchedulerDao) batchSqlSession.getMapper(SchedulerDao.class)).insert(entity);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
} finally {
|
||||
if(batchSqlSession != null) {
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.info("handelScheduleCfg==》定时任务处理完成");
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 basecfg 实体类中获取 schedule cfg
|
||||
* @param baseCfg
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
private ScheduleCfg copyScheduleCfgFromBaseCfg(BaseCfg<?> baseCfg,String tableName){
|
||||
ScheduleCfg schedule = baseCfg.getSchedule();
|
||||
if(schedule != null ) {
|
||||
BeanUtils.copyProperties(baseCfg, schedule,new String[]{"userRegion1","userRegion2","userRegion3","userRegion4","userRegion5"});
|
||||
schedule.setTableName(tableName);
|
||||
schedule.setType(1);
|
||||
}
|
||||
return schedule;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
c.initDefaultValue();
|
||||
BeanUtils.copyProperties(cfg, c,new String[]{"cfgId","ipType","direction",
|
||||
"protocol","protocolId","areaEffectiveIds","cfgRegionCode",
|
||||
"cfgType","ipPattern","srcIpAddress","portPattern","srcPort","destIpAddress","destPort"});
|
||||
"cfgType","srcIpPattern","destIpPattern","srcIpAddress","srcPortPattern","destPortPattern","srcPort","destIpAddress","destPort"});
|
||||
c.setTableName(AreaIpCfg.getTablename());
|
||||
}
|
||||
this.saveIpBatch(cfg.getAreaCfg());
|
||||
@@ -194,6 +194,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
|
||||
}
|
||||
//TODO 处理定时任务【如果有定时任务则新增】
|
||||
handelScheduleCfg(entity, entity.getIndexTable());
|
||||
|
||||
if(isValid==1) {
|
||||
entity.setIsAudit(1);
|
||||
entity.setIsValid(1);
|
||||
@@ -273,6 +275,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
|
||||
}
|
||||
//TODO 处理定时任务【如果有定时任务则删除旧的,新增新的】
|
||||
handelScheduleCfg(entity, entity.getIndexTable());
|
||||
|
||||
if(isValid==1) {
|
||||
entity.setIsAudit(1);
|
||||
entity.setIsValid(1);
|
||||
@@ -320,9 +324,9 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
cfg.setTableName(AreaIpCfg.getTablename());
|
||||
ipCfgDao.updateCfgValid(cfg);
|
||||
}
|
||||
|
||||
//TODO 处理定时任务【如果有定时任务则删除旧的,新增新的】
|
||||
handelScheduleCfg(entity, entity.getIndexTable());
|
||||
}
|
||||
//TODO 处理定时任务【如果有定时任务则删除】
|
||||
|
||||
}
|
||||
/**
|
||||
@@ -349,7 +353,7 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
c.initDefaultValue();
|
||||
BeanUtils.copyProperties(cfg, c,new String[]{"cfgId","ipType","direction",
|
||||
"protocol","protocolId","areaEffectiveIds","cfgRegionCode",
|
||||
"cfgType","ipPattern","srcIpAddress","portPattern","srcPort","destIpAddress","destPort"});
|
||||
"cfgType","srcIpPattern","destIpPattern","srcIpAddress","srcPortPattern","destPortPattern","srcPort","destIpAddress","destPort"});
|
||||
c.setTableName(AreaIpCfg.getTablename());
|
||||
c.setCreatorId(cfg.getCurrentUser().getId());
|
||||
c.setCreateTime(date);
|
||||
@@ -371,9 +375,11 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
,"cfgType"
|
||||
,"cfgId"
|
||||
,"ipType"
|
||||
,"ipPattern"
|
||||
,"srcIpPattern"
|
||||
,"destIpPattern"
|
||||
,"srcIpAddress"
|
||||
,"portPattern"
|
||||
,"srcPortPattern"
|
||||
,"destPortPattern"
|
||||
,"srcPort"
|
||||
,"destPort"
|
||||
,"protocol"
|
||||
@@ -638,7 +644,12 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
areaIpRegionList=map.get("dstList");
|
||||
}
|
||||
}
|
||||
//TODO 处理定时任务【审核通过-》增加一条sche_new;审核不通过-》增加一条sche0,2,sche旧的置为无效;配置取消-》增加一条0,3,sche旧的置为无效】。
|
||||
|
||||
if(isAudit!=1) {
|
||||
//处理定时任务【如果有定时任务则删除旧的,新增新的】
|
||||
handelScheduleCfg(entity, entity.getIndexTable());
|
||||
}
|
||||
|
||||
//构造提交综合服务参数格式,一条配置提交一次综合服务
|
||||
if(isAudit==1){
|
||||
if(maatType==Constants.CALLBACK_TYPE){
|
||||
@@ -704,7 +715,7 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
}else {
|
||||
throw new RuntimeException("<spring:message code=\"request_service_failed\"/>:"+props.getProperty("unknown_cfg_type"));
|
||||
}
|
||||
}else if(isAudit==3){
|
||||
}else if(isAudit==3 && entity.getIsValid()==1){
|
||||
if(maatType==Constants.CALLBACK_TYPE){
|
||||
List<InlineIp> ipList=new ArrayList<>();
|
||||
for(IpPortCfg cfg :entity.getIpPortList()) {
|
||||
|
||||
@@ -1255,8 +1255,9 @@ user_behavior_data=\u7528\u6237\u7edf\u8ba1
|
||||
ip_behavior_data=\u7528\u6237IP\u7edf\u8ba1
|
||||
not_valid_domain=%s\u4e0d\u662f\u4e00\u4e2a\u5408\u6cd5\u57df\u540d
|
||||
cert_not_match_domain=\u57df\u540d\u4e0e\u6240\u9009\u8bc1\u4e66\u4fe1\u606f\u4e0d\u7b26\u5408\uff01
|
||||
crl_file_error=CRL\u6587\u4ef6\u683c\u5f0f\u9519\u8bef
|
||||
certificate_file_error=\u8BC1\u4E66\u683C\u5F0F\u9519\u8BEF
|
||||
PXY_OBJ_TRUSTED_CA_CERT=\u53ef\u4fe1\u8bc1\u4e66
|
||||
crl_file_error=CRL\u6587\u4EF6\u683C\u5F0F\u9519\u8BEF
|
||||
crl_issuer_error=crl\u6587\u4ef6\u7684issuer\u4e0e\u8bc1\u4e66\u6587\u4ef6\u7684issuer\u4e0d\u5339\u914d
|
||||
cert_name=\u8bc1\u4e66\u540d\u79f0
|
||||
add_crl_file=Add CRL File
|
||||
@@ -1507,4 +1508,10 @@ interface_total=\u754c\u9762\u603b\u91cf
|
||||
service_total=\u670d\u52a1\u603b\u91cf
|
||||
unapproved_all=\u5ba1\u6838\u4E0D\u901a\u8fc7\u6240\u6709\u914d\u7f6e!
|
||||
delete_all=\u5220\u9664\u6240\u6709\u914d\u7f6e!
|
||||
none_file_tip=\u8BF7\u9009\u62E9\u6587\u4EF6!
|
||||
none_file_tip=\u8BF7\u9009\u62E9\u6587\u4EF6!
|
||||
the_same_ip_type=\u6e90IP\u4e0e\u76ee\u7684IP\u7684IP\u7c7b\u578b\u5fc5\u987b\u76f8\u540c
|
||||
src_ip_pattern=\u6E90IP\u683C\u5F0F
|
||||
dest_ip_pattern=\u76EE\u7684IP\u683C\u5F0F
|
||||
src_port_pattern=\u6E90\u7AEF\u53E3\u683C\u5F0F
|
||||
dest_port_pattern=\u76EE\u7684\u7AEF\u53E3\u683C\u5F0F
|
||||
range_cross=\u6E90IP\u4E0E\u76EE\u7684IP\u8303\u56F4\u6709\u4EA4\u53C9
|
||||
Reference in New Issue
Block a user