增加APP策略配置

This commit is contained in:
zhangwei
2018-06-22 18:46:01 +08:00
parent d17ab9f36a
commit 14a0714027
14 changed files with 3687 additions and 1242 deletions

View File

@@ -0,0 +1,130 @@
/**
*@Title: BaseStringConfig.java
*@Package com.nis.domain.restful
*@Description TODO
*@author dell
*@date 2018年2月5日 下午5:26:02
*@version 版本号
*/
package com.nis.domain.configuration;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.nis.util.excel.ExcelField;
/**
* @Description: APP策略配置
* @author (dell)
* @date 2018年2月5日 下午5:26:02
* @version V1.0
*/
public class AppByteCfg extends BaseCfg<AppByteCfg> {
/**
*
*/
private static final long serialVersionUID = -3350695484085989968L;
private static final String tableName="app_byte_cfg";
@Expose
private Integer compileId;
@Expose
private Integer ratelimit;
private String appCode;
private Integer specServiceId;
private String bytes;
private String cfgKeywords;
@Expose
@ExcelField(title="expression_type")
@SerializedName("exprType")
protected Integer exprType ;
@Expose
@ExcelField(title="match_method")
@SerializedName("matchMethod")
protected Integer matchMethod ;
@Expose
@ExcelField(title="whether_hexbinary")
@SerializedName("isHexbin")
protected Integer isHexbin;
public Integer getExprType() {
return exprType;
}
public void setExprType(Integer exprType) {
this.exprType = exprType;
}
public Integer getMatchMethod() {
return matchMethod;
}
public void setMatchMethod(Integer matchMethod) {
this.matchMethod = matchMethod;
}
public Integer getIsHexbin() {
return isHexbin;
}
public void setIsHexbin(Integer isHexbin) {
this.isHexbin = isHexbin;
}
@Override
public void initDefaultValue() {
// TODO Auto-generated method stub
super.initDefaultValue();
this.isHexbin = 0;
}
public Integer getCompileId() {
return compileId;
}
public void setCompileId(Integer compileId) {
this.compileId = compileId;
}
public static String getTablename() {
return tableName;
}
public Integer getRatelimit() {
return ratelimit;
}
public void setRatelimit(Integer ratelimit) {
this.ratelimit = ratelimit;
}
public String getAppCode() {
return appCode;
}
public void setAppCode(String appCode) {
this.appCode = appCode;
}
public Integer getSpecServiceId() {
return specServiceId;
}
public void setSpecServiceId(Integer specServiceId) {
this.specServiceId = specServiceId;
}
public String getBytes() {
return bytes;
}
public void setBytes(String bytes) {
this.bytes = bytes;
}
public String getCfgKeywords() {
return cfgKeywords;
}
public void setCfgKeywords(String cfgKeywords) {
this.cfgKeywords = cfgKeywords;
}
}

View File

@@ -0,0 +1,125 @@
/**
*@Title: BaseStringConfig.java
*@Package com.nis.domain.restful
*@Description TODO
*@author dell
*@date 2018年2月5日 下午5:26:02
*@version 版本号
*/
package com.nis.domain.configuration;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.nis.util.excel.ExcelField;
/**
* @Description: APP策略配置
* @author (dell)
* @date 2018年2月5日 下午5:26:02
* @version V1.0
*/
public class AppDomainCfg extends BaseCfg<AppDomainCfg> {
/**
*
*/
private static final long serialVersionUID = -4685445179478960429L;
private static final String tableName="app_domain_cfg";
@Expose
private Integer compileId;
@Expose
private Integer ratelimit;
private String appCode;
private Integer specServiceId;
private String domain;
private String cfgKeywords;
@Expose
@ExcelField(title="expression_type")
@SerializedName("exprType")
protected Integer exprType ;
@Expose
@ExcelField(title="match_method")
@SerializedName("matchMethod")
protected Integer matchMethod ;
@Expose
@ExcelField(title="whether_hexbinary")
@SerializedName("isHexbin")
protected Integer isHexbin;
public Integer getExprType() {
return exprType;
}
public void setExprType(Integer exprType) {
this.exprType = exprType;
}
public Integer getMatchMethod() {
return matchMethod;
}
public void setMatchMethod(Integer matchMethod) {
this.matchMethod = matchMethod;
}
public Integer getIsHexbin() {
return isHexbin;
}
public void setIsHexbin(Integer isHexbin) {
this.isHexbin = isHexbin;
}
@Override
public void initDefaultValue() {
// TODO Auto-generated method stub
super.initDefaultValue();
this.isHexbin = 0;
}
public Integer getCompileId() {
return compileId;
}
public void setCompileId(Integer compileId) {
this.compileId = compileId;
}
public static String getTablename() {
return tableName;
}
public Integer getRatelimit() {
return ratelimit;
}
public void setRatelimit(Integer ratelimit) {
this.ratelimit = ratelimit;
}
public String getAppCode() {
return appCode;
}
public void setAppCode(String appCode) {
this.appCode = appCode;
}
public Integer getSpecServiceId() {
return specServiceId;
}
public void setSpecServiceId(Integer specServiceId) {
this.specServiceId = specServiceId;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public String getCfgKeywords() {
return cfgKeywords;
}
public void setCfgKeywords(String cfgKeywords) {
this.cfgKeywords = cfgKeywords;
}
}

View File

@@ -0,0 +1,130 @@
/**
*@Title: BaseStringConfig.java
*@Package com.nis.domain.restful
*@Description TODO
*@author dell
*@date 2018年2月5日 下午5:26:02
*@version 版本号
*/
package com.nis.domain.configuration;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.nis.util.excel.ExcelField;
/**
* @Description: APP策略配置
* @author (dell)
* @date 2018年2月5日 下午5:26:02
* @version V1.0
*/
public class AppHttpCfg extends BaseCfg<AppHttpCfg> {
/**
*
*/
private static final long serialVersionUID = 7528723915857911560L;
private static final String tableName="app_http_cfg";
@Expose
private Integer compileId;
@Expose
private Integer ratelimit;
private String appCode;
private Integer specServiceId;
private String district;
private String cfgKeywords;
@Expose
@ExcelField(title="expression_type")
@SerializedName("exprType")
protected Integer exprType ;
@Expose
@ExcelField(title="match_method")
@SerializedName("matchMethod")
protected Integer matchMethod ;
@Expose
@ExcelField(title="whether_hexbinary")
@SerializedName("isHexbin")
protected Integer isHexbin;
public Integer getExprType() {
return exprType;
}
public void setExprType(Integer exprType) {
this.exprType = exprType;
}
public Integer getMatchMethod() {
return matchMethod;
}
public void setMatchMethod(Integer matchMethod) {
this.matchMethod = matchMethod;
}
public Integer getIsHexbin() {
return isHexbin;
}
public void setIsHexbin(Integer isHexbin) {
this.isHexbin = isHexbin;
}
@Override
public void initDefaultValue() {
// TODO Auto-generated method stub
super.initDefaultValue();
this.isHexbin = 0;
}
public Integer getCompileId() {
return compileId;
}
public void setCompileId(Integer compileId) {
this.compileId = compileId;
}
public static String getTablename() {
return tableName;
}
public Integer getRatelimit() {
return ratelimit;
}
public void setRatelimit(Integer ratelimit) {
this.ratelimit = ratelimit;
}
public String getAppCode() {
return appCode;
}
public void setAppCode(String appCode) {
this.appCode = appCode;
}
public Integer getSpecServiceId() {
return specServiceId;
}
public void setSpecServiceId(Integer specServiceId) {
this.specServiceId = specServiceId;
}
public String getDistrict() {
return district;
}
public void setDistrict(String district) {
this.district = district;
}
public String getCfgKeywords() {
return cfgKeywords;
}
public void setCfgKeywords(String cfgKeywords) {
this.cfgKeywords = cfgKeywords;
}
}

View File

@@ -0,0 +1,131 @@
/**
*@Title: BaseStringConfig.java
*@Package com.nis.domain.restful
*@Description TODO
*@author dell
*@date 2018年2月5日 下午5:26:02
*@version 版本号
*/
package com.nis.domain.configuration;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.nis.util.excel.ExcelField;
/**
* @Description: APP策略配置
* @author (dell)
* @date 2018年2月5日 下午5:26:02
* @version V1.0
*/
public class AppInnerRuleCfg extends BaseCfg<AppInnerRuleCfg> {
/**
*
*/
private static final long serialVersionUID = 5620659473745698672L;
private static final String tableName="app_inner_rule_cfg";
@Expose
private Integer compileId;
@Expose
private Integer ratelimit;
private String appCode;
private Integer specServiceId;
private String ruleFile;
private String cfgKeywords;
@Expose
@ExcelField(title="expression_type")
@SerializedName("exprType")
protected Integer exprType ;
@Expose
@ExcelField(title="match_method")
@SerializedName("matchMethod")
protected Integer matchMethod ;
@Expose
@ExcelField(title="whether_hexbinary")
@SerializedName("isHexbin")
protected Integer isHexbin;
public Integer getExprType() {
return exprType;
}
public void setExprType(Integer exprType) {
this.exprType = exprType;
}
public Integer getMatchMethod() {
return matchMethod;
}
public void setMatchMethod(Integer matchMethod) {
this.matchMethod = matchMethod;
}
public Integer getIsHexbin() {
return isHexbin;
}
public void setIsHexbin(Integer isHexbin) {
this.isHexbin = isHexbin;
}
@Override
public void initDefaultValue() {
// TODO Auto-generated method stub
super.initDefaultValue();
this.isHexbin = 0;
}
public Integer getCompileId() {
return compileId;
}
public void setCompileId(Integer compileId) {
this.compileId = compileId;
}
public static String getTablename() {
return tableName;
}
public Integer getRatelimit() {
return ratelimit;
}
public void setRatelimit(Integer ratelimit) {
this.ratelimit = ratelimit;
}
public String getAppCode() {
return appCode;
}
public void setAppCode(String appCode) {
this.appCode = appCode;
}
public Integer getSpecServiceId() {
return specServiceId;
}
public void setSpecServiceId(Integer specServiceId) {
this.specServiceId = specServiceId;
}
public String getRuleFile() {
return ruleFile;
}
public void setRuleFile(String ruleFile) {
this.ruleFile = ruleFile;
}
public String getCfgKeywords() {
return cfgKeywords;
}
public void setCfgKeywords(String cfgKeywords) {
this.cfgKeywords = cfgKeywords;
}
}

View File

@@ -0,0 +1,234 @@
package com.nis.domain.configuration;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* @Description: APP策略配置
* @author (dell)
* @date 2018年2月5日 下午5:26:02
* @version V1.0
*/
public class AppIpCfg extends BaseCfg<AppIpCfg> {
/**
*
*/
private static final long serialVersionUID = 4758285716968228089L;
private static final String tableName="app_ip_cfg";
@Expose
private Integer compileId;
@Expose
private Integer ratelimit;
private String appCode;
private Integer specServiceId;
@Expose
@SerializedName("ipType")
protected Integer ipType;
protected Integer ipPattern;
protected String srcIpAddress;
protected String destIpAddress;
protected Integer portPattern;
protected String srcPort;
protected String destPort;
/**
* 方向
*/
@Expose
@SerializedName("direction")
protected Integer direction ;
/**
* 方向
*/
@Expose
@SerializedName("protocol")
protected Integer protocol ;
/**
* 协议ID
*/
@Expose
@SerializedName("protocolId")
protected Integer protocolId ;
/**
* ipType
* @return ipType
*/
public Integer getIpType() {
return ipType;
}
/**
* @param ipType the ipType to set
*/
public void setIpType(Integer ipType) {
this.ipType = ipType;
}
/**
* direction
* @return direction
*/
public Integer getDirection() {
return direction;
}
/**
* @param direction the direction to set
*/
public void setDirection(Integer direction) {
this.direction = direction;
}
/**
* protocol
* @return protocol
*/
public Integer getProtocol() {
return protocol;
}
/**
* @param protocol the protocol to set
*/
public void setProtocol(Integer protocol) {
this.protocol = protocol;
}
/**
* protocolId
* @return protocolId
*/
public Integer getProtocolId() {
return protocolId;
}
/**
* @param protocolId the protocolId to set
*/
public void setProtocolId(Integer protocolId) {
this.protocolId = protocolId;
}
/**
* ipPattern
* @return ipPattern
*/
public Integer getIpPattern() {
return ipPattern;
}
/**
* @param ipPattern the ipPattern to set
*/
public void setIpPattern(Integer ipPattern) {
this.ipPattern = ipPattern;
}
/**
* portPattern
* @return portPattern
*/
public Integer getPortPattern() {
return portPattern;
}
/**
* @param portPattern the portPattern to set
*/
public void setPortPattern(Integer portPattern) {
this.portPattern = portPattern;
}
/**
* srcIpAddress
* @return srcIpAddress
*/
public String getSrcIpAddress() {
return srcIpAddress;
}
/**
* @param srcIpAddress the srcIpAddress to set
*/
public void setSrcIpAddress(String srcIpAddress) {
this.srcIpAddress = srcIpAddress;
}
/**
* destIpAddress
* @return destIpAddress
*/
public String getDestIpAddress() {
return destIpAddress;
}
/**
* @param destIpAddress the destIpAddress to set
*/
public void setDestIpAddress(String destIpAddress) {
this.destIpAddress = destIpAddress;
}
/**
* srcPort
* @return srcPort
*/
public String getSrcPort() {
return srcPort;
}
/**
* @param srcPort the srcPort to set
*/
public void setSrcPort(String srcPort) {
this.srcPort = srcPort;
}
/**
* destPort
* @return destPort
*/
public String getDestPort() {
return destPort;
}
/**
* @param destPort the destPort to set
*/
public void setDestPort(String destPort) {
this.destPort = destPort;
}
@Override
public void initDefaultValue(){
super.initDefaultValue();
this.direction = 0;
}
public Integer getCompileId() {
return compileId;
}
public void setCompileId(Integer compileId) {
this.compileId = compileId;
}
public static String getTablename() {
return tableName;
}
public Integer getRatelimit() {
return ratelimit;
}
public void setRatelimit(Integer ratelimit) {
this.ratelimit = ratelimit;
}
public String getAppCode() {
return appCode;
}
public void setAppCode(String appCode) {
this.appCode = appCode;
}
public Integer getSpecServiceId() {
return specServiceId;
}
public void setSpecServiceId(Integer specServiceId) {
this.specServiceId = specServiceId;
}
}

View File

@@ -0,0 +1,128 @@
/**
*@Title: BaseStringConfig.java
*@Package com.nis.domain.restful
*@Description TODO
*@author dell
*@date 2018年2月5日 下午5:26:02
*@version 版本号
*/
package com.nis.domain.configuration;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.nis.util.excel.ExcelField;
/**
* @Description: APP策略配置
* @author (dell)
* @date 2018年2月5日 下午5:26:02
* @version V1.0
*/
public class AppPolicyCfg extends BaseCfg<AppPolicyCfg> {
/**
*
*/
private static final long serialVersionUID = -5679998383250783571L;
private static final String tableName="app_policy_cfg";
@Expose
private Integer compileId;
@Expose
private Integer ratelimit;
private String appCode;
private Integer specServiceId;
private String appName;
private String cfgKeywords;
@Expose
@ExcelField(title="expression_type")
@SerializedName("exprType")
protected Integer exprType ;
@Expose
@ExcelField(title="match_method")
@SerializedName("matchMethod")
protected Integer matchMethod ;
@Expose
@ExcelField(title="whether_hexbinary")
@SerializedName("isHexbin")
protected Integer isHexbin;
public Integer getExprType() {
return exprType;
}
public void setExprType(Integer exprType) {
this.exprType = exprType;
}
public Integer getMatchMethod() {
return matchMethod;
}
public void setMatchMethod(Integer matchMethod) {
this.matchMethod = matchMethod;
}
public Integer getIsHexbin() {
return isHexbin;
}
public void setIsHexbin(Integer isHexbin) {
this.isHexbin = isHexbin;
}
@Override
public void initDefaultValue() {
// TODO Auto-generated method stub
super.initDefaultValue();
this.isHexbin = 0;
}
public Integer getCompileId() {
return compileId;
}
public void setCompileId(Integer compileId) {
this.compileId = compileId;
}
public static String getTablename() {
return tableName;
}
public Integer getRatelimit() {
return ratelimit;
}
public void setRatelimit(Integer ratelimit) {
this.ratelimit = ratelimit;
}
public String getAppCode() {
return appCode;
}
public void setAppCode(String appCode) {
this.appCode = appCode;
}
public Integer getSpecServiceId() {
return specServiceId;
}
public void setSpecServiceId(Integer specServiceId) {
this.specServiceId = specServiceId;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getCfgKeywords() {
return cfgKeywords;
}
public void setCfgKeywords(String cfgKeywords) {
this.cfgKeywords = cfgKeywords;
}
}

View File

@@ -20,7 +20,7 @@ import com.google.gson.annotations.SerializedName;
*/
public class AppStringCfg extends BaseStringCfg {
private static final String tableName="app_string_cfg";
/**
* @Fields serialVersionUID:TODO用一句话描述这个变量表示什么
*
@@ -29,6 +29,8 @@ public class AppStringCfg extends BaseStringCfg {
private static final long serialVersionUID = 4938724489988587634L;
@Expose
private Integer compileId;
@Expose
private Integer ratelimit;
/* (non-Javadoc)
* @see com.nis.domain.configuration.BaseCfg#initDefaultValue()
@@ -46,5 +48,17 @@ public class AppStringCfg extends BaseStringCfg {
public void setCompileId(Integer compileId) {
this.compileId = compileId;
}
public static String getTablename() {
return tableName;
}
public Integer getRatelimit() {
return ratelimit;
}
public void setRatelimit(Integer ratelimit) {
this.ratelimit = ratelimit;
}
}

View File

@@ -1,12 +1,12 @@
package com.nis.web.controller.configuration;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
@@ -14,16 +14,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.nis.domain.Page;
import com.nis.domain.ServiceConfigInfo;
import com.nis.domain.SystemServiceInfo;
import com.nis.domain.basics.ServiceDictInfo;
import com.nis.domain.basics.SysDictInfo;
import com.nis.domain.configuration.AppIdCfg;
import com.nis.domain.configuration.BaseCfg;
import com.nis.domain.configuration.RequestInfo;
import com.nis.domain.configuration.AppPolicyCfg;
import com.nis.domain.specific.SpecificServiceCfg;
import com.nis.util.Constants;
import com.nis.exceptions.MaatConvertException;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
/**
* 特定协议相关配置控制类
@@ -31,270 +26,79 @@ import com.nis.web.controller.BaseController;
*
*/
@Controller
@RequestMapping("${adminPath}/cfg/app")
@RequestMapping("${adminPath}/app")
public class AppCfgController extends BaseController {
@RequestMapping(value = {"list"})
public String cfgList(Model model,Integer audit,String cfgName,@ModelAttribute("cfg")AppIdCfg cfg,HttpServletRequest request,HttpServletResponse response) {
model.addAttribute("cfgName", cfgName);
model.addAttribute("audit", audit);
if(cfg!=null){
Integer serviceId=cfg.getServiceId();
logger.info("servcice id is "+serviceId);
if(serviceId!=null){
model.addAttribute("serviceId", serviceId);
List<ServiceConfigInfo> serviceList=serviceConfigInfoService.findList(serviceId);
if(serviceList!=null){
for(ServiceConfigInfo s:serviceList){
if(s.getTableType()==2 || s.getTableType()==4){
model.addAttribute("isContainFeaturesCfg", true);
break;
}
}
Page<AppIdCfg> page = appCfgService.findPage(new Page<AppIdCfg>(request, response,"r"), cfg);
model.addAttribute("page", page);
model.addAttribute("action", cfg.getAction());
List<RequestInfo> requestInfos=requestInfoService.getValidRequestInfo();
model.addAttribute("requestInfos", requestInfos);
List<ServiceDictInfo> fls=serviceDictInfoService.findAllFlDict();
model.addAttribute("fls", fls);
List<ServiceDictInfo> xzs=serviceDictInfoService.findAllXzDict();
model.addAttribute("xzs", xzs);
List<ServiceDictInfo> lables=serviceDictInfoService.findAllLableDict();
model.addAttribute("lables", lables);
SpecificServiceCfg specificServiceCfg = new SpecificServiceCfg();
specificServiceCfg.setIsValid(1);
model.addAttribute("protocolList",specificServiceCfgService.findAllSpecificServiceCfg(specificServiceCfg,"spec_service_id DESC"));
}else{
logger.error("未获取到正确的serviceId");
}
}
}
return "/cfg/appCfgList";
}
@RequestMapping(value = {"form"})
public String cfgForm(int action,String cfgName,Integer serviceId,Model model,HttpServletRequest request,HttpServletResponse response) {
model.addAttribute("action", action);
model.addAttribute("serviceId", serviceId);
model.addAttribute("audit", Constants.CFG_PAGE);
model.addAttribute("cfgName", cfgName);
logger.info("sercice id is "+serviceId);
// SystemServiceInfo serviceInfo=systemServiceService.get(serviceId);
// model.addAttribute("serviceInfo", serviceInfo);
//来函信息
List<RequestInfo> requestInfos=requestInfoService.getValidRequestInfo();
model.addAttribute("requestInfos", requestInfos);
//分类信息
List<ServiceDictInfo> fls=serviceDictInfoService.findFlDict();
model.addAttribute("fls", fls);
//性质信息
List<ServiceDictInfo> xzs=serviceDictInfoService.findXzDict();
model.addAttribute("xzs", xzs);
//标签信息
List<ServiceDictInfo> lables=serviceDictInfoService.findLableDict();
model.addAttribute("lables", lables);
//特定服务信息
SpecificServiceCfg specificServiceCfg = new SpecificServiceCfg();
specificServiceCfg.setIsValid(1);
model.addAttribute("protocolList",specificServiceCfgService.findAllSpecificServiceCfg(specificServiceCfg,"spec_service_id DESC"));
//协议特征配置
List<ServiceConfigInfo> featuresList = serviceConfigInfoService.findList(serviceId);
model.addAttribute("featuresList",featuresList);
if(featuresList!=null){
for(ServiceConfigInfo s:featuresList){
if(s.getTableType()==2 || s.getTableType()==4){
model.addAttribute("isContainFeaturesCfg", true);
break;
}
}
}
//特征作用域信息
/*SysDictInfo sysDictInfo = new SysDictInfo();
sysDictInfo.setItemType(3);
Integer[] itType = new Integer[0];
List<SysDictInfo> featuresAreaList = sysDictInfoService.findAllSysDictInfo(sysDictInfo,itType,null);
model.addAttribute("featuresAreaList", featuresAreaList);*/
AppIdCfg cfg = new AppIdCfg();
cfg.initDefaultValue();
cfg.setAction(action);
cfg.setServiceId(serviceId.intValue());
model.addAttribute("_cfg", cfg);
return "/cfg/appCfgForm";
}
@RequestMapping(value = {"updateForm"})
public String updateAppCfgForm(int action,long cfgId,String cfgName,Integer serviceId,Model model,HttpServletRequest request,HttpServletResponse response) {
model.addAttribute("cfgName", cfgName);
model.addAttribute("serviceId", serviceId);
model.addAttribute("action", action);
model.addAttribute("audit", Constants.CFG_PAGE);
AppIdCfg searchBean=new AppIdCfg();
searchBean.setCfgId(cfgId);
AppIdCfg cfg=appCfgService.getAppCfgById(searchBean);
model.addAttribute("_cfg", cfg);
List<RequestInfo> requestInfos=requestInfoService.getAllRequestInfo();
model.addAttribute("requestInfos", requestInfos);
List<ServiceDictInfo> fls=serviceDictInfoService.findAllFlDict();
model.addAttribute("fls", fls);
List<ServiceDictInfo> xzs=serviceDictInfoService.findAllXzDict();
model.addAttribute("xzs", xzs);
List<ServiceDictInfo> lables=serviceDictInfoService.findAllLableDict();
model.addAttribute("lables", lables);
//特定服务信息
SpecificServiceCfg specificServiceCfg = new SpecificServiceCfg();
specificServiceCfg.setIsValid(1);
model.addAttribute("protocolList",specificServiceCfgService.findAllSpecificServiceCfg(specificServiceCfg,"spec_service_id DESC"));
//协议特征配置
List<ServiceConfigInfo> featuresList = serviceConfigInfoService.findList(serviceId);
model.addAttribute("featuresList",featuresList);
return "/cfg/appCfgForm";
}
@RequestMapping(value = {"showFeaturesCfg"})
public String showFeaturesCfg(int action,long cfgId,Integer compileId,String cfgName,Integer serviceId,Model model,HttpServletRequest request,HttpServletResponse response){
AppIdCfg cfg=new AppIdCfg();
cfg.setCfgId(cfgId);
cfg.setCompileId(compileId);
cfg = appCfgService.findAppIdCfg(cfg);
model.addAttribute("_cfg", cfg);
model.addAttribute("cfgName", cfgName);
model.addAttribute("serviceId", serviceId);
model.addAttribute("action", action);
//协议特征配置
List<ServiceConfigInfo> featuresList = serviceConfigInfoService.findList(serviceId);
model.addAttribute("featuresList",featuresList);
return "/cfg/appFeaturesCfg";
}
/**
*
* addAppCfg(新增IP配置)
* (这里描述这个方法适用条件 可选)
* @return
*String
* @exception
* @since 1.0.0
* app策略列表
* @param model
* @param cfg
* @param request
* @param response
* @return
*/
@RequestMapping(value = {"saveOrUpdateCfg"})
public String saveOrUpdateAppCfg(String cfgName,Model model, AppIdCfg cfg) {
model.addAttribute("audit", Constants.CFG_PAGE);
model.addAttribute("cfgType","app");
model.addAttribute("cfgName",cfgName);
model.addAttribute("serviceId",cfg.getServiceId());
model.addAttribute("action",cfg.getAction());
logger.info("saveOrUpdateAppCfg loaded");
if(cfg==null){
logger.error("无法保存空的配置!");
addMessage(model,"save_failed");
@RequestMapping(value = {"policyList"})
public String policyList(Model model,@ModelAttribute("cfg")AppPolicyCfg cfg,HttpServletRequest request,HttpServletResponse response) {
Page<AppPolicyCfg> searchPage=new Page<AppPolicyCfg>(request,response,"r");
Page<AppPolicyCfg> page = appCfgService.findAppPolicyList(searchPage, cfg);
for(AppPolicyCfg entity:page.getList()){
SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
entity.setAppName(app.getSpecServiceName());
}
model.addAttribute("page", page);
initPageCondition(model,cfg);
return "/cfg/app/appPolicyCfgList";
}
@RequestMapping(value = {"policyForm"})
@RequiresPermissions(value={"app:policy:config"})
public String policyForm(Model model,String ids,AppPolicyCfg entity) {
if(StringUtils.isNotBlank(ids)){
entity = appCfgService.getAppPolicyCfg(Long.parseLong(ids));
initUpdateFormCondition(model,entity);
}else{
SpecificServiceCfg protocol = specificServiceCfgService.getBySpecServiceId(cfg.getAppId().intValue());
if(protocol!=null){
cfg.setAppName(protocol.getSpecServiceName());
int serviceId=cfg.getServiceId();
cfg.setIsValid(Constants.VALID_NO);
cfg.setIsAudit(Constants.AUDIT_NOT_YET);
if(cfg.getCfgId()==null){
cfg.setCreatorId(cfg.getCurrentUser().getId());
cfg.setCreateTime(new Date());
try {
appCfgService.addAppCfg(cfg);
} catch (Exception e) {
e.printStackTrace();
logger.error("配置保存失败!"+e.getMessage());
addMessage(model,"save_failed");
}
}else{
cfg.setEditorId(cfg.getCurrentUser().getId());
cfg.setEditTime(new Date());
try {
appCfgService.updateAppCfg(cfg);
} catch (Exception e) {
e.printStackTrace();
logger.error("配置保存失败!"+e.getMessage());
addMessage(model,"save_failed");
}
}
model.addAttribute("serviceId",serviceId);
model.addAttribute("action",cfg.getAction());
addMessage(model,"save_success");
}else{
logger.error("所选协议信息无效!");
addMessage(model,"save_failed");
}
initFormCondition(model,entity);
}
return "/cfg/resultPage";//StringEscapeUtils.escapeHtml4("?serviceId="+cfg.getServiceId()+"&action="+cfg.getAction()+"&cfgName="+cfgName);
model.addAttribute("_cfg", entity);
return "/cfg/app/appPolicyCfgForm";
}
/**
*
* auditAppCfg(审核IP配置)
* (这里描述这个方法适用条件 可选)
* @return
*String
* @exception
* @since 1.0.0
*/
@RequestMapping(value = {"auditCfg"})
public String auditAppCfg(String cfgName,String ids,Integer auditState,Integer serviceId,Integer action,
Model model,RedirectAttributes redirectAttributes) {
model.addAttribute("cfgName", cfgName);
model.addAttribute("audit", Constants.AUDIT_PAGE);
model.addAttribute("serviceId", serviceId);
model.addAttribute("action",action);
model.addAttribute("cfgType","app");
@RequestMapping(value = {"saveAppPolicyCfg"})
@RequiresPermissions(value={"app:policy:config"})
public String saveAppPolicyCfg(Model model,HttpServletRequest request,HttpServletResponse response,
AppPolicyCfg entity,RedirectAttributes redirectAttributes) {
try {
String[] cfgIds = ids.split(",");
int result=appCfgService.auditAppCfg(cfgIds,auditState);
if(result==1){
addMessage(model,"audit_success");
}else{
addMessage(model,"audit_failed");
}
appCfgService.saveOrUpdateAppPolicyCfg(entity);
} catch (Exception e) {
e.printStackTrace();
logger.error("配置下发maat失败"+e.getMessage());
addMessage(model,"audit_failed");
addMessage(redirectAttributes, e.getMessage());
}
return "/cfg/resultPage";
return "redirect:" + adminPath +"/app/policyList?function="+entity.getFunctionId();
}
/**
*
* auditAppCfg(删除IP配置逻辑删除)
* (这里描述这个方法适用条件 可选)
* @return
*String
* @exception
* @since 1.0.0
*/
@RequestMapping(value = {"deleteCfg"})
public String deleteAppCfg(int action,String ids,String cfgName,Integer serviceId,Model model,RedirectAttributes redirectAttributes) {
model.addAttribute("serviceId", serviceId);
model.addAttribute("cfgName", cfgName);
model.addAttribute("action", action);
model.addAttribute("cfgType","app");
model.addAttribute("audit", Constants.CFG_PAGE);
String[] cfgIds = ids.split(",");
int result=appCfgService.deleteAppCfg(cfgIds);
if(result==1){
addMessage(redirectAttributes,"delete_success");
}else{
addMessage(redirectAttributes,"delete_failed");
@RequestMapping(value = {"auditAppPolicyCfg"})
@RequiresPermissions(value={"app:policy:audit"})
public String auditAppPolicyCfg(Integer isAudit,Integer isValid,String ids,Integer functionId, RedirectAttributes redirectAttributes) {
AppPolicyCfg entity = new AppPolicyCfg();
String[] idArray = ids.split(",");
for(String id :idArray){
entity = appCfgService.getAppPolicyCfg(Long.parseLong(id));
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setAuditorId(UserUtils.getUser().getId());
entity.setAuditTime(new Date());
entity.setFunctionId(functionId);
try {
appCfgService.auditAppPolicyCfg(entity,isAudit);
} catch (MaatConvertException e) {
e.printStackTrace();
logger.info("app策略配置下发失败"+e.getMessage());
addMessage(redirectAttributes, e.getMessage());
}
}
return "/cfg/resultPage";
return "redirect:" + adminPath +"/app/policyList?functionId="+functionId;
}
/**
*
* getCompileId(获取编译ID)
* (这里描述这个方法适用条件 可选)
* @return
*long
* @exception
* @since 1.0.0
*/
protected Integer getCompileId(BaseCfg cfg){
return 0;
@RequestMapping(value = {"updateAppPolicyCfgValid"})
@RequiresPermissions(value={"app:policy:config"})
public String updateAppPolicyCfgValid(Integer isValid,String ids,Integer functionId) {
appCfgService.updateAppPolicyCfgValid(isValid,ids,functionId);
return "redirect:" + adminPath +"/app/policyList?functionId="+functionId;
}
}

View File

@@ -5,10 +5,17 @@ import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.nis.domain.configuration.AppByteCfg;
import com.nis.domain.configuration.AppComplexKeywordCfg;
import com.nis.domain.configuration.AppDomainCfg;
import com.nis.domain.configuration.AppHttpCfg;
import com.nis.domain.configuration.AppIdCfg;
import com.nis.domain.configuration.AppIdCfg.AppFeaturesIndex;
import com.nis.domain.configuration.AppInnerRuleCfg;
import com.nis.domain.configuration.AppIpCfg;
import com.nis.domain.configuration.AppPolicyCfg;
import com.nis.domain.configuration.AppStringCfg;
import com.nis.domain.configuration.BaseCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.web.dao.CrudDao;
@@ -21,27 +28,39 @@ import com.nis.web.dao.MyBatisDao;
*
*/
@MyBatisDao
public interface AppCfgDao extends CrudDao<AppIdCfg> {
public AppIdCfg getById(@Param("cfgId")Long id) ;
public AppIdCfg get(AppIdCfg entity) ;
public List<AppIdCfg> findList(AppIdCfg entity) ;
public int insert(AppIdCfg entity) ;
public int updateByPrimaryKeySelective(AppIdCfg entity) ;
public int updateValid(AppIdCfg entity) ;
public int audit(AppIdCfg entity) ;
public int updateFeaturesTableValid(@Param("tableName")String tableName,@Param("compileId")Integer compileId,
@Param("isValid")Integer isValid,@Param("editorId")Long editorId,@Param("editTime")Date editTime) ;
public int auditFeaturesTable(@Param("tableName")String tableName,@Param("compileId")Integer compileId,
@Param("isValid")Integer isValid,@Param("isAudit")Integer isAudit,
@Param("auditorId")Long auditorId,@Param("auditTime")Date auditTime) ;
public int getIsValid(@Param("tableName")String tableName,@Param("cfgId")Long id);
public int getIsValid(@Param("cfgId")Long id);
public int getIsAudit(@Param("tableName")String tableName,@Param("cfgId")Long id);
public int getIsAudit(@Param("cfgId")Long id);
public List<AppFeaturesIndex> getFeaturesTableListByAppCompileId(@Param("appCompileId")Integer appCompileId) ;
public int insertFeatures(AppFeaturesIndex entity) ;
public int updateFeaturesByAppId(AppFeaturesIndex entity) ;
public int deleteFeaturesByAppId(AppFeaturesIndex entity) ;
public List<AppComplexKeywordCfg> getComplexkeywordFeaturesCfgListByCompileId(@Param("featuresTable") String featuresTable,@Param("compileId")Integer compileId);
public List<AppStringCfg> getStrFeaturesCfgListByCompileId(@Param("featuresTable") String featuresTable,@Param("compileId")Integer compileId);
public interface AppCfgDao {
//app策略配置增删改查
public List<AppPolicyCfg> findAppPolicyList(AppPolicyCfg entity) ;
public AppPolicyCfg getAppPolicyCfg(Long cfgId) ;
public int insertAppPolicyCfg(AppPolicyCfg entity);
public int updateAppPolicyCfg(AppPolicyCfg entity);
//app协议IP配置增删改查
public List<AppIpCfg> findAppIpList(AppIpCfg entity) ;
public AppIpCfg getAppIpCfg(Long cfgId) ;
public int insertAppIpCfg(AppIpCfg entity);
public int updateAppIpCfg(AppIpCfg entity);
//app http特征增删改查
public List<AppHttpCfg> findAppHttpList(AppHttpCfg entity) ;
public AppHttpCfg getAppHttpCfg(Long cfgId) ;
public int insertAppHttpCfg(AppHttpCfg entity);
public int updateAppHttpCfg(AppHttpCfg entity);
//app 域名配置增删改查
public List<AppDomainCfg> findAppDomainList(AppDomainCfg entity) ;
public AppDomainCfg getAppDomainCfg(Long cfgId) ;
public int insertAppDomainCfg(AppDomainCfg entity);
public int updateAppDomainCfg(AppDomainCfg entity);
//app 字节特征增删改查
public List<AppByteCfg> findAppByteList(AppByteCfg entity) ;
public AppByteCfg getAppByteCfg(Long cfgId) ;
public int insertAppByteCfg(AppByteCfg entity);
public int updateAppByteCfg(AppByteCfg entity);
//app内置文件增删改查
public List<AppInnerRuleCfg> findAppInnerRuleList(AppInnerRuleCfg entity) ;
public AppInnerRuleCfg getAppInnerRuleCfg(Long cfgId) ;
public int insertAppInnerRuleCfg(AppInnerRuleCfg entity);
public int updateAppInnerRuleCfg(AppInnerRuleCfg entity);
//审核配置
public void auditCfg(BaseCfg entity);
//修改配置状态
public void updateCfgValid(BaseCfg entity);
}

File diff suppressed because it is too large Load Diff

View File

@@ -580,13 +580,16 @@ public abstract class BaseService {
}
}
public static String keywordsEscape(String cfgKeywords){
//不转译特殊字符
cfgKeywords = StringEscapeUtils.unescapeHtml4(cfgKeywords);
cfgKeywords=cfgKeywords.replace("\\", "\\\\");
cfgKeywords=cfgKeywords.replace("&", "\\&");
cfgKeywords=cfgKeywords.replace(" ", "\\b");
//***and***在界面表示多个关键字的与表达式此特殊字符串在common.js中使用定义maat端以&表示
cfgKeywords=cfgKeywords.replace(Constants.KEYWORD_EXPR, "&");
if(StringUtils.isNotEmpty(cfgKeywords)){
//不转译特殊字符
cfgKeywords = StringEscapeUtils.unescapeHtml4(cfgKeywords);
cfgKeywords=cfgKeywords.replace("\\", "\\\\");
cfgKeywords=cfgKeywords.replace("&", "\\&");
cfgKeywords=cfgKeywords.replace(" ", "\\b");
//***and***在界面表示多个关键字的与表达式此特殊字符串在common.js中使用定义maat端以&表示
cfgKeywords=cfgKeywords.replace(Constants.KEYWORD_EXPR, "&");
}
return cfgKeywords;
}
}