2017-12-29 16:18:40 +08:00
|
|
|
|
package com.nis.web.controller;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import java.beans.PropertyEditorSupport;
|
|
|
|
|
|
import java.io.IOException;
|
2018-10-18 11:15:25 +08:00
|
|
|
|
import java.net.URLEncoder;
|
2018-07-10 13:33:28 +08:00
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import java.util.ArrayList;
|
2018-07-10 13:33:28 +08:00
|
|
|
|
import java.util.Calendar;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import java.util.Date;
|
2018-06-05 17:52:26 +08:00
|
|
|
|
import java.util.HashMap;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import java.util.List;
|
2018-06-05 17:52:26 +08:00
|
|
|
|
import java.util.Map;
|
2018-06-13 09:30:03 +08:00
|
|
|
|
import java.util.Properties;
|
2018-10-30 14:52:51 +08:00
|
|
|
|
import java.util.Set;
|
2018-07-02 16:04:41 +08:00
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
|
import java.util.regex.Pattern;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
|
2018-06-13 09:58:13 +08:00
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringEscapeUtils;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import org.apache.log4j.Logger;
|
2018-07-02 16:04:41 +08:00
|
|
|
|
import org.jets3t.service.ServiceException;
|
2018-10-15 10:14:01 +08:00
|
|
|
|
import org.springframework.beans.BeanUtils;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
2018-06-13 09:30:03 +08:00
|
|
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
|
|
import org.springframework.web.bind.WebDataBinder;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.InitBinder;
|
2018-10-15 10:14:01 +08:00
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
|
|
|
|
2018-06-13 09:58:13 +08:00
|
|
|
|
import com.beust.jcommander.internal.Lists;
|
2018-10-30 14:52:51 +08:00
|
|
|
|
import com.beust.jcommander.internal.Sets;
|
2018-05-18 16:46:46 +08:00
|
|
|
|
import com.nis.domain.FunctionRegionDict;
|
|
|
|
|
|
import com.nis.domain.FunctionServiceDict;
|
2018-07-02 16:04:41 +08:00
|
|
|
|
import com.nis.domain.SysDataDictionaryItem;
|
2018-10-25 16:44:04 +08:00
|
|
|
|
import com.nis.domain.basics.AsnIpCfg;
|
2018-07-27 10:16:32 +08:00
|
|
|
|
import com.nis.domain.basics.PolicyGroupInfo;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import com.nis.domain.basics.ServiceDictInfo;
|
|
|
|
|
|
import com.nis.domain.basics.SysDictInfo;
|
2018-10-19 22:07:16 +08:00
|
|
|
|
import com.nis.domain.configuration.AppPolicyCfg;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import com.nis.domain.configuration.AreaBean;
|
|
|
|
|
|
import com.nis.domain.configuration.AreaIpCfg;
|
|
|
|
|
|
import com.nis.domain.configuration.BaseCfg;
|
|
|
|
|
|
import com.nis.domain.configuration.BaseIpCfg;
|
2018-10-20 23:38:56 +08:00
|
|
|
|
import com.nis.domain.configuration.BaseStringCfg;
|
2018-10-15 10:14:01 +08:00
|
|
|
|
import com.nis.domain.configuration.CfgIndexInfo;
|
2018-06-13 09:58:13 +08:00
|
|
|
|
import com.nis.domain.configuration.ComplexStringCfgTemplate;
|
2018-10-20 23:38:56 +08:00
|
|
|
|
import com.nis.domain.configuration.ComplexkeywordCfg;
|
2018-10-22 15:14:32 +08:00
|
|
|
|
import com.nis.domain.configuration.DnsResStrategy;
|
2018-10-15 10:14:01 +08:00
|
|
|
|
import com.nis.domain.configuration.IpPortCfg;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import com.nis.domain.configuration.RequestInfo;
|
2018-06-13 09:58:13 +08:00
|
|
|
|
import com.nis.domain.configuration.StringCfgTemplate;
|
2018-10-25 12:59:11 +08:00
|
|
|
|
import com.nis.domain.configuration.template.AsnIpTemplate;
|
2018-10-20 23:38:56 +08:00
|
|
|
|
import com.nis.domain.configuration.template.ComplexStringAllTemplate;
|
2018-11-01 14:58:48 +08:00
|
|
|
|
import com.nis.domain.configuration.template.DdosIpTemplate;
|
2018-10-23 19:15:37 +08:00
|
|
|
|
import com.nis.domain.configuration.template.DnsComplexStringTemplate;
|
2018-11-01 20:23:56 +08:00
|
|
|
|
import com.nis.domain.configuration.template.DnsIpTemplate;
|
2018-10-15 10:14:01 +08:00
|
|
|
|
import com.nis.domain.configuration.template.IpAllTemplate;
|
2018-07-30 14:41:27 +08:00
|
|
|
|
import com.nis.domain.configuration.template.IpCfgTemplate;
|
2018-10-19 15:28:17 +08:00
|
|
|
|
import com.nis.domain.configuration.template.IpPayloadTemplate;
|
2018-10-17 10:06:08 +08:00
|
|
|
|
import com.nis.domain.configuration.template.IpRateLimitTemplate;
|
2018-10-30 14:52:51 +08:00
|
|
|
|
import com.nis.domain.configuration.template.P2pHashStringTemplate;
|
|
|
|
|
|
import com.nis.domain.configuration.template.P2pIpTemplate;
|
2018-10-20 23:38:56 +08:00
|
|
|
|
import com.nis.domain.configuration.template.StringAllTemplate;
|
2018-06-13 14:36:58 +08:00
|
|
|
|
import com.nis.domain.log.BaseLogEntity;
|
2018-07-06 16:51:23 +08:00
|
|
|
|
import com.nis.domain.log.SearchReport;
|
2018-10-19 22:07:16 +08:00
|
|
|
|
import com.nis.domain.specific.SpecificServiceCfg;
|
2018-07-02 16:04:41 +08:00
|
|
|
|
import com.nis.exceptions.MaatConvertException;
|
2018-11-01 20:23:56 +08:00
|
|
|
|
import com.nis.util.ConfigServiceUtil;
|
2018-06-13 09:30:03 +08:00
|
|
|
|
import com.nis.util.Configurations;
|
2018-05-18 16:46:46 +08:00
|
|
|
|
//import com.nis.main.ConvertTool;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import com.nis.util.Constants;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import com.nis.util.DateUtils;
|
2018-05-18 16:46:46 +08:00
|
|
|
|
import com.nis.util.DictUtils;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import com.nis.util.JsonMapper;
|
2018-08-18 14:59:49 +08:00
|
|
|
|
import com.nis.util.StringUtil;
|
2018-06-13 09:58:13 +08:00
|
|
|
|
import com.nis.util.excel.ExportExcel;
|
2018-10-15 10:14:01 +08:00
|
|
|
|
import com.nis.util.excel.ImportExcel;
|
|
|
|
|
|
import com.nis.web.dao.configuration.IpCfgDao;
|
|
|
|
|
|
import com.nis.web.security.UserUtils;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import com.nis.web.service.ArchiveServcie;
|
|
|
|
|
|
import com.nis.web.service.AreaService;
|
|
|
|
|
|
import com.nis.web.service.DictService;
|
|
|
|
|
|
import com.nis.web.service.LogService;
|
|
|
|
|
|
import com.nis.web.service.MenuService;
|
|
|
|
|
|
import com.nis.web.service.OfficeService;
|
|
|
|
|
|
import com.nis.web.service.RoleService;
|
|
|
|
|
|
import com.nis.web.service.SystemService;
|
|
|
|
|
|
import com.nis.web.service.UserService;
|
2018-08-30 21:21:00 +08:00
|
|
|
|
import com.nis.web.service.basics.AsnIpCfgService;
|
2018-06-20 13:33:46 +08:00
|
|
|
|
import com.nis.web.service.basics.PolicyGroupInfoService;
|
2018-03-06 10:31:18 +08:00
|
|
|
|
import com.nis.web.service.basics.ServiceDictInfoService;
|
|
|
|
|
|
import com.nis.web.service.basics.SysDictInfoService;
|
2018-08-28 13:40:04 +08:00
|
|
|
|
import com.nis.web.service.configuration.AppBuiltInFeatureService;
|
2018-01-09 16:50:39 +08:00
|
|
|
|
import com.nis.web.service.configuration.AppCfgService;
|
2018-09-23 15:02:01 +08:00
|
|
|
|
import com.nis.web.service.configuration.AppMultiFeatureCfgService;
|
2018-08-30 21:21:00 +08:00
|
|
|
|
import com.nis.web.service.configuration.AsnPolicyCfgService;
|
2018-05-18 16:46:46 +08:00
|
|
|
|
import com.nis.web.service.configuration.AvCfgService;
|
2018-05-22 17:30:52 +08:00
|
|
|
|
import com.nis.web.service.configuration.AvContentCfgService;
|
2018-06-13 09:30:03 +08:00
|
|
|
|
import com.nis.web.service.configuration.BgpCfgService;
|
2018-02-28 12:16:37 +08:00
|
|
|
|
import com.nis.web.service.configuration.ComplexStringCfgService;
|
2018-06-23 14:08:53 +08:00
|
|
|
|
import com.nis.web.service.configuration.ControlPolicyService;
|
2018-06-29 15:39:11 +08:00
|
|
|
|
import com.nis.web.service.configuration.DdosCfgService;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import com.nis.web.service.configuration.DnsIpCfgService;
|
2018-06-22 10:12:54 +08:00
|
|
|
|
import com.nis.web.service.configuration.DnsResStrategyService;
|
2018-07-06 17:13:46 +08:00
|
|
|
|
import com.nis.web.service.configuration.DomainService;
|
2018-06-05 11:06:37 +08:00
|
|
|
|
import com.nis.web.service.configuration.FileTransferCfgService;
|
2018-10-22 18:16:57 +08:00
|
|
|
|
import com.nis.web.service.configuration.GroupAreaService;
|
2018-06-29 13:56:08 +08:00
|
|
|
|
import com.nis.web.service.configuration.HttpRedirectCfgService;
|
2018-08-21 11:42:33 +08:00
|
|
|
|
import com.nis.web.service.configuration.InterceptCfgService;
|
2018-01-09 16:50:39 +08:00
|
|
|
|
import com.nis.web.service.configuration.IpCfgService;
|
2018-07-01 16:08:55 +08:00
|
|
|
|
import com.nis.web.service.configuration.IpMultiplexPoolCfgService;
|
2018-01-09 16:50:39 +08:00
|
|
|
|
import com.nis.web.service.configuration.MailCfgService;
|
2018-02-28 12:16:37 +08:00
|
|
|
|
import com.nis.web.service.configuration.NumCfgService;
|
2018-08-21 11:42:33 +08:00
|
|
|
|
import com.nis.web.service.configuration.ProxyFileStrategyService;
|
2018-08-24 15:41:05 +08:00
|
|
|
|
import com.nis.web.service.configuration.PxyObjKeyringService;
|
2018-02-25 18:43:20 +08:00
|
|
|
|
import com.nis.web.service.configuration.RequestInfoService;
|
2018-05-25 13:25:21 +08:00
|
|
|
|
import com.nis.web.service.configuration.WebsiteCfgService;
|
2018-06-13 10:18:06 +08:00
|
|
|
|
import com.nis.web.service.configuration.XmppCfgService;
|
2018-07-11 16:15:23 +08:00
|
|
|
|
import com.nis.web.service.configuration.statistics.ConfigureStatisticsService;
|
2018-03-17 17:09:19 +08:00
|
|
|
|
import com.nis.web.service.specific.SpecificServiceCfgService;
|
|
|
|
|
|
import com.nis.web.service.specific.SpecificServiceHostCfgService;
|
2018-02-23 09:16:32 +08:00
|
|
|
|
import com.nis.web.service.systemService.ServiceConfigInfoService;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
|
|
|
|
|
|
public class BaseController {
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2017-12-29 16:18:40 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected UserService userService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2017-12-29 16:18:40 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected SystemService systemService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2017-12-29 16:18:40 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected OfficeService officeService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2017-12-29 16:18:40 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected AreaService areaService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2017-12-29 16:18:40 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected RoleService roleService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2017-12-29 16:18:40 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected MenuService menuService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2017-12-29 16:18:40 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected LogService logService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2017-12-29 16:18:40 +08:00
|
|
|
|
protected ArchiveServcie archiveServcie;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2017-12-29 16:18:40 +08:00
|
|
|
|
protected DictService dictService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2018-01-09 16:50:39 +08:00
|
|
|
|
protected IpCfgService ipCfgService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2018-03-22 14:41:10 +08:00
|
|
|
|
protected DnsIpCfgService dnsIpCfgService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2018-01-09 16:50:39 +08:00
|
|
|
|
protected MailCfgService mailCfgService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2018-06-05 11:06:37 +08:00
|
|
|
|
protected FileTransferCfgService fileTransferCfgService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2018-01-09 16:50:39 +08:00
|
|
|
|
protected AppCfgService appCfgService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
@Autowired
|
2018-06-23 14:08:53 +08:00
|
|
|
|
protected ControlPolicyService controlPolicyService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-02-23 09:16:32 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected ServiceDictInfoService serviceDictInfoService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-02-23 09:16:32 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected SysDictInfoService sysDictInfoService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-02-23 09:16:32 +08:00
|
|
|
|
protected final Logger logger = Logger.getLogger(this.getClass());
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-02-23 09:16:32 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected ServiceConfigInfoService serviceConfigInfoService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-02-25 18:43:20 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected RequestInfoService requestInfoService;
|
2018-02-27 15:31:30 +08:00
|
|
|
|
@Autowired
|
2018-06-29 12:44:33 +08:00
|
|
|
|
protected DomainService domainService;
|
2018-02-28 12:16:37 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected NumCfgService numCfgService;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected ComplexStringCfgService complexStringCfgService;
|
2018-03-17 17:09:19 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected SpecificServiceCfgService specificServiceCfgService;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected SpecificServiceHostCfgService specificServiceHostCfgService;
|
2018-05-18 16:46:46 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected AvCfgService avCfgService;
|
2018-05-22 17:30:52 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected AvContentCfgService avContentCfgService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
@Autowired
|
2018-05-25 13:25:21 +08:00
|
|
|
|
protected WebsiteCfgService websiteCfgService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
@Autowired
|
2018-06-13 09:30:03 +08:00
|
|
|
|
protected BgpCfgService bgpCfgService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
@Autowired
|
2018-06-13 10:18:06 +08:00
|
|
|
|
protected XmppCfgService xmppCfgService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
@Autowired
|
2018-06-20 13:33:46 +08:00
|
|
|
|
protected PolicyGroupInfoService policyGroupInfoService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
@Autowired
|
2018-06-22 10:12:54 +08:00
|
|
|
|
protected DnsResStrategyService dnsResStrategyService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
@Autowired
|
2018-06-29 13:56:08 +08:00
|
|
|
|
protected HttpRedirectCfgService httpRedirectCfgService;
|
2018-06-29 15:39:11 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected DdosCfgService ddosCfgService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
@Autowired
|
2018-07-01 16:08:55 +08:00
|
|
|
|
protected IpMultiplexPoolCfgService ipMultiplexPoolCfgService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
@Autowired
|
2018-07-11 16:15:23 +08:00
|
|
|
|
protected ConfigureStatisticsService configureStatisticsService;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
@Autowired
|
2018-08-21 11:42:33 +08:00
|
|
|
|
protected InterceptCfgService interceptCfgService;
|
|
|
|
|
|
@Autowired
|
2018-10-18 18:05:49 +08:00
|
|
|
|
protected ProxyFileStrategyService proxyFileStrategyService;// 代理文件策略service
|
2018-08-24 15:41:05 +08:00
|
|
|
|
@Autowired
|
2018-10-18 18:05:49 +08:00
|
|
|
|
protected PxyObjKeyringService pxyObjKeyringService;// 拦截策略service
|
2018-08-28 13:40:04 +08:00
|
|
|
|
@Autowired
|
2018-10-18 18:05:49 +08:00
|
|
|
|
protected AppBuiltInFeatureService appBuiltInFeatureService;// 拦截策略service
|
2018-08-30 21:21:00 +08:00
|
|
|
|
@Autowired
|
2018-10-18 18:05:49 +08:00
|
|
|
|
protected AsnIpCfgService asnIpCfgService;// asn ip service
|
2018-08-30 21:21:00 +08:00
|
|
|
|
@Autowired
|
2018-10-18 18:05:49 +08:00
|
|
|
|
protected AsnPolicyCfgService asnPolicyCfgService;// asn 策略 service
|
2018-09-23 15:02:01 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected AppMultiFeatureCfgService appMultiFeatureCfgService;
|
2018-10-22 18:16:57 +08:00
|
|
|
|
@Autowired
|
2018-10-25 16:44:04 +08:00
|
|
|
|
protected GroupAreaService groupAreaService;// 分组区域管理 service
|
2017-12-29 16:18:40 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 管理基础路径
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Value("${adminPath}")
|
|
|
|
|
|
protected String adminPath;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2017-12-29 16:18:40 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 前端基础路径
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Value("${frontPath}")
|
|
|
|
|
|
protected String frontPath;
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 前端URL后缀
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Value("${urlSuffix}")
|
|
|
|
|
|
protected String urlSuffix;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2017-12-29 16:18:40 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 客户端返回JSON字符串
|
2018-10-18 18:05:49 +08:00
|
|
|
|
*
|
2017-12-29 16:18:40 +08:00
|
|
|
|
* @param response
|
|
|
|
|
|
* @param object
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
protected String renderString(HttpServletResponse response, Object object) {
|
|
|
|
|
|
return renderString(response, JsonMapper.toJsonString(object), "application/json");
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2017-12-29 16:18:40 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 客户端返回字符串
|
2018-10-18 18:05:49 +08:00
|
|
|
|
*
|
2017-12-29 16:18:40 +08:00
|
|
|
|
* @param response
|
|
|
|
|
|
* @param string
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
protected String renderString(HttpServletResponse response, String string, String type) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
response.reset();
|
2018-10-18 18:05:49 +08:00
|
|
|
|
response.setContentType(type);
|
|
|
|
|
|
response.setCharacterEncoding("utf-8");
|
2017-12-29 16:18:40 +08:00
|
|
|
|
response.getWriter().print(string);
|
|
|
|
|
|
return null;
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2017-12-29 16:18:40 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 添加Model消息
|
2018-10-18 18:05:49 +08:00
|
|
|
|
*
|
2017-12-29 16:18:40 +08:00
|
|
|
|
* @param message
|
|
|
|
|
|
*/
|
|
|
|
|
|
protected void addMessage(Model model, String... messages) {
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
2018-10-18 18:05:49 +08:00
|
|
|
|
for (String message : messages) {
|
|
|
|
|
|
sb.append(message).append(messages.length > 1 ? "<br/>" : "");
|
2017-12-29 16:18:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
model.addAttribute("message", sb.toString());
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-08-03 10:59:20 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 添加Model消息 日志用
|
2018-10-18 18:05:49 +08:00
|
|
|
|
*
|
2018-08-03 10:59:20 +08:00
|
|
|
|
* @param message
|
|
|
|
|
|
*/
|
|
|
|
|
|
protected void addMessageLog(Model model, String status) {
|
2018-10-18 18:05:49 +08:00
|
|
|
|
// 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);
|
2018-08-03 10:59:20 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2017-12-29 16:18:40 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 添加Flash消息
|
2018-10-18 18:05:49 +08:00
|
|
|
|
*
|
2017-12-29 16:18:40 +08:00
|
|
|
|
* @param message
|
|
|
|
|
|
*/
|
|
|
|
|
|
protected void addMessage(RedirectAttributes redirectAttributes, String... messages) {
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
2018-10-18 18:05:49 +08:00
|
|
|
|
for (String message : messages) {
|
|
|
|
|
|
sb.append(message).append(messages.length > 1 ? "<br/>" : "");
|
2017-12-29 16:18:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
redirectAttributes.addFlashAttribute("message", sb.toString());
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2017-12-29 16:18:40 +08:00
|
|
|
|
/**
|
2018-10-18 18:05:49 +08:00
|
|
|
|
* 初始化数据绑定 1. 将所有传递进来的String进行HTML编码,防止XSS攻击 2. 将字段中Date类型转换为String类型
|
2017-12-29 16:18:40 +08:00
|
|
|
|
*/
|
|
|
|
|
|
@InitBinder
|
|
|
|
|
|
protected void initBinder(WebDataBinder binder) {
|
|
|
|
|
|
// String类型转换,将所有传递进来的String进行HTML编码,防止XSS攻击
|
|
|
|
|
|
binder.registerCustomEditor(String.class, new PropertyEditorSupport() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void setAsText(String text) {
|
|
|
|
|
|
setValue(text == null ? null : StringEscapeUtils.escapeHtml4(text.trim()));
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2017-12-29 16:18:40 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public String getAsText() {
|
|
|
|
|
|
Object value = getValue();
|
|
|
|
|
|
return value != null ? value.toString() : "";
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
// Date 类型转换
|
|
|
|
|
|
binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void setAsText(String text) {
|
|
|
|
|
|
setValue(DateUtils.parseDate(text));
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
protected void initPageCondition(Model model) {
|
|
|
|
|
|
List<RequestInfo> requestInfos = requestInfoService.getAllRequestInfo();
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("requestInfos", requestInfos);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<ServiceDictInfo> fls = serviceDictInfoService.findAllFlDict();
|
|
|
|
|
|
String pNames = "";
|
2018-07-06 17:13:46 +08:00
|
|
|
|
for (ServiceDictInfo serviceDictInfo : fls) {
|
2018-10-18 18:05:49 +08:00
|
|
|
|
pNames = "";
|
|
|
|
|
|
pNames = serviceDictInfo.getPNames(fls, serviceDictInfo.getParent().getServiceDictId(), pNames);
|
2018-07-06 17:13:46 +08:00
|
|
|
|
serviceDictInfo.setpNames(pNames);
|
|
|
|
|
|
}
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("fls", fls);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<ServiceDictInfo> xzs = serviceDictInfoService.findAllXzDict();
|
2018-07-06 17:13:46 +08:00
|
|
|
|
for (ServiceDictInfo serviceDictInfo : xzs) {
|
2018-10-18 18:05:49 +08:00
|
|
|
|
pNames = "";
|
|
|
|
|
|
pNames = serviceDictInfo.getPNames(xzs, serviceDictInfo.getParent().getServiceDictId(), pNames);
|
2018-07-06 17:13:46 +08:00
|
|
|
|
serviceDictInfo.setpNames(pNames);
|
|
|
|
|
|
}
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("xzs", xzs);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<ServiceDictInfo> lables = serviceDictInfoService.findAllLableDict();
|
2018-07-06 17:13:46 +08:00
|
|
|
|
for (ServiceDictInfo serviceDictInfo : lables) {
|
2018-10-18 18:05:49 +08:00
|
|
|
|
pNames = "";
|
|
|
|
|
|
pNames = serviceDictInfo.getPNames(lables, serviceDictInfo.getParent().getServiceDictId(), pNames);
|
2018-07-06 17:13:46 +08:00
|
|
|
|
serviceDictInfo.setpNames(pNames);
|
|
|
|
|
|
}
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("lables", lables);
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
protected void initPageCondition(Model model, BaseCfg cfg) {
|
|
|
|
|
|
List<RequestInfo> requestInfos = requestInfoService.getAllRequestInfo();
|
2018-05-21 19:42:24 +08:00
|
|
|
|
model.addAttribute("requestInfos", requestInfos);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<ServiceDictInfo> fls = serviceDictInfoService.findAllFlDict();
|
|
|
|
|
|
String pNames = "";
|
2018-10-25 16:44:04 +08:00
|
|
|
|
/*
|
|
|
|
|
|
* for (ServiceDictInfo serviceDictInfo : fls) { pNames = ""; pNames =
|
|
|
|
|
|
* serviceDictInfo.getPNames(fls,
|
|
|
|
|
|
* serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
* serviceDictInfo.setpNames(pNames); }
|
|
|
|
|
|
*/
|
2018-05-21 19:42:24 +08:00
|
|
|
|
model.addAttribute("fls", fls);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<ServiceDictInfo> xzs = serviceDictInfoService.findAllXzDict();
|
2018-10-25 16:44:04 +08:00
|
|
|
|
/*
|
|
|
|
|
|
* for (ServiceDictInfo serviceDictInfo : xzs) { pNames = ""; pNames =
|
|
|
|
|
|
* serviceDictInfo.getPNames(xzs,
|
|
|
|
|
|
* serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
* serviceDictInfo.setpNames(pNames); }
|
|
|
|
|
|
*/
|
2018-05-21 19:42:24 +08:00
|
|
|
|
model.addAttribute("xzs", xzs);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<ServiceDictInfo> lables = serviceDictInfoService.findAllLableDict();
|
2018-10-25 16:44:04 +08:00
|
|
|
|
/*
|
|
|
|
|
|
* for (ServiceDictInfo serviceDictInfo : lables) { pNames = ""; pNames =
|
|
|
|
|
|
* serviceDictInfo.getPNames(lables,
|
|
|
|
|
|
* serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
* serviceDictInfo.setpNames(pNames); }
|
|
|
|
|
|
*/
|
2018-05-21 19:42:24 +08:00
|
|
|
|
model.addAttribute("lables", lables);
|
|
|
|
|
|
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(cfg.getFunctionId());
|
|
|
|
|
|
model.addAttribute("regionList", regionList);
|
|
|
|
|
|
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(cfg.getFunctionId());
|
|
|
|
|
|
model.addAttribute("serviceList", serviceList);
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
protected void initReportCondition(Model model, SearchReport report) {
|
2018-07-06 16:51:23 +08:00
|
|
|
|
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(report.getFunctionId());
|
2018-05-21 19:42:24 +08:00
|
|
|
|
model.addAttribute("serviceList", serviceList);
|
2018-07-11 16:15:23 +08:00
|
|
|
|
if (StringUtils.isBlank(report.getReportTime())) {
|
|
|
|
|
|
report.setReportTime(DateUtils.formatDate(new Date(), "yyyy-MM-dd"));
|
|
|
|
|
|
}
|
2018-07-12 15:28:46 +08:00
|
|
|
|
if (report.getReportType() == null) {
|
|
|
|
|
|
report.setReportType(1);
|
|
|
|
|
|
}
|
2018-05-21 19:42:24 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
protected void initFormCondition(Model model) {
|
|
|
|
|
|
List<RequestInfo> requestInfos = requestInfoService.getValidRequestInfo();
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("requestInfos", requestInfos);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<ServiceDictInfo> fls = serviceDictInfoService.findFlDict();
|
|
|
|
|
|
String pNames = "";
|
2018-10-25 16:44:04 +08:00
|
|
|
|
/*
|
|
|
|
|
|
* for (ServiceDictInfo serviceDictInfo : fls) { pNames = ""; pNames =
|
|
|
|
|
|
* serviceDictInfo.getPNames(fls,
|
|
|
|
|
|
* serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
* serviceDictInfo.setpNames(pNames); }
|
|
|
|
|
|
*/
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("fls", fls);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<ServiceDictInfo> xzs = serviceDictInfoService.findXzDict();
|
2018-10-25 16:44:04 +08:00
|
|
|
|
/*
|
|
|
|
|
|
* for (ServiceDictInfo serviceDictInfo : xzs) { pNames = ""; pNames =
|
|
|
|
|
|
* serviceDictInfo.getPNames(xzs,
|
|
|
|
|
|
* serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
* serviceDictInfo.setpNames(pNames); }
|
|
|
|
|
|
*/
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("xzs", xzs);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<ServiceDictInfo> lables = serviceDictInfoService.findLableDict();
|
2018-10-25 16:44:04 +08:00
|
|
|
|
/*
|
|
|
|
|
|
* for (ServiceDictInfo serviceDictInfo : lables) { pNames = ""; pNames =
|
|
|
|
|
|
* serviceDictInfo.getPNames(lables,
|
|
|
|
|
|
* serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
* serviceDictInfo.setpNames(pNames); }
|
|
|
|
|
|
*/
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("lables", lables);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<Integer> itTypeList = new ArrayList<Integer>();
|
2018-04-09 16:38:45 +08:00
|
|
|
|
itTypeList.add(Constants.ITEM_TYPE_AREA);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<SysDictInfo> areas = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(), itTypeList, null);
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("areas", areas);
|
|
|
|
|
|
itTypeList.clear();
|
|
|
|
|
|
itTypeList.add(Constants.ITEM_TYPE_ISP);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<SysDictInfo> isps = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(), itTypeList, null);
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("isps", isps);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
// 初始化一个默认的地域ip给界面
|
|
|
|
|
|
AreaIpCfg areaIpCfg = new AreaIpCfg();
|
2018-04-09 16:38:45 +08:00
|
|
|
|
areaIpCfg.initDefaultValue();
|
|
|
|
|
|
model.addAttribute("_areaCfg", areaIpCfg);
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
protected void initFormCondition(Model model, BaseCfg cfg) {
|
|
|
|
|
|
List<RequestInfo> requestInfos = requestInfoService.getValidRequestInfo();
|
2018-05-18 16:46:46 +08:00
|
|
|
|
model.addAttribute("requestInfos", requestInfos);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<ServiceDictInfo> fls = serviceDictInfoService.findFlDict();
|
|
|
|
|
|
String pNames = "";
|
2018-10-25 16:44:04 +08:00
|
|
|
|
/*
|
|
|
|
|
|
* for (ServiceDictInfo serviceDictInfo : fls) { pNames = ""; pNames =
|
|
|
|
|
|
* serviceDictInfo.getPNames(fls,
|
|
|
|
|
|
* serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
* serviceDictInfo.setpNames(pNames); }
|
|
|
|
|
|
*/
|
2018-05-18 16:46:46 +08:00
|
|
|
|
model.addAttribute("fls", fls);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<ServiceDictInfo> xzs = serviceDictInfoService.findXzDict();
|
2018-10-25 16:44:04 +08:00
|
|
|
|
/*
|
|
|
|
|
|
* for (ServiceDictInfo serviceDictInfo : xzs) { pNames = ""; pNames =
|
|
|
|
|
|
* serviceDictInfo.getPNames(xzs,
|
|
|
|
|
|
* serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
* serviceDictInfo.setpNames(pNames); }
|
|
|
|
|
|
*/
|
2018-05-18 16:46:46 +08:00
|
|
|
|
model.addAttribute("xzs", xzs);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<ServiceDictInfo> lables = serviceDictInfoService.findLableDict();
|
2018-10-25 16:44:04 +08:00
|
|
|
|
/*
|
|
|
|
|
|
* for (ServiceDictInfo serviceDictInfo : lables) { pNames = ""; pNames =
|
|
|
|
|
|
* serviceDictInfo.getPNames(lables,
|
|
|
|
|
|
* serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
* serviceDictInfo.setpNames(pNames); }
|
|
|
|
|
|
*/
|
2018-05-18 16:46:46 +08:00
|
|
|
|
model.addAttribute("lables", lables);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<Integer> itTypeList = new ArrayList<Integer>();
|
2018-05-18 16:46:46 +08:00
|
|
|
|
itTypeList.add(Constants.ITEM_TYPE_AREA);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<SysDictInfo> areas = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(), itTypeList, null);
|
2018-05-18 16:46:46 +08:00
|
|
|
|
model.addAttribute("areas", areas);
|
|
|
|
|
|
itTypeList.clear();
|
|
|
|
|
|
itTypeList.add(Constants.ITEM_TYPE_ISP);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<SysDictInfo> isps = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(), itTypeList, null);
|
2018-05-18 16:46:46 +08:00
|
|
|
|
model.addAttribute("isps", isps);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
// 初始化一个默认的地域ip给界面
|
|
|
|
|
|
AreaIpCfg areaIpCfg = new AreaIpCfg();
|
2018-05-18 16:46:46 +08:00
|
|
|
|
areaIpCfg.initDefaultValue();
|
|
|
|
|
|
model.addAttribute("_areaCfg", areaIpCfg);
|
|
|
|
|
|
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(cfg.getFunctionId());
|
|
|
|
|
|
model.addAttribute("regionList", regionList);
|
|
|
|
|
|
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(cfg.getFunctionId());
|
|
|
|
|
|
model.addAttribute("serviceList", serviceList);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
// ip配置设置protocolId
|
|
|
|
|
|
if (cfg instanceof BaseIpCfg) {
|
|
|
|
|
|
for (FunctionServiceDict dict : serviceList) {
|
|
|
|
|
|
if (cfg.getFunctionId().intValue() == dict.getFunctionId().intValue()) {
|
2018-05-25 16:01:01 +08:00
|
|
|
|
((BaseIpCfg) cfg).setProtocolId(dict.getProtocolId().intValue());
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-05-18 16:46:46 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
protected void initUpdateFormCondition(Model model, BaseCfg cfg) {
|
|
|
|
|
|
List<Integer> itTypeList = new ArrayList<Integer>();
|
2018-06-01 18:13:07 +08:00
|
|
|
|
itTypeList.add(Constants.ITEM_TYPE_AREA);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<SysDictInfo> areas = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(), itTypeList, null);
|
2018-06-01 18:13:07 +08:00
|
|
|
|
model.addAttribute("areas", areas);
|
|
|
|
|
|
itTypeList.clear();
|
|
|
|
|
|
itTypeList.add(Constants.ITEM_TYPE_ISP);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<SysDictInfo> isps = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(), itTypeList, null);
|
2018-06-01 18:13:07 +08:00
|
|
|
|
model.addAttribute("isps", isps);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
// 查询配置对应的地域ip
|
|
|
|
|
|
if (cfg.getCompileId() != null) {
|
|
|
|
|
|
List<AreaIpCfg> areaCfgs = ipCfgService.getAreaCfgByCompileId(cfg.getCompileId());
|
2018-08-30 21:21:00 +08:00
|
|
|
|
model.addAttribute("areaCfgs", areaCfgs);
|
|
|
|
|
|
|
2018-10-18 18:05:49 +08:00
|
|
|
|
StringBuffer areaCfgIds = new StringBuffer();
|
|
|
|
|
|
for (AreaIpCfg areaCfg : areaCfgs) {
|
|
|
|
|
|
areaCfgIds.append(areaCfg.getCfgId() + ",");
|
2018-08-30 21:21:00 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
// update时判断是否有删除地域ip
|
2018-08-30 21:21:00 +08:00
|
|
|
|
model.addAttribute("areaCfgIds", areaCfgIds.toString());
|
2018-04-09 16:38:45 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
// 初始化一个默认的地域ip给界面
|
|
|
|
|
|
AreaIpCfg areaIpCfg = new AreaIpCfg();
|
2018-04-09 16:38:45 +08:00
|
|
|
|
areaIpCfg.initDefaultValue();
|
|
|
|
|
|
model.addAttribute("_areaCfg", areaIpCfg);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
// 从区域生效ID中获取区域与运营商
|
|
|
|
|
|
String areaEffectiveIds = cfg.getAreaEffectiveIds();
|
|
|
|
|
|
List<AreaBean> areaIspList = new ArrayList<AreaBean>();
|
|
|
|
|
|
getAreaIsps(areaEffectiveIds, areaIspList, isps, areas);
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("_areaIsps", areaIspList);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<RequestInfo> requestInfos = requestInfoService.getValidRequestInfo();// 只查询有效的
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("requestInfos", requestInfos);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<ServiceDictInfo> fls = serviceDictInfoService.findFlDict();// 只查询有效分类字典
|
|
|
|
|
|
String pNames = "";
|
2018-10-25 16:44:04 +08:00
|
|
|
|
/*
|
|
|
|
|
|
* for (ServiceDictInfo serviceDictInfo : fls) { pNames = ""; pNames =
|
|
|
|
|
|
* serviceDictInfo.getPNames(fls,
|
|
|
|
|
|
* serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
* serviceDictInfo.setpNames(pNames); }
|
|
|
|
|
|
*/
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("fls", fls);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<ServiceDictInfo> xzs = serviceDictInfoService.findXzDict();// 只查询有效性质字典
|
2018-10-25 16:44:04 +08:00
|
|
|
|
/*
|
|
|
|
|
|
* for (ServiceDictInfo serviceDictInfo : xzs) { pNames = ""; pNames =
|
|
|
|
|
|
* serviceDictInfo.getPNames(xzs,
|
|
|
|
|
|
* serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
* serviceDictInfo.setpNames(pNames); }
|
|
|
|
|
|
*/
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("xzs", xzs);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<ServiceDictInfo> lables = serviceDictInfoService.findLableDict();// 只查询有效标签字典
|
2018-10-25 16:44:04 +08:00
|
|
|
|
/*
|
|
|
|
|
|
* for (ServiceDictInfo serviceDictInfo : lables) { pNames = ""; pNames =
|
|
|
|
|
|
* serviceDictInfo.getPNames(lables,
|
|
|
|
|
|
* serviceDictInfo.getParent().getServiceDictId(), pNames);
|
|
|
|
|
|
* serviceDictInfo.setpNames(pNames); }
|
|
|
|
|
|
*/
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("lables", lables);
|
2018-05-18 16:46:46 +08:00
|
|
|
|
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(cfg.getFunctionId());
|
|
|
|
|
|
model.addAttribute("regionList", regionList);
|
|
|
|
|
|
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(cfg.getFunctionId());
|
|
|
|
|
|
model.addAttribute("serviceList", serviceList);
|
2018-04-09 16:38:45 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
public List<AreaBean> getAreaIsps(String areaEffectiveIds, List<AreaBean> areaIspList, List<SysDictInfo> isps,
|
|
|
|
|
|
List<SysDictInfo> areas) {
|
|
|
|
|
|
Map<String, SysDictInfo> areaMap = new HashMap<String, SysDictInfo>();
|
2018-06-05 17:52:26 +08:00
|
|
|
|
for (SysDictInfo areaDict : areas) {
|
|
|
|
|
|
areaMap.put(areaDict.getItemCode(), areaDict);
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
Map<String, SysDictInfo> ispMap = new HashMap<String, SysDictInfo>();
|
2018-06-05 17:52:26 +08:00
|
|
|
|
for (SysDictInfo ispDict : isps) {
|
|
|
|
|
|
ispMap.put(ispDict.getItemCode(), ispDict);
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-06-05 17:52:26 +08:00
|
|
|
|
// : 存在冒号,则冒号前为area后为isp;不存在冒号,判断id是否为isp,否则为area
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (StringUtils.isNotBlank(areaEffectiveIds)) {
|
|
|
|
|
|
String[] areaIsps = areaEffectiveIds.split(",");
|
|
|
|
|
|
for (String areaIsp : areaIsps) {
|
|
|
|
|
|
AreaBean area = new AreaBean();
|
|
|
|
|
|
if (areaIsp.contains(":")) {
|
2018-06-05 17:52:26 +08:00
|
|
|
|
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());
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
if (ispMap.keySet().contains(areaIsp)) {
|
2018-06-05 17:52:26 +08:00
|
|
|
|
area.setIsp(areaIsp);
|
|
|
|
|
|
area.setIspName(ispMap.get(areaIsp).getItemValue());
|
|
|
|
|
|
area.setAreaName("");
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else {
|
2018-06-05 17:52:26 +08:00
|
|
|
|
area.setArea(areaIsp);
|
|
|
|
|
|
area.setIspName("");
|
|
|
|
|
|
area.setAreaName(areaMap.get(areaIsp).getItemValue());
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-06-05 17:52:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
areaIspList.add(area);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return areaIspList;
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-06-13 09:30:03 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取国际化配置文件
|
2018-10-18 18:05:49 +08:00
|
|
|
|
*
|
2018-06-13 09:30:03 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-10-18 18:05:49 +08:00
|
|
|
|
public Properties getMsgProp() {
|
2018-06-13 09:30:03 +08:00
|
|
|
|
Properties msgProp = new Properties();
|
|
|
|
|
|
try {
|
|
|
|
|
|
String language = LocaleContextHolder.getLocale().getLanguage();
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (language.equals("zh_cn") || language.equals("zh")) {
|
2018-06-13 09:30:03 +08:00
|
|
|
|
msgProp.load(Configurations.class.getResourceAsStream("/messages/message_zh_CN.properties"));
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (language.equals("ru")) {
|
2018-06-13 09:30:03 +08:00
|
|
|
|
msgProp.load(Configurations.class.getResourceAsStream("/messages/message_ru.properties"));
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else {
|
2018-06-13 09:30:03 +08:00
|
|
|
|
msgProp.load(Configurations.class.getResourceAsStream("/messages/message_en.properties"));
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-06-13 09:30:03 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
msgProp = null;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
logger.error("未知i18n消息配置文件,请确定文件是否存在!", e);
|
2018-06-13 09:30:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
return msgProp;
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
public void importCfgTemplate(HttpServletRequest request, HttpServletResponse response,
|
|
|
|
|
|
RedirectAttributes redirectAttributes, Integer functionId, Integer cfgRegionCode) {
|
2018-06-13 09:58:13 +08:00
|
|
|
|
Properties msgProp = getMsgProp();
|
|
|
|
|
|
try {
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<FunctionRegionDict> dictList = DictUtils.getFunctionRegionDictList(functionId);
|
|
|
|
|
|
for (FunctionRegionDict dict : dictList) {
|
|
|
|
|
|
if (dict.getConfigRegionCode() == cfgRegionCode) {
|
|
|
|
|
|
String fileName = dict.getConfigRegionValue() + ".xlsx";
|
|
|
|
|
|
if (dict.getRegionType() == 1) {
|
|
|
|
|
|
List<IpCfgTemplate> list = Lists.newArrayList();
|
|
|
|
|
|
list.add(new IpCfgTemplate());
|
|
|
|
|
|
new ExportExcel(new FunctionServiceDict(), new FunctionRegionDict(), msgProp, null,
|
|
|
|
|
|
IpCfgTemplate.class, 2).setDataList(msgProp, list, null)
|
|
|
|
|
|
.write(request, response, fileName).dispose();
|
|
|
|
|
|
} else if (dict.getRegionType() == 2) {
|
2018-06-13 09:58:13 +08:00
|
|
|
|
List<StringCfgTemplate> list = Lists.newArrayList();
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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) {
|
2018-06-13 09:58:13 +08:00
|
|
|
|
List<ComplexStringCfgTemplate> list = Lists.newArrayList();
|
2018-10-18 18:05:49 +08:00
|
|
|
|
list.add(new ComplexStringCfgTemplate());
|
|
|
|
|
|
new ExportExcel(new FunctionServiceDict(), new FunctionRegionDict(), msgProp, null,
|
|
|
|
|
|
ComplexStringCfgTemplate.class, 2).setDataList(msgProp, list, null)
|
|
|
|
|
|
.write(request, response, fileName).dispose();
|
2018-06-13 09:58:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-06-13 09:58:13 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
msgProp = null;
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
public void importCfgTemplate(HttpServletRequest request, HttpServletResponse response,
|
|
|
|
|
|
RedirectAttributes redirectAttributes, Integer functionId, Integer cfgRegionCode, Class clazz) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
Properties msgProp = getMsgProp();
|
|
|
|
|
|
try {
|
2018-10-18 18:05:49 +08:00
|
|
|
|
List<FunctionRegionDict> dictList = DictUtils.getFunctionRegionDictList(functionId);
|
|
|
|
|
|
for (FunctionRegionDict dict : dictList) {
|
|
|
|
|
|
if (dict.getConfigRegionCode() == cfgRegionCode) {
|
|
|
|
|
|
String fileName = dict.getConfigRegionValue() + ".xlsx";
|
|
|
|
|
|
if (dict.getRegionType() == 1) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
List<IpCfgTemplate> list = Lists.newArrayList();
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
List<StringCfgTemplate> list = Lists.newArrayList();
|
|
|
|
|
|
list.add(new StringCfgTemplate());
|
2018-10-18 18:05:49 +08:00
|
|
|
|
new ExportExcel(new FunctionServiceDict(), new FunctionRegionDict(), msgProp, null, clazz, 2)
|
|
|
|
|
|
.setDataList(msgProp, list, null).write(request, response, fileName).dispose();
|
|
|
|
|
|
} else if (dict.getRegionType() == 3) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
List<ComplexStringCfgTemplate> list = Lists.newArrayList();
|
|
|
|
|
|
list.add(new ComplexStringCfgTemplate());
|
2018-10-18 18:05:49 +08:00
|
|
|
|
new ExportExcel(new FunctionServiceDict(), new FunctionRegionDict(), msgProp, null, clazz, 2)
|
|
|
|
|
|
.setDataList(msgProp, list, null).write(request, response, fileName).dispose();
|
2018-07-27 10:16:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-07-27 10:16:32 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
msgProp = null;
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
public void setLogAction(BaseLogEntity log, List<FunctionServiceDict> serviceList) {
|
|
|
|
|
|
if (!StringUtil.isEmpty(serviceList)) {
|
2018-08-18 14:59:49 +08:00
|
|
|
|
for (FunctionServiceDict dict : serviceList) {
|
|
|
|
|
|
if (dict.getServiceId().intValue() == log.getService()) {
|
|
|
|
|
|
log.setAction(dict.getAction());
|
|
|
|
|
|
}
|
2018-06-14 10:37:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-06-13 14:36:58 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
// 初始化查询值判断
|
|
|
|
|
|
public void initLogSearchValue(BaseLogEntity entry, Map<String, Object> params) {
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(entry.getSearchFoundStartTime())
|
|
|
|
|
|
&& StringUtils.isNotBlank(entry.getSearchFoundEndTime())) {
|
2018-06-13 16:25:00 +08:00
|
|
|
|
params.put("searchFoundStartTime", entry.getSearchFoundStartTime());
|
|
|
|
|
|
params.put("searchFoundEndTime", entry.getSearchFoundEndTime());
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else {
|
2018-09-02 13:01:10 +08:00
|
|
|
|
// 判断是否是从配置界面过来的日志查询
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (StringUtils.isNotBlank(entry.getIsLogTotalSearch())) {
|
2018-09-28 12:00:13 +08:00
|
|
|
|
Calendar time = Calendar.getInstance();
|
|
|
|
|
|
time.add(Calendar.MINUTE, -5);
|
|
|
|
|
|
String searchEndTime = DateUtils.formatDateTime(time.getTime());
|
2018-10-18 18:05:49 +08:00
|
|
|
|
params.put("searchFoundEndTime", searchEndTime);
|
2018-09-28 12:00:13 +08:00
|
|
|
|
entry.setSearchFoundEndTime(searchEndTime);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-09-28 12:00:13 +08:00
|
|
|
|
time.add(Calendar.MINUTE, -5);
|
|
|
|
|
|
String searchStartTime = DateUtils.formatDateTime(time.getTime());
|
|
|
|
|
|
params.put("searchFoundStartTime", searchStartTime);
|
|
|
|
|
|
entry.setSearchFoundStartTime(searchStartTime);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-09-02 13:01:10 +08:00
|
|
|
|
// 判断startTime是否有值
|
2018-10-18 18:05:49 +08:00
|
|
|
|
/*
|
|
|
|
|
|
* 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 {
|
|
|
|
|
|
// 设置默认查询当前时间及前五分钟
|
2018-09-02 13:01:10 +08:00
|
|
|
|
String endTime = DateUtils.getDateTime();
|
|
|
|
|
|
Date dateStart = new Date(new Date().getTime() - Constants.LOG_TIME_INTERVAL);
|
|
|
|
|
|
String startTime = DateUtils.formatDateTime(dateStart);
|
|
|
|
|
|
params.put("searchFoundStartTime", startTime);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
params.put("searchFoundEndTime", endTime);
|
2018-09-02 13:01:10 +08:00
|
|
|
|
entry.setSearchFoundStartTime(startTime);
|
|
|
|
|
|
entry.setSearchFoundEndTime(endTime);
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
logger.info("searchFoundStartTime:" + params.get("searchFoundStartTime"));
|
|
|
|
|
|
logger.info("searchFoundEndTime:" + params.get("searchFoundEndTime"));
|
2018-06-13 16:25:00 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-07-03 12:46:06 +08:00
|
|
|
|
if (StringUtils.isNotBlank(entry.getTransProto())) {
|
|
|
|
|
|
params.put("searchTransProto", entry.getTransProto());
|
2018-06-13 16:25:00 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (entry.getService() != null) {
|
2018-07-03 12:46:06 +08:00
|
|
|
|
params.put("searchService", entry.getService());
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (entry.getAction() != null) {
|
2018-07-18 19:31:55 +08:00
|
|
|
|
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(entry.getFunctionId());
|
|
|
|
|
|
for (FunctionServiceDict dict : serviceList) {
|
|
|
|
|
|
if (dict.getAction().intValue() == entry.getAction().intValue()
|
|
|
|
|
|
&& dict.getFunctionId().intValue() == entry.getFunctionId().intValue()) {
|
|
|
|
|
|
entry.setService(dict.getServiceId());
|
|
|
|
|
|
params.put("searchService", dict.getServiceId());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-06-13 16:25:00 +08:00
|
|
|
|
}
|
2018-07-03 12:46:06 +08:00
|
|
|
|
if (StringUtils.isNotBlank(entry.getdIp())) {
|
|
|
|
|
|
params.put("searchDIp", entry.getdIp());
|
2018-06-13 16:25:00 +08:00
|
|
|
|
}
|
2018-07-03 12:46:06 +08:00
|
|
|
|
if (StringUtils.isNotBlank(entry.getsIp())) {
|
|
|
|
|
|
params.put("searchSIp", entry.getsIp());
|
2018-06-13 16:25:00 +08:00
|
|
|
|
}
|
2018-07-03 12:46:06 +08:00
|
|
|
|
if (StringUtils.isNotBlank(entry.getCapIp())) {
|
|
|
|
|
|
params.put("searchCapIp", entry.getCapIp());
|
2018-06-13 16:25:00 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (entry.getDirection() != null) {
|
2018-06-13 16:25:00 +08:00
|
|
|
|
params.put("searchDirection", entry.getDirection());
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (entry.getEntranceId() != null) {
|
2018-06-13 16:25:00 +08:00
|
|
|
|
params.put("searchEntranceId", entry.getEntranceId());
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (entry.getCfgId() != null) {
|
2018-06-20 13:33:46 +08:00
|
|
|
|
params.put("searchCfgId", entry.getCfgId());
|
|
|
|
|
|
}
|
2018-10-31 09:56:38 +08:00
|
|
|
|
if (entry.getOrderBy() != null&&entry.getOrderBy()!="") {
|
|
|
|
|
|
params.put("orderBy", entry.getOrderBy());
|
|
|
|
|
|
}
|
2018-06-13 16:25:00 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
|
|
|
|
|
|
public List<BaseStringCfg<?>> checkStringCfg(FunctionServiceDict serviceDict, FunctionRegionDict regionDict,
|
|
|
|
|
|
List<?> list) throws ServiceException {
|
2018-10-20 23:38:56 +08:00
|
|
|
|
List<BaseStringCfg<?>> stringList = new ArrayList<BaseStringCfg<?>>();
|
|
|
|
|
|
Properties prop = this.getMsgProp();
|
2018-10-25 16:44:04 +08:00
|
|
|
|
String exprTypeP = regionDict.getConfigExprType();
|
2018-10-20 23:38:56 +08:00
|
|
|
|
if (StringUtil.isEmpty(exprTypeP)) {
|
|
|
|
|
|
throw new RuntimeException("Found String region,but exprType is Empty");
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
String matchMethodP = regionDict.getConfigMatchMethod();
|
2018-10-20 23:38:56 +08:00
|
|
|
|
if (StringUtil.isEmpty(matchMethodP)) {
|
|
|
|
|
|
throw new RuntimeException("Found String region,but matchMethod is Empty");
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
String hexP = regionDict.getConfigHex();
|
2018-10-20 23:38:56 +08:00
|
|
|
|
if (StringUtil.isEmpty(hexP)) {
|
|
|
|
|
|
throw new RuntimeException("Found String region,but hex is Empty");
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
String mulityKeywordsP = regionDict.getConfigMultiKeywords();
|
2018-10-20 23:38:56 +08:00
|
|
|
|
if (StringUtil.isEmpty(mulityKeywordsP)) {
|
|
|
|
|
|
throw new RuntimeException("Found String region,but mulityKeywords is Empty");
|
|
|
|
|
|
}
|
|
|
|
|
|
StringBuffer errTip = new StringBuffer();
|
2018-10-25 16:44:04 +08:00
|
|
|
|
Pattern pattern = Pattern.compile("\t|\r|\n|\b|\f");
|
2018-10-20 23:38:56 +08:00
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
|
StringBuffer errInfo = new StringBuffer();
|
|
|
|
|
|
BaseStringCfg baseStringCfg = new BaseStringCfg();
|
|
|
|
|
|
BeanUtils.copyProperties(list.get(i), baseStringCfg);
|
|
|
|
|
|
if (regionDict.getRegionType().equals(2)) {
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (regionDict.getFunctionId().equals(510) && "p2p_hash".equals(regionDict.getConfigServiceType())) {
|
|
|
|
|
|
String userRegion1 = baseStringCfg.getUserRegion1();
|
|
|
|
|
|
if (StringUtils.isNotBlank(userRegion1)) {
|
|
|
|
|
|
List<SysDataDictionaryItem> hashs = DictUtils.getDictList("P2P_HASH_TYPE");
|
|
|
|
|
|
boolean has = false;
|
|
|
|
|
|
for (SysDataDictionaryItem hash : hashs) {
|
|
|
|
|
|
if (hash.getItemCode().equals(userRegion1)) {
|
|
|
|
|
|
has = true;
|
2018-10-23 20:31:29 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (!has) {
|
|
|
|
|
|
errInfo.append(String.format(prop.getProperty("is_incorrect"),
|
|
|
|
|
|
prop.getProperty("p2p_hash_type") + " ") + ";");
|
2018-10-23 20:31:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
String keyword = baseStringCfg.getCfgKeywords();
|
|
|
|
|
|
if (StringUtils.isBlank(keyword)) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("can_not_null"), prop.getProperty("key_word") + " ") + ";");
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (mulityKeywordsP.equals("0")) {
|
|
|
|
|
|
if (keyword.indexOf("\n") > -1) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("not_multiple"), prop.getProperty("key_word")) + ";");
|
2018-10-23 19:15:37 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
Matcher m = pattern.matcher(keyword);
|
|
|
|
|
|
if (m.find()) {
|
|
|
|
|
|
errInfo.append(String.format(prop.getProperty("has_invisible_char"),
|
|
|
|
|
|
prop.getProperty("key_word") + " '" + keyword + "'") + ";");
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
boolean has = false;
|
2018-10-30 14:52:51 +08:00
|
|
|
|
Set<String> keywordSet=Sets.newHashSet();
|
2018-10-25 16:44:04 +08:00
|
|
|
|
for (String key : keyword.split("\n")) {
|
|
|
|
|
|
Matcher m = pattern.matcher(key);
|
|
|
|
|
|
if (m.find()) {
|
|
|
|
|
|
has = true;
|
|
|
|
|
|
errInfo.append(String.format(prop.getProperty("has_invisible_char"),
|
|
|
|
|
|
prop.getProperty("key_word") + " '" + key + "'") + ";");
|
2018-10-23 19:15:37 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2018-10-30 14:52:51 +08:00
|
|
|
|
if(!keywordSet.contains(key)) {
|
|
|
|
|
|
keywordSet.add(key);
|
|
|
|
|
|
}else {
|
|
|
|
|
|
errInfo.append(prop.getProperty("key_word") + " '" + key + "'"+" "+prop.getProperty("repeat") + ";");
|
|
|
|
|
|
}
|
2018-10-23 19:15:37 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (!has) {
|
2018-10-30 15:19:13 +08:00
|
|
|
|
if(keyword.replaceAll("\n","").length()>1024) {
|
2018-10-30 14:52:51 +08:00
|
|
|
|
errInfo.append(String.format(prop.getProperty("most_keywords"),
|
|
|
|
|
|
prop.getProperty("key_word")) + ";");
|
|
|
|
|
|
}else {
|
|
|
|
|
|
String reWord = keyword.replaceAll("\n", Constants.KEYWORD_EXPR);
|
|
|
|
|
|
baseStringCfg.setCfgKeywords(reWord);
|
|
|
|
|
|
}
|
2018-10-23 19:15:37 +08:00
|
|
|
|
}
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
Integer exprType = baseStringCfg.getExprType();
|
|
|
|
|
|
boolean has = false;
|
|
|
|
|
|
if (exprType == null) {
|
|
|
|
|
|
if (exprTypeP.indexOf(",") == -1) {
|
|
|
|
|
|
if (mulityKeywordsP.equals("0") && exprTypeP.equals("1")) {
|
|
|
|
|
|
throw new RuntimeException("region dict config error,dict id is " + regionDict.getDictId());
|
2018-10-23 19:15:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
baseStringCfg.setExprType(Integer.parseInt(exprTypeP));
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (exprTypeP.indexOf("0") > -1 && mulityKeywordsP.equals("0")) {
|
2018-10-23 19:15:37 +08:00
|
|
|
|
baseStringCfg.setExprType(0);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (exprTypeP.indexOf("1") > -1 && mulityKeywordsP.equals("1")
|
|
|
|
|
|
&& keyword.indexOf("\n") > -1) {
|
2018-10-23 19:15:37 +08:00
|
|
|
|
baseStringCfg.setExprType(1);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (exprTypeP.indexOf("0") > -1 && mulityKeywordsP.equals("1")
|
|
|
|
|
|
&& keyword.indexOf("\n") == -1) {
|
2018-10-23 19:15:37 +08:00
|
|
|
|
baseStringCfg.setExprType(0);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else {
|
2018-10-23 19:15:37 +08:00
|
|
|
|
baseStringCfg.setExprType(Integer.parseInt(exprTypeP.split(",")[0]));
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
// errInfo.append(String.format(prop.getProperty("can_not_null"),
|
|
|
|
|
|
// prop.getProperty("expression_type"))+";");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
for (String exp : exprTypeP.split(",")) {
|
|
|
|
|
|
if (exp.equals(exprType.toString())) {
|
|
|
|
|
|
has = true;
|
2018-10-22 15:14:32 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (!has) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("expression_type"))
|
|
|
|
|
|
+ ";");
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
has = false;
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
exprType = baseStringCfg.getExprType();
|
|
|
|
|
|
Integer matchMethod = baseStringCfg.getMatchMethod();
|
|
|
|
|
|
if (matchMethod == null) {
|
|
|
|
|
|
if (matchMethodP.indexOf(",") == -1) {
|
|
|
|
|
|
if (exprTypeP.equals("1") && !matchMethodP.equals("0")) {
|
|
|
|
|
|
throw new RuntimeException("region dict config error,dict id is " + regionDict.getDictId());
|
2018-10-23 19:15:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
baseStringCfg.setMatchMethod(Integer.parseInt(matchMethodP));
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (exprType != null && exprType.intValue() == 1) {
|
|
|
|
|
|
if (matchMethodP.indexOf("0") > -1) {
|
2018-10-23 19:15:37 +08:00
|
|
|
|
baseStringCfg.setMatchMethod(0);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
throw new RuntimeException("region dict config error,dict id is " + regionDict.getDictId());
|
2018-10-23 19:15:37 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
|
|
|
|
|
|
} else {
|
2018-10-23 19:15:37 +08:00
|
|
|
|
baseStringCfg.setMatchMethod(Integer.parseInt(matchMethodP.split(",")[0]));
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
// errInfo.append(String.format(prop.getProperty("can_not_null"),
|
|
|
|
|
|
// prop.getProperty("match_method"))+";");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
for (String exp : matchMethodP.split(",")) {
|
|
|
|
|
|
if (exp.equals(matchMethod.toString())) {
|
|
|
|
|
|
has = true;
|
2018-10-22 15:14:32 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (!has) {
|
|
|
|
|
|
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("match_method"))
|
|
|
|
|
|
+ ";");
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
|
|
|
|
|
|
Integer isHex = baseStringCfg.getIsHex();
|
|
|
|
|
|
Integer isCaseInsenstive = baseStringCfg.getIsCaseInsenstive();
|
|
|
|
|
|
if (isHex == null || isCaseInsenstive == null) {
|
|
|
|
|
|
if (isHex == null) {
|
|
|
|
|
|
if (hexP.equals("0") || hexP.equals("2")) {
|
2018-10-23 19:15:37 +08:00
|
|
|
|
baseStringCfg.setIsHex(0);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (hexP.equals("1")) {
|
2018-10-23 19:15:37 +08:00
|
|
|
|
baseStringCfg.setIsHex(1);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("can_not_null"), prop.getProperty("is_hex")) + ";");
|
2018-10-23 19:15:37 +08:00
|
|
|
|
}
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (isCaseInsenstive == null) {
|
|
|
|
|
|
if (hexP.equals("0") || hexP.equals("1")) {
|
2018-10-24 16:09:32 +08:00
|
|
|
|
baseStringCfg.setIsCaseInsenstive(0);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (hexP.equals("2")) {
|
2018-10-24 16:09:32 +08:00
|
|
|
|
baseStringCfg.setIsCaseInsenstive(1);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
errInfo.append(String.format(prop.getProperty("can_not_null"),
|
|
|
|
|
|
prop.getProperty("is_case_insenstive")) + ";");
|
2018-10-23 19:15:37 +08:00
|
|
|
|
}
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
if (isHex.intValue() != 0 && isHex.intValue() != 1) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";");
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (isCaseInsenstive.intValue() != 0 && isCaseInsenstive.intValue() != 1) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive"))
|
|
|
|
|
|
+ ";");
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (hexP.indexOf("1") == -1 && isHex.intValue() == 1) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";");
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (hexP.equals("1") && isHex.intValue() == 0) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";");
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (hexP.indexOf("2") == -1 && isCaseInsenstive.intValue() == 1) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive"))
|
|
|
|
|
|
+ ";");
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (hexP.equals("2") && isCaseInsenstive.intValue() == 0) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive"))
|
|
|
|
|
|
+ ";");
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-24 16:09:32 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
isHex = baseStringCfg.getIsHex();
|
|
|
|
|
|
isCaseInsenstive = baseStringCfg.getIsCaseInsenstive();
|
|
|
|
|
|
if (isHex != null && isCaseInsenstive != null) {
|
|
|
|
|
|
if (isHex.intValue() == 0 && isCaseInsenstive.intValue() == 0) {
|
2018-10-22 15:14:32 +08:00
|
|
|
|
baseStringCfg.setIsHexbin(0);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (isHex.intValue() == 1 && isCaseInsenstive.intValue() == 0) {
|
2018-10-22 15:14:32 +08:00
|
|
|
|
baseStringCfg.setIsHexbin(1);
|
2018-10-31 17:00:40 +08:00
|
|
|
|
} else if (isHex.intValue() == 0 && isCaseInsenstive.intValue() == 1) {
|
2018-10-22 15:14:32 +08:00
|
|
|
|
baseStringCfg.setIsHexbin(2);
|
2018-10-31 17:00:40 +08:00
|
|
|
|
}else {
|
|
|
|
|
|
errInfo.append(prop.getProperty("hex_case_insensitive")+ ";");
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (errInfo.toString().length() > 0) {//
|
|
|
|
|
|
errTip.append(String.format(prop.getProperty("line"), i + 2) + ",");
|
|
|
|
|
|
errTip.append(errInfo);
|
|
|
|
|
|
errTip.append("<br>");
|
|
|
|
|
|
}
|
|
|
|
|
|
stringList.add(baseStringCfg);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (errTip.toString().length() > 0) {
|
|
|
|
|
|
throw new ServiceException(errTip.toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
return stringList;
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
|
|
|
|
|
|
public List<ComplexkeywordCfg> checkComplexStringCfg(FunctionServiceDict serviceDict, FunctionRegionDict regionDict,
|
|
|
|
|
|
List<?> list) throws ServiceException {
|
2018-10-20 23:38:56 +08:00
|
|
|
|
List<ComplexkeywordCfg> stringList = new ArrayList<ComplexkeywordCfg>();
|
|
|
|
|
|
Properties prop = this.getMsgProp();
|
2018-10-25 16:44:04 +08:00
|
|
|
|
String exprTypeP = regionDict.getConfigExprType();
|
2018-10-20 23:38:56 +08:00
|
|
|
|
if (StringUtil.isEmpty(exprTypeP)) {
|
|
|
|
|
|
throw new RuntimeException("Found String region,but exprType is Empty");
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
String matchMethodP = regionDict.getConfigMatchMethod();
|
2018-10-20 23:38:56 +08:00
|
|
|
|
if (StringUtil.isEmpty(matchMethodP)) {
|
|
|
|
|
|
throw new RuntimeException("Found String region,but matchMethod is Empty");
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
String hexP = regionDict.getConfigHex();
|
2018-10-20 23:38:56 +08:00
|
|
|
|
if (StringUtil.isEmpty(hexP)) {
|
|
|
|
|
|
throw new RuntimeException("Found String region,but hex is Empty");
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
String mulityKeywordsP = regionDict.getConfigMultiKeywords();
|
2018-10-20 23:38:56 +08:00
|
|
|
|
if (StringUtil.isEmpty(mulityKeywordsP)) {
|
|
|
|
|
|
throw new RuntimeException("Found String region,but mulityKeywords is Empty");
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
String dirtrictP = regionDict.getConfigDistrict();
|
2018-10-20 23:38:56 +08:00
|
|
|
|
StringBuffer errTip = new StringBuffer();
|
2018-10-25 16:44:04 +08:00
|
|
|
|
Pattern pattern = Pattern.compile("\t|\r|\n|\b|\f");
|
2018-10-20 23:38:56 +08:00
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
|
StringBuffer errInfo = new StringBuffer();
|
|
|
|
|
|
ComplexkeywordCfg baseStringCfg = new ComplexkeywordCfg();
|
|
|
|
|
|
BeanUtils.copyProperties(list.get(i), baseStringCfg);
|
|
|
|
|
|
if (regionDict.getRegionType().equals(3)) {
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (regionDict.getFunctionId().equals(7)) {
|
|
|
|
|
|
Long dnsStrategyId = baseStringCfg.getDnsStrategyId();
|
|
|
|
|
|
if (dnsStrategyId != null) {
|
|
|
|
|
|
List<DnsResStrategy> dnsStrategys = dnsResStrategyService.findDnsResStrategys(dnsStrategyId,
|
|
|
|
|
|
Constants.VALID_YES, Constants.AUDIT_YES);
|
|
|
|
|
|
if (dnsStrategys == null || dnsStrategys.size() == 0) {
|
|
|
|
|
|
errInfo.append(String.format(prop.getProperty("is_incorrect"),
|
|
|
|
|
|
prop.getProperty("dns_res_strategy")) + ";");
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
String keyword = baseStringCfg.getCfgKeywords();
|
|
|
|
|
|
String district = baseStringCfg.getDistrict();
|
|
|
|
|
|
if (StringUtils.isBlank(keyword)) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("can_not_null"), prop.getProperty("key_word") + " ") + ";");
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (StringUtils.isNotBlank(dirtrictP)) {
|
|
|
|
|
|
if (StringUtils.isBlank(district)) {
|
|
|
|
|
|
if (dirtrictP.indexOf(",") == -1) {
|
2018-10-24 11:08:39 +08:00
|
|
|
|
baseStringCfg.setDistrict(dirtrictP);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
// baseStringCfg.setDistrict(dirtrictP.split(",")[0]);
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("can_not_null"), prop.getProperty("district") + " ")
|
|
|
|
|
|
+ ";");
|
2018-10-24 11:08:39 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (dirtrictP.indexOf(district) == -1) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("district") + " ")
|
|
|
|
|
|
+ ";");
|
2018-10-31 17:00:40 +08:00
|
|
|
|
} else if (dirtrictP.indexOf("others")>-1&&district.equals("others")) {
|
|
|
|
|
|
//不允许自定义匹配区域导入
|
|
|
|
|
|
errInfo.append(prop.getProperty("district")+" "+
|
|
|
|
|
|
String.format(prop.getProperty("can_not_be"), " 'others'")+ ";");
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (mulityKeywordsP.equals("0")) {
|
|
|
|
|
|
if (keyword.indexOf("\n") > -1) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("not_multiple"), prop.getProperty("key_word")) + ";");
|
2018-10-23 19:15:37 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
Matcher m = pattern.matcher(keyword);
|
|
|
|
|
|
if (m.find()) {
|
|
|
|
|
|
errInfo.append(String.format(prop.getProperty("has_invisible_char"),
|
|
|
|
|
|
prop.getProperty("key_word") + " '" + keyword + "'") + ";");
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
boolean has = false;
|
2018-10-30 14:52:51 +08:00
|
|
|
|
Set<String> keywordSet=Sets.newHashSet();
|
|
|
|
|
|
|
2018-10-25 16:44:04 +08:00
|
|
|
|
for (String key : keyword.split("\n")) {
|
|
|
|
|
|
Matcher m = pattern.matcher(key);
|
|
|
|
|
|
if (m.find()) {
|
|
|
|
|
|
has = true;
|
|
|
|
|
|
errInfo.append(String.format(prop.getProperty("has_invisible_char"),
|
|
|
|
|
|
prop.getProperty("key_word") + " '" + key + "'") + ";");
|
2018-10-23 19:15:37 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2018-10-30 14:52:51 +08:00
|
|
|
|
if(!keywordSet.contains(key)) {
|
|
|
|
|
|
keywordSet.add(key);
|
|
|
|
|
|
}else {
|
|
|
|
|
|
errInfo.append(prop.getProperty("key_word") + " '" + key + "'"+" "+prop.getProperty("repeat") + ";");
|
|
|
|
|
|
}
|
2018-10-23 19:15:37 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (!has) {
|
2018-10-30 15:19:13 +08:00
|
|
|
|
if(keyword.replaceAll("\n","").length()>1024) {
|
2018-10-30 14:52:51 +08:00
|
|
|
|
errInfo.append(String.format(prop.getProperty("most_keywords"),
|
|
|
|
|
|
prop.getProperty("key_word")) + ";");
|
|
|
|
|
|
}else {
|
|
|
|
|
|
String reWord = keyword.replaceAll("\n", Constants.KEYWORD_EXPR);
|
|
|
|
|
|
baseStringCfg.setCfgKeywords(reWord);
|
|
|
|
|
|
}
|
2018-10-23 19:15:37 +08:00
|
|
|
|
}
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
Integer exprType = baseStringCfg.getExprType();
|
|
|
|
|
|
boolean has = false;
|
|
|
|
|
|
if (exprType == null) {
|
|
|
|
|
|
if (exprTypeP.indexOf(",") == -1) {
|
|
|
|
|
|
if (mulityKeywordsP.equals("0") && exprTypeP.equals("1")) {
|
|
|
|
|
|
throw new RuntimeException("region dict config error,dict id is " + regionDict.getDictId());
|
2018-10-23 19:15:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
baseStringCfg.setExprType(Integer.parseInt(exprTypeP));
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (exprTypeP.indexOf("0") > -1 && mulityKeywordsP.equals("0")) {
|
2018-10-23 19:15:37 +08:00
|
|
|
|
baseStringCfg.setExprType(0);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (exprTypeP.indexOf("1") > -1 && mulityKeywordsP.equals("1")
|
|
|
|
|
|
&& keyword.indexOf("\n") > -1) {
|
2018-10-23 19:15:37 +08:00
|
|
|
|
baseStringCfg.setExprType(1);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (exprTypeP.indexOf("0") > -1 && mulityKeywordsP.equals("1")
|
|
|
|
|
|
&& keyword.indexOf("\n") == -1) {
|
2018-10-23 19:15:37 +08:00
|
|
|
|
baseStringCfg.setExprType(0);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else {
|
2018-10-23 19:15:37 +08:00
|
|
|
|
baseStringCfg.setExprType(Integer.parseInt(exprTypeP.split(",")[0]));
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
// errInfo.append(String.format(prop.getProperty("can_not_null"),
|
|
|
|
|
|
// prop.getProperty("expression_type"))+";");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
for (String exp : exprTypeP.split(",")) {
|
|
|
|
|
|
if (exp.equals(exprType.toString())) {
|
|
|
|
|
|
has = true;
|
2018-10-22 15:14:32 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (!has) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("expression_type"))
|
|
|
|
|
|
+ ";");
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
has = false;
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
exprType = baseStringCfg.getExprType();
|
|
|
|
|
|
Integer matchMethod = baseStringCfg.getMatchMethod();
|
|
|
|
|
|
if (matchMethod == null) {
|
|
|
|
|
|
if (matchMethodP.indexOf(",") == -1) {
|
|
|
|
|
|
if (exprTypeP.equals("1") && !matchMethodP.equals("0")) {
|
|
|
|
|
|
throw new RuntimeException("region dict config error,dict id is " + regionDict.getDictId());
|
2018-10-23 19:15:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
baseStringCfg.setMatchMethod(Integer.parseInt(matchMethodP));
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (exprType != null && exprType.intValue() == 1) {
|
|
|
|
|
|
if (matchMethodP.indexOf("0") > -1) {
|
2018-10-23 19:15:37 +08:00
|
|
|
|
baseStringCfg.setMatchMethod(0);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
throw new RuntimeException("region dict config error,dict id is " + regionDict.getDictId());
|
2018-10-23 19:15:37 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
|
|
|
|
|
|
} else {
|
2018-10-23 19:15:37 +08:00
|
|
|
|
baseStringCfg.setMatchMethod(Integer.parseInt(matchMethodP.split(",")[0]));
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
// errInfo.append(String.format(prop.getProperty("can_not_null"),
|
|
|
|
|
|
// prop.getProperty("match_method"))+";");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
for (String exp : matchMethodP.split(",")) {
|
|
|
|
|
|
if (exp.equals(matchMethod.toString())) {
|
|
|
|
|
|
has = true;
|
2018-10-22 15:14:32 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (!has) {
|
|
|
|
|
|
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("match_method"))
|
|
|
|
|
|
+ ";");
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
Integer isHex = baseStringCfg.getIsHex();
|
|
|
|
|
|
Integer isCaseInsenstive = baseStringCfg.getIsCaseInsenstive();
|
|
|
|
|
|
if (isHex == null || isCaseInsenstive == null) {
|
|
|
|
|
|
if (isHex == null) {
|
|
|
|
|
|
if (hexP.equals("0") || hexP.equals("2")) {
|
2018-10-23 19:15:37 +08:00
|
|
|
|
baseStringCfg.setIsHex(0);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (hexP.equals("1")) {
|
2018-10-23 19:15:37 +08:00
|
|
|
|
baseStringCfg.setIsHex(1);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("can_not_null"), prop.getProperty("is_hex")) + ";");
|
2018-10-23 19:15:37 +08:00
|
|
|
|
}
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (isCaseInsenstive == null) {
|
|
|
|
|
|
if (hexP.equals("0") || hexP.equals("1")) {
|
2018-10-24 16:09:32 +08:00
|
|
|
|
baseStringCfg.setIsCaseInsenstive(0);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (hexP.equals("2")) {
|
2018-10-24 16:09:32 +08:00
|
|
|
|
baseStringCfg.setIsCaseInsenstive(1);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
errInfo.append(String.format(prop.getProperty("can_not_null"),
|
|
|
|
|
|
prop.getProperty("is_case_insenstive")) + ";");
|
2018-10-23 19:15:37 +08:00
|
|
|
|
}
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
if (isHex.intValue() != 0 && isHex.intValue() != 1) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";");
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (isCaseInsenstive.intValue() != 0 && isCaseInsenstive.intValue() != 1) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive"))
|
|
|
|
|
|
+ ";");
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (hexP.indexOf("1") == -1 && isHex.intValue() == 1) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";");
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (hexP.equals("1") && isHex.intValue() == 0) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";");
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (hexP.indexOf("2") == -1 && isCaseInsenstive.intValue() == 1) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive"))
|
|
|
|
|
|
+ ";");
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (hexP.equals("2") && isCaseInsenstive.intValue() == 0) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive"))
|
|
|
|
|
|
+ ";");
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-24 16:09:32 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
isHex = baseStringCfg.getIsHex();
|
|
|
|
|
|
isCaseInsenstive = baseStringCfg.getIsCaseInsenstive();
|
|
|
|
|
|
if (isHex != null && isCaseInsenstive != null) {
|
|
|
|
|
|
if (isHex.intValue() == 0 && isCaseInsenstive.intValue() == 0) {
|
2018-10-22 15:14:32 +08:00
|
|
|
|
baseStringCfg.setIsHexbin(0);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (isHex.intValue() == 1 && isCaseInsenstive.intValue() == 0) {
|
2018-10-22 15:14:32 +08:00
|
|
|
|
baseStringCfg.setIsHexbin(1);
|
2018-10-31 17:00:40 +08:00
|
|
|
|
} else if (isHex.intValue() == 0 && isCaseInsenstive.intValue() == 1) {
|
2018-10-22 15:14:32 +08:00
|
|
|
|
baseStringCfg.setIsHexbin(2);
|
2018-10-31 17:00:40 +08:00
|
|
|
|
}else {
|
|
|
|
|
|
errInfo.append(prop.getProperty("hex_case_insensitive")+ ";");
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (errInfo.toString().length() > 0) {//
|
|
|
|
|
|
errTip.append(String.format(prop.getProperty("line"), i + 2) + ",");
|
|
|
|
|
|
errTip.append(errInfo);
|
|
|
|
|
|
errTip.append("<br>");
|
|
|
|
|
|
}
|
|
|
|
|
|
stringList.add(baseStringCfg);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (errTip.toString().length() > 0) {
|
|
|
|
|
|
throw new ServiceException(errTip.toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
return stringList;
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
public List<BaseIpCfg> checkIpCfg(FunctionServiceDict serviceDict, FunctionRegionDict regionDict, List<?> list)
|
|
|
|
|
|
throws ServiceException {
|
|
|
|
|
|
List<BaseIpCfg> ipList = new ArrayList<BaseIpCfg>();
|
|
|
|
|
|
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();
|
2018-10-15 10:14:01 +08:00
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
2018-10-18 18:05:49 +08:00
|
|
|
|
StringBuffer errInfo = new StringBuffer();
|
|
|
|
|
|
IpPortCfg baseIpCfg = new IpPortCfg();
|
2018-10-17 10:06:08 +08:00
|
|
|
|
BeanUtils.copyProperties(list.get(i), baseIpCfg);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
// 特殊字段验证
|
|
|
|
|
|
// packet ip ratelimit
|
|
|
|
|
|
if (serviceDict!=null&&serviceDict.getFunctionId().intValue() == 5 && serviceDict.getAction().intValue() == 64) {
|
2018-10-30 11:29:37 +08:00
|
|
|
|
String userRegion1 = IpRateLimitTemplate.userRegion1;
|
|
|
|
|
|
baseIpCfg.setUserRegion1(userRegion1);
|
|
|
|
|
|
if("0".equals(userRegion1)) {
|
|
|
|
|
|
String userRegion2 = baseIpCfg.getUserRegion2();
|
|
|
|
|
|
try {
|
|
|
|
|
|
// Double ratelimt= Double.parseDouble(userRegion2);
|
|
|
|
|
|
List<SysDataDictionaryItem> ratelimtList = DictUtils.getDictList("RATE_LIMIT");
|
|
|
|
|
|
boolean has = false;
|
|
|
|
|
|
for (SysDataDictionaryItem ratelimit : ratelimtList) {
|
|
|
|
|
|
if (ratelimit.getItemCode().equals(userRegion2)) {
|
|
|
|
|
|
has = true;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!has) {
|
|
|
|
|
|
errInfo.append(prop.getProperty("ratelimit") + "."
|
|
|
|
|
|
+ String.format(prop.getProperty("must_between"), 0.001, 0.009) + ";");
|
2018-10-22 20:02:59 +08:00
|
|
|
|
}
|
2018-10-30 11:29:37 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
|
errInfo.append(String.format(prop.getProperty("not_number"), prop.getProperty("ratelimit")) + ";");
|
2018-10-22 20:02:59 +08:00
|
|
|
|
}
|
2018-10-30 11:29:37 +08:00
|
|
|
|
}else if("1".equals(userRegion1)) {
|
|
|
|
|
|
String userRegion3 = baseIpCfg.getUserRegion3();
|
|
|
|
|
|
if (StringUtils.isNotBlank(userRegion3)) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
Integer ratelimt=Integer.parseInt(userRegion3);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
|
errInfo.append(String.format(prop.getProperty("not_number"), prop.getProperty("bandwith")) + ";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}else {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("can_not_null"), prop.getProperty("bandwith")) + ";");
|
2018-10-19 12:46:15 +08:00
|
|
|
|
}
|
2018-10-30 11:29:37 +08:00
|
|
|
|
|
2018-10-19 15:28:17 +08:00
|
|
|
|
}
|
2018-10-30 11:29:37 +08:00
|
|
|
|
|
2018-10-19 15:28:17 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
// payload ip
|
|
|
|
|
|
if (regionDict.getFunctionId().equals(212)) {
|
|
|
|
|
|
// replace_zone
|
|
|
|
|
|
String userRegion1 = baseIpCfg.getUserRegion1();
|
|
|
|
|
|
if (StringUtils.isNotBlank(userRegion1)) {
|
2018-10-19 15:28:17 +08:00
|
|
|
|
Object val = DictUtils.getDictLabel("INTERCEPT_REPLACE_ZONE", userRegion1);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (StringUtils.isBlank(val.toString())) {
|
|
|
|
|
|
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("replace_zone"))
|
|
|
|
|
|
+ ";");
|
2018-10-19 15:28:17 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("can_not_null"), prop.getProperty("replace_zone")) + ";");
|
2018-10-19 15:28:17 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
|
|
|
|
|
|
// replaced_content
|
|
|
|
|
|
String userRegion2 = baseIpCfg.getUserRegion2();
|
|
|
|
|
|
if (StringUtils.isBlank(userRegion2)) {
|
|
|
|
|
|
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("replaced_content"))
|
|
|
|
|
|
+ ";");
|
2018-10-19 15:28:17 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
// replace_content
|
|
|
|
|
|
String userRegion3 = baseIpCfg.getUserRegion3();
|
|
|
|
|
|
if (StringUtils.isBlank(userRegion3)) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("can_not_null"), prop.getProperty("replace_content")) + ";");
|
2018-10-19 12:46:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
// dns ip
|
|
|
|
|
|
if (regionDict.getFunctionId().equals(7)) {
|
|
|
|
|
|
Integer dnsStrategyId = baseIpCfg.getDnsStrategyId();
|
|
|
|
|
|
if (dnsStrategyId != null) {
|
|
|
|
|
|
List<DnsResStrategy> dnsStrategys = dnsResStrategyService
|
|
|
|
|
|
.findDnsResStrategys(Long.valueOf(dnsStrategyId), Constants.VALID_YES, Constants.AUDIT_YES);
|
|
|
|
|
|
if (dnsStrategys == null || dnsStrategys.size() == 0) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("dns_res_strategy"))
|
|
|
|
|
|
+ ";");
|
2018-10-22 15:14:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-11-01 20:23:56 +08:00
|
|
|
|
// dns fake ip
|
|
|
|
|
|
if (regionDict.getFunctionId().equals(401)) {
|
|
|
|
|
|
Integer dnsStrategyId = baseIpCfg.getDnsStrategyId();
|
|
|
|
|
|
if (dnsStrategyId != null) {
|
|
|
|
|
|
if(dnsStrategyId>0) {
|
|
|
|
|
|
List<DnsResStrategy> dnsStrategys = dnsResStrategyService
|
|
|
|
|
|
.findDnsResStrategys(Long.valueOf(dnsStrategyId), Constants.VALID_YES, Constants.AUDIT_YES);
|
|
|
|
|
|
if (dnsStrategys == null || dnsStrategys.size() == 0) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("dns_res_strategy"))
|
|
|
|
|
|
+ ";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}else {
|
|
|
|
|
|
baseIpCfg.setDnsStrategyId(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-11-01 14:58:48 +08:00
|
|
|
|
//p2p ip
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (regionDict.getFunctionId().equals(510) && "p2p_ip".equals(regionDict.getConfigServiceType())) { // P2p
|
|
|
|
|
|
// IP
|
|
|
|
|
|
String userRegion1 = baseIpCfg.getUserRegion1();
|
|
|
|
|
|
List<SysDataDictionaryItem> ipTypes = DictUtils.getDictList("P2P_IP_TYPE");
|
|
|
|
|
|
boolean has = false;
|
|
|
|
|
|
for (SysDataDictionaryItem type : ipTypes) {
|
|
|
|
|
|
if (type.getItemCode().equals(userRegion1)) {
|
|
|
|
|
|
has = true;
|
2018-10-23 20:31:29 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (!has) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("p2p_ip_config_type"))
|
|
|
|
|
|
+ ";");
|
2018-10-23 20:31:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-26 18:57:20 +08:00
|
|
|
|
if (regionDict.getFunctionId().equals(600)) {//asn
|
|
|
|
|
|
//asn id
|
|
|
|
|
|
String userRegion1 = baseIpCfg.getUserRegion1();
|
|
|
|
|
|
if(StringUtils.isBlank(userRegion1)) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("can_not_null"), prop.getProperty("asn_no"))
|
|
|
|
|
|
+ ";");
|
|
|
|
|
|
}else {
|
|
|
|
|
|
try {
|
|
|
|
|
|
Integer.parseInt(userRegion1);
|
|
|
|
|
|
/*ConfigGroupInfo configGroupInfo=asnIpCfgService.getConfigGroupInfoByAsnNo(asnNo);
|
|
|
|
|
|
if(configGroupInfo==null) {//不存在则新增
|
|
|
|
|
|
PolicyGroupInfo info=new PolicyGroupInfo();
|
|
|
|
|
|
info.setAsnNo(asnNo);
|
|
|
|
|
|
info.setDescription("Auto generated");
|
|
|
|
|
|
info.setGroupName(baseIpCfg.getCfgDesc()+(i+1));
|
|
|
|
|
|
info.setGroupType(4);
|
|
|
|
|
|
policyGroupInfoService.saveOrUpdate(info);
|
|
|
|
|
|
configGroupInfo=asnIpCfgService.getConfigGroupInfoByAsnNo(asnNo);
|
|
|
|
|
|
}
|
|
|
|
|
|
baseIpCfg.setAsnIpGroup(configGroupInfo.getGroupId());*/
|
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("not_number"), prop.getProperty("asn_no"))
|
|
|
|
|
|
+ ";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-11-01 14:58:48 +08:00
|
|
|
|
if (regionDict.getFunctionId().equals(301)) {
|
|
|
|
|
|
String antiddosProtocol=baseIpCfg.getAntiddosProtocol();
|
|
|
|
|
|
Long bpsThreadshold= baseIpCfg.getBpsThreadshold();
|
|
|
|
|
|
Long ppsThreadshold= baseIpCfg.getPpsThreadshold();
|
|
|
|
|
|
if(StringUtils.isNotBlank(antiddosProtocol)) {
|
|
|
|
|
|
List<SysDataDictionaryItem> antiddosProtocolDicts=DictUtils.getDictList("ANTIDDOS_PROTOCOL");
|
|
|
|
|
|
boolean has=false;
|
|
|
|
|
|
for(SysDataDictionaryItem ditc:antiddosProtocolDicts) {
|
|
|
|
|
|
if(ditc.getItemCode().equals(antiddosProtocol)) {
|
|
|
|
|
|
has=true;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!has) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("antiddos_protocol"))
|
|
|
|
|
|
+ ";");
|
|
|
|
|
|
}
|
|
|
|
|
|
if(bpsThreadshold==null) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("can_not_null"), prop.getProperty("bps_threadshold"))
|
|
|
|
|
|
+ ";");
|
|
|
|
|
|
}
|
|
|
|
|
|
if(ppsThreadshold==null) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("can_not_null"), prop.getProperty("pps_threadshold"))
|
|
|
|
|
|
+ ";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (regionDict.getRegionType().equals(1)) {
|
|
|
|
|
|
// 校验必填的IP,端口
|
2018-10-25 16:44:04 +08:00
|
|
|
|
/*
|
|
|
|
|
|
* 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
|
|
|
|
|
|
* ("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")) + ";"); } } }
|
|
|
|
|
|
*/
|
2018-10-18 18:05:49 +08:00
|
|
|
|
boolean srcIpEmpty = false;
|
2018-10-22 19:06:43 +08:00
|
|
|
|
boolean destIpEmpty = false;
|
2018-10-18 18:05:49 +08:00
|
|
|
|
boolean srcPortEmpty = false;
|
2018-10-22 19:06:43 +08:00
|
|
|
|
boolean destPortEmpty = false;
|
2018-10-30 15:59:56 +08:00
|
|
|
|
Pattern ipv4IpRangeRegexpNew = Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP_NEW);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (StringUtil.isEmpty(baseIpCfg.getSrcIpAddress())) {
|
|
|
|
|
|
srcIpEmpty = true;
|
2018-10-30 15:59:56 +08:00
|
|
|
|
}else {
|
|
|
|
|
|
//处理0.0.0.1-2这种格式,转换为0.0.0.1-0.0.0.2
|
|
|
|
|
|
Matcher m=ipv4IpRangeRegexpNew.matcher(baseIpCfg.getSrcIpAddress());
|
|
|
|
|
|
if(m.matches()) {
|
|
|
|
|
|
String prefix=baseIpCfg.getSrcIpAddress().split("-")[0];
|
|
|
|
|
|
String subfix=baseIpCfg.getSrcIpAddress().split("-")[1];
|
|
|
|
|
|
baseIpCfg.setSrcIpAddress(prefix+"-"+prefix.substring(0, prefix.lastIndexOf(".")+1)+subfix);
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (StringUtil.isEmpty(baseIpCfg.getDestIpAddress())) {
|
2018-10-22 19:06:43 +08:00
|
|
|
|
destIpEmpty = true;
|
2018-10-30 15:59:56 +08:00
|
|
|
|
}else {
|
|
|
|
|
|
//处理0.0.0.1-2这种格式,转换为0.0.0.1-0.0.0.2
|
|
|
|
|
|
Matcher m=ipv4IpRangeRegexpNew.matcher(baseIpCfg.getDestIpAddress());
|
|
|
|
|
|
if(m.matches()) {
|
|
|
|
|
|
String prefix=baseIpCfg.getDestIpAddress().split("-")[0];
|
|
|
|
|
|
String subfix=baseIpCfg.getDestIpAddress().split("-")[1];
|
|
|
|
|
|
baseIpCfg.setDestIpAddress(prefix+"-"+prefix.substring(0, prefix.lastIndexOf(".")+1)+subfix);
|
|
|
|
|
|
}
|
2018-10-22 19:06:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (StringUtil.isEmpty(baseIpCfg.getSrcPort())) {
|
|
|
|
|
|
srcPortEmpty = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (StringUtil.isEmpty(baseIpCfg.getDestPort())) {
|
|
|
|
|
|
destPortEmpty = true;
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (srcIpEmpty && destIpEmpty) {
|
|
|
|
|
|
if (configIpPortShow.indexOf("1") > -1 && configIpPortShow.indexOf("3") > -1) {
|
2018-10-22 19:06:43 +08:00
|
|
|
|
errInfo.append(String.format(prop.getProperty("can_not_null"),
|
|
|
|
|
|
prop.getProperty("client_ip", "Client IP")) + ";");
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (configIpPortShow.indexOf("1") > -1) {
|
2018-10-22 19:06:43 +08:00
|
|
|
|
errInfo.append(String.format(prop.getProperty("can_not_null"),
|
|
|
|
|
|
prop.getProperty("client_ip", "Client IP")) + ";");
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (configIpPortShow.indexOf("3") > -1) {
|
2018-10-22 19:06:43 +08:00
|
|
|
|
errInfo.append(String.format(prop.getProperty("can_not_null"),
|
|
|
|
|
|
prop.getProperty("server_ip", "Server IP")) + ";");
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (destIpEmpty) {// 目的IP为空
|
|
|
|
|
|
if (configIpPortShow.indexOf("3") > -1 && configIpPortShow.indexOf("1") == -1) {// 目的IP必填
|
2018-10-22 19:06:43 +08:00
|
|
|
|
errInfo.append(String.format(prop.getProperty("can_not_null"),
|
|
|
|
|
|
prop.getProperty("server_ip", "Server IP")) + ";");
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (configIpPortShow.indexOf("1") > -1) {
|
|
|
|
|
|
/*
|
|
|
|
|
|
* if(Constants.IPV6_DEFAULT_IP_RANGE_VALUE.equals(baseIpCfg.getSrcIpAddress()))
|
|
|
|
|
|
* { errInfo.append(prop.getProperty("client_ip") +
|
|
|
|
|
|
* String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
* "'"+Constants.IPV6_DEFAULT_IP_RANGE_VALUE+"'")+";"); }else
|
|
|
|
|
|
* if(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.equals(baseIpCfg.getSrcIpAddress())
|
|
|
|
|
|
* ) { errInfo.append(prop.getProperty("client_ip") +
|
|
|
|
|
|
* String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
* "'"+Constants.IPV6_DEFAULT_IP_SUBNET_VALUE+"'")+";"); }else
|
|
|
|
|
|
* if(Constants.IPV6_DEFAULT_IP_VALUE.equals(baseIpCfg.getSrcIpAddress())) {
|
|
|
|
|
|
* errInfo.append(prop.getProperty("client_ip") +
|
|
|
|
|
|
* String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
* "'"+Constants.IPV6_DEFAULT_IP_VALUE+"'")+";"); }else
|
|
|
|
|
|
* if(Constants.IPV4_DEFAULT_IP_RANGE_VALUE.equals(baseIpCfg.getSrcIpAddress()))
|
|
|
|
|
|
* { errInfo.append(prop.getProperty("client_ip") +
|
|
|
|
|
|
* String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
* "'"+Constants.IPV4_DEFAULT_IP_RANGE_VALUE+"'")+";"); }else
|
|
|
|
|
|
* if(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.equals(baseIpCfg.getSrcIpAddress())
|
|
|
|
|
|
* ) { errInfo.append(prop.getProperty("client_ip") +
|
|
|
|
|
|
* String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
* "'"+Constants.IPV4_DEFAULT_IP_SUBNET_VALUE+"'")+";"); }else
|
|
|
|
|
|
* if(Constants.IPV4_DEFAULT_IP_VALUE.equals(baseIpCfg.getSrcIpAddress())) {
|
|
|
|
|
|
* errInfo.append(prop.getProperty("client_ip") +
|
|
|
|
|
|
* String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
* "'"+Constants.IPV4_DEFAULT_IP_VALUE+"'")+";"); }
|
|
|
|
|
|
*/
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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])) {
|
2018-10-25 16:44:04 +08:00
|
|
|
|
errInfo.append(prop.getProperty("client_ip")
|
|
|
|
|
|
+ String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
Constants.IPV6_DEFAULT_IP_RANGE_VALUE.split("-")[0])
|
|
|
|
|
|
+ ";");
|
2018-10-18 18:05:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
} 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])) {
|
2018-10-25 16:44:04 +08:00
|
|
|
|
errInfo.append(
|
|
|
|
|
|
prop.getProperty("client_ip")
|
|
|
|
|
|
+ String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.split("/")[0])
|
|
|
|
|
|
+ ";");
|
2018-10-18 18:05:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
|
|
|
|
|
|
baseIpCfg.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
2018-10-15 10:14:01 +08:00
|
|
|
|
baseIpCfg.setIpPattern(3);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (baseIpCfg.getSrcIpAddress().equals(Constants.IPV6_DEFAULT_IP_VALUE)) {
|
2018-10-25 16:44:04 +08:00
|
|
|
|
errInfo.append(prop.getProperty("client_ip") + String.format(
|
|
|
|
|
|
prop.getProperty("can_not_be"), Constants.IPV6_DEFAULT_IP_VALUE) + ";");
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
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])) {
|
2018-10-25 16:44:04 +08:00
|
|
|
|
errInfo.append(prop.getProperty("client_ip")
|
|
|
|
|
|
+ String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
Constants.IPV4_DEFAULT_IP_RANGE_VALUE.split("-")[0])
|
|
|
|
|
|
+ ";");
|
2018-10-18 18:05:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
} 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])) {
|
2018-10-25 16:44:04 +08:00
|
|
|
|
errInfo.append(
|
|
|
|
|
|
prop.getProperty("client_ip")
|
|
|
|
|
|
+ String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.split("/")[0])
|
|
|
|
|
|
+ ";");
|
2018-10-18 18:05:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
|
|
|
|
|
|
baseIpCfg.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
|
|
|
|
|
baseIpCfg.setIpPattern(3);
|
|
|
|
|
|
if (baseIpCfg.getSrcIpAddress().equals(Constants.IPV4_DEFAULT_IP_VALUE)) {
|
2018-10-25 16:44:04 +08:00
|
|
|
|
errInfo.append(prop.getProperty("client_ip") + String.format(
|
|
|
|
|
|
prop.getProperty("can_not_be"), Constants.IPV4_DEFAULT_IP_VALUE) + ";");
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
baseIpCfg.setIpType(4);
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
|
2018-10-22 19:06:43 +08:00
|
|
|
|
} else if (srcIpEmpty) {// 源IP为空
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (configIpPortShow.indexOf("1") > -1 && configIpPortShow.indexOf("3") == -1) {// 源IP必填
|
2018-10-22 19:06:43 +08:00
|
|
|
|
errInfo.append(String.format(prop.getProperty("can_not_null"),
|
|
|
|
|
|
prop.getProperty("client_ip", "Client IP")) + ";");
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (configIpPortShow.indexOf("3") > -1) {
|
|
|
|
|
|
/*
|
|
|
|
|
|
* if(Constants.IPV6_DEFAULT_IP_RANGE_VALUE.equals(baseIpCfg.getDestIpAddress())
|
|
|
|
|
|
* ) { errInfo.append(prop.getProperty("server_ip") +
|
|
|
|
|
|
* String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
* "'"+Constants.IPV6_DEFAULT_IP_RANGE_VALUE+"'")+";"); }else
|
|
|
|
|
|
* if(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.equals(baseIpCfg.getDestIpAddress()
|
|
|
|
|
|
* )) { errInfo.append(prop.getProperty("server_ip") +
|
|
|
|
|
|
* String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
* "'"+Constants.IPV6_DEFAULT_IP_SUBNET_VALUE+"'")+";"); }else
|
|
|
|
|
|
* if(Constants.IPV6_DEFAULT_IP_VALUE.equals(baseIpCfg.getDestIpAddress())) {
|
|
|
|
|
|
* errInfo.append(prop.getProperty("server_ip") +
|
|
|
|
|
|
* String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
* "'"+Constants.IPV6_DEFAULT_IP_VALUE+"'")+";"); }else
|
|
|
|
|
|
* if(Constants.IPV4_DEFAULT_IP_RANGE_VALUE.equals(baseIpCfg.getDestIpAddress())
|
|
|
|
|
|
* ) { errInfo.append(prop.getProperty("server_ip") +
|
|
|
|
|
|
* String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
* "'"+Constants.IPV4_DEFAULT_IP_RANGE_VALUE+"'")+";"); }else
|
|
|
|
|
|
* if(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.equals(baseIpCfg.getDestIpAddress()
|
|
|
|
|
|
* )) { errInfo.append(prop.getProperty("server_ip") +
|
|
|
|
|
|
* String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
* "'"+Constants.IPV4_DEFAULT_IP_SUBNET_VALUE+"'")+";"); }else
|
|
|
|
|
|
* if(Constants.IPV4_DEFAULT_IP_VALUE.equals(baseIpCfg.getDestIpAddress())) {
|
|
|
|
|
|
* errInfo.append(prop.getProperty("server_ip") +
|
|
|
|
|
|
* String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
* "'"+Constants.IPV4_DEFAULT_IP_VALUE+"'")+";"); }
|
|
|
|
|
|
*/
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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])) {
|
2018-10-25 16:44:04 +08:00
|
|
|
|
errInfo.append(prop.getProperty("server_ip")
|
|
|
|
|
|
+ String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
Constants.IPV6_DEFAULT_IP_RANGE_VALUE.split("-")[0])
|
|
|
|
|
|
+ ";");
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} 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])) {
|
2018-10-25 16:44:04 +08:00
|
|
|
|
errInfo.append(
|
|
|
|
|
|
prop.getProperty("server_ip")
|
|
|
|
|
|
+ String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.split("/")[0])
|
|
|
|
|
|
+ ";");
|
2018-10-18 18:05:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
|
|
|
|
|
|
baseIpCfg.setSrcIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
|
|
|
|
|
baseIpCfg.setIpPattern(3);
|
|
|
|
|
|
if (baseIpCfg.getDestIpAddress().equals(Constants.IPV6_DEFAULT_IP_VALUE)) {
|
2018-10-25 16:44:04 +08:00
|
|
|
|
errInfo.append(prop.getProperty("server_ip") + String.format(
|
|
|
|
|
|
prop.getProperty("can_not_be"), Constants.IPV6_DEFAULT_IP_VALUE) + ";");
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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);
|
2018-10-15 10:14:01 +08:00
|
|
|
|
baseIpCfg.setIpPattern(2);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (baseIpCfg.getDestIpAddress()
|
|
|
|
|
|
.startsWith(Constants.IPV4_DEFAULT_IP_RANGE_VALUE.split("-")[0])) {
|
2018-10-25 16:44:04 +08:00
|
|
|
|
errInfo.append(prop.getProperty("server_ip")
|
|
|
|
|
|
+ String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
Constants.IPV4_DEFAULT_IP_RANGE_VALUE.split("-")[0])
|
|
|
|
|
|
+ ";");
|
2018-10-18 18:05:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else if (matchType.endsWith("SUBNET")) {
|
|
|
|
|
|
// baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
|
|
|
|
|
|
baseIpCfg.setSrcIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
2018-10-15 10:14:01 +08:00
|
|
|
|
baseIpCfg.setIpPattern(1);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (baseIpCfg.getDestIpAddress()
|
|
|
|
|
|
.startsWith(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.split("/")[0])) {
|
2018-10-25 16:44:04 +08:00
|
|
|
|
errInfo.append(
|
|
|
|
|
|
prop.getProperty("server_ip")
|
|
|
|
|
|
+ String.format(prop.getProperty("can_not_be"),
|
|
|
|
|
|
Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.split("/")[0])
|
|
|
|
|
|
+ ";");
|
2018-10-18 18:05:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
|
|
|
|
|
|
baseIpCfg.setSrcIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
2018-10-15 10:14:01 +08:00
|
|
|
|
baseIpCfg.setIpPattern(3);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (baseIpCfg.getDestIpAddress().equals(Constants.IPV4_DEFAULT_IP_VALUE)) {
|
2018-10-25 16:44:04 +08:00
|
|
|
|
errInfo.append(prop.getProperty("server_ip") + String.format(
|
|
|
|
|
|
prop.getProperty("can_not_be"), Constants.IPV4_DEFAULT_IP_VALUE) + ";");
|
2018-10-18 18:05:49 +08:00
|
|
|
|
}
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
baseIpCfg.setIpType(4);
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-22 19:06:43 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} 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)) {
|
2018-10-22 19:06:43 +08:00
|
|
|
|
errInfo.append(prop.get("the_same_ip_type_pattern") + ";");
|
|
|
|
|
|
}
|
|
|
|
|
|
// baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
|
|
|
|
|
|
// baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
|
|
|
|
|
|
if (matchType.startsWith("IPV6")) {
|
|
|
|
|
|
baseIpCfg.setIpType(6);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else {
|
2018-10-22 19:06:43 +08:00
|
|
|
|
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());
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-10-22 19:06:43 +08:00
|
|
|
|
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")) + ";");
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-22 19:06:43 +08:00
|
|
|
|
baseIpCfg.setIpPattern(3);
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO 判断源IP和目的IP的值
|
|
|
|
|
|
// TODO 判断源IP和目的IP格式
|
2018-10-22 19:06:43 +08:00
|
|
|
|
if (destPortEmpty) {
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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);
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
baseIpCfg.setSrcPort(baseIpCfg.getSrcPort().trim());
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
if (srcPortEmpty) {
|
|
|
|
|
|
if (baseIpCfg.getDestPort().indexOf("/") > -1) {
|
|
|
|
|
|
baseIpCfg.setSrcPort("0/0");
|
|
|
|
|
|
baseIpCfg.setPortPattern(2);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
baseIpCfg.setSrcPort("0");
|
|
|
|
|
|
baseIpCfg.setPortPattern(1);
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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());
|
|
|
|
|
|
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
// 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]));
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
baseIpCfg.setProtocolId(serviceDict==null?0:serviceDict.getProtocolId());
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
baseIpCfg.setProtocol(baseIpCfg.getProtocol());
|
2018-10-25 16:44:04 +08:00
|
|
|
|
baseIpCfg.setProtocolId(serviceDict==null?0:serviceDict.getProtocolId());
|
2018-10-18 18:05:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
// 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]));
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
baseIpCfg.setDirection(baseIpCfg.getDirection());
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
// TODO 判断Direction的值
|
|
|
|
|
|
this.validDirection(errInfo, baseIpCfg.getDirection(), direction);
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (errInfo.toString().length() > 0) {//
|
|
|
|
|
|
errTip.append(String.format(prop.getProperty("line"), i + 2) + ",");
|
|
|
|
|
|
errTip.append(errInfo);
|
|
|
|
|
|
errTip.append("<br>");
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
ipList.add(baseIpCfg);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (errTip.toString().length() > 0) {
|
|
|
|
|
|
throw new ServiceException(errTip.toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
return ipList;
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
|
2018-10-18 18:05:49 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 协议与端口验证规则
|
|
|
|
|
|
*
|
|
|
|
|
|
* @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") + ";");
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 验证方向
|
|
|
|
|
|
*
|
|
|
|
|
|
* @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;
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (!has) {
|
2018-10-19 12:46:15 +08:00
|
|
|
|
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("direction")) + "."
|
2018-10-18 18:05:49 +08:00
|
|
|
|
+ String.format(prop.getProperty("alternative_values"), directionPattern) + ";");
|
|
|
|
|
|
}
|
|
|
|
|
|
return has;
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
|
2018-10-18 18:05:49 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 验证协议
|
2018-10-25 16:44:04 +08:00
|
|
|
|
*
|
2018-10-18 18:05:49 +08:00
|
|
|
|
* @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;
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (!has) {
|
2018-10-19 12:46:15 +08:00
|
|
|
|
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol")) + "."
|
2018-10-18 18:05:49 +08:00
|
|
|
|
+ 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;
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("not_number"), prop.getProperty("server_port")) + ";");
|
|
|
|
|
|
valid = false;
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if ((m.matches() && m3.matches()) || (m2.matches() && m1.matches())) {
|
|
|
|
|
|
errInfo.append(prop.getProperty("the_same_port_pattern") + ";");
|
|
|
|
|
|
valid = false;
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (!m.matches() && !m2.matches()) {
|
|
|
|
|
|
errInfo.append(
|
2018-10-25 16:44:04 +08:00
|
|
|
|
String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty("client_port")) + ";");
|
2018-10-18 18:05:49 +08:00
|
|
|
|
valid = false;
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (!m1.matches() && !m3.matches()) {
|
|
|
|
|
|
errInfo.append(
|
2018-10-25 16:44:04 +08:00
|
|
|
|
String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty("server_port")) + ";");
|
2018-10-18 18:05:49 +08:00
|
|
|
|
valid = false;
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
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];
|
2018-10-29 13:07:57 +08:00
|
|
|
|
if ((Integer.parseInt(prefix.split("\\.")[0])<128&&Integer.parseInt(subfix.split("\\.")[0])<128)
|
|
|
|
|
|
||(Integer.parseInt(prefix.split("\\.")[0])>127&&Integer.parseInt(subfix.split("\\.")[0])>127&&Integer.parseInt(prefix.split("\\.")[0])<192&&Integer.parseInt(subfix.split("\\.")[0])<192)
|
|
|
|
|
|
||(Integer.parseInt(prefix.split("\\.")[0])>191&&Integer.parseInt(subfix.split("\\.")[0])>191&&Integer.parseInt(prefix.split("\\.")[0])<224&&Integer.parseInt(subfix.split("\\.")[0])<224)
|
|
|
|
|
|
||(Integer.parseInt(prefix.split("\\.")[0])>223&&Integer.parseInt(subfix.split("\\.")[0])>223&&Integer.parseInt(prefix.split("\\.")[0])<240&&Integer.parseInt(subfix.split("\\.")[0])<240)
|
|
|
|
|
|
||(Integer.parseInt(prefix.split("\\.")[0])>239&&Integer.parseInt(subfix.split("\\.")[0])>239&&Integer.parseInt(prefix.split("\\.")[0])<256&&Integer.parseInt(subfix.split("\\.")[0])<256)) {
|
|
|
|
|
|
}else {
|
|
|
|
|
|
errInfo.append(prop.get(ipName) + " " + prop.get("ip_range_in_the_same") + ";");
|
2018-10-18 18:05:49 +08:00
|
|
|
|
}
|
2018-10-29 13:07:57 +08:00
|
|
|
|
// 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") + ";");
|
|
|
|
|
|
// }
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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))
|
|
|
|
|
|
+ ";");
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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;
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
@Deprecated
|
|
|
|
|
|
public void checkIpCfg(int action, int functionId, List<IpCfgTemplate> list) throws ServiceException {
|
|
|
|
|
|
Properties prop = this.getMsgProp();
|
|
|
|
|
|
List<SysDataDictionaryItem> ipTypeList = DictUtils.getDictList("IP_TYPE");
|
|
|
|
|
|
List<SysDataDictionaryItem> ipPatternList = DictUtils.getDictList("IP_PATTERN");
|
|
|
|
|
|
List<SysDataDictionaryItem> portPatternList = DictUtils.getDictList("PORT_PATTERN");
|
|
|
|
|
|
List<SysDataDictionaryItem> directionList = DictUtils.getDictList("DIRECTION");
|
|
|
|
|
|
List<SysDataDictionaryItem> protocolList = DictUtils.getDictList("PROTOCOL");
|
|
|
|
|
|
List<SysDataDictionaryItem> ipsecProrocolList = DictUtils.getDictList("IPSEC_PROTOCOL");
|
|
|
|
|
|
List<SysDataDictionaryItem> tunnelProrocolList = DictUtils.getDictList("TUNNEL_PROTOCOL");
|
|
|
|
|
|
List<SysDataDictionaryItem> specialFunctionIdList = DictUtils.getDictList("SPECIAL_FUNCTION_ID");
|
|
|
|
|
|
List<SysDataDictionaryItem> 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<SysDataDictionaryItem> icmpprotocolList = DictUtils.getDictList("ICMP_PROTOCOL");
|
|
|
|
|
|
if (action == Constants.DROP_ACTION) {
|
2018-08-01 15:27:21 +08:00
|
|
|
|
protocolList.addAll(icmpprotocolList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
StringBuffer msg = new StringBuffer();
|
|
|
|
|
|
int line = 1;
|
|
|
|
|
|
for (IpCfgTemplate value : list) {
|
|
|
|
|
|
String lineStart = String.format(prop.getProperty("line"), line) + ":";
|
|
|
|
|
|
StringBuffer errInfo = new StringBuffer();
|
2018-07-02 16:04:41 +08:00
|
|
|
|
// ip_type check start
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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;
|
2018-07-02 16:04:41 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (!has) {
|
|
|
|
|
|
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ip_type")) + ";");
|
2018-07-02 16:04:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// ip_type check end
|
|
|
|
|
|
// ip_pattern check start
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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;
|
2018-07-02 16:04:41 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (!has) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("ip_pattern")) + ";");
|
2018-07-02 16:04:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// ip_pattern check end
|
2018-10-18 18:05:49 +08:00
|
|
|
|
// 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)) {
|
2018-07-02 16:04:41 +08:00
|
|
|
|
errInfo.append(_msg);
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
// 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()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (6 == ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (46 == ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (64 == ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (10 == ipType.intValue()) {
|
2018-08-13 10:38:04 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
2018-07-27 10:16:32 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (2 == ipPattern.intValue()) {
|
|
|
|
|
|
if (4 == ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (6 == ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (46 == ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (64 == ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (10 == ipType.intValue()) {
|
2018-08-13 10:38:04 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
2018-07-27 10:16:32 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (3 == ipPattern.intValue()) {
|
|
|
|
|
|
if (4 == ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (6 == ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (46 == ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (64 == ipType.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (10 == ipType.intValue()) {
|
2018-08-13 10:38:04 +08:00
|
|
|
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
2018-07-27 10:16:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} 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 + ";");
|
2018-07-27 10:16:32 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
_msg = checkIP(prop, prop.getProperty("server_ip"), destIp, ipType, ipPattern);
|
|
|
|
|
|
if (StringUtils.isNotBlank(_msg)) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
errInfo.append(_msg);
|
|
|
|
|
|
}
|
2018-07-02 16:04:41 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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)) {
|
2018-08-13 10:38:04 +08:00
|
|
|
|
errInfo.append(_msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
// 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;
|
2018-07-02 16:04:41 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (!has) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("port_pattern")) + ";");
|
2018-07-02 16:04:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
// 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);
|
2018-07-27 10:16:32 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(_msg)) {
|
2018-07-02 16:04:41 +08:00
|
|
|
|
errInfo.append(_msg);
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
// src_port check end
|
|
|
|
|
|
// dest_port check start
|
|
|
|
|
|
String destPort = value.getDestPort();
|
|
|
|
|
|
if ("ipmulitiplex".equals(specialItem)) {// set 默认值
|
|
|
|
|
|
if (portPattern != null) {
|
|
|
|
|
|
if (2 == portPattern.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestPort(Constants.PORT_MASK_DEFAULT);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (1 == portPattern.intValue()) {
|
2018-07-27 10:16:32 +08:00
|
|
|
|
value.setDestPort(Constants.PORT_DEFAULT);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
_msg = checkPort(prop, prop.getProperty("server_port"), destPort, portPattern);
|
2018-07-27 10:16:32 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (StringUtils.isNotBlank(_msg)) {
|
2018-07-02 16:04:41 +08:00
|
|
|
|
errInfo.append(_msg);
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
// 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;
|
2018-07-02 16:04:41 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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;
|
2018-07-31 12:18:34 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (!has) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol"))
|
|
|
|
|
|
+ ";");
|
2018-07-31 12:18:34 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
if (protocol != 0) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol"))
|
|
|
|
|
|
+ ";");
|
2018-07-06 17:13:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} 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())) + ";");
|
2018-07-06 17:13:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-07-06 17:13:46 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
boolean has = false;
|
|
|
|
|
|
for (SysDataDictionaryItem protocolItem : protocolList) {
|
|
|
|
|
|
if (Integer.parseInt(protocolItem.getItemCode()) == protocol.intValue()) {
|
|
|
|
|
|
has = true;
|
2018-07-06 17:13:46 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (!has) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol")) + ";");
|
2018-07-06 17:13:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-07-02 16:04:41 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
// protocol check end
|
2018-07-03 17:16:54 +08:00
|
|
|
|
// requestId check start
|
2018-10-18 18:05:49 +08:00
|
|
|
|
Integer requestId = value.getRequestId();
|
|
|
|
|
|
if (requestId == null) {
|
|
|
|
|
|
if ("whitelistip".equals(specialItem)) {
|
2018-07-26 11:04:57 +08:00
|
|
|
|
value.setRequestId(0);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("letter")) + ";");
|
2018-07-26 11:04:57 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
} else {// 查询数据库是否存在ID
|
|
|
|
|
|
if ("whitelistip".equals(specialItem)) {
|
2018-07-26 11:04:57 +08:00
|
|
|
|
value.setRequestId(0);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} 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"))
|
|
|
|
|
|
+ ";");
|
2018-07-26 11:04:57 +08:00
|
|
|
|
}
|
2018-07-03 17:16:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// requestId check end
|
2018-10-18 18:05:49 +08:00
|
|
|
|
// 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")) + ";");
|
2018-07-03 17:16:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} catch (Exception e) {
|
2018-07-03 17:16:54 +08:00
|
|
|
|
// TODO: handle exception
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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")) + ";");
|
2018-07-03 17:16:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} catch (Exception e) {
|
2018-07-03 17:16:54 +08:00
|
|
|
|
// TODO: handle exception
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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")) + ";");
|
2018-07-03 17:16:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} catch (Exception e) {
|
2018-07-03 17:16:54 +08:00
|
|
|
|
// TODO: handle exception
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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;
|
2018-07-27 10:16:32 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (!has) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("ir_type")) + ";");
|
2018-07-27 10:16:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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")) + ";");
|
2018-07-27 10:16:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if ("ipratelimit".equals(specialItem)) {
|
|
|
|
|
|
String ratelimit = value.getRatelimit();
|
|
|
|
|
|
if (ratelimit == null) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("can_not_null"), prop.getProperty("ratelimit")) + ";");
|
|
|
|
|
|
} else {
|
2018-08-25 16:37:39 +08:00
|
|
|
|
try {
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (Double.parseDouble(ratelimit) < 0 || Double.parseDouble(ratelimit) > 1) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("ratelimit_limit"))
|
|
|
|
|
|
+ ";");
|
2018-08-25 16:37:39 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
errInfo.append(
|
|
|
|
|
|
String.format(prop.getProperty("is_incorrect"), prop.getProperty("ratelimit_limit"))
|
|
|
|
|
|
+ ";");
|
2018-07-27 10:16:32 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-07-27 10:16:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
// attribute check end
|
|
|
|
|
|
if (StringUtils.isNotBlank(errInfo.toString())) {
|
2018-07-02 16:04:41 +08:00
|
|
|
|
msg.append(lineStart).append(errInfo);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (line < list.size()) {
|
2018-07-02 16:04:41 +08:00
|
|
|
|
msg.append("<br/>");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
// group and ir_type check end
|
2018-07-02 16:04:41 +08:00
|
|
|
|
line++;
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (StringUtils.isNotBlank(msg.toString())) {
|
|
|
|
|
|
throw new MaatConvertException(prop.getProperty("save_failed") + "<br/>" + msg.toString());
|
2018-07-02 16:04:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-07-02 16:04:41 +08:00
|
|
|
|
/**
|
|
|
|
|
|
*
|
2018-10-18 18:05:49 +08:00
|
|
|
|
* checkIP(IP格式验证) (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
*
|
2018-07-02 16:04:41 +08:00
|
|
|
|
* @param ipName
|
|
|
|
|
|
* @param ip
|
|
|
|
|
|
* @param ipType
|
|
|
|
|
|
* @param ipPattern
|
2018-10-18 18:05:49 +08:00
|
|
|
|
* @return String
|
|
|
|
|
|
* @exception @since
|
|
|
|
|
|
* 1.0.0
|
2018-07-02 16:04:41 +08:00
|
|
|
|
*/
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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) + ";");
|
2018-07-02 16:04:41 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} 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) + ";");
|
2018-07-02 16:04:41 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} 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) + ";");
|
2018-07-02 16:04:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} 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) + ";");
|
2018-07-02 16:04:41 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} 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) + ";");
|
2018-07-02 16:04:41 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} 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) + ";");
|
2018-07-02 16:04:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return msg.toString();
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-08-21 11:42:33 +08:00
|
|
|
|
/**
|
|
|
|
|
|
*
|
2018-10-18 18:05:49 +08:00
|
|
|
|
* checkIP(IP格式验证) (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
*
|
2018-08-21 11:42:33 +08:00
|
|
|
|
* @param ipName
|
|
|
|
|
|
* @param ip
|
|
|
|
|
|
* @param ipType
|
|
|
|
|
|
* @param ipPattern
|
2018-10-18 18:05:49 +08:00
|
|
|
|
* @return String
|
|
|
|
|
|
* @exception @since
|
|
|
|
|
|
* 1.0.0
|
2018-08-21 11:42:33 +08:00
|
|
|
|
*/
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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) + ";");
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} 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) + ";");
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} 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) + ";");
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} 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) + ";");
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} 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) + ";");
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} 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) + ";");
|
2018-08-21 11:42:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return msg.toString();
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
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) + ";");
|
|
|
|
|
|
}
|
|
|
|
|
|
} 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) + ";");
|
|
|
|
|
|
}
|
|
|
|
|
|
} 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) + ";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} 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) + ";");
|
|
|
|
|
|
}
|
|
|
|
|
|
} 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) + ";");
|
|
|
|
|
|
}
|
|
|
|
|
|
} 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) + ";");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} 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) + ";");
|
|
|
|
|
|
}
|
|
|
|
|
|
} 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) + ";");
|
|
|
|
|
|
}
|
|
|
|
|
|
} 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) + ";");
|
2018-08-13 10:38:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return msg.toString();
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
@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") + ";");
|
2018-07-02 16:04:41 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} catch (Exception e) {
|
2018-07-02 16:04:41 +08:00
|
|
|
|
// TODO: handle exception
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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") + ";");
|
2018-07-02 16:04:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} catch (Exception e) {
|
2018-07-02 16:04:41 +08:00
|
|
|
|
// TODO: handle exception
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (index == 0) {
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("not_number"), portName + " port") + ";");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
msg.append(String.format(prop.getProperty("not_number"), portName + " mask") + ";");
|
2018-07-02 16:04:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
index++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return msg.toString();
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-07-10 13:33:28 +08:00
|
|
|
|
/**
|
|
|
|
|
|
*
|
2018-10-18 18:05:49 +08:00
|
|
|
|
* setReportSearchTime(报表查询设置开始时间与结束时间) (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
*
|
2018-07-10 13:33:28 +08:00
|
|
|
|
* @param bean
|
2018-10-18 18:05:49 +08:00
|
|
|
|
* @throws ParseException
|
|
|
|
|
|
* void
|
|
|
|
|
|
* @exception @since
|
|
|
|
|
|
* 1.0.0
|
2018-07-10 13:33:28 +08:00
|
|
|
|
*/
|
2018-10-18 18:05:49 +08:00
|
|
|
|
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();
|
2018-07-10 13:33:28 +08:00
|
|
|
|
startCal.setTime(getReportTime(reportTime));
|
|
|
|
|
|
startCal.set(Calendar.MINUTE, 0);
|
|
|
|
|
|
startCal.set(Calendar.SECOND, 0);
|
|
|
|
|
|
startCal.set(Calendar.MILLISECOND, 0);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
Calendar endCal = Calendar.getInstance();
|
2018-07-10 13:33:28 +08:00
|
|
|
|
endCal.setTime(getReportTime(reportTime));
|
|
|
|
|
|
endCal.set(Calendar.MINUTE, 59);
|
|
|
|
|
|
endCal.set(Calendar.SECOND, 59);
|
|
|
|
|
|
endCal.set(Calendar.MILLISECOND, 0);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (bean.getReportType() == Constants.REPORT_TYPE_HOUR) {
|
2018-07-10 13:33:28 +08:00
|
|
|
|
startCal.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
|
|
|
endCal.set(Calendar.HOUR_OF_DAY, 23);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (bean.getReportType() == Constants.REPORT_TYPE_DAY) {
|
2018-07-10 13:33:28 +08:00
|
|
|
|
startCal.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
|
|
|
startCal.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
|
|
|
endCal.set(Calendar.HOUR_OF_DAY, 23);
|
|
|
|
|
|
DateUtils.setLastDayOfMonth(endCal);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (bean.getReportType() == Constants.REPORT_TYPE_MONTH) {
|
2018-07-10 13:33:28 +08:00
|
|
|
|
startCal.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
|
|
|
startCal.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
|
|
|
startCal.set(Calendar.MONTH, 0);
|
|
|
|
|
|
endCal.set(Calendar.HOUR_OF_DAY, 23);
|
|
|
|
|
|
DateUtils.setLastDayOfMonth(endCal);
|
|
|
|
|
|
endCal.set(Calendar.MONTH, 11);
|
|
|
|
|
|
}
|
|
|
|
|
|
bean.setReportStartTime(startCal.getTime());
|
|
|
|
|
|
bean.setReportEndTime(endCal.getTime());
|
|
|
|
|
|
bean.setSearchReportStartTime(sdf.format(startCal.getTime()));
|
|
|
|
|
|
bean.setSearchReportEndTime(sdf.format(endCal.getTime()));
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
Date date = new Date();
|
2018-07-10 13:33:28 +08:00
|
|
|
|
bean.setReportEndTime(date);
|
|
|
|
|
|
bean.setSearchReportEndTime(sdf.format(date));
|
2018-10-18 18:05:49 +08:00
|
|
|
|
Calendar startCal = Calendar.getInstance();
|
2018-07-10 13:33:28 +08:00
|
|
|
|
startCal.setTime(date);
|
|
|
|
|
|
startCal.set(Calendar.MINUTE, 0);
|
|
|
|
|
|
startCal.set(Calendar.SECOND, 0);
|
|
|
|
|
|
startCal.set(Calendar.MILLISECOND, 0);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (bean.getReportType() == Constants.REPORT_TYPE_HOUR) {
|
2018-07-10 13:33:28 +08:00
|
|
|
|
startCal.set(Calendar.HOUR_OF_DAY, 0);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (bean.getReportType() == Constants.REPORT_TYPE_DAY) {
|
2018-07-10 13:33:28 +08:00
|
|
|
|
startCal.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
|
|
|
startCal.set(Calendar.DAY_OF_MONTH, 1);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (bean.getReportType() == Constants.REPORT_TYPE_MONTH) {
|
2018-07-10 13:33:28 +08:00
|
|
|
|
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()));
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-07-10 13:33:28 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
logger.info("search start time " + bean.getSearchReportStartTime());
|
|
|
|
|
|
logger.info("search end time " + bean.getSearchReportEndTime());
|
2018-07-10 13:33:28 +08:00
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
public List<String> getDateTitiles(SearchReport bean) {
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat(Constants.SEARCH_DATEFORMAT);
|
|
|
|
|
|
List<String> titles = new ArrayList<String>();
|
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
2018-07-10 13:33:28 +08:00
|
|
|
|
cal.setTime(bean.getReportStartTime());
|
2018-10-18 18:05:49 +08:00
|
|
|
|
while (cal.getTimeInMillis() < bean.getReportEndTime().getTime()) {// 构造标题
|
|
|
|
|
|
// 报表时间单位加一
|
|
|
|
|
|
if (bean.getReportType() == Constants.REPORT_TYPE_HOUR) {
|
|
|
|
|
|
titles.add(sdf.format(cal.getTime()).substring(0, 13));
|
2018-07-10 13:33:28 +08:00
|
|
|
|
cal.add(Calendar.HOUR_OF_DAY, 1);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (bean.getReportType() == Constants.REPORT_TYPE_DAY) {
|
|
|
|
|
|
titles.add(sdf.format(cal.getTime()).substring(0, 10));
|
2018-07-10 13:33:28 +08:00
|
|
|
|
cal.add(Calendar.DAY_OF_MONTH, 1);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else if (bean.getReportType() == Constants.REPORT_TYPE_MONTH) {
|
|
|
|
|
|
titles.add(sdf.format(cal.getTime()).substring(0, 7));
|
2018-07-10 13:33:28 +08:00
|
|
|
|
cal.add(Calendar.MONTH, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return titles;
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
|
|
|
|
|
public Date getReportTime(String reportTime) throws ParseException {
|
|
|
|
|
|
Pattern datePattern = Pattern.compile("^[0-9]{4}-[0-9]{2}-[0-9]{2}$");
|
|
|
|
|
|
Pattern monthPattern = Pattern.compile("^[0-9]{4}-[0-9]{2}$");
|
|
|
|
|
|
Pattern yearPattern = Pattern.compile("^[0-9]{4}$");
|
|
|
|
|
|
Matcher matcher = datePattern.matcher(reportTime);
|
|
|
|
|
|
if (matcher.matches()) {
|
2018-07-10 13:33:28 +08:00
|
|
|
|
return new SimpleDateFormat("yyyy-MM-dd").parse(reportTime);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
matcher = monthPattern.matcher(reportTime);
|
|
|
|
|
|
if (matcher.matches()) {
|
2018-07-10 13:33:28 +08:00
|
|
|
|
return new SimpleDateFormat("yyyy-MM").parse(reportTime);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
matcher = yearPattern.matcher(reportTime);
|
|
|
|
|
|
if (matcher.matches()) {
|
2018-07-10 13:33:28 +08:00
|
|
|
|
return new SimpleDateFormat("yyyy").parse(reportTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-10-15 10:14:01 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 多域导入
|
2018-10-18 18:05:49 +08:00
|
|
|
|
*
|
2018-10-15 10:14:01 +08:00
|
|
|
|
* @param redirectAttributes
|
|
|
|
|
|
* @param files
|
|
|
|
|
|
* @param serviceDictId
|
|
|
|
|
|
* @param regionDictIds
|
|
|
|
|
|
* @param requestId
|
|
|
|
|
|
*/
|
2018-10-25 16:44:04 +08:00
|
|
|
|
public void _import(HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes,
|
|
|
|
|
|
MultipartFile[] files, Integer serviceDictId, String regionDictIds, Integer requestId) {
|
2018-10-15 10:14:01 +08:00
|
|
|
|
try {
|
2018-10-18 18:05:49 +08:00
|
|
|
|
FunctionServiceDict serviceDict = DictUtils.getFunctionServiceDict(serviceDictId);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
List<BaseIpCfg> ipPortCfgs = new ArrayList<BaseIpCfg>();
|
|
|
|
|
|
List<BaseStringCfg<?>> stringCfgs = new ArrayList<BaseStringCfg<?>>();
|
|
|
|
|
|
List<ComplexkeywordCfg> complexkeywordCfgs = new ArrayList<ComplexkeywordCfg>();
|
|
|
|
|
|
List<CfgIndexInfo> cfgIndexInfos = new ArrayList<CfgIndexInfo>();
|
|
|
|
|
|
List<AppPolicyCfg> appPolicyCfgs = new ArrayList<AppPolicyCfg>();
|
|
|
|
|
|
FunctionRegionDict appRegion = null;
|
|
|
|
|
|
if(serviceDict!=null) {
|
|
|
|
|
|
String regionCode = serviceDict.getRegionCode();
|
|
|
|
|
|
for (String code : regionCode.split(",")) {
|
|
|
|
|
|
if (StringUtils.isNotBlank(code)) {
|
|
|
|
|
|
FunctionRegionDict d = DictUtils.getFunctionRegionDictByRegionCode(serviceDict.getFunctionId(),
|
|
|
|
|
|
Integer.parseInt(code));
|
|
|
|
|
|
if (d != null && d.getConfigServiceType() != null
|
|
|
|
|
|
&& d.getConfigServiceType().equals("app_policy")) {
|
|
|
|
|
|
appRegion = d;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-10-19 22:07:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
for (int i = 0; i < files.length; i++) {
|
|
|
|
|
|
MultipartFile file = files[i];
|
|
|
|
|
|
ImportExcel ei = new ImportExcel(file, 0, 0);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-10-25 16:44:04 +08:00
|
|
|
|
FunctionRegionDict regionDict = DictUtils
|
|
|
|
|
|
.getFunctionRegionDict(Integer.parseInt(regionDictIds.split(",")[i]));
|
|
|
|
|
|
if (regionDict.getRegionType().equals(1)) {// IP
|
|
|
|
|
|
if (regionDict.getFunctionId().equals(5)) {
|
|
|
|
|
|
if (serviceDict!=null&&serviceDict.getAction().equals(64)) {
|
|
|
|
|
|
List<IpRateLimitTemplate> list = ei.getDataList(IpRateLimitTemplate.class,
|
2018-10-31 12:31:31 +08:00
|
|
|
|
this.getMsgProp(),regionDict);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
ipPortCfgs = this.checkIpCfg(serviceDict, regionDict, list);
|
|
|
|
|
|
} else {
|
2018-10-31 12:31:31 +08:00
|
|
|
|
List<IpAllTemplate> list = ei.getDataList(IpAllTemplate.class, this.getMsgProp(),regionDict);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
ipPortCfgs = this.checkIpCfg(serviceDict, regionDict, list);
|
|
|
|
|
|
}
|
2018-11-01 20:23:56 +08:00
|
|
|
|
} else if (regionDict.getFunctionId().equals(7)&&serviceDict!=null&&serviceDict.getAction().intValue()==16) {
|
|
|
|
|
|
List<DnsIpTemplate> list = ei.getDataList(DnsIpTemplate.class, this.getMsgProp(),regionDict);
|
|
|
|
|
|
ipPortCfgs = this.checkIpCfg(serviceDict, regionDict, list);
|
|
|
|
|
|
}else if(regionDict.getFunctionId().equals(401)) {
|
|
|
|
|
|
List<DnsIpTemplate> list = ei.getDataList(DnsIpTemplate.class, this.getMsgProp(),regionDict);
|
|
|
|
|
|
ipPortCfgs = this.checkIpCfg(serviceDict, regionDict, list);
|
|
|
|
|
|
}else if (regionDict.getFunctionId().equals(212)) {
|
2018-10-31 12:31:31 +08:00
|
|
|
|
List<IpPayloadTemplate> list = ei.getDataList(IpPayloadTemplate.class, this.getMsgProp(),regionDict);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
ipPortCfgs = this.checkIpCfg(serviceDict, regionDict, list);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (regionDict.getFunctionId().equals(510)
|
|
|
|
|
|
&& "p2p_ip".equals(regionDict.getConfigServiceType())) { // P2p IP
|
2018-10-31 12:31:31 +08:00
|
|
|
|
List<P2pIpTemplate> list = ei.getDataList(P2pIpTemplate.class, this.getMsgProp(),regionDict);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
ipPortCfgs = this.checkIpCfg(serviceDict, regionDict, list);
|
2018-10-26 18:57:20 +08:00
|
|
|
|
} else if (regionDict.getFunctionId().equals(600)) {// ANS IP
|
2018-10-31 12:31:31 +08:00
|
|
|
|
List<AsnIpTemplate> list = ei.getDataList(AsnIpTemplate.class, this.getMsgProp(),regionDict);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
ipPortCfgs = this.checkIpCfg(serviceDict, regionDict, list);
|
2018-11-01 14:58:48 +08:00
|
|
|
|
} else if (regionDict.getFunctionId().equals(301)) {// ANS IP
|
|
|
|
|
|
List<DdosIpTemplate> list = ei.getDataList(DdosIpTemplate.class, this.getMsgProp(),regionDict);
|
|
|
|
|
|
ipPortCfgs = this.checkIpCfg(serviceDict, regionDict, list);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else {
|
2018-10-31 12:31:31 +08:00
|
|
|
|
List<IpAllTemplate> list = ei.getDataList(IpAllTemplate.class, this.getMsgProp(),regionDict);
|
2018-10-18 18:05:49 +08:00
|
|
|
|
ipPortCfgs = this.checkIpCfg(serviceDict, regionDict, list);
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (regionDict.getRegionType().equals(2)) {// 字符串类
|
|
|
|
|
|
if (regionDict.getFunctionId().equals(510)
|
|
|
|
|
|
&& "p2p_hash".equals(regionDict.getConfigServiceType())) { // P2p hash
|
|
|
|
|
|
List<P2pHashStringTemplate> list = ei.getDataList(P2pHashStringTemplate.class,
|
2018-10-31 12:31:31 +08:00
|
|
|
|
this.getMsgProp(),regionDict);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
stringCfgs = this.checkStringCfg(serviceDict, regionDict, list);
|
|
|
|
|
|
} else {
|
2018-10-31 12:31:31 +08:00
|
|
|
|
List<StringAllTemplate> list = ei.getDataList(StringAllTemplate.class, this.getMsgProp(),regionDict);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
stringCfgs = this.checkStringCfg(serviceDict, regionDict, list);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else if (regionDict.getRegionType().equals(3)) {// 增强字符串类
|
2018-10-30 16:53:36 +08:00
|
|
|
|
if (regionDict.getFunctionId().equals(7)&&serviceDict!=null&&serviceDict.getAction().intValue()==16) {
|
2018-10-25 16:44:04 +08:00
|
|
|
|
List<DnsComplexStringTemplate> list = ei.getDataList(DnsComplexStringTemplate.class,
|
2018-10-31 12:31:31 +08:00
|
|
|
|
this.getMsgProp(),regionDict);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
complexkeywordCfgs = this.checkComplexStringCfg(serviceDict, regionDict, list);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<ComplexStringAllTemplate> list = ei.getDataList(ComplexStringAllTemplate.class,
|
2018-10-31 12:31:31 +08:00
|
|
|
|
this.getMsgProp(),regionDict);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
complexkeywordCfgs = this.checkComplexStringCfg(serviceDict, regionDict, list);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
|
String specServiceId = request.getParameter("appId");
|
|
|
|
|
|
String behaviorId = request.getParameter("behaviorId");
|
|
|
|
|
|
String asnIpGroup = request.getParameter("asnGroupId");
|
|
|
|
|
|
SpecificServiceCfg specificServiceCfg = null;
|
|
|
|
|
|
if (serviceDict!=null&&(serviceDict.getServiceId().intValue() == 33 || serviceDict.getServiceId().intValue() == 145
|
|
|
|
|
|
|| serviceDict.getServiceId().intValue() == 35
|
|
|
|
|
|
|| serviceDict.getServiceId().intValue() == 147
|
|
|
|
|
|
|| serviceDict.getServiceId().intValue() == 36
|
|
|
|
|
|
|| serviceDict.getServiceId().intValue() == 148)) {
|
|
|
|
|
|
if (StringUtils.isNotBlank(specServiceId)) {
|
|
|
|
|
|
specificServiceCfg = specificServiceCfgService
|
|
|
|
|
|
.getBySpecServiceId(Integer.parseInt(specServiceId));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (regionDict.getRegionType().equals(1)) {// IP
|
2018-10-26 18:57:20 +08:00
|
|
|
|
if(regionDict.getFunctionId().intValue()==600) {//ans ip
|
|
|
|
|
|
Map<String,List<AsnIpCfg>> asnIpCfgs=new HashMap<>();
|
2018-10-25 16:44:04 +08:00
|
|
|
|
for (BaseIpCfg cfg : ipPortCfgs) {
|
|
|
|
|
|
AsnIpCfg _cfg=new AsnIpCfg();
|
|
|
|
|
|
BeanUtils.copyProperties(cfg, _cfg);
|
|
|
|
|
|
_cfg.setTableName(AsnIpCfg.getTablename());
|
2018-10-26 18:57:20 +08:00
|
|
|
|
_cfg.setAction(0);
|
|
|
|
|
|
_cfg.setCfgRegionCode(regionDict.getConfigRegionCode());
|
2018-10-30 11:29:37 +08:00
|
|
|
|
// _cfg.setCfgRegionCode(regionDict.getConfigRegionCode());
|
2018-10-26 18:57:20 +08:00
|
|
|
|
_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(0);
|
|
|
|
|
|
if(asnIpCfgs.containsKey(_cfg.getUserRegion1())) {
|
|
|
|
|
|
asnIpCfgs.get(_cfg.getUserRegion1()).add(_cfg);
|
|
|
|
|
|
}else {
|
|
|
|
|
|
List<AsnIpCfg> ips=Lists.newArrayList();
|
|
|
|
|
|
ips.add(_cfg);
|
|
|
|
|
|
asnIpCfgs.put(_cfg.getUserRegion1(), ips);
|
|
|
|
|
|
}
|
2018-10-19 22:07:16 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
ipPortCfgs.clear();
|
2018-10-26 18:57:20 +08:00
|
|
|
|
asnIpCfgService.saveAsnIpBatch(asnIpCfgs);
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}else {
|
2018-11-01 20:23:56 +08:00
|
|
|
|
List<Integer> compileIds=Lists.newArrayList();
|
|
|
|
|
|
try {
|
|
|
|
|
|
compileIds = ConfigServiceUtil.getId(1,ipPortCfgs.size());
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger.info("获取编译ID出错");
|
|
|
|
|
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
int ind=0;
|
2018-10-25 16:44:04 +08:00
|
|
|
|
for (BaseIpCfg cfg : ipPortCfgs) {
|
|
|
|
|
|
cfg.setAction(serviceDict==null?null: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==null?null:serviceDict.getServiceId());
|
|
|
|
|
|
cfg.setTableName("ip_port_cfg");
|
2018-11-01 20:23:56 +08:00
|
|
|
|
cfg.setCompileId(compileIds.get(ind));
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (serviceDict!=null&&(serviceDict.getServiceId().intValue() == 33
|
|
|
|
|
|
|| serviceDict.getServiceId().intValue() == 145
|
|
|
|
|
|
|| serviceDict.getServiceId().intValue() == 35
|
|
|
|
|
|
|| serviceDict.getServiceId().intValue() == 147
|
|
|
|
|
|
|| serviceDict.getServiceId().intValue() == 36
|
|
|
|
|
|
|| serviceDict.getServiceId().intValue() == 148)) {
|
|
|
|
|
|
if (specificServiceCfg != null && appRegion != null) {
|
|
|
|
|
|
AppPolicyCfg appPolicyCfg = new AppPolicyCfg();
|
|
|
|
|
|
BeanUtils.copyProperties(cfg, appPolicyCfg);
|
|
|
|
|
|
appPolicyCfg.setSpecServiceId(specificServiceCfg.getSpecServiceId());
|
|
|
|
|
|
appPolicyCfg.setAppCode(specificServiceCfg.getSpecServiceCode());
|
|
|
|
|
|
appPolicyCfg.setMatchMethod(0);
|
|
|
|
|
|
appPolicyCfg.setIsHexbin(0);
|
|
|
|
|
|
appPolicyCfg.setCfgType(appRegion.getConfigRegionValue());
|
|
|
|
|
|
appPolicyCfg.setCfgRegionCode(appRegion.getConfigRegionCode());
|
|
|
|
|
|
if (StringUtils.isNotBlank(behaviorId)) {
|
|
|
|
|
|
appPolicyCfg.setBehavCode(Integer.parseInt(behaviorId));
|
|
|
|
|
|
appPolicyCfg.setExprType(1);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
appPolicyCfg.setExprType(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
appPolicyCfgs.add(appPolicyCfg);
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2018-11-01 20:23:56 +08:00
|
|
|
|
if(regionDict.getFunctionId().intValue()!=600
|
|
|
|
|
|
&®ionDict.getFunctionId().intValue()!=301
|
|
|
|
|
|
&®ionDict.getFunctionId().intValue()!=401) {
|
2018-10-25 16:44:04 +08:00
|
|
|
|
CfgIndexInfo cfgIndexInfo = new CfgIndexInfo();
|
|
|
|
|
|
BeanUtils.copyProperties(cfg, cfgIndexInfo);
|
|
|
|
|
|
cfgIndexInfos.add(cfgIndexInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-11-01 20:23:56 +08:00
|
|
|
|
ind++;
|
2018-10-25 16:44:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(ipPortCfgs!=null&&ipPortCfgs.size()>0) {
|
2018-11-01 14:58:48 +08:00
|
|
|
|
if (regionDict.getFunctionId().equals(301)) {
|
|
|
|
|
|
ddosCfgService.saveDdosIpCfg(ipPortCfgs);
|
2018-11-01 20:23:56 +08:00
|
|
|
|
}else if (regionDict.getFunctionId().equals(401)) {
|
|
|
|
|
|
dnsIpCfgService.saveDnsIpCfg(ipPortCfgs);
|
2018-11-01 14:58:48 +08:00
|
|
|
|
}else {
|
|
|
|
|
|
ipCfgService.saveBatch(ipPortCfgs, IpCfgDao.class);
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
}
|
2018-10-19 22:07:16 +08:00
|
|
|
|
}
|
2018-10-20 23:38:56 +08:00
|
|
|
|
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (regionDict.getRegionType().equals(2)) {
|
2018-11-01 20:23:56 +08:00
|
|
|
|
List<Integer> compileIds=Lists.newArrayList();
|
|
|
|
|
|
try {
|
|
|
|
|
|
compileIds = ConfigServiceUtil.getId(1,stringCfgs.size());
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger.info("获取编译ID出错");
|
|
|
|
|
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
int ind=0;
|
2018-10-25 16:44:04 +08:00
|
|
|
|
for (BaseStringCfg cfg : stringCfgs) {
|
|
|
|
|
|
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());
|
2018-11-01 20:23:56 +08:00
|
|
|
|
cfg.setCompileId(compileIds.get(i));
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (serviceDict.getServiceId().intValue() == 33
|
|
|
|
|
|
|| serviceDict.getServiceId().intValue() == 145
|
|
|
|
|
|
|| serviceDict.getServiceId().intValue() == 35
|
|
|
|
|
|
|| serviceDict.getServiceId().intValue() == 147
|
|
|
|
|
|
|| serviceDict.getServiceId().intValue() == 36
|
|
|
|
|
|
|| serviceDict.getServiceId().intValue() == 148) {
|
|
|
|
|
|
if (specificServiceCfg != null && appRegion != null) {
|
|
|
|
|
|
AppPolicyCfg appPolicyCfg = new AppPolicyCfg();
|
|
|
|
|
|
BeanUtils.copyProperties(cfg, appPolicyCfg);
|
|
|
|
|
|
appPolicyCfg.setSpecServiceId(specificServiceCfg.getSpecServiceId());
|
|
|
|
|
|
appPolicyCfg.setAppCode(specificServiceCfg.getSpecServiceCode());
|
|
|
|
|
|
appPolicyCfg.setMatchMethod(0);
|
|
|
|
|
|
appPolicyCfg.setIsHexbin(0);
|
|
|
|
|
|
appPolicyCfg.setCfgType(appRegion.getConfigRegionValue());
|
|
|
|
|
|
appPolicyCfg.setCfgRegionCode(appRegion.getConfigRegionCode());
|
|
|
|
|
|
if (StringUtils.isNotBlank(behaviorId)) {
|
|
|
|
|
|
appPolicyCfg.setBehavCode(Integer.parseInt(behaviorId));
|
|
|
|
|
|
appPolicyCfg.setExprType(1);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
appPolicyCfg.setExprType(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
appPolicyCfgs.add(appPolicyCfg);
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
CfgIndexInfo cfgIndexInfo = new CfgIndexInfo();
|
2018-10-30 14:52:51 +08:00
|
|
|
|
BeanUtils.copyProperties(cfg, cfgIndexInfo, new String[] {"cfgId"});
|
2018-10-25 16:44:04 +08:00
|
|
|
|
cfgIndexInfos.add(cfgIndexInfo);
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
2018-11-01 20:23:56 +08:00
|
|
|
|
ind++;
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
// 调用对应配置的service
|
|
|
|
|
|
if (regionDict.getDictId().intValue() == 167) {
|
|
|
|
|
|
interceptCfgService.saveInterceptCfg(stringCfgs);
|
|
|
|
|
|
}
|
2018-10-31 17:00:40 +08:00
|
|
|
|
if (regionDict.getDictId().intValue() == 9||regionDict.getDictId().intValue() == 15 || regionDict.getDictId().intValue() == 596) {
|
2018-10-25 16:44:04 +08:00
|
|
|
|
websiteCfgService.saveHttpUrlCfg(stringCfgs);
|
|
|
|
|
|
}
|
2018-10-31 17:00:40 +08:00
|
|
|
|
if (regionDict.getDictId().intValue() == 36||regionDict.getDictId().intValue() == 37) {
|
2018-10-25 16:44:04 +08:00
|
|
|
|
fileTransferCfgService.saveFtpCfg(stringCfgs);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (regionDict.getFunctionId().equals(510)) { // P2p hash
|
|
|
|
|
|
/*
|
|
|
|
|
|
* if("p2p_hash".equals(regionDict.getConfigServiceType())) {
|
|
|
|
|
|
* fileTransferCfgService.saveP2pHashCfg(stringCfgs); }else {
|
|
|
|
|
|
*/
|
2018-10-24 16:09:32 +08:00
|
|
|
|
fileTransferCfgService.saveP2pCfg(stringCfgs);
|
2018-10-25 16:44:04 +08:00
|
|
|
|
/* } */
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2018-10-30 14:52:51 +08:00
|
|
|
|
if (regionDict.getFunctionId().equals(61)) {
|
|
|
|
|
|
bgpCfgService.saveBgpAsCfg(stringCfgs);
|
|
|
|
|
|
}
|
2018-10-30 18:29:36 +08:00
|
|
|
|
if (regionDict.getFunctionId().intValue() == 34) {
|
|
|
|
|
|
websiteCfgService.saveSslCfg(stringCfgs);
|
|
|
|
|
|
}
|
2018-10-31 17:00:40 +08:00
|
|
|
|
if(regionDict.getDictId().intValue()==12||regionDict.getDictId().intValue()==13||regionDict.getDictId().intValue()==601||regionDict.getDictId().intValue()==602) {
|
|
|
|
|
|
websiteCfgService.saveHttpBodyCfg(stringCfgs);
|
2018-10-30 19:47:55 +08:00
|
|
|
|
}
|
2018-10-31 19:44:50 +08:00
|
|
|
|
if(regionDict.getDictId().intValue()==25){
|
|
|
|
|
|
avContentCfgService.saveContUrlCfg(stringCfgs);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(regionDict.getDictId().intValue()==16){
|
|
|
|
|
|
avContentCfgService.saveVoIpAccountCfg(stringCfgs);
|
|
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else if (regionDict.getRegionType().equals(3)) {
|
2018-11-01 20:23:56 +08:00
|
|
|
|
List<Integer> compileIds=Lists.newArrayList();
|
|
|
|
|
|
try {
|
|
|
|
|
|
compileIds = ConfigServiceUtil.getId(1,complexkeywordCfgs.size());
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger.info("获取编译ID出错");
|
|
|
|
|
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
int ind=0;
|
2018-10-25 16:44:04 +08:00
|
|
|
|
for (ComplexkeywordCfg cfg : complexkeywordCfgs) {
|
|
|
|
|
|
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());
|
2018-11-01 20:23:56 +08:00
|
|
|
|
cfg.setCompileId(compileIds.get(ind));
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (serviceDict.getServiceId().intValue() == 33
|
|
|
|
|
|
|| serviceDict.getServiceId().intValue() == 145
|
|
|
|
|
|
|| serviceDict.getServiceId().intValue() == 35
|
|
|
|
|
|
|| serviceDict.getServiceId().intValue() == 147
|
|
|
|
|
|
|| serviceDict.getServiceId().intValue() == 36
|
|
|
|
|
|
|| serviceDict.getServiceId().intValue() == 148) {
|
|
|
|
|
|
if (specificServiceCfg != null && appRegion != null) {
|
|
|
|
|
|
AppPolicyCfg appPolicyCfg = new AppPolicyCfg();
|
|
|
|
|
|
BeanUtils.copyProperties(cfg, appPolicyCfg);
|
|
|
|
|
|
appPolicyCfg.setSpecServiceId(specificServiceCfg.getSpecServiceId());
|
|
|
|
|
|
appPolicyCfg.setAppCode(specificServiceCfg.getSpecServiceCode());
|
|
|
|
|
|
appPolicyCfg.setMatchMethod(0);
|
|
|
|
|
|
appPolicyCfg.setIsHexbin(0);
|
|
|
|
|
|
appPolicyCfg.setCfgType(appRegion.getConfigRegionValue());
|
|
|
|
|
|
appPolicyCfg.setCfgRegionCode(appRegion.getConfigRegionCode());
|
|
|
|
|
|
if (StringUtils.isNotBlank(behaviorId)) {
|
|
|
|
|
|
appPolicyCfg.setBehavCode(Integer.parseInt(behaviorId));
|
|
|
|
|
|
appPolicyCfg.setExprType(1);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
appPolicyCfg.setExprType(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
appPolicyCfgs.add(appPolicyCfg);
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
CfgIndexInfo cfgIndexInfo = new CfgIndexInfo();
|
|
|
|
|
|
BeanUtils.copyProperties(cfg, cfgIndexInfo);
|
|
|
|
|
|
cfgIndexInfos.add(cfgIndexInfo);
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
2018-11-01 20:23:56 +08:00
|
|
|
|
ind++;
|
2018-10-25 16:44:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (regionDict.getDictId().intValue() == 28) {
|
|
|
|
|
|
websiteCfgService.saveDnsCfg(complexkeywordCfgs);
|
|
|
|
|
|
}
|
2018-10-31 12:31:31 +08:00
|
|
|
|
if (regionDict.getDictId().intValue() == 30 || regionDict.getDictId().intValue() == 31||regionDict.getDictId().intValue() == 599) {
|
2018-10-25 16:44:04 +08:00
|
|
|
|
mailCfgService.saveMailCfg(complexkeywordCfgs);
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
2018-10-31 17:00:40 +08:00
|
|
|
|
if(regionDict.getDictId().intValue()==10) {
|
|
|
|
|
|
websiteCfgService.saveHttpReqHeadCfg(complexkeywordCfgs);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(regionDict.getDictId().intValue()==11) {
|
|
|
|
|
|
websiteCfgService.saveHttpResHeadCfg(complexkeywordCfgs);
|
|
|
|
|
|
}
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (cfgIndexInfos != null && cfgIndexInfos.size() > 0) {
|
|
|
|
|
|
ipCfgService.saveCfgIndexOf(cfgIndexInfos);
|
2018-10-20 23:38:56 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
if (appPolicyCfgs != null && appPolicyCfgs.size() > 0) {
|
|
|
|
|
|
appCfgService.savePolicyList(appPolicyCfgs);
|
2018-10-19 22:07:16 +08:00
|
|
|
|
}
|
2018-10-25 16:44:04 +08:00
|
|
|
|
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
2018-10-18 18:05:49 +08:00
|
|
|
|
addMessage(redirectAttributes, e.getMessage());
|
|
|
|
|
|
e.printStackTrace();
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-18 18:05:49 +08:00
|
|
|
|
|
2018-10-15 10:14:01 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 多域配置导出
|
2018-10-18 18:05:49 +08:00
|
|
|
|
*
|
2018-10-15 10:14:01 +08:00
|
|
|
|
* @param columns
|
|
|
|
|
|
* @param model
|
|
|
|
|
|
* @param request
|
|
|
|
|
|
* @param response
|
|
|
|
|
|
* @param entity
|
|
|
|
|
|
* @param ids
|
|
|
|
|
|
* @param redirectAttributes
|
|
|
|
|
|
*/
|
2018-10-18 18:05:49 +08:00
|
|
|
|
public void _export(Model model, HttpServletRequest request, HttpServletResponse response,
|
|
|
|
|
|
RedirectAttributes redirectAttributes, String functionName, List<String> titleList,
|
|
|
|
|
|
Map<String, Class<?>> classMap, Map<String, List> dataMap, Map<String, String> noExportMap)
|
|
|
|
|
|
throws Exception {
|
|
|
|
|
|
// 获取国际化配置
|
|
|
|
|
|
Properties msgProp = getMsgProp();
|
|
|
|
|
|
// 获取分类、性质、标签
|
|
|
|
|
|
List<ServiceDictInfo> fls = serviceDictInfoService.findAllFlDict();
|
|
|
|
|
|
List<ServiceDictInfo> xzs = serviceDictInfoService.findAllXzDict();
|
|
|
|
|
|
List<ServiceDictInfo> labels = serviceDictInfoService.findAllLableDict();
|
|
|
|
|
|
Map<Object, Object> map = new HashMap<Object, Object>();
|
|
|
|
|
|
map.put("fls", fls);
|
|
|
|
|
|
map.put("xzs", xzs);
|
|
|
|
|
|
map.put("labels", labels);
|
|
|
|
|
|
|
|
|
|
|
|
String fileName = msgProp.getProperty(functionName, functionName) + "_" + DateUtils.getDate("yyyyMMddHHmmss")
|
|
|
|
|
|
+ ".xlsx";
|
2018-10-25 16:44:04 +08:00
|
|
|
|
|
|
|
|
|
|
fileName = fileName.replaceAll(" ", "_");
|
2018-10-18 18:05:49 +08:00
|
|
|
|
if (request.getHeader("User-Agent").toUpperCase().indexOf("MSIE") > 0) {
|
|
|
|
|
|
fileName = URLEncoder.encode(fileName, "UTF-8");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");
|
|
|
|
|
|
}
|
|
|
|
|
|
new ExportExcel(msgProp, titleList, noExportMap, classMap, 1).setDataList(msgProp, dataMap, map)
|
|
|
|
|
|
.write(response, fileName).dispose();
|
2018-10-15 10:14:01 +08:00
|
|
|
|
}
|
2017-12-29 16:18:40 +08:00
|
|
|
|
}
|