voip界面去掉无用的检索条件
摘要文件类型增加音视频文件类 ip和http增加配置导出
This commit is contained in:
@@ -7,6 +7,7 @@ import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
@@ -20,12 +21,14 @@ import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jets3t.service.ServiceException;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.beust.jcommander.internal.Lists;
|
||||
@@ -39,9 +42,12 @@ import com.nis.domain.configuration.AreaBean;
|
||||
import com.nis.domain.configuration.AreaIpCfg;
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.configuration.ComplexStringCfgTemplate;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.configuration.RequestInfo;
|
||||
import com.nis.domain.configuration.StringCfgTemplate;
|
||||
import com.nis.domain.configuration.template.IpAllTemplate;
|
||||
import com.nis.domain.configuration.template.IpCfgTemplate;
|
||||
import com.nis.domain.log.BaseLogEntity;
|
||||
import com.nis.domain.log.SearchReport;
|
||||
@@ -54,6 +60,9 @@ import com.nis.util.DictUtils;
|
||||
import com.nis.util.JsonMapper;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.excel.ExportExcel;
|
||||
import com.nis.util.excel.ImportExcel;
|
||||
import com.nis.web.dao.configuration.IpCfgDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
import com.nis.web.service.ArchiveServcie;
|
||||
import com.nis.web.service.AreaService;
|
||||
import com.nis.web.service.DictService;
|
||||
@@ -605,17 +614,17 @@ public class BaseController {
|
||||
if(dict.getRegionType()==1){
|
||||
List<IpCfgTemplate> list = Lists.newArrayList();
|
||||
list.add(new IpCfgTemplate());
|
||||
new ExportExcel(msgProp,null, IpCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
||||
new ExportExcel(new FunctionRegionDict(),msgProp,null, IpCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
||||
write(request,response, fileName).dispose();
|
||||
}else if(dict.getRegionType()==2){
|
||||
List<StringCfgTemplate> list = Lists.newArrayList();
|
||||
list.add(new StringCfgTemplate());
|
||||
new ExportExcel(msgProp,null, StringCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
||||
new ExportExcel(new FunctionRegionDict(),msgProp,null, StringCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
||||
write(request,response, fileName).dispose();
|
||||
}else if(dict.getRegionType()==3){
|
||||
List<ComplexStringCfgTemplate> list = Lists.newArrayList();
|
||||
list.add(new ComplexStringCfgTemplate());
|
||||
new ExportExcel(msgProp,null, ComplexStringCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
||||
new ExportExcel(new FunctionRegionDict(),msgProp,null, ComplexStringCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
||||
write(request,response, fileName).dispose();
|
||||
}
|
||||
}
|
||||
@@ -637,17 +646,17 @@ public class BaseController {
|
||||
if(dict.getRegionType()==1){
|
||||
List<IpCfgTemplate> list = Lists.newArrayList();
|
||||
list.add((IpCfgTemplate)clazz.newInstance());
|
||||
new ExportExcel(msgProp,null, clazz, 2).setDataList(msgProp,list,null).
|
||||
new ExportExcel(new FunctionRegionDict(),msgProp,null, clazz, 2).setDataList(msgProp,list,null).
|
||||
write(request,response, fileName).dispose();
|
||||
}else if(dict.getRegionType()==2){
|
||||
List<StringCfgTemplate> list = Lists.newArrayList();
|
||||
list.add(new StringCfgTemplate());
|
||||
new ExportExcel(msgProp,null, clazz, 2).setDataList(msgProp,list,null).
|
||||
new ExportExcel(new FunctionRegionDict(),msgProp,null, clazz, 2).setDataList(msgProp,list,null).
|
||||
write(request,response, fileName).dispose();
|
||||
}else if(dict.getRegionType()==3){
|
||||
List<ComplexStringCfgTemplate> list = Lists.newArrayList();
|
||||
list.add(new ComplexStringCfgTemplate());
|
||||
new ExportExcel(msgProp,null, clazz, 2).setDataList(msgProp,list,null).
|
||||
new ExportExcel(new FunctionRegionDict(),msgProp,null, clazz, 2).setDataList(msgProp,list,null).
|
||||
write(request,response, fileName).dispose();
|
||||
}
|
||||
}
|
||||
@@ -778,6 +787,572 @@ public class BaseController {
|
||||
params.put("searchCfgId", entry.getCfgId());
|
||||
}
|
||||
}
|
||||
|
||||
public List<BaseIpCfg> checkIpCfg(FunctionServiceDict serviceDict,FunctionRegionDict regionDict,List<IpAllTemplate> list) throws ServiceException{
|
||||
List<BaseIpCfg> ipList=new ArrayList<BaseIpCfg>();
|
||||
Properties prop=this.getMsgProp();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
IpAllTemplate ipCfg=list.get(i);
|
||||
IpPortCfg baseIpCfg=new IpPortCfg();
|
||||
baseIpCfg.setCfgDesc(ipCfg.getCfgDesc());
|
||||
if(regionDict.getIsMaat().equals(1)){
|
||||
if(regionDict.getRegionType().equals(1)){
|
||||
boolean srcIpEmpty=false;
|
||||
boolean srcPortEmpty=false;
|
||||
if(StringUtil.isEmpty(ipCfg.getSrcIpAddress())){
|
||||
srcIpEmpty=true;
|
||||
}
|
||||
if(StringUtil.isEmpty(ipCfg.getDestIpAddress())){
|
||||
if(srcIpEmpty){
|
||||
baseIpCfg.setSrcIpAddress("0.0.0.0");
|
||||
baseIpCfg.setDestIpAddress("0.0.0.0");
|
||||
baseIpCfg.setIpPattern(3);
|
||||
baseIpCfg.setIpType(4);
|
||||
}else{
|
||||
if(ipCfg.getSrcIpAddress().indexOf(":") > -1){
|
||||
if(ipCfg.getSrcIpAddress().indexOf("-") > -1){
|
||||
baseIpCfg.setSrcIpAddress(ipCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress("::-::");
|
||||
baseIpCfg.setIpPattern(2);
|
||||
}else if(ipCfg.getSrcIpAddress().indexOf("/") > -1){
|
||||
baseIpCfg.setSrcIpAddress(ipCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress("::/128");
|
||||
baseIpCfg.setIpPattern(1);
|
||||
}else{
|
||||
baseIpCfg.setSrcIpAddress(ipCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress("::");
|
||||
baseIpCfg.setIpPattern(3);
|
||||
}
|
||||
baseIpCfg.setIpType(6);
|
||||
}else{
|
||||
if(ipCfg.getSrcIpAddress().indexOf("-") > -1){
|
||||
baseIpCfg.setSrcIpAddress("0.0.0.0-"+ipCfg.getSrcIpAddress().split("-")[0].substring(0,ipCfg.getSrcIpAddress().indexOf("-")+1)+ipCfg.getSrcIpAddress().split("-")[1]);
|
||||
baseIpCfg.setDestIpAddress("0.0.0.0-0.0.0.0");
|
||||
baseIpCfg.setIpPattern(2);
|
||||
}else if(ipCfg.getSrcIpAddress().indexOf("/") > -1){
|
||||
baseIpCfg.setSrcIpAddress(ipCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress("0.0.0.0/16");
|
||||
baseIpCfg.setIpPattern(1);
|
||||
}else{
|
||||
baseIpCfg.setSrcIpAddress(ipCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress("0.0.0.0");
|
||||
baseIpCfg.setIpPattern(3);
|
||||
}
|
||||
baseIpCfg.setIpType(4);
|
||||
}
|
||||
}
|
||||
} else{
|
||||
if(srcIpEmpty){
|
||||
if(ipCfg.getDestIpAddress().indexOf(":") > -1){
|
||||
if(ipCfg.getDestIpAddress().indexOf("-") > -1){
|
||||
baseIpCfg.setDestIpAddress(ipCfg.getDestIpAddress());
|
||||
baseIpCfg.setSrcIpAddress("::-::");
|
||||
baseIpCfg.setIpPattern(2);
|
||||
}else if(ipCfg.getDestIpAddress().indexOf("/") > -1){
|
||||
baseIpCfg.setDestIpAddress(ipCfg.getDestIpAddress());
|
||||
baseIpCfg.setSrcIpAddress("::/128");
|
||||
baseIpCfg.setIpPattern(1);
|
||||
}else{
|
||||
baseIpCfg.setDestIpAddress(ipCfg.getDestIpAddress());
|
||||
baseIpCfg.setSrcIpAddress("::");
|
||||
baseIpCfg.setIpPattern(3);
|
||||
}
|
||||
baseIpCfg.setIpType(6);
|
||||
}else{
|
||||
if(ipCfg.getDestIpAddress().indexOf("-") > -1){
|
||||
baseIpCfg.setDestIpAddress("0.0.0.0-"+ipCfg.getDestIpAddress().split("-")[0].substring(0,ipCfg.getDestIpAddress().indexOf("-")+1)+ipCfg.getDestIpAddress().split("-")[1]);
|
||||
baseIpCfg.setSrcIpAddress("0.0.0.0-0.0.0.0");
|
||||
baseIpCfg.setIpPattern(2);
|
||||
}else if(ipCfg.getDestIpAddress().indexOf("/") > -1){
|
||||
baseIpCfg.setDestIpAddress(ipCfg.getDestIpAddress());
|
||||
baseIpCfg.setSrcIpAddress("0.0.0.0/16");
|
||||
baseIpCfg.setIpPattern(1);
|
||||
}else{
|
||||
baseIpCfg.setDestIpAddress(ipCfg.getDestIpAddress());
|
||||
baseIpCfg.setSrcIpAddress("0.0.0.0");
|
||||
baseIpCfg.setIpPattern(3);
|
||||
}
|
||||
baseIpCfg.setIpType(4);
|
||||
}
|
||||
}else{
|
||||
baseIpCfg.setSrcIpAddress(ipCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress(ipCfg.getDestIpAddress());
|
||||
if(ipCfg.getSrcIpAddress().indexOf(":") > -1){
|
||||
baseIpCfg.setIpType(6);
|
||||
}else{
|
||||
baseIpCfg.setIpType(4);
|
||||
}
|
||||
if(ipCfg.getSrcIpAddress().indexOf("-") > -1){
|
||||
baseIpCfg.setIpPattern(2);
|
||||
}else if(ipCfg.getSrcIpAddress().indexOf("/") > -1){
|
||||
baseIpCfg.setIpPattern(1);
|
||||
}else{
|
||||
baseIpCfg.setIpPattern(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO 判断源IP和目的IP的值
|
||||
//TODO 判断源IP和目的IP格式
|
||||
|
||||
if(StringUtil.isEmpty(ipCfg.getSrcPort())){
|
||||
srcPortEmpty=true;
|
||||
}
|
||||
if(StringUtil.isEmpty(ipCfg.getDestPort())){
|
||||
if(srcPortEmpty){
|
||||
baseIpCfg.setSrcPort("0");
|
||||
baseIpCfg.setDestPort("0");
|
||||
baseIpCfg.setPortPattern(1);
|
||||
}else{
|
||||
if(ipCfg.getSrcPort().indexOf("/") > -1){
|
||||
baseIpCfg.setDestPort("0/0");
|
||||
baseIpCfg.setPortPattern(2);
|
||||
}else{
|
||||
baseIpCfg.setDestPort("0");
|
||||
baseIpCfg.setPortPattern(1);
|
||||
}
|
||||
baseIpCfg.setSrcPort(ipCfg.getSrcPort());
|
||||
}
|
||||
}else{
|
||||
if(srcPortEmpty){
|
||||
if(ipCfg.getDestPort().indexOf("/") > -1){
|
||||
baseIpCfg.setSrcPort("0/0");
|
||||
baseIpCfg.setPortPattern(2);
|
||||
}else{
|
||||
baseIpCfg.setSrcPort("0");
|
||||
baseIpCfg.setPortPattern(1);
|
||||
}
|
||||
baseIpCfg.setDestPort(ipCfg.getSrcPort());
|
||||
}else{
|
||||
if(ipCfg.getSrcPort().indexOf("/") > -1){
|
||||
baseIpCfg.setPortPattern(2);
|
||||
}else{
|
||||
baseIpCfg.setPortPattern(1);
|
||||
}
|
||||
baseIpCfg.setSrcPort(ipCfg.getSrcPort());
|
||||
baseIpCfg.setDestPort(ipCfg.getDestPort());
|
||||
|
||||
}
|
||||
}
|
||||
//TODO 判断源端口和目的端口格式
|
||||
//TODO 判断源和目的端口的值
|
||||
|
||||
if(StringUtil.isEmpty(ipCfg.getProtocol())){
|
||||
if(StringUtil.isEmpty(regionDict.getConfigProtocol())){
|
||||
baseIpCfg.setProtocol(0);
|
||||
}else{
|
||||
baseIpCfg.setProtocol(Integer.parseInt(regionDict.getConfigProtocol().split(",")[0]));
|
||||
}
|
||||
baseIpCfg.setProtocolId(serviceDict.getProtocolId());
|
||||
}else{
|
||||
baseIpCfg.setProtocol(ipCfg.getProtocol());
|
||||
baseIpCfg.setProtocolId(serviceDict.getProtocolId());
|
||||
}
|
||||
//TODO 判断Protocol的值
|
||||
|
||||
if(StringUtil.isEmpty(ipCfg.getDirection())){
|
||||
if(StringUtil.isEmpty(regionDict.getConfigDirection())){
|
||||
baseIpCfg.setDirection(0);
|
||||
}else{
|
||||
baseIpCfg.setDirection(Integer.parseInt(regionDict.getConfigDirection().split(",")[0]));
|
||||
}
|
||||
}else{
|
||||
baseIpCfg.setDirection(ipCfg.getDirection());
|
||||
}
|
||||
|
||||
//TODO 判断Direction的值
|
||||
}
|
||||
}
|
||||
ipList.add(baseIpCfg);
|
||||
}
|
||||
return ipList;
|
||||
|
||||
/*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) {
|
||||
protocolList.addAll(icmpprotocolList);
|
||||
}
|
||||
}
|
||||
StringBuffer msg=new StringBuffer();
|
||||
int line=1;
|
||||
for(IpCfgTemplate value:list){
|
||||
String lineStart=String.format(prop.getProperty("line"), line)+":";
|
||||
StringBuffer errInfo=new StringBuffer();
|
||||
// ip_type check start
|
||||
Integer ipType=value.getIpType();
|
||||
if(ipType==null){
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ip_type"))+";");
|
||||
}else{
|
||||
boolean has=false;
|
||||
for(SysDataDictionaryItem ipTypeItem:ipTypeList){
|
||||
if(ipType==Integer.parseInt(ipTypeItem.getItemCode())){
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ip_type"))+";");
|
||||
}
|
||||
}
|
||||
// ip_type check end
|
||||
// ip_pattern check start
|
||||
Integer ipPattern=value.getIpPattern();
|
||||
if(ipPattern==null){
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ip_pattern"))+";");
|
||||
}else{
|
||||
boolean has=false;
|
||||
for(SysDataDictionaryItem ipPatternItem:ipPatternList){
|
||||
if(ipPattern==Integer.parseInt(ipPatternItem.getItemCode())){
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ip_pattern"))+";");
|
||||
}
|
||||
}
|
||||
// ip_pattern check end
|
||||
//client_ip check start
|
||||
String srcIp=value.getSrcIpAddress();
|
||||
String _msg="";
|
||||
if("ipmulitiplex".equals(specialItem)) {
|
||||
_msg=checkIP(prop,prop.getProperty("IP"),srcIp,ipType,ipPattern);
|
||||
}else {
|
||||
_msg=checkIP(prop,prop.getProperty("client_ip"),srcIp,ipType,ipPattern);
|
||||
}
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
//client_ip check end
|
||||
//server_ip check start
|
||||
String destIp=value.getDestIpAddress();
|
||||
if("ipmulitiplex".equals(specialItem)) {//set 默认值
|
||||
if(ipPattern!=null&&ipType!=null) {
|
||||
if(1==ipPattern.intValue()) {
|
||||
if(4==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if(6==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if(46==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if(64==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if(10==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||
}
|
||||
}else if(2==ipPattern.intValue()) {
|
||||
if(4==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if(6==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if(46==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if(64==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if(10==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||
}
|
||||
}else if(3==ipPattern.intValue()) {
|
||||
if(4==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||
}else if(6==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
||||
}else if(46==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
||||
}else if(64==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||
}else if(10==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if(srcIp.equals(destIp)){
|
||||
String info=String.format(prop.getProperty("are_the_same"),prop.getProperty("client_ip"),prop.getProperty("server_ip"));
|
||||
errInfo.append(info+";");
|
||||
}
|
||||
_msg=checkIP(prop,prop.getProperty("server_ip"),destIp,ipType,ipPattern);
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
}
|
||||
if(!"ipmulitiplex".equals(specialItem)&&(46==ipType.intValue()||64==ipType.intValue()||10==ipType.intValue())) {
|
||||
_msg=checkIp(prop, prop.getProperty("client_ip"), srcIp, prop.getProperty("server_ip"), destIp, ipType, ipPattern);
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
}
|
||||
//server_ip check end
|
||||
//port_pattern check start
|
||||
Integer portPattern=value.getPortPattern();
|
||||
if(portPattern==null){
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("port_pattern"))+";");
|
||||
}else{
|
||||
boolean has=false;
|
||||
for(SysDataDictionaryItem portPatternItem:portPatternList){
|
||||
if(portPattern==Integer.parseInt(portPatternItem.getItemCode())){
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("port_pattern"))+";");
|
||||
}
|
||||
}
|
||||
//port_pattern check end
|
||||
//src_port check start
|
||||
String srcPort=value.getSrcPort();
|
||||
if("ipmulitiplex".equals(specialItem)) {
|
||||
_msg=checkPort(prop,prop.getProperty("port"), srcPort, portPattern);
|
||||
}else {
|
||||
_msg=checkPort(prop,prop.getProperty("client_port"), srcPort, portPattern);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
//src_port check end
|
||||
//dest_port check start
|
||||
String destPort=value.getDestPort();
|
||||
if("ipmulitiplex".equals(specialItem)) {//set 默认值
|
||||
if(portPattern!=null) {
|
||||
if(2==portPattern.intValue()) {
|
||||
value.setDestPort(Constants.PORT_MASK_DEFAULT);
|
||||
}else if(1==portPattern.intValue()) {
|
||||
value.setDestPort(Constants.PORT_DEFAULT);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
_msg=checkPort(prop,prop.getProperty("server_port"), destPort, portPattern);
|
||||
}
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
//dest_port check end
|
||||
//direction check start
|
||||
Integer direction=value.getDirection();
|
||||
if(direction==null){
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("direction"))+";");
|
||||
}else{
|
||||
boolean has=false;
|
||||
for(SysDataDictionaryItem directionItem:directionList){
|
||||
if(Integer.parseInt(directionItem.getItemCode())==direction.intValue()){
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("direction"))+";");
|
||||
}
|
||||
}
|
||||
//direction check end
|
||||
//protocol check start
|
||||
Integer protocol= value.getProtocol();
|
||||
if(protocol==null){
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("protocol"))+";");
|
||||
}else{
|
||||
if(specialItem!=null&&("ipsec".equals(specialItem)||"tunnel".equals(specialItem))){
|
||||
if("ipsec".equals(specialItem)){
|
||||
if(action==Constants.DROP_ACTION.intValue()) {
|
||||
boolean has=false;
|
||||
for(SysDataDictionaryItem protocolItem:ipsecProrocolList){
|
||||
if(Integer.parseInt(protocolItem.getItemCode())==protocol.intValue()){
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol"))+";");
|
||||
}
|
||||
}else {
|
||||
if(protocol!=0) {
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol"))+";");
|
||||
}
|
||||
}
|
||||
}else if("tunnel".equals(specialItem)){
|
||||
for(SysDataDictionaryItem protocolItem:tunnelProrocolList){
|
||||
if("default".equals(protocolItem.getItemValue())){
|
||||
if(protocol.intValue()!=Integer.parseInt(protocolItem.getItemCode())){
|
||||
errInfo.append(String.format(prop.getProperty("must_be"), prop.getProperty("protocol"),Integer.parseInt(protocolItem.getItemCode()))+";");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}else{
|
||||
boolean has=false;
|
||||
for(SysDataDictionaryItem protocolItem:protocolList){
|
||||
if(Integer.parseInt(protocolItem.getItemCode())==protocol.intValue()){
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("protocol"))+";");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//protocol check end
|
||||
// requestId check start
|
||||
Integer requestId=value.getRequestId();
|
||||
if(requestId==null){
|
||||
if("whitelistip".equals(specialItem)) {
|
||||
value.setRequestId(0);
|
||||
}else {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("letter"))+";");
|
||||
}
|
||||
|
||||
}else{//查询数据库是否存在ID
|
||||
if("whitelistip".equals(specialItem)) {
|
||||
value.setRequestId(0);
|
||||
}else {
|
||||
RequestInfo info=requestInfoService.getRequestInfoById((long)requestId.intValue());
|
||||
if(info==null){
|
||||
errInfo.append(String.format(prop.getProperty("id_not_exists"),requestId, prop.getProperty("letter"))+";");
|
||||
}else if(info.getIsValid()==Constants.VALID_NO||info.getIsValid()==Constants.VALID_DEL){
|
||||
errInfo.append(String.format(prop.getProperty("id_not_valid"),requestId, prop.getProperty("letter"))+";");
|
||||
}
|
||||
}
|
||||
}
|
||||
// requestId check end
|
||||
//classification check start
|
||||
String classification=value.getClassify();
|
||||
if(StringUtils.isNotBlank(classification)){
|
||||
try{
|
||||
for(String classify:classification.split(",")){
|
||||
if(StringUtils.isNotBlank(classify)){
|
||||
int c=Integer.parseInt(classify);
|
||||
ServiceDictInfo dict=serviceDictInfoService.getDictById(c);
|
||||
if(dict==null){
|
||||
errInfo.append(String.format(prop.getProperty("id_not_exists"),classify, prop.getProperty("classification"))+";");
|
||||
}else if(dict.getIsValid()==Constants.VALID_NO||dict.getIsValid()==Constants.VALID_DEL){
|
||||
errInfo.append(String.format(prop.getProperty("id_not_valid"),classify, prop.getProperty("classification"))+";");
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
errInfo.append(String.format(prop.getProperty("num_split_by_comma"), prop.getProperty("classification"))+";");
|
||||
}
|
||||
}
|
||||
//classification check end
|
||||
//attribute check start
|
||||
String attributes=value.getAttribute();
|
||||
if(StringUtils.isNotBlank(attributes)){
|
||||
try{
|
||||
for(String attribute:attributes.split(",")){
|
||||
if(StringUtils.isNotBlank(attribute)){
|
||||
int c=Integer.parseInt(attribute);
|
||||
ServiceDictInfo dict=serviceDictInfoService.getDictById(c);
|
||||
if(dict==null){
|
||||
errInfo.append(String.format(prop.getProperty("id_not_exists"),attribute, prop.getProperty("attribute"))+";");
|
||||
}else if(dict.getIsValid()==Constants.VALID_NO||dict.getIsValid()==Constants.VALID_DEL){
|
||||
errInfo.append(String.format(prop.getProperty("id_not_valid"),attribute, prop.getProperty("attribute"))+";");
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
errInfo.append(String.format(prop.getProperty("num_split_by_comma"), prop.getProperty("attribute"))+";");
|
||||
}
|
||||
}
|
||||
//attribute check end
|
||||
//attribute check start
|
||||
String labels=value.getLable();
|
||||
if(StringUtils.isNotBlank(labels)){
|
||||
try{
|
||||
for(String label:labels.split(",")){
|
||||
if(StringUtils.isNotBlank(label)){
|
||||
int c=Integer.parseInt(label);
|
||||
ServiceDictInfo dict=serviceDictInfoService.getDictById(c);
|
||||
if(dict==null){
|
||||
errInfo.append(String.format(prop.getProperty("id_not_exists"),label, prop.getProperty("label"))+";");
|
||||
}else if(dict.getIsValid()==Constants.VALID_NO||dict.getIsValid()==Constants.VALID_DEL){
|
||||
errInfo.append(String.format(prop.getProperty("id_not_valid"),label, prop.getProperty("label"))+";");
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
errInfo.append(String.format(prop.getProperty("num_split_by_comma"), prop.getProperty("label"))+";");
|
||||
}
|
||||
}
|
||||
//group and ir_type check start
|
||||
if("ipmulitiplex".equals(specialItem)) {
|
||||
Integer irType= value.getIrType();
|
||||
if(irType==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ir_type"))+";");
|
||||
}else {
|
||||
boolean has=false;
|
||||
for(SysDataDictionaryItem irTypeItem:irTypeList){
|
||||
if(Integer.parseInt(irTypeItem.getItemCode())==irType.intValue()){
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ir_type"))+";");
|
||||
}
|
||||
}
|
||||
Integer dnsStrategyId=value.getDnsStrategyId();
|
||||
if(dnsStrategyId==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("group_name"))+";");
|
||||
}else {
|
||||
PolicyGroupInfo group=policyGroupInfoService.getById(dnsStrategyId.intValue());
|
||||
if(group==null) {
|
||||
errInfo.append(String.format(prop.getProperty("id_not_exists"),dnsStrategyId, prop.getProperty("group_name"))+";");
|
||||
}else if(group.getIsValid()==Constants.VALID_DEL||group.getIsValid()==Constants.VALID_NO) {
|
||||
errInfo.append(String.format(prop.getProperty("id_not_valid"),dnsStrategyId, prop.getProperty("group_name"))+";");
|
||||
}
|
||||
}
|
||||
}
|
||||
if("ipratelimit".equals(specialItem)) {
|
||||
String ratelimit=value.getRatelimit();
|
||||
if(ratelimit==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ratelimit"))+";");
|
||||
}else {
|
||||
try {
|
||||
if(Double.parseDouble(ratelimit)<0||Double.parseDouble(ratelimit)>1) {
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ratelimit_limit"))+";");
|
||||
}
|
||||
}catch (Exception e) {
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ratelimit_limit"))+";");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//attribute check end
|
||||
if(StringUtils.isNotBlank(errInfo.toString())){
|
||||
msg.append(lineStart).append(errInfo);
|
||||
if(line<list.size()){
|
||||
msg.append("<br/>");
|
||||
}
|
||||
}
|
||||
//group and ir_type check end
|
||||
line++;
|
||||
}
|
||||
if(StringUtils.isNotBlank(msg.toString())){
|
||||
throw new MaatConvertException(prop.getProperty("save_failed")+"<br/>"+msg.toString());
|
||||
}*/
|
||||
}
|
||||
|
||||
public void checkIpCfg(int action,int functionId ,List<IpCfgTemplate> list) throws ServiceException{
|
||||
Properties prop=this.getMsgProp();
|
||||
List<SysDataDictionaryItem> ipTypeList = DictUtils.getDictList("IP_TYPE");
|
||||
@@ -1562,4 +2137,97 @@ public class BaseController {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多域导入
|
||||
* @param redirectAttributes
|
||||
* @param files
|
||||
* @param serviceDictId
|
||||
* @param regionDictIds
|
||||
* @param requestId
|
||||
*/
|
||||
public void _import(RedirectAttributes redirectAttributes,MultipartFile[] files
|
||||
,Integer serviceDictId
|
||||
,String regionDictIds
|
||||
,Integer requestId) {
|
||||
try {
|
||||
FunctionServiceDict serviceDict=DictUtils.getFunctionServiceDict(serviceDictId);
|
||||
List<BaseIpCfg> ipPortCfgs=new ArrayList<BaseIpCfg>();
|
||||
List<CfgIndexInfo> cfgIndexInfos=new ArrayList<CfgIndexInfo>();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
MultipartFile file = files[i];
|
||||
ImportExcel ei = new ImportExcel(file, 0, 0);
|
||||
|
||||
FunctionRegionDict regionDict=DictUtils.getFunctionRegionDict(Integer.parseInt(regionDictIds.split(",")[i]));
|
||||
|
||||
if(regionDict.getIsMaat().equals(1)){
|
||||
if(regionDict.getRegionType().equals(1)){
|
||||
List<IpAllTemplate> list = ei.getDataList(IpAllTemplate.class);
|
||||
ipPortCfgs=this.checkIpCfg(serviceDict,regionDict,list);
|
||||
Date date=new Date();
|
||||
for(BaseIpCfg cfg : ipPortCfgs){
|
||||
CfgIndexInfo cfgIndexInfo=new CfgIndexInfo();
|
||||
cfg.setAction(serviceDict.getAction());
|
||||
cfg.setAuditorId(UserUtils.getUser().getId());
|
||||
cfg.setAuditTime(date);
|
||||
cfg.setCfgRegionCode(regionDict.getConfigRegionCode());
|
||||
cfg.setCfgType(regionDict.getConfigRegionValue());
|
||||
cfg.setCreateTime(date);
|
||||
cfg.setCreatorId(UserUtils.getUser().getId());
|
||||
cfg.setDoLog(1);
|
||||
cfg.setFunctionId(regionDict.getFunctionId());
|
||||
cfg.setIsAudit(0);
|
||||
cfg.setIsValid(0);
|
||||
cfg.setIsAreaEffective(0);
|
||||
cfg.setAttribute("0");
|
||||
cfg.setClassify("0");
|
||||
cfg.setLable("0");
|
||||
cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0:requestId);
|
||||
cfg.setServiceId(serviceDict.getServiceId());
|
||||
cfg.setTableName("ip_port_cfg");
|
||||
cfg.setCompileId(ipCfgService.getCompileId());
|
||||
|
||||
BeanUtils.copyProperties(cfg, cfgIndexInfo);
|
||||
cfgIndexInfos.add(cfgIndexInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ipCfgService.saveBatch(ipPortCfgs, IpCfgDao.class);
|
||||
ipCfgService.saveCfgIndexOf(cfgIndexInfos);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
addMessage(redirectAttributes, e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 多域配置导出
|
||||
* @param columns
|
||||
* @param model
|
||||
* @param request
|
||||
* @param response
|
||||
* @param entity
|
||||
* @param ids
|
||||
* @param redirectAttributes
|
||||
*/
|
||||
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";
|
||||
new ExportExcel(msgProp,titleList,noExportMap,classMap,1).setDataList(msgProp,dataMap,map).write(response, fileName).dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user