ip模板提交
样例的level改成下拉选项 拦截强度做成下拉选项
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.nis.web.controller;
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@@ -49,6 +50,7 @@ import com.nis.domain.configuration.RequestInfo;
|
||||
import com.nis.domain.configuration.StringCfgTemplate;
|
||||
import com.nis.domain.configuration.template.IpAllTemplate;
|
||||
import com.nis.domain.configuration.template.IpCfgTemplate;
|
||||
import com.nis.domain.configuration.template.IpRateLimitTemplate;
|
||||
import com.nis.domain.log.BaseLogEntity;
|
||||
import com.nis.domain.log.SearchReport;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
@@ -614,17 +616,17 @@ public class BaseController {
|
||||
if(dict.getRegionType()==1){
|
||||
List<IpCfgTemplate> list = Lists.newArrayList();
|
||||
list.add(new IpCfgTemplate());
|
||||
new ExportExcel(new FunctionRegionDict(),msgProp,null, IpCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
||||
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 FunctionRegionDict(),msgProp,null, StringCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
||||
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 FunctionRegionDict(),msgProp,null, ComplexStringCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
||||
new ExportExcel(new FunctionServiceDict(),new FunctionRegionDict(),msgProp,null, ComplexStringCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
||||
write(request,response, fileName).dispose();
|
||||
}
|
||||
}
|
||||
@@ -646,17 +648,17 @@ public class BaseController {
|
||||
if(dict.getRegionType()==1){
|
||||
List<IpCfgTemplate> list = Lists.newArrayList();
|
||||
list.add((IpCfgTemplate)clazz.newInstance());
|
||||
new ExportExcel(new FunctionRegionDict(),msgProp,null, clazz, 2).setDataList(msgProp,list,null).
|
||||
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 FunctionRegionDict(),msgProp,null, clazz, 2).setDataList(msgProp,list,null).
|
||||
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 FunctionRegionDict(),msgProp,null, clazz, 2).setDataList(msgProp,list,null).
|
||||
new ExportExcel(new FunctionServiceDict(),new FunctionRegionDict(),msgProp,null, clazz, 2).setDataList(msgProp,list,null).
|
||||
write(request,response, fileName).dispose();
|
||||
}
|
||||
}
|
||||
@@ -788,53 +790,51 @@ public class BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
public List<BaseIpCfg> checkIpCfg(FunctionServiceDict serviceDict,FunctionRegionDict regionDict,List<IpAllTemplate> list) throws ServiceException{
|
||||
public List<BaseIpCfg> checkIpCfg(FunctionServiceDict serviceDict,FunctionRegionDict regionDict,List<?> list) throws ServiceException{
|
||||
List<BaseIpCfg> ipList=new ArrayList<BaseIpCfg>();
|
||||
Properties prop=this.getMsgProp();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
IpAllTemplate ipCfg=list.get(i);
|
||||
IpPortCfg baseIpCfg=new IpPortCfg();
|
||||
baseIpCfg.setCfgDesc(ipCfg.getCfgDesc());
|
||||
if(regionDict.getIsMaat().equals(1)){
|
||||
BeanUtils.copyProperties(list.get(i), baseIpCfg);
|
||||
if(regionDict.getRegionType().equals(1)){
|
||||
boolean srcIpEmpty=false;
|
||||
boolean srcPortEmpty=false;
|
||||
if(StringUtil.isEmpty(ipCfg.getSrcIpAddress())){
|
||||
if(StringUtil.isEmpty(baseIpCfg.getSrcIpAddress())){
|
||||
srcIpEmpty=true;
|
||||
}
|
||||
if(StringUtil.isEmpty(ipCfg.getDestIpAddress())){
|
||||
if(StringUtil.isEmpty(baseIpCfg.getDestIpAddress())){
|
||||
if(srcIpEmpty){
|
||||
baseIpCfg.setSrcIpAddress("0.0.0.0");
|
||||
baseIpCfg.setDestIpAddress("0.0.0.0");
|
||||
baseIpCfg.setIpPattern(3);
|
||||
baseIpCfg.setIpType(4);
|
||||
}else{
|
||||
if(ipCfg.getSrcIpAddress().indexOf(":") > -1){
|
||||
if(ipCfg.getSrcIpAddress().indexOf("-") > -1){
|
||||
baseIpCfg.setSrcIpAddress(ipCfg.getSrcIpAddress());
|
||||
if(baseIpCfg.getSrcIpAddress().indexOf(":") > -1){
|
||||
if(baseIpCfg.getSrcIpAddress().indexOf("-") > -1){
|
||||
baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress("::-::");
|
||||
baseIpCfg.setIpPattern(2);
|
||||
}else if(ipCfg.getSrcIpAddress().indexOf("/") > -1){
|
||||
baseIpCfg.setSrcIpAddress(ipCfg.getSrcIpAddress());
|
||||
}else if(baseIpCfg.getSrcIpAddress().indexOf("/") > -1){
|
||||
baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress("::/128");
|
||||
baseIpCfg.setIpPattern(1);
|
||||
}else{
|
||||
baseIpCfg.setSrcIpAddress(ipCfg.getSrcIpAddress());
|
||||
baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress("::");
|
||||
baseIpCfg.setIpPattern(3);
|
||||
}
|
||||
baseIpCfg.setIpType(6);
|
||||
}else{
|
||||
if(ipCfg.getSrcIpAddress().indexOf("-") > -1){
|
||||
baseIpCfg.setSrcIpAddress("0.0.0.0-"+ipCfg.getSrcIpAddress().split("-")[0].substring(0,ipCfg.getSrcIpAddress().indexOf("-")+1)+ipCfg.getSrcIpAddress().split("-")[1]);
|
||||
if(baseIpCfg.getSrcIpAddress().indexOf("-") > -1){
|
||||
baseIpCfg.setSrcIpAddress("0.0.0.0-"+baseIpCfg.getSrcIpAddress().split("-")[0].substring(0,baseIpCfg.getSrcIpAddress().indexOf("-")+1)+baseIpCfg.getSrcIpAddress().split("-")[1]);
|
||||
baseIpCfg.setDestIpAddress("0.0.0.0-0.0.0.0");
|
||||
baseIpCfg.setIpPattern(2);
|
||||
}else if(ipCfg.getSrcIpAddress().indexOf("/") > -1){
|
||||
baseIpCfg.setSrcIpAddress(ipCfg.getSrcIpAddress());
|
||||
}else if(baseIpCfg.getSrcIpAddress().indexOf("/") > -1){
|
||||
baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress("0.0.0.0/16");
|
||||
baseIpCfg.setIpPattern(1);
|
||||
}else{
|
||||
baseIpCfg.setSrcIpAddress(ipCfg.getSrcIpAddress());
|
||||
baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress("0.0.0.0");
|
||||
baseIpCfg.setIpPattern(3);
|
||||
}
|
||||
@@ -843,48 +843,50 @@ public class BaseController {
|
||||
}
|
||||
} else{
|
||||
if(srcIpEmpty){
|
||||
if(ipCfg.getDestIpAddress().indexOf(":") > -1){
|
||||
if(ipCfg.getDestIpAddress().indexOf("-") > -1){
|
||||
baseIpCfg.setDestIpAddress(ipCfg.getDestIpAddress());
|
||||
if(baseIpCfg.getDestIpAddress().indexOf(":") > -1){
|
||||
if(baseIpCfg.getDestIpAddress().indexOf("-") > -1){
|
||||
baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
|
||||
baseIpCfg.setSrcIpAddress("::-::");
|
||||
baseIpCfg.setIpPattern(2);
|
||||
}else if(ipCfg.getDestIpAddress().indexOf("/") > -1){
|
||||
baseIpCfg.setDestIpAddress(ipCfg.getDestIpAddress());
|
||||
}else if(baseIpCfg.getDestIpAddress().indexOf("/") > -1){
|
||||
baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
|
||||
baseIpCfg.setSrcIpAddress("::/128");
|
||||
baseIpCfg.setIpPattern(1);
|
||||
}else{
|
||||
baseIpCfg.setDestIpAddress(ipCfg.getDestIpAddress());
|
||||
baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
|
||||
baseIpCfg.setSrcIpAddress("::");
|
||||
baseIpCfg.setIpPattern(3);
|
||||
}
|
||||
baseIpCfg.setIpType(6);
|
||||
}else{
|
||||
if(ipCfg.getDestIpAddress().indexOf("-") > -1){
|
||||
baseIpCfg.setDestIpAddress("0.0.0.0-"+ipCfg.getDestIpAddress().split("-")[0].substring(0,ipCfg.getDestIpAddress().indexOf("-")+1)+ipCfg.getDestIpAddress().split("-")[1]);
|
||||
if(baseIpCfg.getDestIpAddress().indexOf("-") > -1){
|
||||
baseIpCfg.setDestIpAddress("0.0.0.0-"+baseIpCfg.getDestIpAddress().split("-")[0]
|
||||
.substring(0,baseIpCfg.getDestIpAddress().indexOf("-")+1)
|
||||
+baseIpCfg.getDestIpAddress().split("-")[1]);
|
||||
baseIpCfg.setSrcIpAddress("0.0.0.0-0.0.0.0");
|
||||
baseIpCfg.setIpPattern(2);
|
||||
}else if(ipCfg.getDestIpAddress().indexOf("/") > -1){
|
||||
baseIpCfg.setDestIpAddress(ipCfg.getDestIpAddress());
|
||||
}else if(baseIpCfg.getDestIpAddress().indexOf("/") > -1){
|
||||
baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
|
||||
baseIpCfg.setSrcIpAddress("0.0.0.0/16");
|
||||
baseIpCfg.setIpPattern(1);
|
||||
}else{
|
||||
baseIpCfg.setDestIpAddress(ipCfg.getDestIpAddress());
|
||||
baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
|
||||
baseIpCfg.setSrcIpAddress("0.0.0.0");
|
||||
baseIpCfg.setIpPattern(3);
|
||||
}
|
||||
baseIpCfg.setIpType(4);
|
||||
}
|
||||
}else{
|
||||
baseIpCfg.setSrcIpAddress(ipCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress(ipCfg.getDestIpAddress());
|
||||
if(ipCfg.getSrcIpAddress().indexOf(":") > -1){
|
||||
baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
|
||||
if(baseIpCfg.getSrcIpAddress().indexOf(":") > -1){
|
||||
baseIpCfg.setIpType(6);
|
||||
}else{
|
||||
baseIpCfg.setIpType(4);
|
||||
}
|
||||
if(ipCfg.getSrcIpAddress().indexOf("-") > -1){
|
||||
if(baseIpCfg.getSrcIpAddress().indexOf("-") > -1){
|
||||
baseIpCfg.setIpPattern(2);
|
||||
}else if(ipCfg.getSrcIpAddress().indexOf("/") > -1){
|
||||
}else if(baseIpCfg.getSrcIpAddress().indexOf("/") > -1){
|
||||
baseIpCfg.setIpPattern(1);
|
||||
}else{
|
||||
baseIpCfg.setIpPattern(3);
|
||||
@@ -895,49 +897,49 @@ public class BaseController {
|
||||
//TODO 判断源IP和目的IP的值
|
||||
//TODO 判断源IP和目的IP格式
|
||||
|
||||
if(StringUtil.isEmpty(ipCfg.getSrcPort())){
|
||||
if(StringUtil.isEmpty(baseIpCfg.getSrcPort())){
|
||||
srcPortEmpty=true;
|
||||
}
|
||||
if(StringUtil.isEmpty(ipCfg.getDestPort())){
|
||||
if(StringUtil.isEmpty(baseIpCfg.getDestPort())){
|
||||
if(srcPortEmpty){
|
||||
baseIpCfg.setSrcPort("0");
|
||||
baseIpCfg.setDestPort("0");
|
||||
baseIpCfg.setPortPattern(1);
|
||||
}else{
|
||||
if(ipCfg.getSrcPort().indexOf("/") > -1){
|
||||
if(baseIpCfg.getSrcPort().indexOf("/") > -1){
|
||||
baseIpCfg.setDestPort("0/0");
|
||||
baseIpCfg.setPortPattern(2);
|
||||
}else{
|
||||
baseIpCfg.setDestPort("0");
|
||||
baseIpCfg.setPortPattern(1);
|
||||
}
|
||||
baseIpCfg.setSrcPort(ipCfg.getSrcPort());
|
||||
baseIpCfg.setSrcPort(baseIpCfg.getSrcPort());
|
||||
}
|
||||
}else{
|
||||
if(srcPortEmpty){
|
||||
if(ipCfg.getDestPort().indexOf("/") > -1){
|
||||
if(baseIpCfg.getDestPort().indexOf("/") > -1){
|
||||
baseIpCfg.setSrcPort("0/0");
|
||||
baseIpCfg.setPortPattern(2);
|
||||
}else{
|
||||
baseIpCfg.setSrcPort("0");
|
||||
baseIpCfg.setPortPattern(1);
|
||||
}
|
||||
baseIpCfg.setDestPort(ipCfg.getSrcPort());
|
||||
baseIpCfg.setDestPort(baseIpCfg.getSrcPort());
|
||||
}else{
|
||||
if(ipCfg.getSrcPort().indexOf("/") > -1){
|
||||
if(baseIpCfg.getSrcPort().indexOf("/") > -1){
|
||||
baseIpCfg.setPortPattern(2);
|
||||
}else{
|
||||
baseIpCfg.setPortPattern(1);
|
||||
}
|
||||
baseIpCfg.setSrcPort(ipCfg.getSrcPort());
|
||||
baseIpCfg.setDestPort(ipCfg.getDestPort());
|
||||
baseIpCfg.setSrcPort(baseIpCfg.getSrcPort());
|
||||
baseIpCfg.setDestPort(baseIpCfg.getDestPort());
|
||||
|
||||
}
|
||||
}
|
||||
//TODO 判断源端口和目的端口格式
|
||||
//TODO 判断源和目的端口的值
|
||||
|
||||
if(StringUtil.isEmpty(ipCfg.getProtocol())){
|
||||
if(StringUtil.isEmpty(baseIpCfg.getProtocol())){
|
||||
if(StringUtil.isEmpty(regionDict.getConfigProtocol())){
|
||||
baseIpCfg.setProtocol(0);
|
||||
}else{
|
||||
@@ -945,24 +947,23 @@ public class BaseController {
|
||||
}
|
||||
baseIpCfg.setProtocolId(serviceDict.getProtocolId());
|
||||
}else{
|
||||
baseIpCfg.setProtocol(ipCfg.getProtocol());
|
||||
baseIpCfg.setProtocol(baseIpCfg.getProtocol());
|
||||
baseIpCfg.setProtocolId(serviceDict.getProtocolId());
|
||||
}
|
||||
//TODO 判断Protocol的值
|
||||
|
||||
if(StringUtil.isEmpty(ipCfg.getDirection())){
|
||||
if(StringUtil.isEmpty(baseIpCfg.getDirection())){
|
||||
if(StringUtil.isEmpty(regionDict.getConfigDirection())){
|
||||
baseIpCfg.setDirection(0);
|
||||
}else{
|
||||
baseIpCfg.setDirection(Integer.parseInt(regionDict.getConfigDirection().split(",")[0]));
|
||||
}
|
||||
}else{
|
||||
baseIpCfg.setDirection(ipCfg.getDirection());
|
||||
baseIpCfg.setDirection(baseIpCfg.getDirection());
|
||||
}
|
||||
|
||||
//TODO 判断Direction的值
|
||||
}
|
||||
}
|
||||
ipList.add(baseIpCfg);
|
||||
}
|
||||
return ipList;
|
||||
@@ -2159,40 +2160,48 @@ public class BaseController {
|
||||
ImportExcel ei = new ImportExcel(file, 0, 0);
|
||||
|
||||
FunctionRegionDict regionDict=DictUtils.getFunctionRegionDict(Integer.parseInt(regionDictIds.split(",")[i]));
|
||||
|
||||
if(regionDict.getIsMaat().equals(1)){
|
||||
if(regionDict.getRegionType().equals(1)){
|
||||
List<IpAllTemplate> list = ei.getDataList(IpAllTemplate.class);
|
||||
ipPortCfgs=this.checkIpCfg(serviceDict,regionDict,list);
|
||||
Date date=new Date();
|
||||
for(BaseIpCfg cfg : ipPortCfgs){
|
||||
CfgIndexInfo cfgIndexInfo=new CfgIndexInfo();
|
||||
cfg.setAction(serviceDict.getAction());
|
||||
cfg.setAuditorId(UserUtils.getUser().getId());
|
||||
cfg.setAuditTime(date);
|
||||
cfg.setCfgRegionCode(regionDict.getConfigRegionCode());
|
||||
cfg.setCfgType(regionDict.getConfigRegionValue());
|
||||
cfg.setCreateTime(date);
|
||||
cfg.setCreatorId(UserUtils.getUser().getId());
|
||||
cfg.setDoLog(1);
|
||||
cfg.setFunctionId(regionDict.getFunctionId());
|
||||
cfg.setIsAudit(0);
|
||||
cfg.setIsValid(0);
|
||||
cfg.setIsAreaEffective(0);
|
||||
cfg.setAttribute("0");
|
||||
cfg.setClassify("0");
|
||||
cfg.setLable("0");
|
||||
cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0:requestId);
|
||||
cfg.setServiceId(serviceDict.getServiceId());
|
||||
cfg.setTableName("ip_port_cfg");
|
||||
cfg.setCompileId(ipCfgService.getCompileId());
|
||||
|
||||
BeanUtils.copyProperties(cfg, cfgIndexInfo);
|
||||
cfgIndexInfos.add(cfgIndexInfo);
|
||||
if(regionDict.getFunctionId().equals(5) ){
|
||||
if(serviceDict.getAction().equals(64)){//ip
|
||||
if(regionDict.getRegionType().equals(1)){
|
||||
List<IpRateLimitTemplate> list = ei.getDataList(IpRateLimitTemplate.class);
|
||||
ipPortCfgs=this.checkIpCfg(serviceDict,regionDict,list);
|
||||
}
|
||||
}else{
|
||||
if(regionDict.getRegionType().equals(1)){
|
||||
List<IpAllTemplate> list = ei.getDataList(IpAllTemplate.class);
|
||||
ipPortCfgs=this.checkIpCfg(serviceDict,regionDict,list);
|
||||
}
|
||||
}
|
||||
}else if(regionDict.getRegionType().equals(1)){
|
||||
List<IpAllTemplate> list = ei.getDataList(IpAllTemplate.class);
|
||||
ipPortCfgs=this.checkIpCfg(serviceDict,regionDict,list);
|
||||
}
|
||||
Date date=new Date();
|
||||
for(BaseIpCfg cfg : ipPortCfgs){
|
||||
CfgIndexInfo cfgIndexInfo=new CfgIndexInfo();
|
||||
cfg.setAction(serviceDict.getAction());
|
||||
cfg.setAuditorId(UserUtils.getUser().getId());
|
||||
cfg.setAuditTime(date);
|
||||
cfg.setCfgRegionCode(regionDict.getConfigRegionCode());
|
||||
cfg.setCfgType(regionDict.getConfigRegionValue());
|
||||
cfg.setCreateTime(date);
|
||||
cfg.setCreatorId(UserUtils.getUser().getId());
|
||||
cfg.setDoLog(1);
|
||||
cfg.setFunctionId(regionDict.getFunctionId());
|
||||
cfg.setIsAudit(0);
|
||||
cfg.setIsValid(0);
|
||||
cfg.setIsAreaEffective(0);
|
||||
cfg.setAttribute("0");
|
||||
cfg.setClassify("0");
|
||||
cfg.setLable("0");
|
||||
cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0:requestId);
|
||||
cfg.setServiceId(serviceDict.getServiceId());
|
||||
cfg.setTableName("ip_port_cfg");
|
||||
cfg.setCompileId(ipCfgService.getCompileId());
|
||||
|
||||
BeanUtils.copyProperties(cfg, cfgIndexInfo);
|
||||
cfgIndexInfos.add(cfgIndexInfo);
|
||||
}
|
||||
|
||||
ipCfgService.saveBatch(ipPortCfgs, IpCfgDao.class);
|
||||
ipCfgService.saveCfgIndexOf(cfgIndexInfos);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user