diff --git a/src/main/java/com/nis/util/excel/ImportExcel.java b/src/main/java/com/nis/util/excel/ImportExcel.java
index f5147571f..05a939490 100644
--- a/src/main/java/com/nis/util/excel/ImportExcel.java
+++ b/src/main/java/com/nis/util/excel/ImportExcel.java
@@ -379,7 +379,7 @@ public class ImportExcel {
if (valType == String.class){
String s = String.valueOf(val.toString());
//0.0.0.0表示任意IP的含义
- if(StringUtils.endsWith(s, ".0") && !s.equals("0.0.0.0")){
+ if(StringUtils.endsWith(s, ".0") && !s.endsWith("0.0.0.0")){
val = StringUtils.substringBefore(s, ".0");
}else{
val = String.valueOf(val.toString());
diff --git a/src/main/java/com/nis/web/controller/BaseController.java b/src/main/java/com/nis/web/controller/BaseController.java
index 1fa03ffed..7d93f7b33 100644
--- a/src/main/java/com/nis/web/controller/BaseController.java
+++ b/src/main/java/com/nis/web/controller/BaseController.java
@@ -1,7 +1,7 @@
package com.nis.web.controller;
+
import java.beans.PropertyEditorSupport;
import java.io.IOException;
-import java.lang.reflect.Field;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -9,7 +9,6 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -110,63 +109,62 @@ import com.nis.web.service.specific.SpecificServiceHostCfgService;
import com.nis.web.service.systemService.ServiceConfigInfoService;
public class BaseController {
-
+
@Autowired
protected UserService userService;
-
+
@Autowired
protected SystemService systemService;
-
+
@Autowired
protected OfficeService officeService;
-
+
@Autowired
protected AreaService areaService;
-
+
@Autowired
protected RoleService roleService;
-
+
@Autowired
protected MenuService menuService;
-
+
@Autowired
protected LogService logService;
-
- @Autowired
+
+ @Autowired
protected ArchiveServcie archiveServcie;
-
- @Autowired
+
+ @Autowired
protected DictService dictService;
-
- @Autowired
+
+ @Autowired
protected IpCfgService ipCfgService;
-
- @Autowired
+
+ @Autowired
protected DnsIpCfgService dnsIpCfgService;
-
- @Autowired
+
+ @Autowired
protected MailCfgService mailCfgService;
-
- @Autowired
+
+ @Autowired
protected FileTransferCfgService fileTransferCfgService;
-
- @Autowired
+
+ @Autowired
protected AppCfgService appCfgService;
- @Autowired
+ @Autowired
protected ControlPolicyService controlPolicyService;
-
-
+
@Autowired
protected ServiceDictInfoService serviceDictInfoService;
-
+
@Autowired
protected SysDictInfoService sysDictInfoService;
-
+
protected final Logger logger = Logger.getLogger(this.getClass());
-
+
@Autowired
protected ServiceConfigInfoService serviceConfigInfoService;
-
+
@Autowired
protected RequestInfoService requestInfoService;
@Autowired
@@ -183,36 +181,36 @@ public class BaseController {
protected AvCfgService avCfgService;
@Autowired
protected AvContentCfgService avContentCfgService;
- @Autowired
+ @Autowired
protected WebsiteCfgService websiteCfgService;
- @Autowired
+ @Autowired
protected BgpCfgService bgpCfgService;
- @Autowired
+ @Autowired
protected XmppCfgService xmppCfgService;
- @Autowired
+ @Autowired
protected PolicyGroupInfoService policyGroupInfoService;
- @Autowired
+ @Autowired
protected DnsResStrategyService dnsResStrategyService;
- @Autowired
+ @Autowired
protected HttpRedirectCfgService httpRedirectCfgService;
@Autowired
protected DdosCfgService ddosCfgService;
- @Autowired
+ @Autowired
protected IpMultiplexPoolCfgService ipMultiplexPoolCfgService;
- @Autowired
+ @Autowired
protected ConfigureStatisticsService configureStatisticsService;
- @Autowired
+ @Autowired
protected InterceptCfgService interceptCfgService;
@Autowired
- protected ProxyFileStrategyService proxyFileStrategyService;//代理文件策略service
+ protected ProxyFileStrategyService proxyFileStrategyService;// 代理文件策略service
@Autowired
- protected PxyObjKeyringService pxyObjKeyringService;//拦截策略service
+ protected PxyObjKeyringService pxyObjKeyringService;// 拦截策略service
@Autowired
- protected AppBuiltInFeatureService appBuiltInFeatureService;//拦截策略service
+ protected AppBuiltInFeatureService appBuiltInFeatureService;// 拦截策略service
@Autowired
- protected AsnIpCfgService asnIpCfgService;//asn ip service
+ protected AsnIpCfgService asnIpCfgService;// asn ip service
@Autowired
- protected AsnPolicyCfgService asnPolicyCfgService;//asn 策略 service
+ protected AsnPolicyCfgService asnPolicyCfgService;// asn 策略 service
@Autowired
protected AppMultiFeatureCfgService appMultiFeatureCfgService;
/**
@@ -220,7 +218,7 @@ public class BaseController {
*/
@Value("${adminPath}")
protected String adminPath;
-
+
/**
* 前端基础路径
*/
@@ -231,10 +229,10 @@ public class BaseController {
*/
@Value("${urlSuffix}")
protected String urlSuffix;
-
-
+
/**
* 客户端返回JSON字符串
+ *
* @param response
* @param object
* @return
@@ -242,10 +240,10 @@ public class BaseController {
protected String renderString(HttpServletResponse response, Object object) {
return renderString(response, JsonMapper.toJsonString(object), "application/json");
}
-
-
+
/**
* 客户端返回字符串
+ *
* @param response
* @param string
* @return
@@ -253,62 +251,63 @@ public class BaseController {
protected String renderString(HttpServletResponse response, String string, String type) {
try {
response.reset();
- response.setContentType(type);
- response.setCharacterEncoding("utf-8");
+ response.setContentType(type);
+ response.setCharacterEncoding("utf-8");
response.getWriter().print(string);
return null;
} catch (IOException e) {
return null;
}
}
-
-
+
/**
* 添加Model消息
+ *
* @param message
*/
protected void addMessage(Model model, String... messages) {
StringBuilder sb = new StringBuilder();
- for (String message : messages){
- sb.append(message).append(messages.length>1?"
":"");
+ for (String message : messages) {
+ sb.append(message).append(messages.length > 1 ? "
" : "");
}
model.addAttribute("message", sb.toString());
}
+
/**
* 添加Model消息 日志用
+ *
* @param message
*/
protected void addMessageLog(Model model, String status) {
- //status 接口状态码
- String messages="search_error";
- if(null!=status){
- if("400".equals(status)){
- messages="data_format_error";
- }else if("500".equals(status)){
- messages="server_internal_error";
- }else if(status.indexOf("request_service_failed")!=-1){
- messages="server_internal_error";
+ // status 接口状态码
+ String messages = "search_error";
+ if (null != status) {
+ if ("400".equals(status)) {
+ messages = "data_format_error";
+ } else if ("500".equals(status)) {
+ messages = "server_internal_error";
+ } else if (status.indexOf("request_service_failed") != -1) {
+ messages = "server_internal_error";
}
}
- model.addAttribute("message",messages);
+ model.addAttribute("message", messages);
}
-
+
/**
* 添加Flash消息
+ *
* @param message
*/
protected void addMessage(RedirectAttributes redirectAttributes, String... messages) {
StringBuilder sb = new StringBuilder();
- for (String message : messages){
- sb.append(message).append(messages.length>1?"
":"");
+ for (String message : messages) {
+ sb.append(message).append(messages.length > 1 ? "
" : "");
}
redirectAttributes.addFlashAttribute("message", sb.toString());
}
-
+
/**
- * 初始化数据绑定
- * 1. 将所有传递进来的String进行HTML编码,防止XSS攻击
- * 2. 将字段中Date类型转换为String类型
+ * 初始化数据绑定 1. 将所有传递进来的String进行HTML编码,防止XSS攻击 2. 将字段中Date类型转换为String类型
*/
@InitBinder
protected void initBinder(WebDataBinder binder) {
@@ -318,6 +317,7 @@ public class BaseController {
public void setAsText(String text) {
setValue(text == null ? null : StringEscapeUtils.escapeHtml4(text.trim()));
}
+
@Override
public String getAsText() {
Object value = getValue();
@@ -332,54 +332,56 @@ public class BaseController {
}
});
}
- protected void initPageCondition(Model model){
- List requestInfos=requestInfoService.getAllRequestInfo();
+
+ protected void initPageCondition(Model model) {
+ List requestInfos = requestInfoService.getAllRequestInfo();
model.addAttribute("requestInfos", requestInfos);
- List fls=serviceDictInfoService.findAllFlDict();
- String pNames="";
+ List fls = serviceDictInfoService.findAllFlDict();
+ String pNames = "";
for (ServiceDictInfo serviceDictInfo : fls) {
- pNames="";
- pNames=serviceDictInfo.getPNames(fls, serviceDictInfo.getParent().getServiceDictId(), pNames);
+ pNames = "";
+ pNames = serviceDictInfo.getPNames(fls, serviceDictInfo.getParent().getServiceDictId(), pNames);
serviceDictInfo.setpNames(pNames);
}
model.addAttribute("fls", fls);
- List xzs=serviceDictInfoService.findAllXzDict();
+ List xzs = serviceDictInfoService.findAllXzDict();
for (ServiceDictInfo serviceDictInfo : xzs) {
- pNames="";
- pNames=serviceDictInfo.getPNames(xzs, serviceDictInfo.getParent().getServiceDictId(), pNames);
+ pNames = "";
+ pNames = serviceDictInfo.getPNames(xzs, serviceDictInfo.getParent().getServiceDictId(), pNames);
serviceDictInfo.setpNames(pNames);
}
model.addAttribute("xzs", xzs);
- List lables=serviceDictInfoService.findAllLableDict();
+ List lables = serviceDictInfoService.findAllLableDict();
for (ServiceDictInfo serviceDictInfo : lables) {
- pNames="";
- pNames=serviceDictInfo.getPNames(lables, serviceDictInfo.getParent().getServiceDictId(), pNames);
+ pNames = "";
+ pNames = serviceDictInfo.getPNames(lables, serviceDictInfo.getParent().getServiceDictId(), pNames);
serviceDictInfo.setpNames(pNames);
}
model.addAttribute("lables", lables);
}
- protected void initPageCondition(Model model,BaseCfg cfg){
- List requestInfos=requestInfoService.getAllRequestInfo();
+
+ protected void initPageCondition(Model model, BaseCfg cfg) {
+ List requestInfos = requestInfoService.getAllRequestInfo();
model.addAttribute("requestInfos", requestInfos);
- List fls=serviceDictInfoService.findAllFlDict();
- String pNames="";
+ List fls = serviceDictInfoService.findAllFlDict();
+ String pNames = "";
for (ServiceDictInfo serviceDictInfo : fls) {
- pNames="";
- pNames=serviceDictInfo.getPNames(fls, serviceDictInfo.getParent().getServiceDictId(), pNames);
+ pNames = "";
+ pNames = serviceDictInfo.getPNames(fls, serviceDictInfo.getParent().getServiceDictId(), pNames);
serviceDictInfo.setpNames(pNames);
}
model.addAttribute("fls", fls);
- List xzs=serviceDictInfoService.findAllXzDict();
+ List xzs = serviceDictInfoService.findAllXzDict();
for (ServiceDictInfo serviceDictInfo : xzs) {
- pNames="";
- pNames=serviceDictInfo.getPNames(xzs, serviceDictInfo.getParent().getServiceDictId(), pNames);
+ pNames = "";
+ pNames = serviceDictInfo.getPNames(xzs, serviceDictInfo.getParent().getServiceDictId(), pNames);
serviceDictInfo.setpNames(pNames);
}
model.addAttribute("xzs", xzs);
- List lables=serviceDictInfoService.findAllLableDict();
+ List lables = serviceDictInfoService.findAllLableDict();
for (ServiceDictInfo serviceDictInfo : lables) {
- pNames="";
- pNames=serviceDictInfo.getPNames(lables, serviceDictInfo.getParent().getServiceDictId(), pNames);
+ pNames = "";
+ pNames = serviceDictInfo.getPNames(lables, serviceDictInfo.getParent().getServiceDictId(), pNames);
serviceDictInfo.setpNames(pNames);
}
model.addAttribute("lables", lables);
@@ -388,7 +390,8 @@ public class BaseController {
List serviceList = DictUtils.getFunctionServiceDictList(cfg.getFunctionId());
model.addAttribute("serviceList", serviceList);
}
- protected void initReportCondition(Model model,SearchReport report){
+
+ protected void initReportCondition(Model model, SearchReport report) {
List serviceList = DictUtils.getFunctionServiceDictList(report.getFunctionId());
model.addAttribute("serviceList", serviceList);
if (StringUtils.isBlank(report.getReportTime())) {
@@ -398,147 +401,150 @@ public class BaseController {
report.setReportType(1);
}
}
- protected void initFormCondition(Model model){
- List requestInfos=requestInfoService.getValidRequestInfo();
+
+ protected void initFormCondition(Model model) {
+ List requestInfos = requestInfoService.getValidRequestInfo();
model.addAttribute("requestInfos", requestInfos);
- List fls=serviceDictInfoService.findFlDict();
- String pNames="";
+ List fls = serviceDictInfoService.findFlDict();
+ String pNames = "";
for (ServiceDictInfo serviceDictInfo : fls) {
- pNames="";
- pNames=serviceDictInfo.getPNames(fls, serviceDictInfo.getParent().getServiceDictId(), pNames);
+ pNames = "";
+ pNames = serviceDictInfo.getPNames(fls, serviceDictInfo.getParent().getServiceDictId(), pNames);
serviceDictInfo.setpNames(pNames);
}
model.addAttribute("fls", fls);
- List xzs=serviceDictInfoService.findXzDict();
+ List xzs = serviceDictInfoService.findXzDict();
for (ServiceDictInfo serviceDictInfo : xzs) {
- pNames="";
- pNames=serviceDictInfo.getPNames(xzs, serviceDictInfo.getParent().getServiceDictId(), pNames);
+ pNames = "";
+ pNames = serviceDictInfo.getPNames(xzs, serviceDictInfo.getParent().getServiceDictId(), pNames);
serviceDictInfo.setpNames(pNames);
}
model.addAttribute("xzs", xzs);
- List lables=serviceDictInfoService.findLableDict();
+ List lables = serviceDictInfoService.findLableDict();
for (ServiceDictInfo serviceDictInfo : lables) {
- pNames="";
- pNames=serviceDictInfo.getPNames(lables, serviceDictInfo.getParent().getServiceDictId(), pNames);
+ pNames = "";
+ pNames = serviceDictInfo.getPNames(lables, serviceDictInfo.getParent().getServiceDictId(), pNames);
serviceDictInfo.setpNames(pNames);
}
model.addAttribute("lables", lables);
- List itTypeList=new ArrayList();
+ List itTypeList = new ArrayList();
itTypeList.add(Constants.ITEM_TYPE_AREA);
- List areas = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
+ List areas = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(), itTypeList, null);
model.addAttribute("areas", areas);
itTypeList.clear();
itTypeList.add(Constants.ITEM_TYPE_ISP);
- List isps = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
+ List isps = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(), itTypeList, null);
model.addAttribute("isps", isps);
- //初始化一个默认的地域ip给界面
- AreaIpCfg areaIpCfg=new AreaIpCfg();
+ // 初始化一个默认的地域ip给界面
+ AreaIpCfg areaIpCfg = new AreaIpCfg();
areaIpCfg.initDefaultValue();
model.addAttribute("_areaCfg", areaIpCfg);
}
- protected void initFormCondition(Model model,BaseCfg cfg){
- List requestInfos=requestInfoService.getValidRequestInfo();
+
+ protected void initFormCondition(Model model, BaseCfg cfg) {
+ List requestInfos = requestInfoService.getValidRequestInfo();
model.addAttribute("requestInfos", requestInfos);
- List fls=serviceDictInfoService.findFlDict();
- String pNames="";
+ List fls = serviceDictInfoService.findFlDict();
+ String pNames = "";
for (ServiceDictInfo serviceDictInfo : fls) {
- pNames="";
- pNames=serviceDictInfo.getPNames(fls, serviceDictInfo.getParent().getServiceDictId(), pNames);
+ pNames = "";
+ pNames = serviceDictInfo.getPNames(fls, serviceDictInfo.getParent().getServiceDictId(), pNames);
serviceDictInfo.setpNames(pNames);
}
model.addAttribute("fls", fls);
- List xzs=serviceDictInfoService.findXzDict();
+ List xzs = serviceDictInfoService.findXzDict();
for (ServiceDictInfo serviceDictInfo : xzs) {
- pNames="";
- pNames=serviceDictInfo.getPNames(xzs, serviceDictInfo.getParent().getServiceDictId(), pNames);
+ pNames = "";
+ pNames = serviceDictInfo.getPNames(xzs, serviceDictInfo.getParent().getServiceDictId(), pNames);
serviceDictInfo.setpNames(pNames);
}
model.addAttribute("xzs", xzs);
- List lables=serviceDictInfoService.findLableDict();
+ List lables = serviceDictInfoService.findLableDict();
for (ServiceDictInfo serviceDictInfo : lables) {
- pNames="";
- pNames=serviceDictInfo.getPNames(lables, serviceDictInfo.getParent().getServiceDictId(), pNames);
+ pNames = "";
+ pNames = serviceDictInfo.getPNames(lables, serviceDictInfo.getParent().getServiceDictId(), pNames);
serviceDictInfo.setpNames(pNames);
}
model.addAttribute("lables", lables);
- List itTypeList=new ArrayList();
+ List itTypeList = new ArrayList();
itTypeList.add(Constants.ITEM_TYPE_AREA);
- List areas = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
+ List areas = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(), itTypeList, null);
model.addAttribute("areas", areas);
itTypeList.clear();
itTypeList.add(Constants.ITEM_TYPE_ISP);
- List isps = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
+ List isps = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(), itTypeList, null);
model.addAttribute("isps", isps);
- //初始化一个默认的地域ip给界面
- AreaIpCfg areaIpCfg=new AreaIpCfg();
+ // 初始化一个默认的地域ip给界面
+ AreaIpCfg areaIpCfg = new AreaIpCfg();
areaIpCfg.initDefaultValue();
model.addAttribute("_areaCfg", areaIpCfg);
List regionList = DictUtils.getFunctionRegionDictList(cfg.getFunctionId());
model.addAttribute("regionList", regionList);
List serviceList = DictUtils.getFunctionServiceDictList(cfg.getFunctionId());
model.addAttribute("serviceList", serviceList);
- //ip配置设置protocolId
- if(cfg instanceof BaseIpCfg){
- for(FunctionServiceDict dict:serviceList){
- if(cfg.getFunctionId().intValue()==dict.getFunctionId().intValue()){
+ // ip配置设置protocolId
+ if (cfg instanceof BaseIpCfg) {
+ for (FunctionServiceDict dict : serviceList) {
+ if (cfg.getFunctionId().intValue() == dict.getFunctionId().intValue()) {
((BaseIpCfg) cfg).setProtocolId(dict.getProtocolId().intValue());
break;
}
}
}
}
- protected void initUpdateFormCondition(Model model,BaseCfg cfg){
- List itTypeList=new ArrayList();
+
+ protected void initUpdateFormCondition(Model model, BaseCfg cfg) {
+ List itTypeList = new ArrayList();
itTypeList.add(Constants.ITEM_TYPE_AREA);
- List areas = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
+ List areas = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(), itTypeList, null);
model.addAttribute("areas", areas);
itTypeList.clear();
itTypeList.add(Constants.ITEM_TYPE_ISP);
- List isps = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
+ List isps = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(), itTypeList, null);
model.addAttribute("isps", isps);
-
- //查询配置对应的地域ip
- if(cfg.getCompileId()!=null) {
- List areaCfgs=ipCfgService.getAreaCfgByCompileId(cfg.getCompileId());
+
+ // 查询配置对应的地域ip
+ if (cfg.getCompileId() != null) {
+ List areaCfgs = ipCfgService.getAreaCfgByCompileId(cfg.getCompileId());
model.addAttribute("areaCfgs", areaCfgs);
- StringBuffer areaCfgIds=new StringBuffer();
- for(AreaIpCfg areaCfg:areaCfgs){
- areaCfgIds.append(areaCfg.getCfgId()+",");
+ StringBuffer areaCfgIds = new StringBuffer();
+ for (AreaIpCfg areaCfg : areaCfgs) {
+ areaCfgIds.append(areaCfg.getCfgId() + ",");
}
- //update时判断是否有删除地域ip
+ // update时判断是否有删除地域ip
model.addAttribute("areaCfgIds", areaCfgIds.toString());
}
- //初始化一个默认的地域ip给界面
- AreaIpCfg areaIpCfg=new AreaIpCfg();
+ // 初始化一个默认的地域ip给界面
+ AreaIpCfg areaIpCfg = new AreaIpCfg();
areaIpCfg.initDefaultValue();
model.addAttribute("_areaCfg", areaIpCfg);
- //从区域生效ID中获取区域与运营商
- String areaEffectiveIds=cfg.getAreaEffectiveIds();
- List areaIspList=new ArrayList();
- getAreaIsps(areaEffectiveIds,areaIspList,isps,areas);
+ // 从区域生效ID中获取区域与运营商
+ String areaEffectiveIds = cfg.getAreaEffectiveIds();
+ List areaIspList = new ArrayList();
+ getAreaIsps(areaEffectiveIds, areaIspList, isps, areas);
model.addAttribute("_areaIsps", areaIspList);
- List requestInfos=requestInfoService.getValidRequestInfo();//只查询有效的
+ List requestInfos = requestInfoService.getValidRequestInfo();// 只查询有效的
model.addAttribute("requestInfos", requestInfos);
- List fls=serviceDictInfoService.findFlDict();//只查询有效分类字典
- String pNames="";
+ List fls = serviceDictInfoService.findFlDict();// 只查询有效分类字典
+ String pNames = "";
for (ServiceDictInfo serviceDictInfo : fls) {
- pNames="";
- pNames=serviceDictInfo.getPNames(fls, serviceDictInfo.getParent().getServiceDictId(), pNames);
+ pNames = "";
+ pNames = serviceDictInfo.getPNames(fls, serviceDictInfo.getParent().getServiceDictId(), pNames);
serviceDictInfo.setpNames(pNames);
}
model.addAttribute("fls", fls);
- List xzs=serviceDictInfoService.findXzDict();//只查询有效性质字典
+ List xzs = serviceDictInfoService.findXzDict();// 只查询有效性质字典
for (ServiceDictInfo serviceDictInfo : xzs) {
- pNames="";
- pNames=serviceDictInfo.getPNames(xzs, serviceDictInfo.getParent().getServiceDictId(), pNames);
+ pNames = "";
+ pNames = serviceDictInfo.getPNames(xzs, serviceDictInfo.getParent().getServiceDictId(), pNames);
serviceDictInfo.setpNames(pNames);
}
model.addAttribute("xzs", xzs);
- List lables=serviceDictInfoService.findLableDict();//只查询有效标签字典
+ List lables = serviceDictInfoService.findLableDict();// 只查询有效标签字典
for (ServiceDictInfo serviceDictInfo : lables) {
- pNames="";
- pNames=serviceDictInfo.getPNames(lables, serviceDictInfo.getParent().getServiceDictId(), pNames);
+ pNames = "";
+ pNames = serviceDictInfo.getPNames(lables, serviceDictInfo.getParent().getServiceDictId(), pNames);
serviceDictInfo.setpNames(pNames);
}
model.addAttribute("lables", lables);
@@ -547,132 +553,141 @@ public class BaseController {
List serviceList = DictUtils.getFunctionServiceDictList(cfg.getFunctionId());
model.addAttribute("serviceList", serviceList);
}
- public List getAreaIsps(String areaEffectiveIds,List areaIspList,List isps,List areas) {
- Map areaMap=new HashMap();
+
+ public List getAreaIsps(String areaEffectiveIds, List areaIspList, List isps,
+ List areas) {
+ Map areaMap = new HashMap();
for (SysDictInfo areaDict : areas) {
areaMap.put(areaDict.getItemCode(), areaDict);
}
- Map ispMap=new HashMap();
+ Map ispMap = new HashMap();
for (SysDictInfo ispDict : isps) {
ispMap.put(ispDict.getItemCode(), ispDict);
}
-
+
// : 存在冒号,则冒号前为area后为isp;不存在冒号,判断id是否为isp,否则为area
- if(StringUtils.isNotBlank(areaEffectiveIds)){
- String[] areaIsps=areaEffectiveIds.split(",");
- for(String areaIsp:areaIsps){
- AreaBean area=new AreaBean();
- if(areaIsp.contains(":")){
+ if (StringUtils.isNotBlank(areaEffectiveIds)) {
+ String[] areaIsps = areaEffectiveIds.split(",");
+ for (String areaIsp : areaIsps) {
+ AreaBean area = new AreaBean();
+ if (areaIsp.contains(":")) {
area.setArea(areaIsp.split(":")[0]);
area.setIsp(areaIsp.split(":")[1]);
area.setAreaName(areaMap.get(areaIsp.split(":")[0]).getItemValue());
area.setIspName(ispMap.get(areaIsp.split(":")[1]).getItemValue());
- }else{
- if(ispMap.keySet().contains(areaIsp)){
+ } else {
+ if (ispMap.keySet().contains(areaIsp)) {
area.setIsp(areaIsp);
area.setIspName(ispMap.get(areaIsp).getItemValue());
area.setAreaName("");
- }else{
+ } else {
area.setArea(areaIsp);
area.setIspName("");
area.setAreaName(areaMap.get(areaIsp).getItemValue());
}
-
+
}
areaIspList.add(area);
}
}
return areaIspList;
}
+
/**
* 获取国际化配置文件
+ *
* @return
*/
- public Properties getMsgProp(){
+ public Properties getMsgProp() {
Properties msgProp = new Properties();
try {
String language = LocaleContextHolder.getLocale().getLanguage();
- if(language.equals("zh_cn")||language.equals("zh")){
+ if (language.equals("zh_cn") || language.equals("zh")) {
msgProp.load(Configurations.class.getResourceAsStream("/messages/message_zh_CN.properties"));
- }else if(language.equals("ru")){
+ } else if (language.equals("ru")) {
msgProp.load(Configurations.class.getResourceAsStream("/messages/message_ru.properties"));
- }else{
+ } else {
msgProp.load(Configurations.class.getResourceAsStream("/messages/message_en.properties"));
}
-
+
} catch (Exception e) {
msgProp = null;
- logger.error("未知i18n消息配置文件,请确定文件是否存在!",e);
+ logger.error("未知i18n消息配置文件,请确定文件是否存在!", e);
}
return msgProp;
}
- public void importCfgTemplate(HttpServletRequest request,HttpServletResponse response,
- RedirectAttributes redirectAttributes,Integer functionId,Integer cfgRegionCode){
+
+ public void importCfgTemplate(HttpServletRequest request, HttpServletResponse response,
+ RedirectAttributes redirectAttributes, Integer functionId, Integer cfgRegionCode) {
Properties msgProp = getMsgProp();
try {
- List dictList = DictUtils.getFunctionRegionDictList(functionId);
- for(FunctionRegionDict dict:dictList){
- if(dict.getConfigRegionCode()==cfgRegionCode){
- String fileName = dict.getConfigRegionValue()+".xlsx";
- if(dict.getRegionType()==1){
- List 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 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 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();
- }
- }
- public void importCfgTemplate(HttpServletRequest request,HttpServletResponse response,
- RedirectAttributes redirectAttributes,Integer functionId,Integer cfgRegionCode,Class clazz){
- Properties msgProp = getMsgProp();
- try {
- List dictList = DictUtils.getFunctionRegionDictList(functionId);
- for(FunctionRegionDict dict:dictList){
- if(dict.getConfigRegionCode()==cfgRegionCode){
- String fileName = dict.getConfigRegionValue()+".xlsx";
- if(dict.getRegionType()==1){
+ List dictList = DictUtils.getFunctionRegionDictList(functionId);
+ for (FunctionRegionDict dict : dictList) {
+ if (dict.getConfigRegionCode() == cfgRegionCode) {
+ String fileName = dict.getConfigRegionValue() + ".xlsx";
+ if (dict.getRegionType() == 1) {
List 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.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 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){
+ 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 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();
+ 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();
}
}
-
- public void setLogAction(BaseLogEntity log,List serviceList) {
- if(!StringUtil.isEmpty(serviceList)){
+
+ public void importCfgTemplate(HttpServletRequest request, HttpServletResponse response,
+ RedirectAttributes redirectAttributes, Integer functionId, Integer cfgRegionCode, Class clazz) {
+ Properties msgProp = getMsgProp();
+ try {
+ List dictList = DictUtils.getFunctionRegionDictList(functionId);
+ for (FunctionRegionDict dict : dictList) {
+ if (dict.getConfigRegionCode() == cfgRegionCode) {
+ String fileName = dict.getConfigRegionValue() + ".xlsx";
+ if (dict.getRegionType() == 1) {
+ List 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 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 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 serviceList) {
+ if (!StringUtil.isEmpty(serviceList)) {
for (FunctionServiceDict dict : serviceList) {
if (dict.getServiceId().intValue() == log.getService()) {
log.setAction(dict.getAction());
@@ -680,88 +695,77 @@ public class BaseController {
}
}
}
-
- //初始化查询值判断
- public void initLogSearchValue(BaseLogEntity entry,Map params){
-
- if (StringUtils.isNotBlank(entry.getSearchFoundStartTime())&&StringUtils.isNotBlank(entry.getSearchFoundEndTime())) {
+
+ // 初始化查询值判断
+ public void initLogSearchValue(BaseLogEntity entry, Map params) {
+
+ if (StringUtils.isNotBlank(entry.getSearchFoundStartTime())
+ && StringUtils.isNotBlank(entry.getSearchFoundEndTime())) {
params.put("searchFoundStartTime", entry.getSearchFoundStartTime());
params.put("searchFoundEndTime", entry.getSearchFoundEndTime());
- }else{
+ } else {
// 判断是否是从配置界面过来的日志查询
- if(StringUtils.isNotBlank(entry.getIsLogTotalSearch())) {
+ if (StringUtils.isNotBlank(entry.getIsLogTotalSearch())) {
Calendar time = Calendar.getInstance();
time.add(Calendar.MINUTE, -5);
String searchEndTime = DateUtils.formatDateTime(time.getTime());
- params.put("searchFoundEndTime",searchEndTime);
+ params.put("searchFoundEndTime", searchEndTime);
entry.setSearchFoundEndTime(searchEndTime);
-
+
time.add(Calendar.MINUTE, -5);
String searchStartTime = DateUtils.formatDateTime(time.getTime());
params.put("searchFoundStartTime", searchStartTime);
entry.setSearchFoundStartTime(searchStartTime);
-
+
// 判断startTime是否有值
- /*if(StringUtils.isNotBlank(Constants.LOG_TIME_START)) {
- String endTime = Constants.LOG_TIME_END;
- if(StringUtils.isBlank(endTime)) {
- endTime = DateUtils.getDateTime();
- }
- params.put("searchFoundStartTime", Constants.LOG_TIME_START);
- params.put("searchFoundEndTime",endTime );
- entry.setSearchFoundStartTime(Constants.LOG_TIME_START);
- entry.setSearchFoundEndTime(endTime);
- }else {
- Calendar startTimeCal = Calendar.getInstance();
- if(StringUtils.isNotEmpty(entry.getDate())) {
- startTimeCal.setTimeInMillis(Long.parseLong(entry.getDate()));// 同步日志总量查询时间
- }
- // 时间间隔
- int interval = Constants.LOG_TIME_RANGE/1000/60;
- if(interval < 60) {
- // 查询上一个5分钟
- startTimeCal.set(Calendar.SECOND, 0);
- int minute = startTimeCal.get(Calendar.MINUTE);
- startTimeCal.set(Calendar.MINUTE, minute/interval*interval);
- }else {
- // 查询上一个1小时
- startTimeCal.set(Calendar.SECOND, 0);
- startTimeCal.set(Calendar.MINUTE, 0);
- }
- Calendar endTimeCal = Calendar.getInstance();
- endTimeCal.setTimeInMillis(startTimeCal.getTimeInMillis());
- //endTimeCal.add(Calendar.SECOND, -1);
-
- startTimeCal.add(Calendar.MINUTE, -interval); //开始时间减去时间间隔
-
- String searchStartTime = DateUtils.formatDateTime(startTimeCal.getTime());
- String searchEndTime = DateUtils.formatDateTime(endTimeCal.getTime());
- params.put("searchFoundStartTime", searchStartTime);
- params.put("searchFoundEndTime",searchEndTime);
- entry.setSearchFoundStartTime(searchStartTime);
- entry.setSearchFoundEndTime(searchEndTime);
- }*/
-
- }else {
- //设置默认查询当前时间及前五分钟
+ /*
+ * if(StringUtils.isNotBlank(Constants.LOG_TIME_START)) { String endTime =
+ * Constants.LOG_TIME_END; if(StringUtils.isBlank(endTime)) { endTime =
+ * DateUtils.getDateTime(); } params.put("searchFoundStartTime",
+ * Constants.LOG_TIME_START); params.put("searchFoundEndTime",endTime );
+ * entry.setSearchFoundStartTime(Constants.LOG_TIME_START);
+ * entry.setSearchFoundEndTime(endTime); }else { Calendar startTimeCal =
+ * Calendar.getInstance(); if(StringUtils.isNotEmpty(entry.getDate())) {
+ * startTimeCal.setTimeInMillis(Long.parseLong(entry.getDate()));// 同步日志总量查询时间 }
+ * // 时间间隔 int interval = Constants.LOG_TIME_RANGE/1000/60; if(interval < 60) {
+ * // 查询上一个5分钟 startTimeCal.set(Calendar.SECOND, 0); int minute =
+ * startTimeCal.get(Calendar.MINUTE); startTimeCal.set(Calendar.MINUTE,
+ * minute/interval*interval); }else { // 查询上一个1小时
+ * startTimeCal.set(Calendar.SECOND, 0); startTimeCal.set(Calendar.MINUTE, 0); }
+ * Calendar endTimeCal = Calendar.getInstance();
+ * endTimeCal.setTimeInMillis(startTimeCal.getTimeInMillis());
+ * //endTimeCal.add(Calendar.SECOND, -1);
+ *
+ * startTimeCal.add(Calendar.MINUTE, -interval); //开始时间减去时间间隔
+ *
+ * String searchStartTime = DateUtils.formatDateTime(startTimeCal.getTime());
+ * String searchEndTime = DateUtils.formatDateTime(endTimeCal.getTime());
+ * params.put("searchFoundStartTime", searchStartTime);
+ * params.put("searchFoundEndTime",searchEndTime);
+ * entry.setSearchFoundStartTime(searchStartTime);
+ * entry.setSearchFoundEndTime(searchEndTime); }
+ */
+
+ } else {
+ // 设置默认查询当前时间及前五分钟
String endTime = DateUtils.getDateTime();
Date dateStart = new Date(new Date().getTime() - Constants.LOG_TIME_INTERVAL);
String startTime = DateUtils.formatDateTime(dateStart);
params.put("searchFoundStartTime", startTime);
- params.put("searchFoundEndTime",endTime );
+ params.put("searchFoundEndTime", endTime);
entry.setSearchFoundStartTime(startTime);
entry.setSearchFoundEndTime(endTime);
}
- logger.info("searchFoundStartTime:"+params.get("searchFoundStartTime"));
- logger.info("searchFoundEndTime:"+params.get("searchFoundEndTime"));
+ logger.info("searchFoundStartTime:" + params.get("searchFoundStartTime"));
+ logger.info("searchFoundEndTime:" + params.get("searchFoundEndTime"));
}
-
+
if (StringUtils.isNotBlank(entry.getTransProto())) {
params.put("searchTransProto", entry.getTransProto());
}
- if (entry.getService()!=null) {
+ if (entry.getService() != null) {
params.put("searchService", entry.getService());
- } else if (entry.getAction()!=null) {
+ } else if (entry.getAction() != null) {
List serviceList = DictUtils.getFunctionServiceDictList(entry.getFunctionId());
for (FunctionServiceDict dict : serviceList) {
if (dict.getAction().intValue() == entry.getAction().intValue()
@@ -780,1246 +784,1481 @@ public class BaseController {
if (StringUtils.isNotBlank(entry.getCapIp())) {
params.put("searchCapIp", entry.getCapIp());
}
- if (entry.getDirection()!=null) {
+ if (entry.getDirection() != null) {
params.put("searchDirection", entry.getDirection());
}
- if (entry.getEntranceId()!=null) {
+ if (entry.getEntranceId() != null) {
params.put("searchEntranceId", entry.getEntranceId());
}
- if (entry.getCfgId()!=null) {
+ if (entry.getCfgId() != null) {
params.put("searchCfgId", entry.getCfgId());
}
}
-
- public List checkIpCfg(FunctionServiceDict serviceDict,FunctionRegionDict regionDict,List> list) throws ServiceException{
- List ipList=new ArrayList();
- Properties prop=this.getMsgProp();
+
+ public List checkIpCfg(FunctionServiceDict serviceDict, FunctionRegionDict regionDict, List> list)
+ throws ServiceException {
+ List ipList = new ArrayList();
+ Properties prop = this.getMsgProp();
+ // ip必填一个,configIpPortShow不能为空,否则字典配错;
+ String configIpPortShow = regionDict.getConfigIpPortShow();
+ if (StringUtil.isEmpty(configIpPortShow)) {
+ throw new RuntimeException("Found IP region,but configIpPortShow is Empty");
+ }
+ String ipType = regionDict.getConfigIpType();
+ if (StringUtil.isEmpty(ipType)) {
+ throw new RuntimeException("Found IP region,but ipType is Empty");
+ }
+ boolean canIPv4 = ipType.indexOf("4") > -1;
+ boolean canIPv6 = ipType.indexOf("6") > -1;
+ String ipPattern = regionDict.getConfigIpPattern();
+ if (StringUtil.isEmpty(ipPattern)) {
+ throw new RuntimeException("Found IP region,but ipPattern is Empty");
+ }
+ boolean canIPFormat = ipType.indexOf("3") > -1;
+ boolean canIPSubnetFormat = ipType.indexOf("1") > -1;
+ boolean canIPRangeFormat = ipType.indexOf("2") > -1;
+ String portPattern = regionDict.getConfigPortPattern();
+ String protocol = regionDict.getConfigProtocol();
+ String direction = regionDict.getConfigDirection();
+ StringBuffer errTip = new StringBuffer();
for (int i = 0; i < list.size(); i++) {
- IpPortCfg baseIpCfg=new IpPortCfg();
+ StringBuffer errInfo = new StringBuffer();
+ IpPortCfg baseIpCfg = new IpPortCfg();
BeanUtils.copyProperties(list.get(i), baseIpCfg);
- if(regionDict.getRegionType().equals(1)){
- boolean srcIpEmpty=false;
- boolean srcPortEmpty=false;
- if(StringUtil.isEmpty(baseIpCfg.getSrcIpAddress())){
- srcIpEmpty=true;
- }
- 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(baseIpCfg.getSrcIpAddress().indexOf(":") > -1){
- if(baseIpCfg.getSrcIpAddress().indexOf("-") > -1){
- baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
- baseIpCfg.setDestIpAddress("::-::");
- baseIpCfg.setIpPattern(2);
- }else if(baseIpCfg.getSrcIpAddress().indexOf("/") > -1){
- baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
- baseIpCfg.setDestIpAddress("::/128");
- baseIpCfg.setIpPattern(1);
- }else{
- baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
- baseIpCfg.setDestIpAddress("::");
- baseIpCfg.setIpPattern(3);
- }
- baseIpCfg.setIpType(6);
- }else{
- 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(baseIpCfg.getSrcIpAddress().indexOf("/") > -1){
- baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
- baseIpCfg.setDestIpAddress("0.0.0.0/16");
- baseIpCfg.setIpPattern(1);
- }else{
- baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
- baseIpCfg.setDestIpAddress("0.0.0.0");
- baseIpCfg.setIpPattern(3);
- }
- baseIpCfg.setIpType(4);
- }
+ if (regionDict.getRegionType().equals(1)) {
+ // 校验必填的IP,端口
+ for (String code : configIpPortShow.split(",")) {
+ if ("1".equals(code)) {// 源IP
+ if (StringUtil.isEmpty(baseIpCfg.getSrcIpAddress())) {
+ errInfo.append(String.format(prop.getProperty("can_not_null"),
+ prop.getProperty("client_ip", "Client IP")) + ";");
}
- } else{
- if(srcIpEmpty){
- if(baseIpCfg.getDestIpAddress().indexOf(":") > -1){
- if(baseIpCfg.getDestIpAddress().indexOf("-") > -1){
- baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
- baseIpCfg.setSrcIpAddress("::-::");
- baseIpCfg.setIpPattern(2);
- }else if(baseIpCfg.getDestIpAddress().indexOf("/") > -1){
- baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
- baseIpCfg.setSrcIpAddress("::/128");
- baseIpCfg.setIpPattern(1);
- }else{
- baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
- baseIpCfg.setSrcIpAddress("::");
- baseIpCfg.setIpPattern(3);
- }
- baseIpCfg.setIpType(6);
- }else{
- 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(baseIpCfg.getDestIpAddress().indexOf("/") > -1){
- baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
- baseIpCfg.setSrcIpAddress("0.0.0.0/16");
- baseIpCfg.setIpPattern(1);
- }else{
- baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
- baseIpCfg.setSrcIpAddress("0.0.0.0");
- baseIpCfg.setIpPattern(3);
- }
- baseIpCfg.setIpType(4);
- }
- }else{
- baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
- baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
- if(baseIpCfg.getSrcIpAddress().indexOf(":") > -1){
- baseIpCfg.setIpType(6);
- }else{
- baseIpCfg.setIpType(4);
- }
- if(baseIpCfg.getSrcIpAddress().indexOf("-") > -1){
- baseIpCfg.setIpPattern(2);
- }else if(baseIpCfg.getSrcIpAddress().indexOf("/") > -1){
- baseIpCfg.setIpPattern(1);
- }else{
- baseIpCfg.setIpPattern(3);
- }
+ } else if ("2".equals(code)) {// 源端口
+ if (StringUtil.isEmpty(baseIpCfg.getSrcPort())) {
+ errInfo.append(String.format(prop.getProperty("can_not_null"),
+ prop.getProperty("client_port", "Client Port")) + ";");
+ }
+ } else if ("3".equals(code)) {// 目的IP
+ if (StringUtil.isEmpty(baseIpCfg.getDestIpAddress())) {
+ errInfo.append(String.format(prop.getProperty("can_not_null"),
+ prop.getProperty("server_ip", "Server IP")) + ";");
+ }
+ } else if ("4".equals(code)) {// 目的端口
+ if (StringUtil.isEmpty(baseIpCfg.getDestPort())) {
+ errInfo.append(String.format(prop.getProperty("can_not_null"),
+ prop.getProperty("server_port", "Server Port")) + ";");
}
}
-
- //TODO 判断源IP和目的IP的值
- //TODO 判断源IP和目的IP格式
-
- if(StringUtil.isEmpty(baseIpCfg.getSrcPort())){
- srcPortEmpty=true;
- }
- if(StringUtil.isEmpty(baseIpCfg.getDestPort())){
- if(srcPortEmpty){
- baseIpCfg.setSrcPort("0");
- baseIpCfg.setDestPort("0");
- baseIpCfg.setPortPattern(1);
- }else{
- if(baseIpCfg.getSrcPort().indexOf("/") > -1){
- baseIpCfg.setDestPort("0/0");
- baseIpCfg.setPortPattern(2);
- }else{
- baseIpCfg.setDestPort("0");
- baseIpCfg.setPortPattern(1);
- }
- baseIpCfg.setSrcPort(baseIpCfg.getSrcPort());
- }
- }else{
- if(srcPortEmpty){
- if(baseIpCfg.getDestPort().indexOf("/") > -1){
- baseIpCfg.setSrcPort("0/0");
- baseIpCfg.setPortPattern(2);
- }else{
- baseIpCfg.setSrcPort("0");
- baseIpCfg.setPortPattern(1);
- }
- baseIpCfg.setDestPort(baseIpCfg.getSrcPort());
- }else{
- if(baseIpCfg.getSrcPort().indexOf("/") > -1){
- baseIpCfg.setPortPattern(2);
- }else{
- baseIpCfg.setPortPattern(1);
- }
- baseIpCfg.setSrcPort(baseIpCfg.getSrcPort());
- baseIpCfg.setDestPort(baseIpCfg.getDestPort());
-
- }
- }
- //TODO 判断源端口和目的端口格式
- //TODO 判断源和目的端口的值
-
- if(StringUtil.isEmpty(baseIpCfg.getProtocol())){
- if(StringUtil.isEmpty(regionDict.getConfigProtocol())){
- baseIpCfg.setProtocol(0);
- }else{
- baseIpCfg.setProtocol(Integer.parseInt(regionDict.getConfigProtocol().split(",")[0]));
- }
- baseIpCfg.setProtocolId(serviceDict.getProtocolId());
- }else{
- baseIpCfg.setProtocol(baseIpCfg.getProtocol());
- baseIpCfg.setProtocolId(serviceDict.getProtocolId());
- }
- //TODO 判断Protocol的值
-
- 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(baseIpCfg.getDirection());
- }
-
- //TODO 判断Direction的值
}
+ boolean srcIpEmpty = false;
+ boolean srcPortEmpty = false;
+ if (StringUtil.isEmpty(baseIpCfg.getSrcIpAddress())) {
+ srcIpEmpty = true;
+ }
+ if (StringUtil.isEmpty(baseIpCfg.getDestIpAddress())) {
+ if (srcIpEmpty) {// 全部为空,填值
+ if (canIPv4 && canIPFormat) {
+ baseIpCfg.setSrcIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
+ baseIpCfg.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
+ baseIpCfg.setIpType(4);
+ baseIpCfg.setIpPattern(3);
+ } else if (canIPv6 && canIPFormat) {
+ baseIpCfg.setSrcIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
+ baseIpCfg.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
+ baseIpCfg.setIpType(6);
+ baseIpCfg.setIpPattern(3);
+ } else if (canIPv4 && canIPSubnetFormat) {
+ baseIpCfg.setSrcIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
+ baseIpCfg.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
+ baseIpCfg.setIpType(4);
+ baseIpCfg.setIpPattern(3);
+ } else if (canIPv6 && canIPSubnetFormat) {
+ baseIpCfg.setSrcIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
+ baseIpCfg.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
+ baseIpCfg.setIpType(6);
+ baseIpCfg.setIpPattern(3);
+ } else if (canIPv4 && canIPRangeFormat) {
+ baseIpCfg.setSrcIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
+ baseIpCfg.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
+ baseIpCfg.setIpType(4);
+ baseIpCfg.setIpPattern(3);
+ } else if (canIPv6 && canIPRangeFormat) {
+ baseIpCfg.setSrcIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
+ baseIpCfg.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
+ baseIpCfg.setIpType(6);
+ baseIpCfg.setIpPattern(3);
+ }
+
+ } else {
+ // 目的IP为空
+ String matchType = this.validIPAddress("client_ip", errInfo, baseIpCfg.getSrcIpAddress(),
+ ipType, ipPattern);
+ if (matchType.startsWith("IPV6")) {
+ if (matchType.endsWith("RANGE")) {
+ // baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
+ baseIpCfg.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
+ baseIpCfg.setIpPattern(2);
+ if (baseIpCfg.getSrcIpAddress()
+ .startsWith(Constants.IPV6_DEFAULT_IP_RANGE_VALUE.split("-")[0])) {
+ errInfo.append(prop.getProperty("client_ip") + String.format("can_not_be",
+ Constants.IPV6_DEFAULT_IP_RANGE_VALUE.split("-")[0]));
+ }
+ } else if (matchType.endsWith("SUBNET")) {
+ // baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
+ baseIpCfg.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
+ baseIpCfg.setIpPattern(1);
+ if (baseIpCfg.getSrcIpAddress()
+ .startsWith(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.split("/")[0])) {
+ errInfo.append(prop.getProperty("client_ip") + String.format("can_not_be",
+ Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.split("/")[0]));
+ }
+ } else {
+ // baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
+ baseIpCfg.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
+ baseIpCfg.setIpPattern(3);
+ if (baseIpCfg.getSrcIpAddress().equals(Constants.IPV6_DEFAULT_IP_VALUE)) {
+ errInfo.append(prop.getProperty("client_ip")
+ + String.format("can_not_be", Constants.IPV6_DEFAULT_IP_VALUE));
+ }
+ }
+ baseIpCfg.setIpType(6);
+ } else {
+ if (matchType.endsWith("RANGE")) {
+ this.validIPv4Range("client_ip", errInfo, baseIpCfg.getSrcIpAddress());
+ // baseIpCfg.setSrcIpAddress("0.0.0.0-"+baseIpCfg.getSrcIpAddress().split("-")[0].substring(0,baseIpCfg.getSrcIpAddress().indexOf("-")+1)+baseIpCfg.getSrcIpAddress().split("-")[1]);
+ baseIpCfg.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
+ baseIpCfg.setIpPattern(2);
+ if (baseIpCfg.getSrcIpAddress()
+ .startsWith(Constants.IPV4_DEFAULT_IP_RANGE_VALUE.split("-")[0])) {
+ errInfo.append(prop.getProperty("client_ip") + String.format("can_not_be",
+ Constants.IPV4_DEFAULT_IP_RANGE_VALUE.split("-")[0]));
+ }
+ } else if (matchType.endsWith("SUBNET")) {
+ // baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
+ baseIpCfg.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
+ baseIpCfg.setIpPattern(1);
+ if (baseIpCfg.getSrcIpAddress()
+ .startsWith(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.split("/")[0])) {
+ errInfo.append(prop.getProperty("client_ip") + String.format("can_not_be",
+ Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.split("/")[0]));
+ }
+ } else {
+ baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
+ baseIpCfg.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
+ baseIpCfg.setIpPattern(3);
+ if (baseIpCfg.getSrcIpAddress().equals(Constants.IPV4_DEFAULT_IP_VALUE)) {
+ errInfo.append(prop.getProperty("client_ip")
+ + String.format("can_not_be", Constants.IPV4_DEFAULT_IP_VALUE));
+ }
+ }
+ baseIpCfg.setIpType(4);
+ }
+ }
+ } else {
+ if (srcIpEmpty) {// 源IP为空
+ String matchType = this.validIPAddress("server_ip", errInfo, baseIpCfg.getDestIpAddress(),
+ ipType, ipPattern);
+ if (matchType.startsWith("IPV6")) {
+ if (matchType.endsWith("RANGE")) {
+ // baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
+ baseIpCfg.setSrcIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
+ baseIpCfg.setIpPattern(2);
+ if (baseIpCfg.getDestIpAddress()
+ .startsWith(Constants.IPV6_DEFAULT_IP_RANGE_VALUE.split("-")[0])) {
+ errInfo.append(prop.getProperty("server_ip") + String.format("can_not_be",
+ Constants.IPV6_DEFAULT_IP_RANGE_VALUE.split("-")[0]));
+ }
+ } else if (matchType.endsWith("SUBNET")) {
+ // baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
+ baseIpCfg.setSrcIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
+ baseIpCfg.setIpPattern(1);
+ if (baseIpCfg.getDestIpAddress()
+ .startsWith(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.split("/")[0])) {
+ errInfo.append(prop.getProperty("server_ip") + String.format("can_not_be",
+ Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.split("/")[0]));
+ }
+ } else {
+ // baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
+ baseIpCfg.setSrcIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
+ baseIpCfg.setIpPattern(3);
+ if (baseIpCfg.getDestIpAddress().equals(Constants.IPV6_DEFAULT_IP_VALUE)) {
+ errInfo.append(prop.getProperty("server_ip")
+ + String.format("can_not_be", Constants.IPV6_DEFAULT_IP_VALUE));
+ }
+ }
+ baseIpCfg.setIpType(6);
+ } else {
+ if (matchType.endsWith("RANGE")) {
+ this.validIPv4Range("server_ip", errInfo, baseIpCfg.getDestIpAddress());
+ // baseIpCfg.setDestIpAddress("0.0.0.0-"+baseIpCfg.getDestIpAddress().split("-")[0]
+ // .substring(0,baseIpCfg.getDestIpAddress().indexOf("-")+1)
+ // +baseIpCfg.getDestIpAddress().split("-")[1]);
+ baseIpCfg.setSrcIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
+ baseIpCfg.setIpPattern(2);
+ if (baseIpCfg.getDestIpAddress()
+ .startsWith(Constants.IPV4_DEFAULT_IP_RANGE_VALUE.split("-")[0])) {
+ errInfo.append(prop.getProperty("server_ip") + String.format("can_not_be",
+ Constants.IPV4_DEFAULT_IP_RANGE_VALUE.split("-")[0]));
+ }
+ } else if (matchType.endsWith("SUBNET")) {
+ // baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
+ baseIpCfg.setSrcIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
+ baseIpCfg.setIpPattern(1);
+ if (baseIpCfg.getDestIpAddress()
+ .startsWith(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.split("/")[0])) {
+ errInfo.append(prop.getProperty("server_ip") + String.format("can_not_be",
+ Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.split("/")[0]));
+ }
+ } else {
+ // baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
+ baseIpCfg.setSrcIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
+ baseIpCfg.setIpPattern(3);
+ if (baseIpCfg.getDestIpAddress().equals(Constants.IPV4_DEFAULT_IP_VALUE)) {
+ errInfo.append(prop.getProperty("server_ip")
+ + String.format("can_not_be", Constants.IPV4_DEFAULT_IP_VALUE));
+ }
+ }
+ baseIpCfg.setIpType(4);
+ }
+ } else {
+ String matchType = this.validIPAddress("client_ip", errInfo, baseIpCfg.getSrcIpAddress(),
+ ipType, ipPattern);
+ String matchType1 = this.validIPAddress("server_ip", errInfo, baseIpCfg.getDestIpAddress(),
+ ipType, ipPattern);
+ if (StringUtils.isNotBlank(matchType)&&StringUtils.isNotBlank(matchType1)&&
+ !matchType.equals(matchType1)) {
+ errInfo.append(prop.get("the_same_ip_type_pattern") + ";");
+ }
+ // baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
+ // baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
+ if (matchType.startsWith("IPV6")) {
+ baseIpCfg.setIpType(6);
+ } else {
+ baseIpCfg.setIpType(4);
+ }
+ if (matchType.endsWith("RANGE")) {
+ if (matchType.startsWith("IPV4")) {
+ this.validIPv4Range("client_ip", errInfo, baseIpCfg.getSrcIpAddress());
+ this.validIPv4Range("server_ip", errInfo, baseIpCfg.getDestIpAddress());
+ }
+
+ if (baseIpCfg.getSrcIpAddress().split("-")[0]
+ .equals(baseIpCfg.getDestIpAddress().split("-")[0])) {
+ errInfo.append(String.format(prop.getProperty("are_the_same"),
+ baseIpCfg.getSrcIpAddress().split("-")[0],
+ baseIpCfg.getDestIpAddress().split("-")[0]) + ";");
+ }
+ baseIpCfg.setIpPattern(2);
+ } else if (matchType.endsWith("SUBNET")) {
+ if (baseIpCfg.getSrcIpAddress().split("/")[0]
+ .equals(baseIpCfg.getDestIpAddress().split("/")[0])) {
+ errInfo.append(String.format(prop.getProperty("are_the_same"),
+ baseIpCfg.getSrcIpAddress().split("/")[0],
+ baseIpCfg.getDestIpAddress().split("/")[0]) + ";");
+ }
+ baseIpCfg.setIpPattern(1);
+ } else {
+ if (baseIpCfg.getSrcIpAddress().equals(baseIpCfg.getDestIpAddress())) {
+ errInfo.append(String.format(prop.getProperty("are_the_same"),
+ prop.getProperty("client_ip"), prop.getProperty("server_ip")) + ";");
+ }
+ baseIpCfg.setIpPattern(3);
+ }
+ }
+ }
+
+ // TODO 判断源IP和目的IP的值
+ // TODO 判断源IP和目的IP格式
+
+ if (StringUtil.isEmpty(baseIpCfg.getSrcPort())) {
+ srcPortEmpty = true;
+ }
+ if (StringUtil.isEmpty(baseIpCfg.getDestPort())) {
+ if (srcPortEmpty) {
+ baseIpCfg.setSrcPort("0");
+ baseIpCfg.setDestPort("0");
+ baseIpCfg.setPortPattern(1);
+ } else {
+ if (baseIpCfg.getSrcPort().indexOf("/") > -1) {
+ baseIpCfg.setDestPort("0/0");
+ baseIpCfg.setPortPattern(2);
+ } else {
+ baseIpCfg.setDestPort("0");
+ baseIpCfg.setPortPattern(1);
+ }
+ baseIpCfg.setSrcPort(baseIpCfg.getSrcPort().trim());
+ }
+ } else {
+ if (srcPortEmpty) {
+ if (baseIpCfg.getDestPort().indexOf("/") > -1) {
+ baseIpCfg.setSrcPort("0/0");
+ baseIpCfg.setPortPattern(2);
+ } else {
+ baseIpCfg.setSrcPort("0");
+ baseIpCfg.setPortPattern(1);
+ }
+ baseIpCfg.setDestPort(baseIpCfg.getSrcPort().trim());
+ } else {
+ if (baseIpCfg.getSrcPort().indexOf("/") > -1) {
+ baseIpCfg.setPortPattern(2);
+ } else {
+ baseIpCfg.setPortPattern(1);
+ }
+ baseIpCfg.setSrcPort(baseIpCfg.getSrcPort().trim());
+ baseIpCfg.setDestPort(baseIpCfg.getDestPort().trim());
+
+ }
+ }
+ // TODO 判断源端口和目的端口格式
+ // TODO 判断源和目的端口的值
+ boolean validPort = this.validPort(errInfo, baseIpCfg.getSrcPort(), baseIpCfg.getDestPort(),
+ portPattern);
+ if (StringUtil.isEmpty(baseIpCfg.getProtocol())) {
+ if (StringUtil.isEmpty(regionDict.getConfigProtocol())) {
+ baseIpCfg.setProtocol(0);
+ } else {
+ baseIpCfg.setProtocol(Integer.parseInt(regionDict.getConfigProtocol().split(",")[0]));
+ }
+ baseIpCfg.setProtocolId(serviceDict.getProtocolId());
+ } else {
+ baseIpCfg.setProtocol(baseIpCfg.getProtocol());
+ baseIpCfg.setProtocolId(serviceDict.getProtocolId());
+ }
+ // TODO 判断Protocol的值
+ boolean validProtocol = this.validProtocol(errInfo, baseIpCfg.getProtocol(), protocol);
+ // 验证protocol与port是否符合逻辑
+ if (validProtocol && validPort) {
+ validProtocolAndPort(errInfo, baseIpCfg.getProtocol(), baseIpCfg.getSrcPort(),
+ baseIpCfg.getDestPort());
+ }
+ 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(baseIpCfg.getDirection());
+ }
+
+ // TODO 判断Direction的值
+ this.validDirection(errInfo, baseIpCfg.getDirection(), direction);
+ }
+ if (errInfo.toString().length() > 0) {//
+ errTip.append(String.format(prop.getProperty("line"), i + 2) + ",");
+ errTip.append(errInfo);
+ errTip.append("
");
+ }
ipList.add(baseIpCfg);
}
+ if (errTip.toString().length() > 0) {
+ throw new ServiceException(errTip.toString());
+ }
return ipList;
-
- /*List ipTypeList = DictUtils.getDictList("IP_TYPE");
- List ipPatternList = DictUtils.getDictList("IP_PATTERN");
- List portPatternList = DictUtils.getDictList("PORT_PATTERN");
- List directionList = DictUtils.getDictList("DIRECTION");
- List protocolList = DictUtils.getDictList("PROTOCOL");
- List ipsecProrocolList = DictUtils.getDictList("IPSEC_PROTOCOL");
- List tunnelProrocolList = DictUtils.getDictList("TUNNEL_PROTOCOL");
- List specialFunctionIdList = DictUtils.getDictList("SPECIAL_FUNCTION_ID");
- List irTypeList = DictUtils.getDictList("IR_TYPE");
- String specialItem=null;
- for(SysDataDictionaryItem sfuncItem:specialFunctionIdList){
- if(functionId==Integer.parseInt(sfuncItem.getItemCode())){
- specialItem=sfuncItem.getItemValue();
+ }
+ /**
+ * 协议与端口验证规则
+ *
+ * @param errInfo
+ * @param protocol
+ * @param srcPort
+ * @param destPort
+ */
+ public void validProtocolAndPort(StringBuffer errInfo, Integer protocol, String srcPort, String destPort) {
+ Properties prop = this.getMsgProp();
+ if (srcPort.indexOf("/") > -1) {
+ srcPort = srcPort.split("/")[0];
+ }
+ if (destPort.indexOf("/") > -1) {
+ destPort = destPort.split("/")[0];
+ }
+ if (protocol == 0) {
+ return;
+ } else if (protocol != 6 && protocol != 17) {
+ if (!"0".equals(srcPort) || !"0".equals(destPort)) {
+ errInfo.append(prop.get("protocol_and_port") + ";");
}
}
- if("ipaddr".equals(specialItem)){
- List icmpprotocolList = DictUtils.getDictList("ICMP_PROTOCOL");
- if(action==Constants.DROP_ACTION) {
+
+ }
+
+ /**
+ * 验证方向
+ *
+ * @param errInfo
+ * @param direction
+ * @param directionPattern
+ * @throws ServiceException
+ */
+ public boolean validDirection(StringBuffer errInfo, Integer direction, String directionPattern)
+ throws ServiceException {
+ Properties prop = this.getMsgProp();
+ if (direction == null) {
+ errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("direction")) + ";");
+ return false;
+ }
+ boolean has = false;
+ for (String p : directionPattern.split(",")) {
+ if (p.equals(direction.toString())) {
+ has = true;
+ break;
+ }
+ }
+ if (!has) {
+ errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("direction")) + ","
+ + String.format(prop.getProperty("alternative_values"), directionPattern) + ";");
+ }
+ return has;
+ }
+ /**
+ * 验证协议
+ * @param errInfo
+ * @param protocol
+ * @param protocolPattern
+ * @return
+ * @throws ServiceException
+ */
+ public boolean validProtocol(StringBuffer errInfo, Integer protocol, String protocolPattern)
+ throws ServiceException {
+ Properties prop = this.getMsgProp();
+ if (protocol == null) {
+ errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("protocol")) + ";");
+ return false;
+ }
+ boolean has = false;
+ for (String p : protocolPattern.split(",")) {
+ if (p.equals(protocol.toString())) {
+ has = true;
+ break;
+ }
+ }
+ if (!has) {
+ errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol")) + ","
+ + String.format(prop.getProperty("alternative_values"), protocolPattern) + ";");
+ }
+ return has;
+ }
+
+ /**
+ * 验证端口格式
+ *
+ * @param srcPortStr
+ * @param destPortStr
+ * @param portPattern
+ * @throws ServiceException
+ */
+ public boolean validPort(StringBuffer errInfo, String srcPortStr, String destPortStr, String portPattern)
+ throws ServiceException {
+ boolean valid = true;
+ Properties prop = this.getMsgProp();
+ if (portPattern.equals("1")) {
+ try {
+ Integer srcPort = Integer.parseInt(srcPortStr);
+ if (srcPort < 0 || srcPort > 65535) {
+ errInfo.append(prop.getProperty("client_port")
+ + String.format(prop.getProperty("must_between"), 0, 65535) + ";");
+ valid = false;
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ errInfo.append(String.format(prop.getProperty("not_number"), prop.getProperty("client_port")) + ";");
+ valid = false;
+ }
+ try {
+ Integer destPort = Integer.parseInt(destPortStr);
+ if (destPort < 0 || destPort > 65535) {
+ errInfo.append(prop.getProperty("server_port")
+ + String.format(prop.getProperty("must_between"), 0, 65535) + ";");
+ valid = false;
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ errInfo.append(String.format(prop.getProperty("not_number"), prop.getProperty("server_port")) + ";");
+ valid = false;
+ }
+ } else if (portPattern.equals("2")) {
+ Pattern p = Pattern.compile("^[0-9]+/[0-9]+$");
+ Matcher m = p.matcher(srcPortStr);
+ if (!m.matches()) {
+ errInfo.append(
+ String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty("client_port")) + ";");
+ valid = false;
+ }
+ m = p.matcher(destPortStr);
+ if (!m.matches()) {
+ errInfo.append(
+ String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty("server_port")) + ";");
+ valid = false;
+ }
+ Integer srcPort = Integer.parseInt(srcPortStr.split("/")[0]);
+ Integer srcPortMask = Integer.parseInt(srcPortStr.split("/")[1]);
+ Integer destPort = Integer.parseInt(destPortStr.split("/")[0]);
+ Integer destPortMask = Integer.parseInt(destPortStr.split("/")[1]);
+ if (srcPort < 0 || srcPort > 65535) {
+ errInfo.append(prop.getProperty("client_port")
+ + String.format(prop.getProperty("must_between"), 0, 65535) + ";");
+ valid = false;
+ }
+ if (srcPortMask < 0 || srcPortMask > 65535) {
+ errInfo.append(prop.getProperty("client_port_mask")
+ + String.format(prop.getProperty("must_between"), 0, 65535) + ";");
+ valid = false;
+ }
+ if (destPort < 0 || destPort > 65535) {
+ errInfo.append(prop.getProperty("server_port")
+ + String.format(prop.getProperty("must_between"), 0, 65535) + ";");
+ valid = false;
+ }
+ if (destPortMask < 0 || destPortMask > 65535) {
+ errInfo.append(prop.getProperty("server_port_mask")
+ + String.format(prop.getProperty("must_between"), 0, 65535) + ";");
+ valid = false;
+ }
+ } else if (portPattern.indexOf("1") > -1 && portPattern.indexOf("2") > -1) {
+ Pattern p = Pattern.compile("^[0-9]+/[0-9]+$");
+ Pattern p1 = Pattern.compile("^[0-9]+$");
+ Matcher m = p.matcher(srcPortStr);// 源端口是端口掩码格式
+ Matcher m1 = p.matcher(destPortStr);// 目的端口是端口掩码格式
+ Matcher m2 = p1.matcher(srcPortStr);// 源端口是端口格式
+ Matcher m3 = p1.matcher(destPortStr);// 目的端口是端口格式
+ if (m.matches()) {
+ Integer srcPort = Integer.parseInt(srcPortStr.split("/")[0]);
+ Integer srcPortMask = Integer.parseInt(srcPortStr.split("/")[1]);
+ if (srcPort < 0 || srcPort > 65535) {
+ errInfo.append(prop.getProperty("client_port")
+ + String.format(prop.getProperty("must_between"), 0, 65535) + ";");
+ valid = false;
+ }
+ if (srcPortMask < 0 || srcPortMask > 65535) {
+ errInfo.append(prop.getProperty("client_port_mask")
+ + String.format(prop.getProperty("must_between"), 0, 65535) + ";");
+ valid = false;
+ }
+ }
+ if (m1.matches()) {
+ Integer destPort = Integer.parseInt(destPortStr.split("/")[0]);
+ Integer destPortMask = Integer.parseInt(destPortStr.split("/")[1]);
+
+ if (destPort < 0 || destPort > 65535) {
+ errInfo.append(prop.getProperty("server_port")
+ + String.format(prop.getProperty("must_between"), 0, 65535) + ";");
+ valid = false;
+ }
+ if (destPortMask < 0 || destPortMask > 65535) {
+ errInfo.append(prop.getProperty("server_port_mask")
+ + String.format(prop.getProperty("must_between"), 0, 65535) + ";");
+ valid = false;
+ }
+ }
+ if (m2.matches()) {
+ try {
+ Integer srcPort = Integer.parseInt(srcPortStr);
+ if (srcPort < 0 || srcPort > 65535) {
+ errInfo.append(prop.getProperty("client_port")
+ + String.format(prop.getProperty("must_between"), 0, 65535) + ";");
+ valid = false;
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ errInfo.append(
+ String.format(prop.getProperty("not_number"), prop.getProperty("client_port")) + ";");
+ valid = false;
+ }
+ }
+ if (m3.matches()) {
+ try {
+ Integer destPort = Integer.parseInt(destPortStr);
+ if (destPort < 0 || destPort > 65535) {
+ errInfo.append(prop.getProperty("server_port")
+ + String.format(prop.getProperty("must_between"), 0, 65535) + ";");
+ valid = false;
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ errInfo.append(
+ String.format(prop.getProperty("not_number"), prop.getProperty("server_port")) + ";");
+ valid = false;
+ }
+ }
+ if ((m.matches() && m3.matches()) || (m2.matches() && m1.matches())) {
+ errInfo.append(prop.getProperty("the_same_port_pattern") + ";");
+ valid = false;
+ }
+ if (!m.matches() && !m2.matches()) {
+ errInfo.append(
+ String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty("client_port"))
+ + ";");
+ valid = false;
+ }
+ if (!m1.matches() && !m3.matches()) {
+ errInfo.append(
+ String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty("server_port"))
+ + ";");
+ valid = false;
+ }
+
+
+ }
+ return valid;
+ }
+
+ /**
+ * IPv4 范围验证
+ *
+ * @param ipName
+ * @param errInfo
+ * @param ip
+ */
+ public void validIPv4Range(String ipName, StringBuffer errInfo, String ip) {
+ Properties prop = this.getMsgProp();
+ String prefix = ip.split("-")[0];
+ String subfix = ip.split("-")[1];
+ if (Integer.parseInt(prefix.split("\\.")[0]) < 192 || Integer.parseInt(prefix.split("\\.")[0]) > 223
+ || Integer.parseInt(subfix.split("\\.")[0]) < 192 || Integer.parseInt(subfix.split("\\.")[0]) > 223) {
+ errInfo.append(prop.get(ipName) + " " + prop.get("ip_range_in_c") + ";");
+ }
+ if (!prefix.split("\\.")[0].equals(subfix.split("\\.")[0])
+ || !prefix.split("\\.")[1].equals(subfix.split("\\.")[1])
+ || !prefix.split("\\.")[2].equals(subfix.split("\\.")[2])) {
+ errInfo.append(prop.get(ipName) + " " + prop.get("ip_range_bit_field") + ";");
+ }
+ if (ipToInt(prefix) >= ipToInt(subfix)) {
+ errInfo.append(prop.get(ipName) + " " + prop.get("ip_range_smaller") + ";");
+ }
+ }
+
+ /**
+ * 根据位运算把 byte[] -> int
+ *
+ * @param bytes
+ * @return int
+ */
+ public static int bytesToInt(byte[] bytes) {
+ int addr = bytes[3] & 0xFF;
+ addr |= ((bytes[2] << 8) & 0xFF00);
+ addr |= ((bytes[1] << 16) & 0xFF0000);
+ addr |= ((bytes[0] << 24) & 0xFF000000);
+ return addr;
+ }
+
+ public static int ipToInt(String ipAddr) {
+ try {
+ return bytesToInt(ipToBytesByReg(ipAddr));
+ } catch (Exception e) {
+ throw new IllegalArgumentException(ipAddr + " is invalid IP");
+ }
+ }
+
+ /**
+ * 把IP地址转化为int
+ *
+ * @param ipAddr
+ * @return int
+ */
+ public static byte[] ipToBytesByReg(String ipAddr) {
+ byte[] ret = new byte[4];
+ try {
+ String[] ipArr = ipAddr.split("\\.");
+ ret[0] = (byte) (Integer.parseInt(ipArr[0]) & 0xFF);
+ ret[1] = (byte) (Integer.parseInt(ipArr[1]) & 0xFF);
+ ret[2] = (byte) (Integer.parseInt(ipArr[2]) & 0xFF);
+ ret[3] = (byte) (Integer.parseInt(ipArr[3]) & 0xFF);
+ return ret;
+ } catch (Exception e) {
+ throw new IllegalArgumentException(ipAddr + " is invalid IP");
+ }
+
+ }
+
+ /**
+ * 校验ip
+ *
+ * @param ipName
+ * @param errInfo
+ * @param ip
+ * @param ipType
+ * @param ipPattern
+ * @return
+ * @throws ServiceException
+ */
+ public String validIPAddress(String ipName, StringBuffer errInfo, String ip, String ipType, String ipPattern)
+ throws ServiceException {
+ Properties prop = this.getMsgProp();
+ String matchType = "";
+ Pattern ipv4IpSubnetRegexp = Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
+ Pattern ipv6IpSubnetRegexp = Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
+ Pattern ipv4IpRangeRegexp = Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
+ Pattern ipv6IpRangeRegexp = Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
+ Pattern ipv4IpRegexp = Pattern.compile(Constants.IPV4_IP_REGEXP);
+ Pattern ipv6IpRegexp = Pattern.compile(Constants.IPV6_IP_REGEXP);
+ Matcher matcher = ipv4IpRegexp.matcher(ip);
+ if (matcher.matches()) {
+ matchType = "IPV4_IP";
+ } else {
+ matcher = ipv6IpRegexp.matcher(ip);
+ if (matcher.matches()) {
+ matchType = "IPV6_IP";
+ } else {
+ matcher = ipv4IpSubnetRegexp.matcher(ip);
+ if (matcher.matches()) {
+ matchType = "IPV4_IP_SUBNET";
+ } else {
+ matcher = ipv6IpSubnetRegexp.matcher(ip);
+ if (matcher.matches()) {
+ matchType = "IPV6_IP_SUBNET";
+ } else {
+ matcher = ipv4IpRangeRegexp.matcher(ip);
+ if (matcher.matches()) {
+ matchType = "IPV4_IP_RANGE";
+ } else {
+ matcher = ipv6IpRangeRegexp.matcher(ip);
+ if (matcher.matches()) {
+ matchType = "IPV6_IP_RANGE";
+ } else {
+ errInfo.append(
+ String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty(ipName))
+ + ";");
+ }
+ }
+ }
+ }
+ }
+ }
+ if (ipType.indexOf("4") == -1 && matchType.startsWith("IPV4")) {
+ errInfo.append(
+ prop.getProperty("ip_type") + " " + String.format(prop.getProperty("can_not_be"), "IPv4") + ",4;");
+ }
+ if (ipType.indexOf("6") == -1 && matchType.startsWith("IPV6")) {
+ errInfo.append(
+ prop.getProperty("ip_type") + " " + String.format(prop.getProperty("can_not_be"), "IPv6") + ",6;");
+ }
+ if (ipPattern.indexOf("3") == -1 && matchType.endsWith("IP")) {
+ errInfo.append(
+ prop.getProperty("ip_pattern") + " " + String.format(prop.getProperty("can_not_be"), "IP") + ",3;");
+ }
+ if (ipPattern.indexOf("1") == -1 && matchType.endsWith("SUBNET")) {
+ errInfo.append(prop.getProperty("ip_pattern") + " "
+ + String.format(prop.getProperty("can_not_be"), prop.getProperty("ip_subnet")) + ",1;");
+ }
+ if (ipPattern.indexOf("2") == -1 && matchType.endsWith("RANGE")) {
+ errInfo.append(prop.getProperty("ip_pattern") + " "
+ + String.format(prop.getProperty("can_not_be"), prop.getProperty("ip_range")) + ",2;");
+ }
+ return matchType;
+ }
+
+ @Deprecated
+ public void checkIpCfg(int action, int functionId, List list) throws ServiceException {
+ Properties prop = this.getMsgProp();
+ List ipTypeList = DictUtils.getDictList("IP_TYPE");
+ List ipPatternList = DictUtils.getDictList("IP_PATTERN");
+ List portPatternList = DictUtils.getDictList("PORT_PATTERN");
+ List directionList = DictUtils.getDictList("DIRECTION");
+ List protocolList = DictUtils.getDictList("PROTOCOL");
+ List ipsecProrocolList = DictUtils.getDictList("IPSEC_PROTOCOL");
+ List tunnelProrocolList = DictUtils.getDictList("TUNNEL_PROTOCOL");
+ List specialFunctionIdList = DictUtils.getDictList("SPECIAL_FUNCTION_ID");
+ List irTypeList = DictUtils.getDictList("IR_TYPE");
+ String specialItem = null;
+ for (SysDataDictionaryItem sfuncItem : specialFunctionIdList) {
+ if (functionId == Integer.parseInt(sfuncItem.getItemCode())) {
+ specialItem = sfuncItem.getItemValue();
+ }
+ }
+ if ("ipaddr".equals(specialItem)) {
+ List icmpprotocolList = DictUtils.getDictList("ICMP_PROTOCOL");
+ if (action == Constants.DROP_ACTION) {
protocolList.addAll(icmpprotocolList);
}
}
- StringBuffer msg=new StringBuffer();
- int line=1;
- for(IpCfgTemplate value:list){
- String lineStart=String.format(prop.getProperty("line"), line)+":";
- StringBuffer errInfo=new StringBuffer();
+ StringBuffer msg = new StringBuffer();
+ int line = 1;
+ for (IpCfgTemplate value : list) {
+ String lineStart = String.format(prop.getProperty("line"), line) + ":";
+ StringBuffer errInfo = new StringBuffer();
// ip_type check start
- Integer ipType=value.getIpType();
- if(ipType==null){
- errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ip_type"))+";");
- }else{
- boolean has=false;
- for(SysDataDictionaryItem ipTypeItem:ipTypeList){
- if(ipType==Integer.parseInt(ipTypeItem.getItemCode())){
- has=true;
+ Integer ipType = value.getIpType();
+ if (ipType == null) {
+ errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ip_type")) + ";");
+ } else {
+ boolean has = false;
+ for (SysDataDictionaryItem ipTypeItem : ipTypeList) {
+ if (ipType == Integer.parseInt(ipTypeItem.getItemCode())) {
+ has = true;
break;
}
}
- if(!has){
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ip_type"))+";");
+ if (!has) {
+ errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ip_type")) + ";");
}
}
// ip_type check end
// ip_pattern check start
- Integer ipPattern=value.getIpPattern();
- if(ipPattern==null){
- errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ip_pattern"))+";");
- }else{
- boolean has=false;
- for(SysDataDictionaryItem ipPatternItem:ipPatternList){
- if(ipPattern==Integer.parseInt(ipPatternItem.getItemCode())){
- has=true;
+ Integer ipPattern = value.getIpPattern();
+ if (ipPattern == null) {
+ errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ip_pattern")) + ";");
+ } else {
+ boolean has = false;
+ for (SysDataDictionaryItem ipPatternItem : ipPatternList) {
+ if (ipPattern == Integer.parseInt(ipPatternItem.getItemCode())) {
+ has = true;
break;
}
}
- if(!has){
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ip_pattern"))+";");
+ if (!has) {
+ errInfo.append(
+ String.format(prop.getProperty("is_incorrect"), prop.getProperty("ip_pattern")) + ";");
}
}
// ip_pattern check end
- //client_ip check start
- String srcIp=value.getSrcIpAddress();
- String _msg="";
- if("ipmulitiplex".equals(specialItem)) {
- _msg=checkIP(prop,prop.getProperty("IP"),srcIp,ipType,ipPattern);
- }else {
- _msg=checkIP(prop,prop.getProperty("client_ip"),srcIp,ipType,ipPattern);
+ // client_ip check start
+ String srcIp = value.getSrcIpAddress();
+ String _msg = "";
+ if ("ipmulitiplex".equals(specialItem)) {
+ _msg = checkIP(prop, prop.getProperty("IP"), srcIp, ipType, ipPattern);
+ } else {
+ _msg = checkIP(prop, prop.getProperty("client_ip"), srcIp, ipType, ipPattern);
}
- if(StringUtils.isNotBlank(_msg)){
+ if (StringUtils.isNotBlank(_msg)) {
errInfo.append(_msg);
}
- //client_ip check end
- //server_ip check start
- String destIp=value.getDestIpAddress();
- if("ipmulitiplex".equals(specialItem)) {//set 默认值
- if(ipPattern!=null&&ipType!=null) {
- if(1==ipPattern.intValue()) {
- if(4==ipType.intValue()) {
+ // client_ip check end
+ // server_ip check start
+ String destIp = value.getDestIpAddress();
+ if ("ipmulitiplex".equals(specialItem)) {// set 默认值
+ if (ipPattern != null && ipType != null) {
+ if (1 == ipPattern.intValue()) {
+ if (4 == ipType.intValue()) {
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
- }else if(6==ipType.intValue()) {
+ } else if (6 == ipType.intValue()) {
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
- }else if(46==ipType.intValue()) {
+ } else if (46 == ipType.intValue()) {
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
- }else if(64==ipType.intValue()) {
+ } else if (64 == ipType.intValue()) {
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
- }else if(10==ipType.intValue()) {
+ } else if (10 == ipType.intValue()) {
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
}
- }else if(2==ipPattern.intValue()) {
- if(4==ipType.intValue()) {
+ } else if (2 == ipPattern.intValue()) {
+ if (4 == ipType.intValue()) {
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
- }else if(6==ipType.intValue()) {
+ } else if (6 == ipType.intValue()) {
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
- }else if(46==ipType.intValue()) {
+ } else if (46 == ipType.intValue()) {
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
- }else if(64==ipType.intValue()) {
+ } else if (64 == ipType.intValue()) {
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
- }else if(10==ipType.intValue()) {
+ } else if (10 == ipType.intValue()) {
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
}
- }else if(3==ipPattern.intValue()) {
- if(4==ipType.intValue()) {
+ } else if (3 == ipPattern.intValue()) {
+ if (4 == ipType.intValue()) {
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
- }else if(6==ipType.intValue()) {
+ } else if (6 == ipType.intValue()) {
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
- }else if(46==ipType.intValue()) {
+ } else if (46 == ipType.intValue()) {
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
- }else if(64==ipType.intValue()) {
+ } else if (64 == ipType.intValue()) {
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
- }else if(10==ipType.intValue()) {
+ } else if (10 == ipType.intValue()) {
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
}
}
}
- }else {
- if(srcIp.equals(destIp)){
- String info=String.format(prop.getProperty("are_the_same"),prop.getProperty("client_ip"),prop.getProperty("server_ip"));
- errInfo.append(info+";");
+ } else {
+ if (srcIp.equals(destIp)) {
+ String info = String.format(prop.getProperty("are_the_same"), prop.getProperty("client_ip"),
+ prop.getProperty("server_ip"));
+ errInfo.append(info + ";");
}
- _msg=checkIP(prop,prop.getProperty("server_ip"),destIp,ipType,ipPattern);
- if(StringUtils.isNotBlank(_msg)){
+ _msg = checkIP(prop, prop.getProperty("server_ip"), destIp, ipType, ipPattern);
+ if (StringUtils.isNotBlank(_msg)) {
errInfo.append(_msg);
}
}
- if(!"ipmulitiplex".equals(specialItem)&&(46==ipType.intValue()||64==ipType.intValue()||10==ipType.intValue())) {
- _msg=checkIp(prop, prop.getProperty("client_ip"), srcIp, prop.getProperty("server_ip"), destIp, ipType, ipPattern);
- if(StringUtils.isNotBlank(_msg)){
+ if (!"ipmulitiplex".equals(specialItem)
+ && (46 == ipType.intValue() || 64 == ipType.intValue() || 10 == ipType.intValue())) {
+ _msg = checkIp(prop, prop.getProperty("client_ip"), srcIp, prop.getProperty("server_ip"), destIp,
+ ipType, ipPattern);
+ if (StringUtils.isNotBlank(_msg)) {
errInfo.append(_msg);
}
}
- //server_ip check end
- //port_pattern check start
- Integer portPattern=value.getPortPattern();
- if(portPattern==null){
- errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("port_pattern"))+";");
- }else{
- boolean has=false;
- for(SysDataDictionaryItem portPatternItem:portPatternList){
- if(portPattern==Integer.parseInt(portPatternItem.getItemCode())){
- has=true;
+ // server_ip check end
+ // port_pattern check start
+ Integer portPattern = value.getPortPattern();
+ if (portPattern == null) {
+ errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("port_pattern")) + ";");
+ } else {
+ boolean has = false;
+ for (SysDataDictionaryItem portPatternItem : portPatternList) {
+ if (portPattern == Integer.parseInt(portPatternItem.getItemCode())) {
+ has = true;
break;
}
}
- if(!has){
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("port_pattern"))+";");
+ if (!has) {
+ errInfo.append(
+ String.format(prop.getProperty("is_incorrect"), prop.getProperty("port_pattern")) + ";");
}
}
- //port_pattern check end
- //src_port check start
- String srcPort=value.getSrcPort();
- if("ipmulitiplex".equals(specialItem)) {
- _msg=checkPort(prop,prop.getProperty("port"), srcPort, portPattern);
- }else {
- _msg=checkPort(prop,prop.getProperty("client_port"), srcPort, portPattern);
+ // port_pattern check end
+ // src_port check start
+ String srcPort = value.getSrcPort();
+ if ("ipmulitiplex".equals(specialItem)) {
+ _msg = checkPort(prop, prop.getProperty("port"), srcPort, portPattern);
+ } else {
+ _msg = checkPort(prop, prop.getProperty("client_port"), srcPort, portPattern);
}
-
- if(StringUtils.isNotBlank(_msg)){
+
+ if (StringUtils.isNotBlank(_msg)) {
errInfo.append(_msg);
}
- //src_port check end
- //dest_port check start
- String destPort=value.getDestPort();
- if("ipmulitiplex".equals(specialItem)) {//set 默认值
- if(portPattern!=null) {
- if(2==portPattern.intValue()) {
+ // src_port check end
+ // dest_port check start
+ String destPort = value.getDestPort();
+ if ("ipmulitiplex".equals(specialItem)) {// set 默认值
+ if (portPattern != null) {
+ if (2 == portPattern.intValue()) {
value.setDestPort(Constants.PORT_MASK_DEFAULT);
- }else if(1==portPattern.intValue()) {
+ } else if (1 == portPattern.intValue()) {
value.setDestPort(Constants.PORT_DEFAULT);
}
}
- }else {
- _msg=checkPort(prop,prop.getProperty("server_port"), destPort, portPattern);
+ } else {
+ _msg = checkPort(prop, prop.getProperty("server_port"), destPort, portPattern);
}
- if(StringUtils.isNotBlank(_msg)){
+ if (StringUtils.isNotBlank(_msg)) {
errInfo.append(_msg);
}
- //dest_port check end
- //direction check start
- Integer direction=value.getDirection();
- if(direction==null){
- errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("direction"))+";");
- }else{
- boolean has=false;
- for(SysDataDictionaryItem directionItem:directionList){
- if(Integer.parseInt(directionItem.getItemCode())==direction.intValue()){
- has=true;
+ // dest_port check end
+ // direction check start
+ Integer direction = value.getDirection();
+ if (direction == null) {
+ errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("direction")) + ";");
+ } else {
+ boolean has = false;
+ for (SysDataDictionaryItem directionItem : directionList) {
+ if (Integer.parseInt(directionItem.getItemCode()) == direction.intValue()) {
+ has = true;
break;
}
}
- if(!has){
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("direction"))+";");
+ if (!has) {
+ errInfo.append(
+ String.format(prop.getProperty("is_incorrect"), prop.getProperty("direction")) + ";");
}
}
- //direction check end
- //protocol check start
- Integer protocol= value.getProtocol();
- if(protocol==null){
- errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("protocol"))+";");
- }else{
- if(specialItem!=null&&("ipsec".equals(specialItem)||"tunnel".equals(specialItem))){
- if("ipsec".equals(specialItem)){
- if(action==Constants.DROP_ACTION.intValue()) {
- boolean has=false;
- for(SysDataDictionaryItem protocolItem:ipsecProrocolList){
- if(Integer.parseInt(protocolItem.getItemCode())==protocol.intValue()){
- has=true;
+ // direction check end
+ // protocol check start
+ Integer protocol = value.getProtocol();
+ if (protocol == null) {
+ errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("protocol")) + ";");
+ } else {
+ if (specialItem != null && ("ipsec".equals(specialItem) || "tunnel".equals(specialItem))) {
+ if ("ipsec".equals(specialItem)) {
+ if (action == Constants.DROP_ACTION.intValue()) {
+ boolean has = false;
+ for (SysDataDictionaryItem protocolItem : ipsecProrocolList) {
+ if (Integer.parseInt(protocolItem.getItemCode()) == protocol.intValue()) {
+ has = true;
break;
}
}
- if(!has){
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol"))+";");
+ if (!has) {
+ errInfo.append(
+ String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol"))
+ + ";");
}
- }else {
- if(protocol!=0) {
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol"))+";");
+ } else {
+ if (protocol != 0) {
+ errInfo.append(
+ String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol"))
+ + ";");
}
}
- }else if("tunnel".equals(specialItem)){
- for(SysDataDictionaryItem protocolItem:tunnelProrocolList){
- if("default".equals(protocolItem.getItemValue())){
- if(protocol.intValue()!=Integer.parseInt(protocolItem.getItemCode())){
- errInfo.append(String.format(prop.getProperty("must_be"), prop.getProperty("protocol"),Integer.parseInt(protocolItem.getItemCode()))+";");
+ } else if ("tunnel".equals(specialItem)) {
+ for (SysDataDictionaryItem protocolItem : tunnelProrocolList) {
+ if ("default".equals(protocolItem.getItemValue())) {
+ if (protocol.intValue() != Integer.parseInt(protocolItem.getItemCode())) {
+ errInfo.append(
+ String.format(prop.getProperty("must_be"), prop.getProperty("protocol"),
+ Integer.parseInt(protocolItem.getItemCode())) + ";");
}
break;
}
}
-
+
}
- }else{
- boolean has=false;
- for(SysDataDictionaryItem protocolItem:protocolList){
- if(Integer.parseInt(protocolItem.getItemCode())==protocol.intValue()){
- has=true;
+ } else {
+ boolean has = false;
+ for (SysDataDictionaryItem protocolItem : protocolList) {
+ if (Integer.parseInt(protocolItem.getItemCode()) == protocol.intValue()) {
+ has = true;
break;
}
}
- if(!has){
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol"))+";");
+ if (!has) {
+ errInfo.append(
+ String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol")) + ";");
}
}
-
+
}
- //protocol check end
+ // protocol check end
// requestId check start
- Integer requestId=value.getRequestId();
- if(requestId==null){
- if("whitelistip".equals(specialItem)) {
+ Integer requestId = value.getRequestId();
+ if (requestId == null) {
+ if ("whitelistip".equals(specialItem)) {
value.setRequestId(0);
- }else {
- errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("letter"))+";");
+ } else {
+ errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("letter")) + ";");
}
-
- }else{//查询数据库是否存在ID
- if("whitelistip".equals(specialItem)) {
+
+ } else {// 查询数据库是否存在ID
+ if ("whitelistip".equals(specialItem)) {
value.setRequestId(0);
- }else {
- RequestInfo info=requestInfoService.getRequestInfoById((long)requestId.intValue());
- if(info==null){
- errInfo.append(String.format(prop.getProperty("id_not_exists"),requestId, prop.getProperty("letter"))+";");
- }else if(info.getIsValid()==Constants.VALID_NO||info.getIsValid()==Constants.VALID_DEL){
- errInfo.append(String.format(prop.getProperty("id_not_valid"),requestId, prop.getProperty("letter"))+";");
+ } else {
+ RequestInfo info = requestInfoService.getRequestInfoById((long) requestId.intValue());
+ if (info == null) {
+ errInfo.append(
+ String.format(prop.getProperty("id_not_exists"), requestId, prop.getProperty("letter"))
+ + ";");
+ } else if (info.getIsValid() == Constants.VALID_NO || info.getIsValid() == Constants.VALID_DEL) {
+ errInfo.append(
+ String.format(prop.getProperty("id_not_valid"), requestId, prop.getProperty("letter"))
+ + ";");
}
}
}
// requestId check end
- //classification check start
- String classification=value.getClassify();
- if(StringUtils.isNotBlank(classification)){
- try{
- for(String classify:classification.split(",")){
- if(StringUtils.isNotBlank(classify)){
- int c=Integer.parseInt(classify);
- ServiceDictInfo dict=serviceDictInfoService.getDictById(c);
- if(dict==null){
- errInfo.append(String.format(prop.getProperty("id_not_exists"),classify, prop.getProperty("classification"))+";");
- }else if(dict.getIsValid()==Constants.VALID_NO||dict.getIsValid()==Constants.VALID_DEL){
- errInfo.append(String.format(prop.getProperty("id_not_valid"),classify, prop.getProperty("classification"))+";");
+ // classification check start
+ String classification = value.getClassify();
+ if (StringUtils.isNotBlank(classification)) {
+ try {
+ for (String classify : classification.split(",")) {
+ if (StringUtils.isNotBlank(classify)) {
+ int c = Integer.parseInt(classify);
+ ServiceDictInfo dict = serviceDictInfoService.getDictById(c);
+ if (dict == null) {
+ errInfo.append(String.format(prop.getProperty("id_not_exists"), classify,
+ prop.getProperty("classification")) + ";");
+ } else if (dict.getIsValid() == Constants.VALID_NO
+ || dict.getIsValid() == Constants.VALID_DEL) {
+ errInfo.append(String.format(prop.getProperty("id_not_valid"), classify,
+ prop.getProperty("classification")) + ";");
}
}
}
- }catch (Exception e) {
+ } catch (Exception e) {
// TODO: handle exception
- errInfo.append(String.format(prop.getProperty("num_split_by_comma"), prop.getProperty("classification"))+";");
+ errInfo.append(
+ String.format(prop.getProperty("num_split_by_comma"), prop.getProperty("classification"))
+ + ";");
}
}
- //classification check end
- //attribute check start
- String attributes=value.getAttribute();
- if(StringUtils.isNotBlank(attributes)){
- try{
- for(String attribute:attributes.split(",")){
- if(StringUtils.isNotBlank(attribute)){
- int c=Integer.parseInt(attribute);
- ServiceDictInfo dict=serviceDictInfoService.getDictById(c);
- if(dict==null){
- errInfo.append(String.format(prop.getProperty("id_not_exists"),attribute, prop.getProperty("attribute"))+";");
- }else if(dict.getIsValid()==Constants.VALID_NO||dict.getIsValid()==Constants.VALID_DEL){
- errInfo.append(String.format(prop.getProperty("id_not_valid"),attribute, prop.getProperty("attribute"))+";");
+ // classification check end
+ // attribute check start
+ String attributes = value.getAttribute();
+ if (StringUtils.isNotBlank(attributes)) {
+ try {
+ for (String attribute : attributes.split(",")) {
+ if (StringUtils.isNotBlank(attribute)) {
+ int c = Integer.parseInt(attribute);
+ ServiceDictInfo dict = serviceDictInfoService.getDictById(c);
+ if (dict == null) {
+ errInfo.append(String.format(prop.getProperty("id_not_exists"), attribute,
+ prop.getProperty("attribute")) + ";");
+ } else if (dict.getIsValid() == Constants.VALID_NO
+ || dict.getIsValid() == Constants.VALID_DEL) {
+ errInfo.append(String.format(prop.getProperty("id_not_valid"), attribute,
+ prop.getProperty("attribute")) + ";");
}
}
}
- }catch (Exception e) {
+ } catch (Exception e) {
// TODO: handle exception
- errInfo.append(String.format(prop.getProperty("num_split_by_comma"), prop.getProperty("attribute"))+";");
+ errInfo.append(
+ String.format(prop.getProperty("num_split_by_comma"), prop.getProperty("attribute")) + ";");
}
}
- //attribute check end
- //attribute check start
- String labels=value.getLable();
- if(StringUtils.isNotBlank(labels)){
- try{
- for(String label:labels.split(",")){
- if(StringUtils.isNotBlank(label)){
- int c=Integer.parseInt(label);
- ServiceDictInfo dict=serviceDictInfoService.getDictById(c);
- if(dict==null){
- errInfo.append(String.format(prop.getProperty("id_not_exists"),label, prop.getProperty("label"))+";");
- }else if(dict.getIsValid()==Constants.VALID_NO||dict.getIsValid()==Constants.VALID_DEL){
- errInfo.append(String.format(prop.getProperty("id_not_valid"),label, prop.getProperty("label"))+";");
+ // attribute check end
+ // attribute check start
+ String labels = value.getLable();
+ if (StringUtils.isNotBlank(labels)) {
+ try {
+ for (String label : labels.split(",")) {
+ if (StringUtils.isNotBlank(label)) {
+ int c = Integer.parseInt(label);
+ ServiceDictInfo dict = serviceDictInfoService.getDictById(c);
+ if (dict == null) {
+ errInfo.append(String.format(prop.getProperty("id_not_exists"), label,
+ prop.getProperty("label")) + ";");
+ } else if (dict.getIsValid() == Constants.VALID_NO
+ || dict.getIsValid() == Constants.VALID_DEL) {
+ errInfo.append(String.format(prop.getProperty("id_not_valid"), label,
+ prop.getProperty("label")) + ";");
}
}
}
- }catch (Exception e) {
+ } catch (Exception e) {
// TODO: handle exception
- errInfo.append(String.format(prop.getProperty("num_split_by_comma"), prop.getProperty("label"))+";");
+ errInfo.append(
+ String.format(prop.getProperty("num_split_by_comma"), prop.getProperty("label")) + ";");
}
}
- //group and ir_type check start
- if("ipmulitiplex".equals(specialItem)) {
- Integer irType= value.getIrType();
- if(irType==null) {
- errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ir_type"))+";");
- }else {
- boolean has=false;
- for(SysDataDictionaryItem irTypeItem:irTypeList){
- if(Integer.parseInt(irTypeItem.getItemCode())==irType.intValue()){
- has=true;
+ // group and ir_type check start
+ if ("ipmulitiplex".equals(specialItem)) {
+ Integer irType = value.getIrType();
+ if (irType == null) {
+ errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ir_type")) + ";");
+ } else {
+ boolean has = false;
+ for (SysDataDictionaryItem irTypeItem : irTypeList) {
+ if (Integer.parseInt(irTypeItem.getItemCode()) == irType.intValue()) {
+ has = true;
break;
}
}
- if(!has){
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ir_type"))+";");
+ if (!has) {
+ errInfo.append(
+ String.format(prop.getProperty("is_incorrect"), prop.getProperty("ir_type")) + ";");
}
}
- Integer dnsStrategyId=value.getDnsStrategyId();
- if(dnsStrategyId==null) {
- errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("group_name"))+";");
- }else {
- PolicyGroupInfo group=policyGroupInfoService.getById(dnsStrategyId.intValue());
- if(group==null) {
- errInfo.append(String.format(prop.getProperty("id_not_exists"),dnsStrategyId, prop.getProperty("group_name"))+";");
- }else if(group.getIsValid()==Constants.VALID_DEL||group.getIsValid()==Constants.VALID_NO) {
- errInfo.append(String.format(prop.getProperty("id_not_valid"),dnsStrategyId, prop.getProperty("group_name"))+";");
+ Integer dnsStrategyId = value.getDnsStrategyId();
+ if (dnsStrategyId == null) {
+ errInfo.append(
+ String.format(prop.getProperty("can_not_null"), prop.getProperty("group_name")) + ";");
+ } else {
+ PolicyGroupInfo group = policyGroupInfoService.getById(dnsStrategyId.intValue());
+ if (group == null) {
+ errInfo.append(String.format(prop.getProperty("id_not_exists"), dnsStrategyId,
+ prop.getProperty("group_name")) + ";");
+ } else if (group.getIsValid() == Constants.VALID_DEL || group.getIsValid() == Constants.VALID_NO) {
+ errInfo.append(String.format(prop.getProperty("id_not_valid"), dnsStrategyId,
+ prop.getProperty("group_name")) + ";");
}
}
}
- if("ipratelimit".equals(specialItem)) {
- String ratelimit=value.getRatelimit();
- if(ratelimit==null) {
- errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ratelimit"))+";");
- }else {
+ if ("ipratelimit".equals(specialItem)) {
+ String ratelimit = value.getRatelimit();
+ if (ratelimit == null) {
+ errInfo.append(
+ String.format(prop.getProperty("can_not_null"), prop.getProperty("ratelimit")) + ";");
+ } else {
try {
- if(Double.parseDouble(ratelimit)<0||Double.parseDouble(ratelimit)>1) {
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ratelimit_limit"))+";");
+ if (Double.parseDouble(ratelimit) < 0 || Double.parseDouble(ratelimit) > 1) {
+ errInfo.append(
+ String.format(prop.getProperty("is_incorrect"), prop.getProperty("ratelimit_limit"))
+ + ";");
}
- }catch (Exception e) {
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ratelimit_limit"))+";");
+ } catch (Exception e) {
+ errInfo.append(
+ String.format(prop.getProperty("is_incorrect"), prop.getProperty("ratelimit_limit"))
+ + ";");
}
-
+
}
}
- //attribute check end
- if(StringUtils.isNotBlank(errInfo.toString())){
+ // attribute check end
+ if (StringUtils.isNotBlank(errInfo.toString())) {
msg.append(lineStart).append(errInfo);
- if(line");
}
}
- //group and ir_type check end
+ // group and ir_type check end
line++;
}
- if(StringUtils.isNotBlank(msg.toString())){
- throw new MaatConvertException(prop.getProperty("save_failed")+"
"+msg.toString());
- }*/
- }
-
- public void checkIpCfg(int action,int functionId ,List list) throws ServiceException{
- Properties prop=this.getMsgProp();
- List ipTypeList = DictUtils.getDictList("IP_TYPE");
- List ipPatternList = DictUtils.getDictList("IP_PATTERN");
- List portPatternList = DictUtils.getDictList("PORT_PATTERN");
- List directionList = DictUtils.getDictList("DIRECTION");
- List protocolList = DictUtils.getDictList("PROTOCOL");
- List ipsecProrocolList = DictUtils.getDictList("IPSEC_PROTOCOL");
- List tunnelProrocolList = DictUtils.getDictList("TUNNEL_PROTOCOL");
- List specialFunctionIdList = DictUtils.getDictList("SPECIAL_FUNCTION_ID");
- List irTypeList = DictUtils.getDictList("IR_TYPE");
- String specialItem=null;
- for(SysDataDictionaryItem sfuncItem:specialFunctionIdList){
- if(functionId==Integer.parseInt(sfuncItem.getItemCode())){
- specialItem=sfuncItem.getItemValue();
- }
- }
- if("ipaddr".equals(specialItem)){
- List icmpprotocolList = DictUtils.getDictList("ICMP_PROTOCOL");
- if(action==Constants.DROP_ACTION) {
- protocolList.addAll(icmpprotocolList);
- }
- }
- StringBuffer msg=new StringBuffer();
- int line=1;
- for(IpCfgTemplate value:list){
- String lineStart=String.format(prop.getProperty("line"), line)+":";
- StringBuffer errInfo=new StringBuffer();
- // ip_type check start
- Integer ipType=value.getIpType();
- if(ipType==null){
- errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ip_type"))+";");
- }else{
- boolean has=false;
- for(SysDataDictionaryItem ipTypeItem:ipTypeList){
- if(ipType==Integer.parseInt(ipTypeItem.getItemCode())){
- has=true;
- break;
- }
- }
- if(!has){
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ip_type"))+";");
- }
- }
- // ip_type check end
- // ip_pattern check start
- Integer ipPattern=value.getIpPattern();
- if(ipPattern==null){
- errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ip_pattern"))+";");
- }else{
- boolean has=false;
- for(SysDataDictionaryItem ipPatternItem:ipPatternList){
- if(ipPattern==Integer.parseInt(ipPatternItem.getItemCode())){
- has=true;
- break;
- }
- }
- if(!has){
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ip_pattern"))+";");
- }
- }
- // ip_pattern check end
- //client_ip check start
- String srcIp=value.getSrcIpAddress();
- String _msg="";
- if("ipmulitiplex".equals(specialItem)) {
- _msg=checkIP(prop,prop.getProperty("IP"),srcIp,ipType,ipPattern);
- }else {
- _msg=checkIP(prop,prop.getProperty("client_ip"),srcIp,ipType,ipPattern);
- }
- if(StringUtils.isNotBlank(_msg)){
- errInfo.append(_msg);
- }
- //client_ip check end
- //server_ip check start
- String destIp=value.getDestIpAddress();
- if("ipmulitiplex".equals(specialItem)) {//set 默认值
- if(ipPattern!=null&&ipType!=null) {
- if(1==ipPattern.intValue()) {
- if(4==ipType.intValue()) {
- value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
- }else if(6==ipType.intValue()) {
- value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
- }else if(46==ipType.intValue()) {
- value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
- }else if(64==ipType.intValue()) {
- value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
- }else if(10==ipType.intValue()) {
- value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
- }
- }else if(2==ipPattern.intValue()) {
- if(4==ipType.intValue()) {
- value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
- }else if(6==ipType.intValue()) {
- value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
- }else if(46==ipType.intValue()) {
- value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
- }else if(64==ipType.intValue()) {
- value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
- }else if(10==ipType.intValue()) {
- value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
- }
- }else if(3==ipPattern.intValue()) {
- if(4==ipType.intValue()) {
- value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
- }else if(6==ipType.intValue()) {
- value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
- }else if(46==ipType.intValue()) {
- value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
- }else if(64==ipType.intValue()) {
- value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
- }else if(10==ipType.intValue()) {
- value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
- }
- }
- }
- }else {
- if(srcIp.equals(destIp)){
- String info=String.format(prop.getProperty("are_the_same"),prop.getProperty("client_ip"),prop.getProperty("server_ip"));
- errInfo.append(info+";");
- }
- _msg=checkIP(prop,prop.getProperty("server_ip"),destIp,ipType,ipPattern);
- if(StringUtils.isNotBlank(_msg)){
- errInfo.append(_msg);
- }
- }
- if(!"ipmulitiplex".equals(specialItem)&&(46==ipType.intValue()||64==ipType.intValue()||10==ipType.intValue())) {
- _msg=checkIp(prop, prop.getProperty("client_ip"), srcIp, prop.getProperty("server_ip"), destIp, ipType, ipPattern);
- if(StringUtils.isNotBlank(_msg)){
- errInfo.append(_msg);
- }
- }
- //server_ip check end
- //port_pattern check start
- Integer portPattern=value.getPortPattern();
- if(portPattern==null){
- errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("port_pattern"))+";");
- }else{
- boolean has=false;
- for(SysDataDictionaryItem portPatternItem:portPatternList){
- if(portPattern==Integer.parseInt(portPatternItem.getItemCode())){
- has=true;
- break;
- }
- }
- if(!has){
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("port_pattern"))+";");
- }
- }
- //port_pattern check end
- //src_port check start
- String srcPort=value.getSrcPort();
- if("ipmulitiplex".equals(specialItem)) {
- _msg=checkPort(prop,prop.getProperty("port"), srcPort, portPattern);
- }else {
- _msg=checkPort(prop,prop.getProperty("client_port"), srcPort, portPattern);
- }
-
- if(StringUtils.isNotBlank(_msg)){
- errInfo.append(_msg);
- }
- //src_port check end
- //dest_port check start
- String destPort=value.getDestPort();
- if("ipmulitiplex".equals(specialItem)) {//set 默认值
- if(portPattern!=null) {
- if(2==portPattern.intValue()) {
- value.setDestPort(Constants.PORT_MASK_DEFAULT);
- }else if(1==portPattern.intValue()) {
- value.setDestPort(Constants.PORT_DEFAULT);
- }
- }
- }else {
- _msg=checkPort(prop,prop.getProperty("server_port"), destPort, portPattern);
- }
- if(StringUtils.isNotBlank(_msg)){
- errInfo.append(_msg);
- }
- //dest_port check end
- //direction check start
- Integer direction=value.getDirection();
- if(direction==null){
- errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("direction"))+";");
- }else{
- boolean has=false;
- for(SysDataDictionaryItem directionItem:directionList){
- if(Integer.parseInt(directionItem.getItemCode())==direction.intValue()){
- has=true;
- break;
- }
- }
- if(!has){
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("direction"))+";");
- }
- }
- //direction check end
- //protocol check start
- Integer protocol= value.getProtocol();
- if(protocol==null){
- errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("protocol"))+";");
- }else{
- if(specialItem!=null&&("ipsec".equals(specialItem)||"tunnel".equals(specialItem))){
- if("ipsec".equals(specialItem)){
- if(action==Constants.DROP_ACTION.intValue()) {
- boolean has=false;
- for(SysDataDictionaryItem protocolItem:ipsecProrocolList){
- if(Integer.parseInt(protocolItem.getItemCode())==protocol.intValue()){
- has=true;
- break;
- }
- }
- if(!has){
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol"))+";");
- }
- }else {
- if(protocol!=0) {
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol"))+";");
- }
- }
- }else if("tunnel".equals(specialItem)){
- for(SysDataDictionaryItem protocolItem:tunnelProrocolList){
- if("default".equals(protocolItem.getItemValue())){
- if(protocol.intValue()!=Integer.parseInt(protocolItem.getItemCode())){
- errInfo.append(String.format(prop.getProperty("must_be"), prop.getProperty("protocol"),Integer.parseInt(protocolItem.getItemCode()))+";");
- }
- break;
- }
- }
-
- }
- }else{
- boolean has=false;
- for(SysDataDictionaryItem protocolItem:protocolList){
- if(Integer.parseInt(protocolItem.getItemCode())==protocol.intValue()){
- has=true;
- break;
- }
- }
- if(!has){
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol"))+";");
- }
- }
-
- }
- //protocol check end
- // requestId check start
- Integer requestId=value.getRequestId();
- if(requestId==null){
- if("whitelistip".equals(specialItem)) {
- value.setRequestId(0);
- }else {
- errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("letter"))+";");
- }
-
- }else{//查询数据库是否存在ID
- if("whitelistip".equals(specialItem)) {
- value.setRequestId(0);
- }else {
- RequestInfo info=requestInfoService.getRequestInfoById((long)requestId.intValue());
- if(info==null){
- errInfo.append(String.format(prop.getProperty("id_not_exists"),requestId, prop.getProperty("letter"))+";");
- }else if(info.getIsValid()==Constants.VALID_NO||info.getIsValid()==Constants.VALID_DEL){
- errInfo.append(String.format(prop.getProperty("id_not_valid"),requestId, prop.getProperty("letter"))+";");
- }
- }
- }
- // requestId check end
- //classification check start
- String classification=value.getClassify();
- if(StringUtils.isNotBlank(classification)){
- try{
- for(String classify:classification.split(",")){
- if(StringUtils.isNotBlank(classify)){
- int c=Integer.parseInt(classify);
- ServiceDictInfo dict=serviceDictInfoService.getDictById(c);
- if(dict==null){
- errInfo.append(String.format(prop.getProperty("id_not_exists"),classify, prop.getProperty("classification"))+";");
- }else if(dict.getIsValid()==Constants.VALID_NO||dict.getIsValid()==Constants.VALID_DEL){
- errInfo.append(String.format(prop.getProperty("id_not_valid"),classify, prop.getProperty("classification"))+";");
- }
- }
- }
- }catch (Exception e) {
- // TODO: handle exception
- errInfo.append(String.format(prop.getProperty("num_split_by_comma"), prop.getProperty("classification"))+";");
- }
- }
- //classification check end
- //attribute check start
- String attributes=value.getAttribute();
- if(StringUtils.isNotBlank(attributes)){
- try{
- for(String attribute:attributes.split(",")){
- if(StringUtils.isNotBlank(attribute)){
- int c=Integer.parseInt(attribute);
- ServiceDictInfo dict=serviceDictInfoService.getDictById(c);
- if(dict==null){
- errInfo.append(String.format(prop.getProperty("id_not_exists"),attribute, prop.getProperty("attribute"))+";");
- }else if(dict.getIsValid()==Constants.VALID_NO||dict.getIsValid()==Constants.VALID_DEL){
- errInfo.append(String.format(prop.getProperty("id_not_valid"),attribute, prop.getProperty("attribute"))+";");
- }
- }
- }
- }catch (Exception e) {
- // TODO: handle exception
- errInfo.append(String.format(prop.getProperty("num_split_by_comma"), prop.getProperty("attribute"))+";");
- }
- }
- //attribute check end
- //attribute check start
- String labels=value.getLable();
- if(StringUtils.isNotBlank(labels)){
- try{
- for(String label:labels.split(",")){
- if(StringUtils.isNotBlank(label)){
- int c=Integer.parseInt(label);
- ServiceDictInfo dict=serviceDictInfoService.getDictById(c);
- if(dict==null){
- errInfo.append(String.format(prop.getProperty("id_not_exists"),label, prop.getProperty("label"))+";");
- }else if(dict.getIsValid()==Constants.VALID_NO||dict.getIsValid()==Constants.VALID_DEL){
- errInfo.append(String.format(prop.getProperty("id_not_valid"),label, prop.getProperty("label"))+";");
- }
- }
- }
- }catch (Exception e) {
- // TODO: handle exception
- errInfo.append(String.format(prop.getProperty("num_split_by_comma"), prop.getProperty("label"))+";");
- }
- }
- //group and ir_type check start
- if("ipmulitiplex".equals(specialItem)) {
- Integer irType= value.getIrType();
- if(irType==null) {
- errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ir_type"))+";");
- }else {
- boolean has=false;
- for(SysDataDictionaryItem irTypeItem:irTypeList){
- if(Integer.parseInt(irTypeItem.getItemCode())==irType.intValue()){
- has=true;
- break;
- }
- }
- if(!has){
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ir_type"))+";");
- }
- }
- Integer dnsStrategyId=value.getDnsStrategyId();
- if(dnsStrategyId==null) {
- errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("group_name"))+";");
- }else {
- PolicyGroupInfo group=policyGroupInfoService.getById(dnsStrategyId.intValue());
- if(group==null) {
- errInfo.append(String.format(prop.getProperty("id_not_exists"),dnsStrategyId, prop.getProperty("group_name"))+";");
- }else if(group.getIsValid()==Constants.VALID_DEL||group.getIsValid()==Constants.VALID_NO) {
- errInfo.append(String.format(prop.getProperty("id_not_valid"),dnsStrategyId, prop.getProperty("group_name"))+";");
- }
- }
- }
- if("ipratelimit".equals(specialItem)) {
- String ratelimit=value.getRatelimit();
- if(ratelimit==null) {
- errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ratelimit"))+";");
- }else {
- try {
- if(Double.parseDouble(ratelimit)<0||Double.parseDouble(ratelimit)>1) {
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ratelimit_limit"))+";");
- }
- }catch (Exception e) {
- errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ratelimit_limit"))+";");
- }
-
- }
- }
- //attribute check end
- if(StringUtils.isNotBlank(errInfo.toString())){
- msg.append(lineStart).append(errInfo);
- if(line");
- }
- }
- //group and ir_type check end
- line++;
- }
- if(StringUtils.isNotBlank(msg.toString())){
- throw new MaatConvertException(prop.getProperty("save_failed")+"
"+msg.toString());
+ if (StringUtils.isNotBlank(msg.toString())) {
+ throw new MaatConvertException(prop.getProperty("save_failed") + "
" + msg.toString());
}
}
+
/**
*
- * checkIP(IP格式验证)
- * (这里描述这个方法适用条件 – 可选)
+ * checkIP(IP格式验证) (这里描述这个方法适用条件 – 可选)
+ *
* @param ipName
* @param ip
* @param ipType
* @param ipPattern
- * @return
- *String
- * @exception
- * @since 1.0.0
+ * @return String
+ * @exception @since
+ * 1.0.0
*/
- public static String checkIP(Properties prop,String ipName,String ip,String ipType,String ipPattern){
- StringBuffer msg=new StringBuffer();
- if(StringUtils.isBlank(ip)){
- msg.append(String.format(prop.getProperty("can_not_null"), ipName)+";");
- }else{
- if("ipv4".equals(ipType)){
- if("ip_subnet".equals(ipPattern)){
- Pattern pattern=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
- Matcher matcher=pattern.matcher(ip);
- if(!matcher.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
+ public static String checkIP(Properties prop, String ipName, String ip, String ipType, String ipPattern) {
+ StringBuffer msg = new StringBuffer();
+ if (StringUtils.isBlank(ip)) {
+ msg.append(String.format(prop.getProperty("can_not_null"), ipName) + ";");
+ } else {
+ if ("ipv4".equals(ipType)) {
+ if ("ip_subnet".equals(ipPattern)) {
+ Pattern pattern = Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
+ Matcher matcher = pattern.matcher(ip);
+ if (!matcher.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
}
- }else if("ip_range".equals(ipPattern)){
- Pattern pattern=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
- Matcher matcher=pattern.matcher(ip);
- if(!matcher.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
+ } else if ("ip_range".equals(ipPattern)) {
+ Pattern pattern = Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
+ Matcher matcher = pattern.matcher(ip);
+ if (!matcher.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
}
- }else if("ip".equals(ipPattern)){
- Pattern pattern=Pattern.compile(Constants.IPV4_IP_REGEXP);
- Matcher matcher=pattern.matcher(ip);
- if(!matcher.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
+ } else if ("ip".equals(ipPattern)) {
+ Pattern pattern = Pattern.compile(Constants.IPV4_IP_REGEXP);
+ Matcher matcher = pattern.matcher(ip);
+ if (!matcher.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
}
}
- }else if("ipv6".equals(ipType)){
- if("ip_subnet".equals(ipPattern)){
- Pattern pattern=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
- Matcher matcher=pattern.matcher(ip);
- if(!matcher.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
+ } else if ("ipv6".equals(ipType)) {
+ if ("ip_subnet".equals(ipPattern)) {
+ Pattern pattern = Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
+ Matcher matcher = pattern.matcher(ip);
+ if (!matcher.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
}
- }else if("ip_range".equals(ipPattern)){
- Pattern pattern=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
- Matcher matcher=pattern.matcher(ip);
- if(!matcher.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
+ } else if ("ip_range".equals(ipPattern)) {
+ Pattern pattern = Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
+ Matcher matcher = pattern.matcher(ip);
+ if (!matcher.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
}
- }else if("ip".equals(ipPattern)){
- Pattern pattern=Pattern.compile(Constants.IPV6_IP_REGEXP);
- Matcher matcher=pattern.matcher(ip);
- if(!matcher.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
+ } else if ("ip".equals(ipPattern)) {
+ Pattern pattern = Pattern.compile(Constants.IPV6_IP_REGEXP);
+ Matcher matcher = pattern.matcher(ip);
+ if (!matcher.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
}
}
}
}
return msg.toString();
}
+
/**
*
- * checkIP(IP格式验证)
- * (这里描述这个方法适用条件 – 可选)
+ * checkIP(IP格式验证) (这里描述这个方法适用条件 – 可选)
+ *
* @param ipName
* @param ip
* @param ipType
* @param ipPattern
- * @return
- *String
- * @exception
- * @since 1.0.0
+ * @return String
+ * @exception @since
+ * 1.0.0
*/
- public static String checkIP(Properties prop,String ipName,String ip,Integer ipType,Integer ipPattern){
- StringBuffer msg=new StringBuffer();
- if(StringUtils.isBlank(ip)){
- msg.append(String.format(prop.getProperty("can_not_null"), ipName)+";");
- }else{
- if(4==ipType.intValue()){
- if(1==ipPattern.intValue()){
- Pattern pattern=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
- Matcher matcher=pattern.matcher(ip);
- if(!matcher.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
+ public static String checkIP(Properties prop, String ipName, String ip, Integer ipType, Integer ipPattern) {
+ StringBuffer msg = new StringBuffer();
+ if (StringUtils.isBlank(ip)) {
+ msg.append(String.format(prop.getProperty("can_not_null"), ipName) + ";");
+ } else {
+ if (4 == ipType.intValue()) {
+ if (1 == ipPattern.intValue()) {
+ Pattern pattern = Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
+ Matcher matcher = pattern.matcher(ip);
+ if (!matcher.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
}
- }else if(2==ipPattern.intValue()){
- Pattern pattern=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
- Matcher matcher=pattern.matcher(ip);
- if(!matcher.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
+ } else if (2 == ipPattern.intValue()) {
+ Pattern pattern = Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
+ Matcher matcher = pattern.matcher(ip);
+ if (!matcher.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
}
- }else if(3==ipPattern.intValue()){
- Pattern pattern=Pattern.compile(Constants.IPV4_IP_REGEXP);
- Matcher matcher=pattern.matcher(ip);
- if(!matcher.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
+ } else if (3 == ipPattern.intValue()) {
+ Pattern pattern = Pattern.compile(Constants.IPV4_IP_REGEXP);
+ Matcher matcher = pattern.matcher(ip);
+ if (!matcher.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
}
}
- }else if(6==ipType.intValue()){
- if(1==ipPattern.intValue()){
- Pattern pattern=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
- Matcher matcher=pattern.matcher(ip);
- if(!matcher.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
+ } else if (6 == ipType.intValue()) {
+ if (1 == ipPattern.intValue()) {
+ Pattern pattern = Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
+ Matcher matcher = pattern.matcher(ip);
+ if (!matcher.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
}
- }else if(2==ipPattern.intValue()){
- Pattern pattern=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
- Matcher matcher=pattern.matcher(ip);
- if(!matcher.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
+ } else if (2 == ipPattern.intValue()) {
+ Pattern pattern = Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
+ Matcher matcher = pattern.matcher(ip);
+ if (!matcher.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
}
- }else if(3==ipPattern.intValue()){
- Pattern pattern=Pattern.compile(Constants.IPV6_IP_REGEXP);
- Matcher matcher=pattern.matcher(ip);
- if(!matcher.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
+ } else if (3 == ipPattern.intValue()) {
+ Pattern pattern = Pattern.compile(Constants.IPV6_IP_REGEXP);
+ Matcher matcher = pattern.matcher(ip);
+ if (!matcher.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
}
}
}
}
return msg.toString();
}
- public static String checkIp(Properties prop,String srcIpName,String srcIp,String destIpName,String destIp,Integer ipType,Integer ipPattern) {
- StringBuffer msg=new StringBuffer();
- if(46==ipType.intValue()){
- if(1==ipPattern.intValue()){
- Pattern patternV4=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
- Pattern patternV6=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
- Matcher matcherV4=patternV4.matcher(srcIp);
- Matcher matcherV6=patternV6.matcher(destIp);
- if(!matcherV4.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
+
+ public static String checkIp(Properties prop, String srcIpName, String srcIp, String destIpName, String destIp,
+ Integer ipType, Integer ipPattern) {
+ StringBuffer msg = new StringBuffer();
+ if (46 == ipType.intValue()) {
+ if (1 == ipPattern.intValue()) {
+ Pattern patternV4 = Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
+ Pattern patternV6 = Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
+ Matcher matcherV4 = patternV4.matcher(srcIp);
+ Matcher matcherV6 = patternV6.matcher(destIp);
+ if (!matcherV4.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName) + ";");
}
- if(!matcherV6.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
+ if (!matcherV6.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName) + ";");
}
- }else if(2==ipPattern.intValue()){
- Pattern patternV4=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
- Pattern patternV6=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
- Matcher matcherV4=patternV4.matcher(srcIp);
- Matcher matcherV6=patternV6.matcher(destIp);
- if(!matcherV4.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
+ } else if (2 == ipPattern.intValue()) {
+ Pattern patternV4 = Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
+ Pattern patternV6 = Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
+ Matcher matcherV4 = patternV4.matcher(srcIp);
+ Matcher matcherV6 = patternV6.matcher(destIp);
+ if (!matcherV4.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName) + ";");
}
- if(!matcherV6.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
+ if (!matcherV6.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName) + ";");
}
- }else if(3==ipPattern.intValue()){
- Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
- Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP);
- Matcher matcherV4=patternV4.matcher(srcIp);
- Matcher matcherV6=patternV6.matcher(destIp);
- if(!matcherV4.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
+ } else if (3 == ipPattern.intValue()) {
+ Pattern patternV4 = Pattern.compile(Constants.IPV4_IP_REGEXP);
+ Pattern patternV6 = Pattern.compile(Constants.IPV6_IP_REGEXP);
+ Matcher matcherV4 = patternV4.matcher(srcIp);
+ Matcher matcherV6 = patternV6.matcher(destIp);
+ if (!matcherV4.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName) + ";");
}
- if(!matcherV6.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
+ if (!matcherV6.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName) + ";");
}
}
- }else if(64==ipType.intValue()) {
- if(1==ipPattern.intValue()){
- Pattern patternV4=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
- Pattern patternV6=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
- Matcher matcherV4=patternV4.matcher(destIp);
- Matcher matcherV6=patternV6.matcher(srcIp);
- if(!matcherV4.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
+ } else if (64 == ipType.intValue()) {
+ if (1 == ipPattern.intValue()) {
+ Pattern patternV4 = Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
+ Pattern patternV6 = Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
+ Matcher matcherV4 = patternV4.matcher(destIp);
+ Matcher matcherV6 = patternV6.matcher(srcIp);
+ if (!matcherV4.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName) + ";");
}
- if(!matcherV6.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
+ if (!matcherV6.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName) + ";");
}
- }else if(2==ipPattern.intValue()){
- Pattern patternV4=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
- Pattern patternV6=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
- Matcher matcherV4=patternV4.matcher(destIp);
- Matcher matcherV6=patternV6.matcher(srcIp);
- if(!matcherV4.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"),destIpName)+";");
+ } else if (2 == ipPattern.intValue()) {
+ Pattern patternV4 = Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
+ Pattern patternV6 = Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
+ Matcher matcherV4 = patternV4.matcher(destIp);
+ Matcher matcherV6 = patternV6.matcher(srcIp);
+ if (!matcherV4.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName) + ";");
}
- if(!matcherV6.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName )+";");
+ if (!matcherV6.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName) + ";");
}
- }else if(3==ipPattern.intValue()){
- Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
- Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP);
- Matcher matcherV4=patternV4.matcher(destIp);
- Matcher matcherV6=patternV6.matcher(srcIp);
- if(!matcherV4.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
+ } else if (3 == ipPattern.intValue()) {
+ Pattern patternV4 = Pattern.compile(Constants.IPV4_IP_REGEXP);
+ Pattern patternV6 = Pattern.compile(Constants.IPV6_IP_REGEXP);
+ Matcher matcherV4 = patternV4.matcher(destIp);
+ Matcher matcherV6 = patternV6.matcher(srcIp);
+ if (!matcherV4.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName) + ";");
}
- if(!matcherV6.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
+ if (!matcherV6.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName) + ";");
}
}
- }else if(10==ipType.intValue()) {
- if(1==ipPattern.intValue()){
- Pattern patternV4=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
- Pattern patternV6=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
- Matcher matcherSrcIpV4=patternV4.matcher(srcIp);
- Matcher matcherSrcIpV6=patternV6.matcher(srcIp);
- Matcher matcherDestIpV4=patternV4.matcher(destIp);
- Matcher matcherDestIpV6=patternV6.matcher(destIp);
- if(!matcherSrcIpV4.matches()&&!matcherSrcIpV6.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
+ } else if (10 == ipType.intValue()) {
+ if (1 == ipPattern.intValue()) {
+ Pattern patternV4 = Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
+ Pattern patternV6 = Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
+ Matcher matcherSrcIpV4 = patternV4.matcher(srcIp);
+ Matcher matcherSrcIpV6 = patternV6.matcher(srcIp);
+ Matcher matcherDestIpV4 = patternV4.matcher(destIp);
+ Matcher matcherDestIpV6 = patternV6.matcher(destIp);
+ if (!matcherSrcIpV4.matches() && !matcherSrcIpV6.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName) + ";");
}
- if(!matcherDestIpV4.matches()&&!matcherDestIpV6.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
+ if (!matcherDestIpV4.matches() && !matcherDestIpV6.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName) + ";");
}
- }else if(2==ipPattern.intValue()){
- Pattern patternV4=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
- Pattern patternV6=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
- Matcher matcherSrcIpV4=patternV4.matcher(srcIp);
- Matcher matcherSrcIpV6=patternV6.matcher(srcIp);
- Matcher matcherDestIpV4=patternV4.matcher(destIp);
- Matcher matcherDestIpV6=patternV6.matcher(destIp);
- if(!matcherSrcIpV4.matches()&&!matcherSrcIpV6.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
+ } else if (2 == ipPattern.intValue()) {
+ Pattern patternV4 = Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
+ Pattern patternV6 = Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
+ Matcher matcherSrcIpV4 = patternV4.matcher(srcIp);
+ Matcher matcherSrcIpV6 = patternV6.matcher(srcIp);
+ Matcher matcherDestIpV4 = patternV4.matcher(destIp);
+ Matcher matcherDestIpV6 = patternV6.matcher(destIp);
+ if (!matcherSrcIpV4.matches() && !matcherSrcIpV6.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName) + ";");
}
- if(!matcherDestIpV4.matches()&&!matcherDestIpV6.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
+ if (!matcherDestIpV4.matches() && !matcherDestIpV6.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName) + ";");
}
- }else if(3==ipPattern.intValue()){
- Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
- Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP);
- Matcher matcherSrcIpV4=patternV4.matcher(srcIp);
- Matcher matcherSrcIpV6=patternV6.matcher(srcIp);
- Matcher matcherDestIpV4=patternV4.matcher(destIp);
- Matcher matcherDestIpV6=patternV6.matcher(destIp);
- if(!matcherSrcIpV4.matches()&&!matcherSrcIpV6.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
+ } else if (3 == ipPattern.intValue()) {
+ Pattern patternV4 = Pattern.compile(Constants.IPV4_IP_REGEXP);
+ Pattern patternV6 = Pattern.compile(Constants.IPV6_IP_REGEXP);
+ Matcher matcherSrcIpV4 = patternV4.matcher(srcIp);
+ Matcher matcherSrcIpV6 = patternV6.matcher(srcIp);
+ Matcher matcherDestIpV4 = patternV4.matcher(destIp);
+ Matcher matcherDestIpV6 = patternV6.matcher(destIp);
+ if (!matcherSrcIpV4.matches() && !matcherSrcIpV6.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName) + ";");
}
- if(!matcherDestIpV4.matches()&&!matcherDestIpV6.matches()){//完全匹配
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
+ if (!matcherDestIpV4.matches() && !matcherDestIpV6.matches()) {// 完全匹配
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName) + ";");
}
}
}
return msg.toString();
}
- public static String checkPort(Properties prop,String portName,String port,Integer portPattern){
- StringBuffer msg=new StringBuffer();
- if(StringUtils.isBlank(port)){
- msg.append(String.format(prop.getProperty("can_not_null"), portName)+";");
- }else{
- if(1==portPattern.intValue()){
- try{
- Integer portInt=Integer.parseInt(port);
- if(portInt<0||portInt>65535){
- msg.append(portName+" "+String.format(prop.getProperty("must_between"), "0","65535")+";");
+
+ @Deprecated
+ public static String checkPort(Properties prop, String portName, String port, Integer portPattern) {
+ StringBuffer msg = new StringBuffer();
+ if (StringUtils.isBlank(port)) {
+ msg.append(String.format(prop.getProperty("can_not_null"), portName) + ";");
+ } else {
+ if (1 == portPattern.intValue()) {
+ try {
+ Integer portInt = Integer.parseInt(port);
+ if (portInt < 0 || portInt > 65535) {
+ msg.append(
+ portName + " " + String.format(prop.getProperty("must_between"), "0", "65535") + ";");
}
- }catch (Exception e) {
+ } catch (Exception e) {
// TODO: handle exception
- msg.append(String.format(prop.getProperty("not_number"), portName)+";");
+ msg.append(String.format(prop.getProperty("not_number"), portName) + ";");
}
- }else if(2==portPattern.intValue()){
- if(port.indexOf("/")==-1){
- msg.append(String.format(prop.getProperty("is_in_wrong_format"), portName)+";");
- }else{
- int index=0;
- String[] portArray=port.split("/");
- for(String portPart:portArray){
- try{
- Integer portInt=Integer.parseInt(portPart);
- if(portInt<0||portInt>65535){
- if(index==0){
-
- msg.append(String.format(prop.getProperty("must_between"), portName+" port")+";");
- }else{
- msg.append(String.format(prop.getProperty("must_between"), portName+" mask")+";");
+ } else if (2 == portPattern.intValue()) {
+ if (port.indexOf("/") == -1) {
+ msg.append(String.format(prop.getProperty("is_in_wrong_format"), portName) + ";");
+ } else {
+ int index = 0;
+ String[] portArray = port.split("/");
+ for (String portPart : portArray) {
+ try {
+ Integer portInt = Integer.parseInt(portPart);
+ if (portInt < 0 || portInt > 65535) {
+ if (index == 0) {
+
+ msg.append(
+ String.format(prop.getProperty("must_between"), portName + " port") + ";");
+ } else {
+ msg.append(
+ String.format(prop.getProperty("must_between"), portName + " mask") + ";");
}
}
- }catch (Exception e) {
+ } catch (Exception e) {
// TODO: handle exception
- if(index==0){
- msg.append(String.format(prop.getProperty("not_number"), portName+" port")+";");
- }else{
- msg.append(String.format(prop.getProperty("not_number"), portName+" mask")+";");
+ if (index == 0) {
+ msg.append(String.format(prop.getProperty("not_number"), portName + " port") + ";");
+ } else {
+ msg.append(String.format(prop.getProperty("not_number"), portName + " mask") + ";");
}
}
index++;
@@ -2029,39 +2268,40 @@ public class BaseController {
}
return msg.toString();
}
+
/**
*
- * setReportSearchTime(报表查询设置开始时间与结束时间)
- * (这里描述这个方法适用条件 – 可选)
+ * setReportSearchTime(报表查询设置开始时间与结束时间) (这里描述这个方法适用条件 – 可选)
+ *
* @param bean
- * @throws ParseException
- *void
- * @exception
- * @since 1.0.0
+ * @throws ParseException
+ * void
+ * @exception @since
+ * 1.0.0
*/
- public void setReportSearchTime(SearchReport bean) throws ParseException{
- SimpleDateFormat sdf=new SimpleDateFormat(Constants.SEARCH_DATEFORMAT);
- String reportTime=bean.getReportTime();
- if(StringUtils.isNotBlank(reportTime)){
- Calendar startCal=Calendar.getInstance();
+ public void setReportSearchTime(SearchReport bean) throws ParseException {
+ SimpleDateFormat sdf = new SimpleDateFormat(Constants.SEARCH_DATEFORMAT);
+ String reportTime = bean.getReportTime();
+ if (StringUtils.isNotBlank(reportTime)) {
+ Calendar startCal = Calendar.getInstance();
startCal.setTime(getReportTime(reportTime));
startCal.set(Calendar.MINUTE, 0);
startCal.set(Calendar.SECOND, 0);
startCal.set(Calendar.MILLISECOND, 0);
- Calendar endCal=Calendar.getInstance();
+ Calendar endCal = Calendar.getInstance();
endCal.setTime(getReportTime(reportTime));
endCal.set(Calendar.MINUTE, 59);
endCal.set(Calendar.SECOND, 59);
endCal.set(Calendar.MILLISECOND, 0);
- if(bean.getReportType()==Constants.REPORT_TYPE_HOUR){
+ if (bean.getReportType() == Constants.REPORT_TYPE_HOUR) {
startCal.set(Calendar.HOUR_OF_DAY, 0);
endCal.set(Calendar.HOUR_OF_DAY, 23);
- }else if(bean.getReportType()==Constants.REPORT_TYPE_DAY){
+ } else if (bean.getReportType() == Constants.REPORT_TYPE_DAY) {
startCal.set(Calendar.HOUR_OF_DAY, 0);
startCal.set(Calendar.DAY_OF_MONTH, 1);
endCal.set(Calendar.HOUR_OF_DAY, 23);
DateUtils.setLastDayOfMonth(endCal);
- }else if(bean.getReportType()==Constants.REPORT_TYPE_MONTH){
+ } else if (bean.getReportType() == Constants.REPORT_TYPE_MONTH) {
startCal.set(Calendar.HOUR_OF_DAY, 0);
startCal.set(Calendar.DAY_OF_MONTH, 1);
startCal.set(Calendar.MONTH, 0);
@@ -2073,146 +2313,150 @@ public class BaseController {
bean.setReportEndTime(endCal.getTime());
bean.setSearchReportStartTime(sdf.format(startCal.getTime()));
bean.setSearchReportEndTime(sdf.format(endCal.getTime()));
- }else{
- Date date=new Date();
+ } else {
+ Date date = new Date();
bean.setReportEndTime(date);
bean.setSearchReportEndTime(sdf.format(date));
- Calendar startCal=Calendar.getInstance();
+ Calendar startCal = Calendar.getInstance();
startCal.setTime(date);
startCal.set(Calendar.MINUTE, 0);
startCal.set(Calendar.SECOND, 0);
startCal.set(Calendar.MILLISECOND, 0);
- if(bean.getReportType()==Constants.REPORT_TYPE_HOUR){
+ if (bean.getReportType() == Constants.REPORT_TYPE_HOUR) {
startCal.set(Calendar.HOUR_OF_DAY, 0);
- }else if(bean.getReportType()==Constants.REPORT_TYPE_DAY){
+ } else if (bean.getReportType() == Constants.REPORT_TYPE_DAY) {
startCal.set(Calendar.HOUR_OF_DAY, 0);
startCal.set(Calendar.DAY_OF_MONTH, 1);
- }else if(bean.getReportType()==Constants.REPORT_TYPE_MONTH){
+ } else if (bean.getReportType() == Constants.REPORT_TYPE_MONTH) {
startCal.set(Calendar.HOUR_OF_DAY, 0);
startCal.set(Calendar.DAY_OF_MONTH, 1);
startCal.set(Calendar.MONTH, 0);
}
bean.setReportStartTime(startCal.getTime());
bean.setSearchReportStartTime(sdf.format(startCal.getTime()));
-
+
}
- logger.info("search start time "+bean.getSearchReportStartTime());
- logger.info("search end time "+bean.getSearchReportEndTime());
+ logger.info("search start time " + bean.getSearchReportStartTime());
+ logger.info("search end time " + bean.getSearchReportEndTime());
}
- public List getDateTitiles(SearchReport bean){
- SimpleDateFormat sdf=new SimpleDateFormat(Constants.SEARCH_DATEFORMAT);
- List titles=new ArrayList();
- Calendar cal=Calendar.getInstance();
+
+ public List getDateTitiles(SearchReport bean) {
+ SimpleDateFormat sdf = new SimpleDateFormat(Constants.SEARCH_DATEFORMAT);
+ List titles = new ArrayList();
+ Calendar cal = Calendar.getInstance();
cal.setTime(bean.getReportStartTime());
- while(cal.getTimeInMillis() ipPortCfgs=new ArrayList();
- List cfgIndexInfos=new ArrayList();
- for (int i = 0; i < files.length; i++) {
- MultipartFile file = files[i];
- ImportExcel ei = new ImportExcel(file, 0, 0);
-
- FunctionRegionDict regionDict=DictUtils.getFunctionRegionDict(Integer.parseInt(regionDictIds.split(",")[i]));
- if(regionDict.getFunctionId().equals(5) ){
- if(serviceDict.getAction().equals(64)){//ip
- if(regionDict.getRegionType().equals(1)){
- List list = ei.getDataList(IpRateLimitTemplate.class);
- ipPortCfgs=this.checkIpCfg(serviceDict,regionDict,list);
- }
- }else{
- if(regionDict.getRegionType().equals(1)){
- List list = ei.getDataList(IpAllTemplate.class);
- ipPortCfgs=this.checkIpCfg(serviceDict,regionDict,list);
+ FunctionServiceDict serviceDict = DictUtils.getFunctionServiceDict(serviceDictId);
+ List ipPortCfgs = new ArrayList();
+ List cfgIndexInfos = new ArrayList();
+ for (int i = 0; i < files.length; i++) {
+ MultipartFile file = files[i];
+ ImportExcel ei = new ImportExcel(file, 0, 0);
+
+ FunctionRegionDict regionDict = DictUtils
+ .getFunctionRegionDict(Integer.parseInt(regionDictIds.split(",")[i]));
+ if (regionDict.getFunctionId().equals(5)) {
+ if (serviceDict.getAction().equals(64)) {// ip
+ if (regionDict.getRegionType().equals(1)) {
+ List list = ei.getDataList(IpRateLimitTemplate.class);
+ ipPortCfgs = this.checkIpCfg(serviceDict, regionDict, list);
+ }
+ } else {
+ if (regionDict.getRegionType().equals(1)) {
+ List list = ei.getDataList(IpAllTemplate.class);
+ ipPortCfgs = this.checkIpCfg(serviceDict, regionDict, list);
+ }
}
+ } else if (regionDict.getRegionType().equals(1)) {
+ List list = ei.getDataList(IpAllTemplate.class);
+ ipPortCfgs = this.checkIpCfg(serviceDict, regionDict, list);
}
- }else if(regionDict.getRegionType().equals(1)){
- List 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);
}
- 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);
- }
} catch (Exception e) {
- addMessage(redirectAttributes, e.getMessage());
- e.printStackTrace();
+ addMessage(redirectAttributes, e.getMessage());
+ e.printStackTrace();
}
}
+
/**
* 多域配置导出
+ *
* @param columns
* @param model
* @param request
@@ -2221,28 +2465,29 @@ public class BaseController {
* @param ids
* @param redirectAttributes
*/
- public void _export(Model model,HttpServletRequest request,HttpServletResponse response,
- RedirectAttributes redirectAttributes
- ,String functionName
- ,List titleList,Map> classMap,Map dataMap
- ,Map noExportMap) throws Exception{
- //获取国际化配置
- Properties msgProp = getMsgProp();
- //获取分类、性质、标签
- List fls=serviceDictInfoService.findAllFlDict();
- List xzs=serviceDictInfoService.findAllXzDict();
- List labels=serviceDictInfoService.findAllLableDict();
- Map