66 Commits

Author SHA1 Message Date
段冬梅
0d6dd1352d 20190508升级sql内容 2019-07-03 14:49:10 +08:00
duandongmei
883a7e46f1 综合服务修改接口未上线前,修改恢复为INSERT_ACTION动作 2019-05-19 11:21:47 +08:00
段冬梅
a4d8bd11e8 Update README.md 2019-05-16 11:44:35 +08:00
段冬梅
a941afae72 Update README.md 2019-05-13 13:34:46 +08:00
wangwei
04c12c67ae 更新俄文国际化配置文件
Conflicts:
	src/main/resources/messages/message_ru.properties
2019-05-06 10:41:12 +08:00
duandongmei
06d08fce4e SSL配置取消失败BUG; 2019-05-06 09:47:03 +08:00
duandongmei
af926a7a37 帮助文档的内容显示有row-10修改为row-9 2019-05-05 13:33:26 +08:00
duandongmei
4845198a76 中文、俄文国际化缺失补充 2019-05-05 11:43:56 +08:00
duandongmei
1060a5f85e 恢复之前的定时任务配置取消不走综合服务的问题;
去掉英文国际化的合并记录
2019-05-05 11:02:11 +08:00
duandongmei
148c18e943 经确认,定时任务配置失效可直接使用配置正常的失效接口。 2019-05-05 10:07:51 +08:00
duandongmei
e0d7ad06ef 定时任务的接口调用恢复之前的停启用接口 2019-05-04 17:36:00 +08:00
段冬梅
516ea7e653 schedual use startStopService 2019-05-03 16:02:16 +08:00
duandongmei
beb45e5059 代理帮助文档增加文件名 2019-05-03 16:02:05 +08:00
duandongmei
6af0b7b3b6 代理的拦截和控制策略配置取消增加配置状态判断 2019-05-03 10:26:51 +08:00
duandongmei
9f4eb23b8c 代理最新帮助文档sql及帮助文档md文件提交 2019-05-02 20:50:28 +08:00
duandongmei
0704e85a9f 审核角色自动添加审核菜单;
审核角色禁止修改角色名称
2019-04-30 11:34:08 +08:00
wangwei
d6866b7407 添加零时表单的移除 2019-04-30 09:34:44 +08:00
wangxin
f7f2d5ad1b 优化galaxyMessageFormat中的json解析速度,使用fastjson替换JSONObject 2019-04-30 09:34:40 +08:00
duandongmei
d5b790f3a3 system.err打印换成log.info 2019-04-29 10:49:26 +08:00
wangxin
37c032d7a4 优化导出速度 2019-04-29 10:45:47 +08:00
duandongmei
8f524daa01 配置统计增加配置审核时间 2019-04-29 10:11:33 +08:00
段冬梅
89c8dbefc7 IP spoofing pool定时任务修改时只改is_valid状态,is_audit默认为1 2019-04-29 09:52:02 +08:00
wangwei
8828d88584 修复Anti DDOS修改定时任务选项展示 2019-04-29 09:17:47 +08:00
wangwei
8c5b78d165 修正抗ddos攻击修改时多余提示信息 2019-04-28 18:00:26 +08:00
段冬梅
92605e323e 恢复ip和代理模块审核方法中二次查询域信息代码,避免同一种域允许新增多个的问题 2019-04-28 12:05:50 +08:00
zhangwenqing
38d1fb5a82 修正saveAndAudit角色用户新增SSL配置失败bug 2019-04-28 12:05:39 +08:00
duandongmei
3910bcb4e1 证书验证公私钥不匹配
Conflicts:
	src/main/resources/messages/message_en.properties
	src/main/resources/messages/message_ru.properties
	src/main/resources/messages/message_zh_CN.properties
2019-04-27 19:02:26 +08:00
shangguanyanfei
ad5e517f23 定时器公共页面-长期选项,增加开始时间不能小于当前时间加上2分钟的验证 2019-04-27 19:01:01 +08:00
李皓宸
5f36272250 捕捉异常后增加记录异常日志的操作 2019-04-26 17:47:31 +08:00
李皓宸
ac524ee76f 修复系统日志中异常日志显示不全的问题 2019-04-26 17:44:03 +08:00
wangwei
f5a4d31498 修改配置导出文件名乱码问题 2019-04-26 17:43:29 +08:00
duandongmei
6b55ae266f IP Spoofing增加定时任务ipPool状态变更BUG更改;
IP Spoofing取消状态的配置修改,ippool状态更改
2019-04-26 16:55:41 +08:00
shangguanyanfei
8b1258e06e 报表统计-事件报表-时间查询条件范围更改为一个月 2019-04-26 16:11:43 +08:00
wangwei
cb98f7c7fb 修复IP Spoofing失效下发至服务端 2019-04-26 16:04:49 +08:00
shangguanyanfei
754d82e9f4 音频样例配置下发,源文件时长不能超过120s的错误信息提示 2019-04-26 16:02:58 +08:00
wangwei
fdb270e0ff 修复 IP Spoofing定时任务配置相关表数据状态不同步 2019-04-26 15:56:43 +08:00
duandongmei
8c199d8be4 ddos定时任务修改 2019-04-26 15:42:39 +08:00
duandongmei
3ae64f6645 修复VOIP新增成功无数据BUG 2019-04-25 16:59:22 +08:00
duandongmei
b12a74e27f ip地址增加必选一种域配置的提示 2019-04-25 16:02:18 +08:00
shangguanyanfei
627dc7661c 监测、统计时间查询条件范围更改为一个月,通联日志为一天 2019-04-25 15:25:30 +08:00
duandongmei
826543d5ba 此版本不打开批量 2019-04-25 15:08:55 +08:00
wangwei
d7ceba7e5c 取消视频添加阻默认阻断动作下置信度显示 2019-04-25 14:32:07 +08:00
zhangwenqing
2c19901ef8 修正回调类配置批量取消失败问题 2019-04-25 14:30:53 +08:00
段冬梅
a540ad577e 俄文OK翻译;
定时任务错误信息打印;
恢复白名单被覆盖的logger.error;
2019-04-25 14:29:32 +08:00
wangwei
c2f07c514f 修正导出逻辑判断关键词 2019-04-25 14:29:01 +08:00
段冬梅
ba141e1a5d 修复加密隧道协议不显示定时任务图标BUG;
修复批量之后无法查询所有状态数据bug
2019-04-25 14:25:13 +08:00
wangwei
aa465f5fd5 修正导出条件逻辑判断 2019-04-25 14:24:16 +08:00
李皓宸
752386dd28 撤销国际化的修改
Conflicts:
	src/main/resources/messages/message_en.properties
2019-04-25 14:23:50 +08:00
李皓宸
b76dc62cbb 1.添加了部分菜单的中英文国际化
2.业务配置的流媒体审核异常已解决

Conflicts:
	src/main/resources/messages/message_en.properties
2019-04-25 14:22:24 +08:00
wangwei
001b8948bd 修改文件导出改为post传参;修复拦截修复策略必选属性为空不提示问题 2019-04-25 14:20:53 +08:00
wangwei
cd114c263d 删除测试代码 2019-04-25 14:20:31 +08:00
zhangwenqing
cd4bd32b3f 修正(saveAndAudit)角色用户新增配置出现保护名单提示后无法提交bug 2019-04-25 14:19:53 +08:00
wangwei
6f83f45d6e 修改导出遮罩层显示时间:处理完成时关闭 2019-04-25 14:18:57 +08:00
zhangwenqing
ba151692c0 补充提交. 2019-04-25 14:18:18 +08:00
duandongmei
3b98511c29 增加ip模板的的包导入 2019-04-25 14:17:59 +08:00
zhangwenqing
007416034f IPSpoofing配置批量审核操作增加欺骗IP池配置处理,修正图片样例批量审核功能 2019-04-25 14:16:11 +08:00
wangxin
db040c2752 (1)删除调用switchIpType方法的页面相关代码
(2)Stream列表页面展示表单Block,ratelimt有定时任务没有IP时的错位问题
2019-04-25 14:13:55 +08:00
wangxin
45a99aa7ab 添加谓语 2019-04-25 14:12:41 +08:00
wangxin
9cc00beaae 调整定时任务开始时间比当前时间至少早两分钟翻译 2019-04-25 14:12:06 +08:00
duandongmei
3016a82c17 修复ddos定时任务界面BUG;
修复基础协议定时任务图标不显示bug;
所有业务增加定时任务逻辑

Conflicts:
	src/main/java/com/nis/web/service/configuration/AvContentCfgService.java
2019-04-25 14:10:13 +08:00
duandongmei
7fdd0f7568 白名单增加定时任务处理;
修复白名单热修改被覆盖jsp

Conflicts:
	src/main/java/com/nis/web/service/configuration/IpCfgService.java
	src/main/resources/sql/20190417/extends_ip_port_pattern.sql
2019-04-25 13:36:48 +08:00
段冬梅
6bcb9d6fd6 白名单增加各个操作的定时任务处理;
各种批量操作增加定时任务的处理;
2019-04-25 13:29:08 +08:00
duandongmei
bf3921c9e0 5b63b023合并 2019-04-25 13:24:14 +08:00
段冬梅
00acc9c94a 白名单增加各个操作的定时任务处理
各种批量操作增加定时任务的处理
2019-04-25 13:18:17 +08:00
zhangwenqing
c982b506a4 修正保护名单配置回车不提示、重复数据问题
Conflicts:
	src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_en.js
	src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_ru.js
	src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_zh.js
2019-04-25 11:35:51 +08:00
shangguanyanfei
aaa0028cbb stream、DDOS和高级功能模块对某些用户的配置不经过审核直接生效及生效中的配置进行修改的功能 2019-04-25 11:27:53 +08:00
424 changed files with 10115 additions and 63792 deletions

View File

@@ -1,7 +1,18 @@
630上线内容版本 5.8号升级版本
1、统计整合为一个模块儿 1、系统支持单独配置 SubscribeID即仅使用SubscribeID作为配置条件进行监测或者封堵无需与其它条件组合
2、object-list-group HTTP和代理
3、代理新功能 2、系统增加配置30个用户并发进行导入每次导入不超过2w条 。
3、系统增加saveAndAudit角色拥有该角色的用户新增配置配置不经过审核流程直接生效。
4、日志页面单次可以下载2万条以内的日志
5、支持监测、统计志查询条件扩展到1个月 通联日志只能是1天
6、配置 页面支持按照配置 id进行查询支持配置 id输入方式为 10-15101315

View File

@@ -20,14 +20,12 @@ public class AsnIpCfg extends BaseCfg<AsnIpCfg> {
@ExcelField(title="ip_type",dictType="IP_TYPE",sort=6) @ExcelField(title="ip_type",dictType="IP_TYPE",sort=6)
@SerializedName("ipType") @SerializedName("ipType")
private Integer ipType; private Integer ipType;
private Integer srcIpPattern; @ExcelField(title="ip_pattern",dictType="IP_PATTERN",sort=8)
@ExcelField(title="dest_ip_pattern",dictType="IP_PATTERN",sort=8) private Integer ipPattern;
private Integer destIpPattern;
private String srcIpAddress; private String srcIpAddress;
@ExcelField(title="ip",sort=7) @ExcelField(title="ip",sort=7)
private String destIpAddress; private String destIpAddress;
private Integer srcPortPattern; private Integer portPattern;
private Integer destPortPattern;
private String srcPort; private String srcPort;
private String destPort; private String destPort;
//@ExcelField(title="group",sort=2) //@ExcelField(title="group",sort=2)
@@ -119,30 +117,11 @@ public class AsnIpCfg extends BaseCfg<AsnIpCfg> {
public void setIpType(Integer ipType) { public void setIpType(Integer ipType) {
this.ipType = ipType; this.ipType = ipType;
} }
public Integer getIpPattern() {
public Integer getSrcIpPattern() { return ipPattern;
return srcIpPattern;
} }
public void setSrcIpPattern(Integer srcIpPattern) { public void setIpPattern(Integer ipPattern) {
this.srcIpPattern = srcIpPattern; this.ipPattern = ipPattern;
}
public Integer getDestIpPattern() {
return destIpPattern;
}
public void setDestIpPattern(Integer destIpPattern) {
this.destIpPattern = destIpPattern;
}
public Integer getSrcPortPattern() {
return srcPortPattern;
}
public void setSrcPortPattern(Integer srcPortPattern) {
this.srcPortPattern = srcPortPattern;
}
public Integer getDestPortPattern() {
return destPortPattern;
}
public void setDestPortPattern(Integer destPortPattern) {
this.destPortPattern = destPortPattern;
} }
public String getSrcIpAddress() { public String getSrcIpAddress() {
return srcIpAddress; return srcIpAddress;
@@ -156,6 +135,12 @@ public class AsnIpCfg extends BaseCfg<AsnIpCfg> {
public void setDestIpAddress(String destIpAddress) { public void setDestIpAddress(String destIpAddress) {
this.destIpAddress = destIpAddress; this.destIpAddress = destIpAddress;
} }
public Integer getPortPattern() {
return portPattern;
}
public void setPortPattern(Integer portPattern) {
this.portPattern = portPattern;
}
public String getSrcPort() { public String getSrcPort() {
return srcPort; return srcPort;
} }
@@ -191,10 +176,9 @@ public class AsnIpCfg extends BaseCfg<AsnIpCfg> {
} }
@Override @Override
public String toString() { public String toString() {
return "AsnIpCfg [regionId=" + regionId + ", ratelimit=" + ratelimit + ", ipType=" + ipType + ", srcIpPattern=" return "AsnIpCfg [regionId=" + regionId + ", ratelimit=" + ratelimit + ", ipType=" + ipType + ", ipPattern="
+ srcIpPattern + ", destIpPattern="+ destIpPattern+ ", srcIpAddress=" + srcIpAddress + ", destIpAddress=" + ipPattern + ", srcIpAddress=" + srcIpAddress + ", destIpAddress=" + destIpAddress + ", portPattern="
+ destIpAddress + ", srcPortPattern="+ srcPortPattern+", destPortPattern="+ destPortPattern + ", srcPort=" + portPattern + ", srcPort=" + srcPort + ", destPort=" + destPort + ", asnIpGroupName=" + asnIpGroupName
+ srcPort + ", destPort=" + destPort + ", asnIpGroupName=" + asnIpGroupName
+ ", asnIpGroup=" + asnIpGroup + ", direction=" + direction + ", protocol=" + protocol + ", protocolId=" + ", asnIpGroup=" + asnIpGroup + ", direction=" + direction + ", protocol=" + protocol + ", protocolId="
+ protocolId + ", compileId=" + compileId + ", isValid=" + isValid + ", userRegion1=" + userRegion1 + protocolId + ", compileId=" + compileId + ", isValid=" + isValid + ", userRegion1=" + userRegion1
+ ", userRegion2=" + userRegion2 + ", userRegion3=" + userRegion3 + ", userRegion4=" + userRegion4 + ", userRegion2=" + userRegion2 + ", userRegion3=" + userRegion3 + ", userRegion4=" + userRegion4

View File

@@ -1,74 +0,0 @@
package com.nis.domain.basics;
import java.io.Serializable;
import java.util.Date;
import com.nis.domain.configuration.BaseCfg;
import com.nis.util.excel.ExcelField;
/**
* 公共分组实体
*/
public class CommonGroupInfo extends BaseCfg<CommonGroupInfo> implements Serializable{
/**
*
*/
private static final long serialVersionUID = 7931466570918016654L;
private Integer groupId;
@ExcelField(title="group_name",sort=1)
private String groupName;
@ExcelField(title="group_type",dictType="GROUP_TYPE",sort=2)
private Integer groupType;
private Integer serviceGroupId;
@ExcelField(title="desc",sort=4)
private String description;
public Integer getServiceGroupId() {
return serviceGroupId;
}
public void setServiceGroupId(Integer serviceGroupId) {
this.serviceGroupId = serviceGroupId;
}
public Integer getGroupId() {
return groupId;
}
public void setGroupId(Integer groupId) {
this.groupId = groupId;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getEditTime() {
return editTime;
}
public void setEditTime(Date editTime) {
this.editTime = editTime;
}
public Integer getGroupType() {
return groupType;
}
public void setGroupType(Integer groupType) {
this.groupType = groupType;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

View File

@@ -1,67 +0,0 @@
package com.nis.domain.basics;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.util.excel.ExcelField;
public class DomainCommCfg extends BaseStringCfg<DomainCommCfg>{
private static final long serialVersionUID = 5117517145731135023L;
private static final String tableName="domain_comm_cfg";
@ExcelField(title="key_word",sort=3)
protected String cfgKeywords;
protected Integer isHexbin;
protected String ratelimit;
@ExcelField(title="group_name",sort=2)
protected String groupName;//公共组名称
@ExcelField(title="expression_type",dictType="EXPRESSION_TYPE",sort=18)
protected Integer exprType;
@ExcelField(title="match_method",dictType="MATCH_METHOD",sort=20)
protected Integer matchMethod;
public String getCfgKeywords() {
return cfgKeywords;
}
public void setCfgKeywords(String cfgKeywords) {
this.cfgKeywords = cfgKeywords;
}
public Integer getIsHexbin() {
return isHexbin;
}
public void setIsHexbin(Integer isHexbin) {
this.isHexbin = isHexbin;
}
public String getRatelimit() {
return ratelimit;
}
public void setRatelimit(String ratelimit) {
this.ratelimit = ratelimit;
}
public static String getTablename() {
return tableName;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public Integer getMatchMethod() {
return matchMethod;
}
public void setMatchMethod(Integer matchMethod) {
this.matchMethod = matchMethod;
}
public Integer getExprType() {
return exprType;
}
public void setExprType(Integer exprType) {
this.exprType = exprType;
}
}

View File

@@ -1,312 +0,0 @@
package com.nis.domain.basics;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.nis.domain.configuration.BaseCfg;
import com.nis.util.excel.ExcelField;
public class IpCommCfg extends BaseCfg<IpCommCfg> {
/**
*
*/
private static final long serialVersionUID = 4218856118489784060L;
/**
* 创建一个新的实例 BaseIpCfg.
*
*/
public IpCommCfg() {
super();
// TODO Auto-generated constructor stub
}
private static final String indexTable="ip_comm_cfg";
/**
* ip类型
*/
@Expose
@SerializedName("ipType")
@ExcelField(title="ip_type",dictType="IP_TYPE",sort=50)
protected Integer ipType;
@ExcelField(title="src_ip_pattern",dictType="IP_PATTERN",sort=51)
protected Integer srcIpPattern;
@ExcelField(title="client_ip",sort=52)
protected String srcIpAddress;
@ExcelField(title="dest_ip_pattern",dictType="IP_PATTERN",sort=53)
protected Integer destIpPattern;
@ExcelField(title="server_ip",sort=54)
protected String destIpAddress;
@ExcelField(title="src_port_pattern",dictType="PORT_PATTERN",sort=54)
protected Integer srcPortPattern;
@ExcelField(title="dest_port_pattern",dictType="PORT_PATTERN",sort=56)
protected Integer destPortPattern;
@ExcelField(title="client_port",sort=55)
protected String srcPort;
@ExcelField(title="server_port",sort=57)
protected String destPort;
protected Integer dnsStrategyId;
@ExcelField(title="ir_type",dictType="IR_TYPE",sort=58)
protected Integer irType;
@ExcelField(title="group_name",sort=45)
protected String groupName;
// @ExcelField(title="log_total",sort=42)
private Long totalLogs;
private Integer regionId;
private Integer groupId;
public Integer getRegionId() {
return regionId;
}
public void setRegionId(Integer regionId) {
this.regionId = regionId;
}
public Integer getGroupId() {
return groupId;
}
public void setGroupId(Integer groupId) {
this.groupId = groupId;
}
public Long getTotalLogs() {
return totalLogs;
}
public void setTotalLogs(Long totalLogs) {
this.totalLogs = totalLogs;
}
/**
* irType
* @return irType
*/
public Integer getIrType() {
return irType;
}
/**
* @param irType the irType to set
*/
public void setIrType(Integer irType) {
this.irType = irType;
}
/**
* groupName
* @return groupName
*/
public String getGroupName() {
return groupName;
}
/**
* @param groupName the groupName to set
*/
public void setGroupName(String groupName) {
this.groupName = groupName;
}
/**
* 方向
*/
@Expose
@SerializedName("direction")
@ExcelField(title="direction",dictType="DIRECTION",sort=58)
protected Integer direction ;
/**
* 协议
*/
@Expose
@SerializedName("protocol")
@ExcelField(title="protocol",dictType="PROTOCOL",sort=59)
protected Integer protocol ;
/**
* 协议ID
*/
@Expose
@SerializedName("protocolId")
protected Integer protocolId ;
/**
* 限速比例
*/
protected String ratelimit ;
/**
* ratelimit
* @return ratelimit
*/
public String getRatelimit() {
return ratelimit;
}
/**
* @param ratelimit the ratelimit to set
*/
public void setRatelimit(String ratelimit) {
this.ratelimit = ratelimit;
}
/**
* 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;
}
public Integer getSrcIpPattern() {
return srcIpPattern;
}
public void setSrcIpPattern(Integer srcIpPattern) {
this.srcIpPattern = srcIpPattern;
}
public Integer getDestIpPattern() {
return destIpPattern;
}
public void setDestIpPattern(Integer destIpPattern) {
this.destIpPattern = destIpPattern;
}
public Integer getSrcPortPattern() {
return srcPortPattern;
}
public void setSrcPortPattern(Integer srcPortPattern) {
this.srcPortPattern = srcPortPattern;
}
public Integer getDestPortPattern() {
return destPortPattern;
}
public void setDestPortPattern(Integer destPortPattern) {
this.destPortPattern = destPortPattern;
}
/**
* 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;
}
/**
* dnsStrategyId
* @return dnsStrategyId
*/
public Integer getDnsStrategyId() {
return dnsStrategyId;
}
/**
* @param dnsStrategyId the dnsStrategyId to set
*/
public void setDnsStrategyId(Integer dnsStrategyId) {
this.dnsStrategyId = dnsStrategyId;
}
@Override
public void initDefaultValue(){
super.initDefaultValue();
this.direction = 0;
}
public static String getIndexTable() {
return indexTable;
}
public Integer getIndex() {
return index;
}
public void setIndex(Integer index) {
this.index = index;
}
}

View File

@@ -1,67 +0,0 @@
package com.nis.domain.basics;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.util.excel.ExcelField;
public class ScriberIdCommCfg extends BaseStringCfg<ScriberIdCommCfg>{
private static final long serialVersionUID = 5117517145731135023L;
private static final String tableName="scriberid_comm_cfg";
@ExcelField(title="key_word",sort=3)
protected String cfgKeywords;
protected Integer isHexbin;
protected String ratelimit;
@ExcelField(title="group_name",sort=2)
protected String groupName;//公共组名称
@ExcelField(title="expression_type",dictType="EXPRESSION_TYPE",sort=18)
protected Integer exprType;
@ExcelField(title="match_method",dictType="MATCH_METHOD",sort=20)
protected Integer matchMethod;
public String getCfgKeywords() {
return cfgKeywords;
}
public void setCfgKeywords(String cfgKeywords) {
this.cfgKeywords = cfgKeywords;
}
public Integer getIsHexbin() {
return isHexbin;
}
public void setIsHexbin(Integer isHexbin) {
this.isHexbin = isHexbin;
}
public String getRatelimit() {
return ratelimit;
}
public void setRatelimit(String ratelimit) {
this.ratelimit = ratelimit;
}
public static String getTablename() {
return tableName;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public Integer getMatchMethod() {
return matchMethod;
}
public void setMatchMethod(Integer matchMethod) {
this.matchMethod = matchMethod;
}
public Integer getExprType() {
return exprType;
}
public void setExprType(Integer exprType) {
this.exprType = exprType;
}
}

View File

@@ -1,66 +0,0 @@
package com.nis.domain.basics;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.util.excel.ExcelField;
public class UrlCommCfg extends BaseStringCfg<UrlCommCfg>{
private static final long serialVersionUID = 398247881810945300L;
private static final String tableName="url_comm_cfg";
@ExcelField(title="key_word",sort=3)
protected String cfgKeywords;//url关键字配置
protected Integer isHexbin;//是否大小写敏感
protected String ratelimit;//限速比例,0到1之间
@ExcelField(title="group_name",sort=2)
protected String groupName;//公共组名称
@ExcelField(title="expression_type",dictType="EXPRESSION_TYPE",sort=18)
protected Integer exprType;
@ExcelField(title="match_method",dictType="MATCH_METHOD",sort=20)
protected Integer matchMethod;
public String getCfgKeywords() {
return cfgKeywords;
}
public void setCfgKeywords(String cfgKeywords) {
this.cfgKeywords = cfgKeywords;
}
public Integer getIsHexbin() {
return isHexbin;
}
public void setIsHexbin(Integer isHexbin) {
this.isHexbin = isHexbin;
}
public String getRatelimit() {
return ratelimit;
}
public void setRatelimit(String ratelimit) {
this.ratelimit = ratelimit;
}
public static String getTablename() {
return tableName;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public Integer getMatchMethod() {
return matchMethod;
}
public void setMatchMethod(Integer matchMethod) {
this.matchMethod = matchMethod;
}
public Integer getExprType() {
return exprType;
}
public void setExprType(Integer exprType) {
this.exprType = exprType;
}
}

View File

@@ -1,54 +0,0 @@
package com.nis.domain.callback;
import com.nis.domain.configuration.BaseCfg;
import com.nis.util.excel.ExcelField;
/**
* http代理劫持文件
* @author lenovo
*
*/
public class ProxyFileHijackCfg extends BaseCfg<ProxyFileHijackCfg>{
private static final long serialVersionUID = -4600604393808056286L;
public String indexTable = "pxy_profile_hijack_files";//对应表名
@ExcelField(title="profile_name",sort=1)
private String profileName;//名称,辅助记忆
@ExcelField(title="content_type",sort=3)
private String contentType;//填充HTTP content-type如“video/mp4” exe、apk
@ExcelField(title="hijack_file_strategy",sort=2)
private String path;//储存路径
@ExcelField(title="content_name",sort=4)
private String contentName;//内容格式
public String getContentName() {
return contentName;
}
public void setContentName(String contentName) {
this.contentName = contentName;
}
public String getIndexTable() {
return indexTable;
}
public void setIndexTable(String indexTable) {
this.indexTable = indexTable;
}
public String getProfileName() {
return profileName;
}
public void setProfileName(String profileName) {
this.profileName = profileName;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
}

View File

@@ -1,114 +0,0 @@
package com.nis.domain.callback;
import java.util.Date;
import com.google.gson.annotations.Expose;
public class ProxyFileHijackCfgAudit {
@Expose
private Long id; //compileId
@Expose
private Integer cfgId; //compileId
@Expose
private Integer profileId;//compileId
@Expose
private Integer action;
@Expose
private Integer service;
@Expose
private Integer isValid;
@Expose
private Date opTime;
@Expose
private String profileName;
@Expose
private String contentType;
@Expose
private String path;
@Expose
private String contentName;
@Expose
private Long opUser;
public Long getOpUser() {
return opUser;
}
public void setOpUser(Long opUser) {
this.opUser = opUser;
}
public String getContentName() {
return contentName;
}
public void setContentName(String contentName) {
this.contentName = contentName;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public Long getId() {
return id;
}
public Integer getProfileId() {
return profileId;
}
public void setProfileId(Integer profileId) {
this.profileId = profileId;
}
public void setId(Long id) {
this.id = id;
}
public Integer getCfgId() {
return cfgId;
}
public void setCfgId(Integer cfgId) {
this.cfgId = cfgId;
}
public Integer getAction() {
return action;
}
public void setAction(Integer action) {
this.action = action;
}
public Integer getService() {
return service;
}
public void setService(Integer service) {
this.service = service;
}
public Integer getIsValid() {
return isValid;
}
public void setIsValid(Integer isValid) {
this.isValid = isValid;
}
public Date getOpTime() {
return opTime;
}
public void setOpTime(Date opTime) {
this.opTime = opTime;
}
public String getProfileName() {
return profileName;
}
public void setProfileName(String profileName) {
this.profileName = profileName;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
}

View File

@@ -1,40 +0,0 @@
package com.nis.domain.callback;
import com.nis.domain.configuration.BaseCfg;
import com.nis.util.excel.ExcelField;
public class ProxyFileInsertScriptCfg extends BaseCfg<ProxyFileInsertScriptCfg>{
private static final long serialVersionUID = 4705202662940705064L;
public String indexTable = "pxy_profile_insert_scripts";//对应表名
@ExcelField(title="script_name",sort=1)
private String cfgDesc;//名称,辅助记忆
@ExcelField(title="script_format",sort=3)
private String format;//css/js
@ExcelField(title="script_file",sort=2)
private String path;//储存路径
public String getIndexTable() {
return indexTable;
}
public void setIndexTable(String indexTable) {
this.indexTable = indexTable;
}
public String getCfgDesc() {
return cfgDesc;
}
public void setCfgDesc(String cfgDesc) {
this.cfgDesc = cfgDesc;
}
public String getFormat() {
return format;
}
public void setFormat(String format) {
this.format = format;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
}

View File

@@ -1,99 +0,0 @@
package com.nis.domain.callback;
import java.util.Date;
import com.google.gson.annotations.Expose;
public class ProxyFileInsertScriptCfgAudit {
@Expose
private Long id; //compileId
@Expose
private Integer cfgId; //compileId
@Expose
private Integer profileId;//compileId
@Expose
private Integer action;
@Expose
private Integer service;
@Expose
private Integer isValid;
@Expose
private Date opTime;
@Expose
private String profileName;
@Expose
private String format;
@Expose
private String path;
@Expose
private Long opUser;
public Long getOpUser() {
return opUser;
}
public void setOpUser(Long opUser) {
this.opUser = opUser;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getCfgId() {
return cfgId;
}
public void setCfgId(Integer cfgId) {
this.cfgId = cfgId;
}
public Integer getProfileId() {
return profileId;
}
public void setProfileId(Integer profileId) {
this.profileId = profileId;
}
public Integer getAction() {
return action;
}
public void setAction(Integer action) {
this.action = action;
}
public Integer getService() {
return service;
}
public void setService(Integer service) {
this.service = service;
}
public Integer getIsValid() {
return isValid;
}
public void setIsValid(Integer isValid) {
this.isValid = isValid;
}
public Date getOpTime() {
return opTime;
}
public void setOpTime(Date opTime) {
this.opTime = opTime;
}
public String getProfileName() {
return profileName;
}
public void setProfileName(String profileName) {
this.profileName = profileName;
}
public String getFormat() {
return format;
}
public void setFormat(String format) {
this.format = format;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
}

View File

@@ -1,67 +0,0 @@
package com.nis.domain.callback;
import com.nis.domain.configuration.BaseCfg;
import com.nis.util.excel.ExcelField;
/**
* http代理文件策略
* @author nanfang
*
*/
public class ProxyFileResponsePageCfg extends BaseCfg<ProxyFileResponsePageCfg> {
private static final long serialVersionUID = -1989406217948847813L;
public final static String TABLE_NAME = "pxy_profile_response_pages";//对应表名
private String indexTable = "pxy_profile_response_pages";
@ExcelField(title="file_desc",sort=1)
private String fileDesc;//文件描述
@ExcelField(title="response_file",sort=2)
private String url;//文件保存的url
@ExcelField(title="format",sort=3)
private String contentType;//内容类型如text/html取字典表contentType
private String md5;//文件md5值
private Long contentLength;//文件长度
public String getIndexTable() {
return indexTable;
}
public void setIndexTable(String indexTable) {
this.indexTable = indexTable;
}
public ProxyFileResponsePageCfg() {
super();
}
public String getFileDesc() {
return fileDesc;
}
public void setFileDesc(String fileDesc) {
this.fileDesc = fileDesc;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public Long getContentLength() {
return contentLength;
}
public void setContentLength(Long contentLength) {
this.contentLength = contentLength;
}
public String getMd5() {
return md5;
}
public void setMd5(String md5) {
this.md5 = md5;
}
}

View File

@@ -1,106 +0,0 @@
package com.nis.domain.callback;
import java.util.Date;
import com.google.gson.annotations.Expose;
public class ProxyFileResponsePageCfgAudit {
@Expose
private Long id; //compileId
@Expose
private Integer cfgId; //compileId
@Expose
private Integer action;
@Expose
private Integer service;
@Expose
private Integer isValid;
@Expose
private Date opTime;
@Expose
private String format;
@Expose
private Long contentLength;
@Expose
private String path;
@Expose
private Long profileId;
@Expose
private String profileName;
@Expose
private Long opUser;
public Long getOpUser() {
return opUser;
}
public void setOpUser(Long opUser) {
this.opUser = opUser;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getCfgId() {
return cfgId;
}
public void setCfgId(Integer cfgId) {
this.cfgId = cfgId;
}
public Integer getAction() {
return action;
}
public void setAction(Integer action) {
this.action = action;
}
public Integer getService() {
return service;
}
public void setService(Integer service) {
this.service = service;
}
public Integer getIsValid() {
return isValid;
}
public void setIsValid(Integer isValid) {
this.isValid = isValid;
}
public Date getOpTime() {
return opTime;
}
public void setOpTime(Date opTime) {
this.opTime = opTime;
}
public String getFormat() {
return format;
}
public void setFormat(String format) {
this.format = format;
}
public Long getContentLength() {
return contentLength;
}
public void setContentLength(Long contentLength) {
this.contentLength = contentLength;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public Long getProfileId() {
return profileId;
}
public void setProfileId(Long profileId) {
this.profileId = profileId;
}
public String getProfileName() {
return profileName;
}
public void setProfileName(String profileName) {
this.profileName = profileName;
}
}

View File

@@ -9,21 +9,12 @@ import com.nis.domain.configuration.BaseCfg;
public class ProxyFileStrategyCfg extends BaseCfg<ProxyFileStrategyCfg> { public class ProxyFileStrategyCfg extends BaseCfg<ProxyFileStrategyCfg> {
private static final long serialVersionUID = 4283944377949702481L; private static final long serialVersionUID = 4283944377949702481L;
public final static String TABLE_NAME = "PROXY_FILE_STRATEGY_CFG";//对应表名 public final static String TABLE_NAME = "PROXY_FILE_STRATEGY_CFG";//对应表名
private String indexTable = "proxy_file_strategy_cfg";
private String fileDesc;//文件描述 private String fileDesc;//文件描述
private String url;//文件保存的url private String url;//文件保存的url
private String contentType;//内容类型如text/html取字典表contentType private String contentType;//内容类型如text/html取字典表contentType
private String md5;//文件md5值 private String md5;//文件md5值
private Long contentLength;//文件长度 private Long contentLength;//文件长度
public String getIndexTable() {
return indexTable;
}
public void setIndexTable(String indexTable) {
this.indexTable = indexTable;
}
public ProxyFileStrategyCfg() { public ProxyFileStrategyCfg() {
super(); super();
} }

View File

@@ -1,106 +0,0 @@
package com.nis.domain.callback;
import java.util.Date;
import com.google.gson.annotations.Expose;
public class ProxyFileStrategyCfgAudit {
@Expose
private Long id; //compileId
@Expose
private Integer cfgId; //compileId
@Expose
private Integer action;
@Expose
private Integer service;
@Expose
private Integer isValid;
@Expose
private Date opTime;
@Expose
private String contentType;
@Expose
private Long contentLength;
@Expose
private String filePath;
@Expose
private Long fileId;
@Expose
private String fileDesc;
@Expose
private Long opUser;
public Long getOpUser() {
return opUser;
}
public void setOpUser(Long opUser) {
this.opUser = opUser;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getCfgId() {
return cfgId;
}
public void setCfgId(Integer cfgId) {
this.cfgId = cfgId;
}
public Integer getAction() {
return action;
}
public void setAction(Integer action) {
this.action = action;
}
public Integer getService() {
return service;
}
public void setService(Integer service) {
this.service = service;
}
public Integer getIsValid() {
return isValid;
}
public void setIsValid(Integer isValid) {
this.isValid = isValid;
}
public Date getOpTime() {
return opTime;
}
public void setOpTime(Date opTime) {
this.opTime = opTime;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public Long getContentLength() {
return contentLength;
}
public void setContentLength(Long contentLength) {
this.contentLength = contentLength;
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public Long getFileId() {
return fileId;
}
public void setFileId(Long fileId) {
this.fileId = fileId;
}
public String getFileDesc() {
return fileDesc;
}
public void setFileDesc(String fileDesc) {
this.fileDesc = fileDesc;
}
}

View File

@@ -1,45 +0,0 @@
package com.nis.domain.callback;
import java.util.Arrays;
import com.nis.domain.configuration.BaseCfg;
import com.nis.util.excel.ExcelField;
import antlr.collections.List;
public class ProxyFileTrafficMirrorCfg extends BaseCfg<ProxyFileTrafficMirrorCfg>{
private static final long serialVersionUID = -5895958073449509268L;
public String indexTable = "pxy_profile_traffic_mirror";//对应表名
@ExcelField(title="address_name",sort=1)
private String cfgDesc;//名称,辅助记忆
@ExcelField(title="mirror_addr_list",sort=3)
private String addrList;//目标表示列表
@ExcelField(title="mirror_addr_type",sort=2)
private String addrType;//目标表示类型
public String getIndexTable() {
return indexTable;
}
public void setIndexTable(String indexTable) {
this.indexTable = indexTable;
}
public String getCfgDesc() {
return cfgDesc;
}
public void setCfgDesc(String cfgDesc) {
this.cfgDesc = cfgDesc;
}
public String getAddrList() {
return addrList;
}
public void setAddrList(String addrList) {
this.addrList = addrList;
}
public String getAddrType() {
return addrType;
}
public void setAddrType(String addrType) {
this.addrType = addrType;
}
}

View File

@@ -1,106 +0,0 @@
package com.nis.domain.callback;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.google.gson.annotations.Expose;
public class ProxyFileTrafficMirrorCfgAudit {
@Expose
private Long id; //compileId
@Expose
private Integer cfgId; //compileId
@Expose
private Integer profileId;//compileId
@Expose
private Integer action;
@Expose
private Integer service;
@Expose
private Integer isValid;
@Expose
private Date opTime;
@Expose
private String profileName;
@Expose
private String addrList;
@Expose
private String addrContent;
@Expose
private String addrType;
@Expose
private Long opUser;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getCfgId() {
return cfgId;
}
public void setCfgId(Integer cfgId) {
this.cfgId = cfgId;
}
public Integer getProfileId() {
return profileId;
}
public void setProfileId(Integer profileId) {
this.profileId = profileId;
}
public Integer getAction() {
return action;
}
public void setAction(Integer action) {
this.action = action;
}
public Integer getService() {
return service;
}
public void setService(Integer service) {
this.service = service;
}
public Integer getIsValid() {
return isValid;
}
public void setIsValid(Integer isValid) {
this.isValid = isValid;
}
public Date getOpTime() {
return opTime;
}
public void setOpTime(Date opTime) {
this.opTime = opTime;
}
public String getProfileName() {
return profileName;
}
public void setProfileName(String profileName) {
this.profileName = profileName;
}
public String getAddrList() {
return addrList;
}
public void setAddrList(String addrList) {
this.addrList = addrList;
}
public String getAddrContent() {
return addrContent;
}
public void setAddrContent(String addrContent) {
this.addrContent = addrContent;
}
public String getAddrType() {
return addrType;
}
public void setAddrType(String addrType) {
this.addrType = addrType;
}
public Long getOpUser() {
return opUser;
}
public void setOpUser(Long opUser) {
this.opUser = opUser;
}
}

View File

@@ -1,6 +1,8 @@
package com.nis.domain.configuration; package com.nis.domain.configuration;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import com.google.gson.annotations.Expose; import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import com.nis.util.excel.ExcelField; import com.nis.util.excel.ExcelField;
@@ -32,13 +34,11 @@ public class AppIpCfg extends BaseCfg<AppIpCfg> {
@ExcelField(title="ip_type",dictType="IP_TYPE",sort=3) @ExcelField(title="ip_type",dictType="IP_TYPE",sort=3)
@SerializedName("ipType") @SerializedName("ipType")
protected Integer ipType; protected Integer ipType;
protected Integer srcIpPattern; protected Integer ipPattern;
protected Integer destIpPattern;
protected String srcIpAddress; protected String srcIpAddress;
@ExcelField(title="server_ip",sort=4) @ExcelField(title="server_ip",sort=4)
protected String destIpAddress; protected String destIpAddress;
protected Integer srcPortPattern; protected Integer portPattern;
protected Integer destPortPattern;
protected String srcPort; protected String srcPort;
@ExcelField(title="server_port",sort=5) @ExcelField(title="server_port",sort=5)
protected String destPort; protected String destPort;
@@ -121,7 +121,34 @@ public class AppIpCfg extends BaseCfg<AppIpCfg> {
// this.protocolId = 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 * srcIpAddress
@@ -131,30 +158,6 @@ public class AppIpCfg extends BaseCfg<AppIpCfg> {
public String getSrcIpAddress() { public String getSrcIpAddress() {
return srcIpAddress; return srcIpAddress;
} }
public Integer getSrcIpPattern() {
return srcIpPattern;
}
public void setSrcIpPattern(Integer srcIpPattern) {
this.srcIpPattern = srcIpPattern;
}
public Integer getDestIpPattern() {
return destIpPattern;
}
public void setDestIpPattern(Integer destIpPattern) {
this.destIpPattern = destIpPattern;
}
public Integer getSrcPortPattern() {
return srcPortPattern;
}
public void setSrcPortPattern(Integer srcPortPattern) {
this.srcPortPattern = srcPortPattern;
}
public Integer getDestPortPattern() {
return destPortPattern;
}
public void setDestPortPattern(Integer destPortPattern) {
this.destPortPattern = destPortPattern;
}
/** /**
* @param srcIpAddress the srcIpAddress to set * @param srcIpAddress the srcIpAddress to set
*/ */
@@ -254,10 +257,16 @@ public class AppIpCfg extends BaseCfg<AppIpCfg> {
public String toString() { public String toString() {
return "AppIpCfg [compileId=" + compileId + ", ratelimit=" + ratelimit + ", appCode=" + appCode + ", behavCode=" return "AppIpCfg [compileId=" + compileId + ", ratelimit=" + ratelimit + ", appCode=" + appCode + ", behavCode="
+ behavCode + ", specServiceId=" + specServiceId + ", appName=" + appName + ", ipType=" + ipType + behavCode + ", specServiceId=" + specServiceId + ", appName=" + appName + ", ipType=" + ipType
+ ", srcIpPattern=" + srcIpPattern + ", destIpPattern=" + destIpPattern + ", srcIpAddress=" + ", ipPattern=" + ipPattern + ", srcIpAddress=" + srcIpAddress + ", destIpAddress=" + destIpAddress
+ srcIpAddress + ", destIpAddress=" + destIpAddress + ", srcPortPattern=" + srcPortPattern + ", portPattern=" + portPattern + ", srcPort=" + srcPort + ", destPort=" + destPort + ", direction="
+ ", destPortPattern=" + destPortPattern + ", srcPort=" + srcPort + ", destPort=" + destPort + direction + ", protocol=" + protocol + ", userRegion1=" + userRegion1 + ", userRegion2=" + userRegion2
+ ", direction=" + direction + ", protocol=" + protocol + "]"; + ", userRegion3=" + userRegion3 + ", userRegion4=" + userRegion4 + ", userRegion5=" + userRegion5
+ ", cfgId=" + cfgId + ", cfgDesc=" + cfgDesc + ", action=" + action + ", isValid=" + isValid
+ ", isAudit=" + isAudit + ", creatorId=" + creatorId + ", createTime=" + createTime + ", editorId="
+ editorId + ", editTime=" + editTime + ", auditorId=" + auditorId + ", auditTime=" + auditTime
+ ", serviceId=" + serviceId + ", requestId=" + requestId + ", cancelRequestId=" + cancelRequestId
+ ", isAreaEffective=" + isAreaEffective + ", classify=" + classify + ", attribute=" + attribute
+ ", lable=" + lable + ", areaEffectiveIds=" + areaEffectiveIds + ", cfgRegionCode=" + cfgRegionCode
+ ", cfgType=" + cfgType + ", functionId=" + functionId + ", doLog=" + doLog + "]";
} }
} }

View File

@@ -59,8 +59,7 @@ public class AreaIpCfg extends BaseIpCfg {
this.cfgType=Constants.AREA_REGION; this.cfgType=Constants.AREA_REGION;
this.cfgRegionCode=1; this.cfgRegionCode=1;
this.protocol=0; this.protocol=0;
this.srcPortPattern=1; this.portPattern=1;
this.destPortPattern=1;
this.srcPort="0"; this.srcPort="0";
this.destPort="0"; this.destPort="0";
this.direction=0; this.direction=0;

View File

@@ -63,10 +63,6 @@ public class BaseCfg<T> extends BaseEntity<T> implements Cloneable{
protected String hColumns;//导出隐藏列 protected String hColumns;//导出隐藏列
protected String compileIdNew;// 查询 配置ID 范围 protected String compileIdNew;// 查询 配置ID 范围
//批量操作时记录isAudit和isValid检索条件
protected String batchAuditValue;
protected String batchValidValue;
/** /**
* 定时任务信息 * 定时任务信息
@@ -76,29 +72,17 @@ public class BaseCfg<T> extends BaseEntity<T> implements Cloneable{
* 定时任务信息2019年1月18日18:54:53 修改 * 定时任务信息2019年1月18日18:54:53 修改
*/ */
protected ScheduleCfg schedule; protected ScheduleCfg schedule;
protected String commonGroupIds; //公共组织id(考虑一个compile存在多个asn组织的情况)
protected Integer groupType; //url组以及dns组相关功能使用
protected Integer udFlag; //url组以及dns组相关功能使用 过滤数据库数据标记
private String commonGroupIds; //公共组织id(考虑一个compile存在多个asn组织的情况)
public String getCommonGroupIds() { public String getCommonGroupIds() {
return commonGroupIds; return commonGroupIds;
} }
public void setCommonGroupIds(String commonGroupIds) { public void setCommonGroupIds(String commonGroupIds) {
this.commonGroupIds = commonGroupIds; this.commonGroupIds = commonGroupIds;
} }
public Integer getGroupType() {
return groupType;
}
public void setGroupType(Integer groupType) {
this.groupType = groupType;
}
public Integer getUdFlag() {
return udFlag;
}
public void setUdFlag(Integer udFlag) {
this.udFlag = udFlag;
}
public String getExType() { public String getExType() {
return exType; return exType;
@@ -1020,17 +1004,6 @@ public class BaseCfg<T> extends BaseEntity<T> implements Cloneable{
public void setSchedule(ScheduleCfg schedule) { public void setSchedule(ScheduleCfg schedule) {
this.schedule = schedule; this.schedule = schedule;
} }
public String getBatchAuditValue() {
return batchAuditValue;
}
public String getBatchValidValue() {
return batchValidValue;
}
public void setBatchAuditValue(String batchAuditValue) {
this.batchAuditValue = batchAuditValue;
}
public void setBatchValidValue(String batchValidValue) {
this.batchValidValue = batchValidValue;
}
} }

View File

@@ -9,7 +9,6 @@
package com.nis.domain.configuration; package com.nis.domain.configuration;
import java.util.List; import java.util.List;
import java.util.Map;
import com.google.gson.annotations.Expose; import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
@@ -46,18 +45,14 @@ public class BaseIpCfg extends BaseCfg<BaseIpCfg> {
@SerializedName("ipType") @SerializedName("ipType")
@ExcelField(title="ip_type",dictType="IP_TYPE",sort=50) @ExcelField(title="ip_type",dictType="IP_TYPE",sort=50)
protected Integer ipType; protected Integer ipType;
@ExcelField(title="src_ip_pattern",dictType="IP_PATTERN",sort=51) @ExcelField(title="ip_pattern",dictType="IP_PATTERN",sort=51)
protected Integer srcIpPattern; protected Integer ipPattern;
@ExcelField(title="client_ip",sort=52) @ExcelField(title="client_ip",sort=53)
protected String srcIpAddress; protected String srcIpAddress;
@ExcelField(title="dest_ip_pattern",dictType="IP_PATTERN",sort=53) @ExcelField(title="server_ip",sort=52)
protected Integer destIpPattern;
@ExcelField(title="server_ip",sort=54)
protected String destIpAddress; protected String destIpAddress;
@ExcelField(title="src_port_pattern",dictType="PORT_PATTERN",sort=54) @ExcelField(title="port_pattern",dictType="PORT_PATTERN",sort=54)
protected Integer srcPortPattern; protected Integer portPattern;
@ExcelField(title="dest_port_pattern",dictType="PORT_PATTERN",sort=54)
protected Integer destPortPattern;
@ExcelField(title="client_port",sort=55) @ExcelField(title="client_port",sort=55)
protected String srcPort; protected String srcPort;
@ExcelField(title="server_port",sort=56) @ExcelField(title="server_port",sort=56)
@@ -274,31 +269,35 @@ public class BaseIpCfg extends BaseCfg<BaseIpCfg> {
this.protocolId = protocolId; this.protocolId = protocolId;
} }
/**
* ipPattern
* @return ipPattern
*/
public Integer getSrcIpPattern() { public Integer getIpPattern() {
return srcIpPattern; return ipPattern;
} }
public void setSrcIpPattern(Integer srcIpPattern) { /**
this.srcIpPattern = srcIpPattern; * @param ipPattern the ipPattern to set
*/
public void setIpPattern(Integer ipPattern) {
this.ipPattern = ipPattern;
} }
public Integer getDestIpPattern() { /**
return destIpPattern; * portPattern
* @return portPattern
*/
public Integer getPortPattern() {
return portPattern;
} }
public void setDestIpPattern(Integer destIpPattern) { /**
this.destIpPattern = destIpPattern; * @param portPattern the portPattern to set
} */
public Integer getSrcPortPattern() { public void setPortPattern(Integer portPattern) {
return srcPortPattern; this.portPattern = portPattern;
}
public void setSrcPortPattern(Integer srcPortPattern) {
this.srcPortPattern = srcPortPattern;
}
public Integer getDestPortPattern() {
return destPortPattern;
}
public void setDestPortPattern(Integer destPortPattern) {
this.destPortPattern = destPortPattern;
} }
/** /**
* srcIpAddress * srcIpAddress
* @return srcIpAddress * @return srcIpAddress
@@ -400,125 +399,4 @@ public class BaseIpCfg extends BaseCfg<BaseIpCfg> {
public void setIndex(Integer index) { public void setIndex(Integer index) {
this.index = index; this.index = index;
} }
protected Integer keyring;
protected Integer evCert;
protected Integer certTransparency;
protected Integer clientCertReq;
protected Integer pinning;
protected Integer protocolErrors;
protected Integer cn;
protected Integer issuer;
protected Integer selfSigned;
protected Integer expiration;
protected String failMethod;
protected String min;
protected String max;
protected Integer mirrorClient;
protected Integer allowHttp2;
protected Integer enable;
protected Integer mirrorProfile;
public Integer getKeyring() {
return keyring;
}
public void setKeyring(Integer keyring) {
this.keyring = keyring;
}
public Integer getEvCert() {
return evCert;
}
public void setEvCert(Integer evCert) {
this.evCert = evCert;
}
public Integer getCertTransparency() {
return certTransparency;
}
public void setCertTransparency(Integer certTransparency) {
this.certTransparency = certTransparency;
}
public Integer getClientCertReq() {
return clientCertReq;
}
public void setClientCertReq(Integer clientCertReq) {
this.clientCertReq = clientCertReq;
}
public Integer getPinning() {
return pinning;
}
public void setPinning(Integer pinning) {
this.pinning = pinning;
}
public Integer getProtocolErrors() {
return protocolErrors;
}
public void setProtocolErrors(Integer protocolErrors) {
this.protocolErrors = protocolErrors;
}
public Integer getCn() {
return cn;
}
public void setCn(Integer cn) {
this.cn = cn;
}
public Integer getIssuer() {
return issuer;
}
public void setIssuer(Integer issuer) {
this.issuer = issuer;
}
public Integer getSelfSigned() {
return selfSigned;
}
public void setSelfSigned(Integer selfSigned) {
this.selfSigned = selfSigned;
}
public Integer getExpiration() {
return expiration;
}
public void setExpiration(Integer expiration) {
this.expiration = expiration;
}
public String getFailMethod() {
return failMethod;
}
public void setFailMethod(String failMethod) {
this.failMethod = failMethod;
}
public String getMin() {
return min;
}
public void setMin(String min) {
this.min = min;
}
public String getMax() {
return max;
}
public void setMax(String max) {
this.max = max;
}
public Integer getMirrorClient() {
return mirrorClient;
}
public void setMirrorClient(Integer mirrorClient) {
this.mirrorClient = mirrorClient;
}
public Integer getAllowHttp2() {
return allowHttp2;
}
public void setAllowHttp2(Integer allowHttp2) {
this.allowHttp2 = allowHttp2;
}
public Integer getEnable() {
return enable;
}
public void setEnable(Integer enable) {
this.enable = enable;
}
public Integer getMirrorProfile() {
return mirrorProfile;
}
public void setMirrorProfile(Integer mirrorProfile) {
this.mirrorProfile = mirrorProfile;
}
} }

View File

@@ -45,14 +45,7 @@ public class BaseStringCfg<T> extends BaseCfg<T> {
protected Integer specServiceId;//仅用于copy属性使用 protected Integer specServiceId;//仅用于copy属性使用
protected String domain;//仅用于copy属性使用 protected String domain;//仅用于copy属性使用
protected Integer dnsStrategyId;//仅用作复制属性使用 protected Integer dnsStrategyId;//仅用作复制属性使用
protected String groupName;
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public Integer getDnsStrategyId() { public Integer getDnsStrategyId() {
return dnsStrategyId; return dnsStrategyId;
} }
@@ -289,124 +282,5 @@ public class BaseStringCfg<T> extends BaseCfg<T> {
public void setRegionId(Integer regionId) { public void setRegionId(Integer regionId) {
this.regionId = regionId; this.regionId = regionId;
} }
protected Integer keyring;
protected Integer evCert;
protected Integer certTransparency;
protected Integer clientCertReq;
protected Integer pinning;
protected Integer protocolErrors;
protected Integer cn;
protected Integer issuer;
protected Integer selfSigned;
protected Integer expiration;
protected String failMethod;
protected String min;
protected String max;
protected Integer mirrorClient;
protected Integer allowHttp2;
protected Integer enable;
protected Integer mirrorProfile;
public Integer getKeyring() {
return keyring;
}
public void setKeyring(Integer keyring) {
this.keyring = keyring;
}
public Integer getEvCert() {
return evCert;
}
public void setEvCert(Integer evCert) {
this.evCert = evCert;
}
public Integer getCertTransparency() {
return certTransparency;
}
public void setCertTransparency(Integer certTransparency) {
this.certTransparency = certTransparency;
}
public Integer getClientCertReq() {
return clientCertReq;
}
public void setClientCertReq(Integer clientCertReq) {
this.clientCertReq = clientCertReq;
}
public Integer getPinning() {
return pinning;
}
public void setPinning(Integer pinning) {
this.pinning = pinning;
}
public Integer getProtocolErrors() {
return protocolErrors;
}
public void setProtocolErrors(Integer protocolErrors) {
this.protocolErrors = protocolErrors;
}
public Integer getCn() {
return cn;
}
public void setCn(Integer cn) {
this.cn = cn;
}
public Integer getIssuer() {
return issuer;
}
public void setIssuer(Integer issuer) {
this.issuer = issuer;
}
public Integer getSelfSigned() {
return selfSigned;
}
public void setSelfSigned(Integer selfSigned) {
this.selfSigned = selfSigned;
}
public Integer getExpiration() {
return expiration;
}
public void setExpiration(Integer expiration) {
this.expiration = expiration;
}
public String getFailMethod() {
return failMethod;
}
public void setFailMethod(String failMethod) {
this.failMethod = failMethod;
}
public String getMin() {
return min;
}
public void setMin(String min) {
this.min = min;
}
public String getMax() {
return max;
}
public void setMax(String max) {
this.max = max;
}
public Integer getMirrorClient() {
return mirrorClient;
}
public void setMirrorClient(Integer mirrorClient) {
this.mirrorClient = mirrorClient;
}
public Integer getAllowHttp2() {
return allowHttp2;
}
public void setAllowHttp2(Integer allowHttp2) {
this.allowHttp2 = allowHttp2;
}
public Integer getEnable() {
return enable;
}
public void setEnable(Integer enable) {
this.enable = enable;
}
public Integer getMirrorProfile() {
return mirrorProfile;
}
public void setMirrorProfile(Integer mirrorProfile) {
this.mirrorProfile = mirrorProfile;
}
} }

View File

@@ -14,11 +14,7 @@ import java.util.Map;
import com.google.gson.annotations.Expose; import com.google.gson.annotations.Expose;
import com.nis.domain.basics.AsnGroupInfo; import com.nis.domain.basics.AsnGroupInfo;
import com.nis.domain.basics.AsnIpCfg; import com.nis.domain.basics.AsnIpCfg;
import com.nis.domain.basics.DomainCommCfg;
import com.nis.domain.basics.IpCommCfg;
import com.nis.domain.basics.IpReuseIpCfg; import com.nis.domain.basics.IpReuseIpCfg;
import com.nis.domain.basics.ScriberIdCommCfg;
import com.nis.domain.basics.UrlCommCfg;
import com.nis.util.Constants; import com.nis.util.Constants;
import com.nis.util.excel.ExcelField; import com.nis.util.excel.ExcelField;
@@ -92,12 +88,8 @@ public class CfgIndexInfo extends BaseCfg<CfgIndexInfo> {
private List<AsnKeywordCfg> asnKeywords; private List<AsnKeywordCfg> asnKeywords;
@ExcelField(title="log_total",sort=42) @ExcelField(title="log_total",sort=42)
private Long totalLogs; private Long totalLogs;
private List<UrlCommCfg> urlCommGroupList;
private List<IpCommCfg> ipCommGroupCfgList;
private List<DomainCommCfg> domainCommGroupList;
private List<ScriberIdCommCfg> scriberIdCommGroupList;
private String groupName;
/*private CachePolicyUserRegion cachePolicyUserRegion;//缓存策略用户自定义域参数 /*private CachePolicyUserRegion cachePolicyUserRegion;//缓存策略用户自定义域参数
public static class CachePolicyUserRegion{ public static class CachePolicyUserRegion{
@@ -109,18 +101,6 @@ public class CfgIndexInfo extends BaseCfg<CfgIndexInfo> {
public String getOrganization() { public String getOrganization() {
return organization; return organization;
} }
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public List<IpCommCfg> getIpCommGroupCfgList() {
return ipCommGroupCfgList;
}
public void setIpCommGroupCfgList(List<IpCommCfg> ipCommGroupCfgList) {
this.ipCommGroupCfgList = ipCommGroupCfgList;
}
public List<AsnKeywordCfg> getAsnKeywords() { public List<AsnKeywordCfg> getAsnKeywords() {
return asnKeywords; return asnKeywords;
} }
@@ -431,26 +411,4 @@ public class CfgIndexInfo extends BaseCfg<CfgIndexInfo> {
public void setTotalLogs(Long totalLogs) { public void setTotalLogs(Long totalLogs) {
this.totalLogs = totalLogs; this.totalLogs = totalLogs;
} }
public List<UrlCommCfg> getUrlCommGroupList() {
return urlCommGroupList;
}
public void setUrlCommGroupList(List<UrlCommCfg> urlCommGroupList) {
this.urlCommGroupList = urlCommGroupList;
}
public List<DomainCommCfg> getDomainCommGroupList() {
return domainCommGroupList;
}
public void setDomainCommGroupList(List<DomainCommCfg> domainCommGroupList) {
this.domainCommGroupList = domainCommGroupList;
}
public List<ScriberIdCommCfg> getScriberIdCommGroupList() {
return scriberIdCommGroupList;
}
public void setScriberIdCommGroupList(List<ScriberIdCommCfg> scriberIdCommGroupList) {
this.scriberIdCommGroupList = scriberIdCommGroupList;
}
} }

View File

@@ -1,58 +0,0 @@
package com.nis.domain.configuration;
import com.nis.util.excel.ExcelField;
public class ManipulatCfgExport extends CfgIndexInfo {
/**
*
*/
private static final long serialVersionUID = -842585769617969577L;
@ExcelField(title="block_type",dictType="SERVICE_ACTION",sort=2)
private String actionExport;
@ExcelField(title="method_export",dictType="SERVICE_ACTION",sort=3)
private String methodExport;
@ExcelField(title="response_code",sort=3)
private String responseCode;
@ExcelField(title="profile_info",sort=10)
private String profileInfo;
private Integer action;
public String getResponseCode() {
return responseCode;
}
public void setResponseCode(String responseCode) {
this.responseCode = responseCode;
}
public String getMethodExport() {
return methodExport;
}
public void setMethodExport(String methodExport) {
this.methodExport = methodExport;
}
public String getProfileInfo() {
return profileInfo;
}
public void setProfileInfo(String profileInfo) {
this.profileInfo = profileInfo;
}
public String getActionExport() {
return actionExport;
}
public void setActionExport(String actionExport) {
this.actionExport = actionExport;
}
public Integer getAction() {
return action;
}
public void setAction(Integer action) {
this.action = action;
}
}

View File

@@ -1,60 +0,0 @@
package com.nis.domain.configuration;
import com.nis.util.excel.ExcelField;
public class ObjGroupCfg extends BaseCfg<ObjGroupCfg> {
@ExcelField(title="ip_group",sort=33)
private String ipGroup;
@ExcelField(title="url_group",sort=35)
private String urlGroup;
@ExcelField(title="subscribe_id_group",sort=34)
private String subscribeIdGroup;
@ExcelField(title="domain_group",sort=36)
private String domainGroup;
@ExcelField(title="block_type",sort=2)//这里没有使用公共方法处理直接将字典值set进去了不用使用dictType
protected String actionCode;
@ExcelField(title="protocol",sort=3)
protected String userRegion1;
public String getActionCode() {
return actionCode;
}
public void setActionCode(String actionCode) {
this.actionCode = actionCode;
}
public String getIpGroup() {
return ipGroup;
}
public void setIpGroup(String ipGroup) {
this.ipGroup = ipGroup;
}
public String getUrlGroup() {
return urlGroup;
}
public void setUrlGroup(String urlGroup) {
this.urlGroup = urlGroup;
}
public String getSubscribeIdGroup() {
return subscribeIdGroup;
}
public void setSubscribeIdGroup(String subscribeIdGroup) {
this.subscribeIdGroup = subscribeIdGroup;
}
public String getDomainGroup() {
return domainGroup;
}
public void setDomainGroup(String domainGroup) {
this.domainGroup = domainGroup;
}
protected Integer action;//覆盖默认的action上的注解
}

View File

@@ -1,153 +0,0 @@
package com.nis.domain.configuration;
import com.nis.util.excel.ExcelField;
public class PxyInterceptCfg extends CfgIndexInfo {
/**
*
*/
private static final long serialVersionUID = 994229066993318362L;
@ExcelField(title="pxy_intercept_monit_keyring",sort=8)
private String keyring;
@ExcelField(title="exclusions_ev_cert",dictType="SYS_YES_NO",sort=9)
private String evCert;
@ExcelField(title="exclusions_cert_transparency",dictType="SYS_YES_NO",sort=10)
private String certTransparency;
@ExcelField(title="exclusions_client_cert_req",dictType="SYS_YES_NO",sort=11)
private String clientCertReq;
@ExcelField(title="exclusions_pinning",dictType="SYS_YES_NO",sort=12)
private String pinning;
@ExcelField(title="exclusions_protocol_errors",dictType="SYS_YES_NO",sort=13)
private String protocolErrors;
@ExcelField(title="cert_verify_approach_cn",dictType="SYS_YES_NO",sort=14)
private String cn;
@ExcelField(title="cert_verify_approach_issuer",dictType="SYS_YES_NO",sort=15)
private String issuer;
@ExcelField(title="cert_verify_approach_self_signed",dictType="SYS_YES_NO",sort=16)
private String selfSigned;
@ExcelField(title="cert_verify_approach_expiration",dictType="SYS_YES_NO",sort=17)
private String expiration;
@ExcelField(title="cert_verify_fail_method",dictType="FAIL_METHOD",sort=18)
private String failMethod;
@ExcelField(title="ssl_ver_min",dictType="SSL_VERSION",sort=19)
private String min;
@ExcelField(title="ssl_ver_max",dictType="SSL_VERSION",sort=20)
private String max;
@ExcelField(title="ssl_ver_mirror_client",dictType="SYS_YES_NO",sort=21)
private String mirrorClient;
@ExcelField(title="ssl_ver_allow_http2",dictType="SYS_YES_NO",sort=22)
private String allowHttp2;
@ExcelField(title="decrypt_mirror_enable",dictType="SYS_YES_NO",sort=23)
private String enable;
@ExcelField(title="decrypt_mirror_mirror_profile",sort=24)
private String mirrorProfile;
private String userRegion1;
private String userRegion2;
private String userRegion3;
private String userRegion4;
// private String userRegion5;
public String getKeyring() {
return keyring;
}
public void setKeyring(String keyring) {
this.keyring = keyring;
}
public String getEvCert() {
return evCert;
}
public void setEvCert(String evCert) {
this.evCert = evCert;
}
public String getCertTransparency() {
return certTransparency;
}
public void setCertTransparency(String certTransparency) {
this.certTransparency = certTransparency;
}
public String getClientCertReq() {
return clientCertReq;
}
public void setClientCertReq(String clientCertReq) {
this.clientCertReq = clientCertReq;
}
public String getPinning() {
return pinning;
}
public void setPinning(String pinning) {
this.pinning = pinning;
}
public String getProtocolErrors() {
return protocolErrors;
}
public void setProtocolErrors(String protocolErrors) {
this.protocolErrors = protocolErrors;
}
public String getCn() {
return cn;
}
public void setCn(String cn) {
this.cn = cn;
}
public String getIssuer() {
return issuer;
}
public void setIssuer(String issuer) {
this.issuer = issuer;
}
public String getSelfSigned() {
return selfSigned;
}
public void setSelfSigned(String selfSigned) {
this.selfSigned = selfSigned;
}
public String getExpiration() {
return expiration;
}
public void setExpiration(String expiration) {
this.expiration = expiration;
}
public String getFailMethod() {
return failMethod;
}
public void setFailMethod(String failMethod) {
this.failMethod = failMethod;
}
public String getMin() {
return min;
}
public void setMin(String min) {
this.min = min;
}
public String getMax() {
return max;
}
public void setMax(String max) {
this.max = max;
}
public String getMirrorClient() {
return mirrorClient;
}
public void setMirrorClient(String mirrorClient) {
this.mirrorClient = mirrorClient;
}
public String getAllowHttp2() {
return allowHttp2;
}
public void setAllowHttp2(String allowHttp2) {
this.allowHttp2 = allowHttp2;
}
public String getEnable() {
return enable;
}
public void setEnable(String enable) {
this.enable = enable;
}
public String getMirrorProfile() {
return mirrorProfile;
}
public void setMirrorProfile(String mirrorProfile) {
this.mirrorProfile = mirrorProfile;
}
}

View File

@@ -25,7 +25,6 @@ public class PxyObjKeyring extends BaseCfg<PxyObjKeyring> {
@ExcelField(title="expire_after",sort=5) @ExcelField(title="expire_after",sort=5)
private Integer expireAfter; private Integer expireAfter;
private String publicKeyAlgo; private String publicKeyAlgo;
@ExcelField(title="CRL",sort=5)
private String crl; private String crl;
@ExcelField(title="issuer",sort=6) @ExcelField(title="issuer",sort=6)
private String issuer; private String issuer;

View File

@@ -18,18 +18,9 @@ public class PxyObjTrustedCaCert extends BaseCfg<PxyObjTrustedCaCert> {
private String issuer; //颁发者 private String issuer; //颁发者
@ExcelField(title="certificate_file",sort=2) @ExcelField(title="certificate_file",sort=2)
private String certFile; private String certFile;
//@ExcelField(title="crl_file",sort=4) @ExcelField(title="crl_file",sort=4)
private String crlFile; private String crlFile;
private Integer builtIn;//是否内置证书
@ExcelField(title="built_in",sort=5)//是否内置证书(导出用)
private String builtInExp;
public String getBuiltInExp() {
return builtInExp;
}
public void setBuiltInExp(String builtInExp) {
this.builtInExp = builtInExp;
}
public String getCrlFile() { public String getCrlFile() {
return crlFile; return crlFile;
} }
@@ -56,11 +47,6 @@ public class PxyObjTrustedCaCert extends BaseCfg<PxyObjTrustedCaCert> {
public void setIndexTable(String indexTable) { public void setIndexTable(String indexTable) {
this.indexTable = indexTable; this.indexTable = indexTable;
} }
public Integer getBuiltIn() {
return builtIn;
}
public void setBuiltIn(Integer builtIn) {
this.builtIn = builtIn;
}
} }

View File

@@ -1,23 +0,0 @@
package com.nis.domain.configuration.template;
import com.nis.util.excel.ExcelField;
/**
* 域名公共组配置 导入模板
* @author dell
*
*/
public class DomainCommCfgTemplate extends StringAllNotDoLogTemplate{
@ExcelField(title="group_name",align=2,sort=10)
private String groupName;
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
}

View File

@@ -1,160 +0,0 @@
package com.nis.domain.configuration.template;
import com.nis.util.excel.ExcelField;
public class InterceptDomainTemplate extends StringAllNotDoLogTemplate {
private Integer keyring;
private Integer evCert;
private Integer certTransparency;
private Integer clientCertReq;
private Integer pinning;
private Integer protocolErrors;
private Integer cn;
private Integer issuer;
private Integer selfSigned;
private Integer expiration;
private String failMethod;
private String min;
private String max;
private Integer mirrorClient;
private Integer allowHttp2;
private Integer enable;
private Integer mirrorProfile;
@ExcelField(title="pxy_intercept_monit_keyring",align=2,sort=17)
public Integer getKeyring() {
return keyring;
}
public void setKeyring(Integer keyring) {
this.keyring = keyring;
}
@ExcelField(title="exclusions_ev_cert",align=2,sort=18)
public Integer getEvCert() {
return evCert;
}
public void setEvCert(Integer evCert) {
this.evCert = evCert;
}
@ExcelField(title="exclusions_cert_transparency",align=2,sort=19)
public Integer getCertTransparency() {
return certTransparency;
}
public void setCertTransparency(Integer certTransparency) {
this.certTransparency = certTransparency;
}
@ExcelField(title="exclusions_client_cert_req",align=2,sort=20)
public Integer getClientCertReq() {
return clientCertReq;
}
public void setClientCertReq(Integer clientCertReq) {
this.clientCertReq = clientCertReq;
}
@ExcelField(title="exclusions_pinning",align=2,sort=21)
public Integer getPinning() {
return pinning;
}
public void setPinning(Integer pinning) {
this.pinning = pinning;
}
@ExcelField(title="protocol_errors",align=2,sort=22)
public Integer getProtocolErrors() {
return protocolErrors;
}
public void setProtocolErrors(Integer protocolErrors) {
this.protocolErrors = protocolErrors;
}
@ExcelField(title="cert_verify_approach_cn",align=2,sort=23)
public Integer getCn() {
return cn;
}
public void setCn(Integer cn) {
this.cn = cn;
}
@ExcelField(title="cert_verify_approach_issuer",align=2,sort=24)
public Integer getIssuer() {
return issuer;
}
public void setIssuer(Integer issuer) {
this.issuer = issuer;
}
@ExcelField(title="cert_verify_approach_self_signed",align=2,sort=25)
public Integer getSelfSigned() {
return selfSigned;
}
public void setSelfSigned(Integer selfSigned) {
this.selfSigned = selfSigned;
}
@ExcelField(title="cert_verify_approach_expiration",align=2,sort=26)
public Integer getExpiration() {
return expiration;
}
public void setExpiration(Integer expiration) {
this.expiration = expiration;
}
@ExcelField(title="cert_verify_fail_method",dictType="FAIL_METHOD",align=2,sort=27)
public String getFailMethod() {
return failMethod;
}
public void setFailMethod(String failMethod) {
this.failMethod = failMethod;
}
@ExcelField(title="ssl_ver_min",dictType="SSL_VERSION",align=2,sort=28)
public String getMin() {
return min;
}
public void setMin(String min) {
this.min = min;
}
@ExcelField(title="ssl_ver_max",dictType="SSL_VERSION",align=2,sort=29)
public String getMax() {
return max;
}
public void setMax(String max) {
this.max = max;
}
@ExcelField(title="ssl_ver_mirror_client",align=2,sort=30)
public Integer getMirrorClient() {
return mirrorClient;
}
public void setMirrorClient(Integer mirrorClient) {
this.mirrorClient = mirrorClient;
}
@ExcelField(title="ssl_ver_allow_http2",align=2,sort=31)
public Integer getAllowHttp2() {
return allowHttp2;
}
public void setAllowHttp2(Integer allowHttp2) {
this.allowHttp2 = allowHttp2;
}
@ExcelField(title="decrypt_mirror_enable",align=2,sort=32)
public Integer getEnable() {
return enable;
}
public void setEnable(Integer enable) {
this.enable = enable;
}
@ExcelField(title="decrypt_mirror_mirror_profile",align=2,sort=33)
public Integer getMirrorProfile() {
return mirrorProfile;
}
public void setMirrorProfile(Integer mirrorProfile) {
this.mirrorProfile = mirrorProfile;
}
}

View File

@@ -1,161 +0,0 @@
package com.nis.domain.configuration.template;
import com.nis.util.excel.ExcelField;
public class InterceptIpTemplate extends IpAllNotDoLogTemplate {
private Integer keyring;
private Integer evCert;
private Integer certTransparency;
private Integer clientCertReq;
private Integer pinning;
private Integer protocolErrors;
private Integer cn;
private Integer issuer;
private Integer selfSigned;
private Integer expiration;
private String failMethod;
private String min;
private String max;
private Integer mirrorClient;
private Integer allowHttp2;
private Integer enable;
private Integer mirrorProfile;
@ExcelField(title="pxy_intercept_monit_keyring",align=2,sort=17)
public Integer getKeyring() {
return keyring;
}
public void setKeyring(Integer keyring) {
this.keyring = keyring;
}
@ExcelField(title="exclusions_ev_cert",align=2,sort=18)
public Integer getEvCert() {
return evCert;
}
public void setEvCert(Integer evCert) {
this.evCert = evCert;
}
@ExcelField(title="exclusions_cert_transparency",align=2,sort=19)
public Integer getCertTransparency() {
return certTransparency;
}
public void setCertTransparency(Integer certTransparency) {
this.certTransparency = certTransparency;
}
@ExcelField(title="exclusions_client_cert_req",align=2,sort=20)
public Integer getClientCertReq() {
return clientCertReq;
}
public void setClientCertReq(Integer clientCertReq) {
this.clientCertReq = clientCertReq;
}
@ExcelField(title="exclusions_pinning",align=2,sort=21)
public Integer getPinning() {
return pinning;
}
public void setPinning(Integer pinning) {
this.pinning = pinning;
}
@ExcelField(title="exclusions_protocol_errors",align=2,sort=22)
public Integer getProtocolErrors() {
return protocolErrors;
}
public void setProtocolErrors(Integer protocolErrors) {
this.protocolErrors = protocolErrors;
}
@ExcelField(title="cert_verify_approach_cn",align=2,sort=23)
public Integer getCn() {
return cn;
}
public void setCn(Integer cn) {
this.cn = cn;
}
@ExcelField(title="cert_verify_approach_issuer",align=2,sort=24)
public Integer getIssuer() {
return issuer;
}
public void setIssuer(Integer issuer) {
this.issuer = issuer;
}
@ExcelField(title="cert_verify_approach_self_signed",align=2,sort=25)
public Integer getSelfSigned() {
return selfSigned;
}
public void setSelfSigned(Integer selfSigned) {
this.selfSigned = selfSigned;
}
@ExcelField(title="cert_verify_approach_expiration",align=2,sort=26)
public Integer getExpiration() {
return expiration;
}
public void setExpiration(Integer expiration) {
this.expiration = expiration;
}
@ExcelField(title="cert_verify_fail_method",dictType="FAIL_METHOD",align=2,sort=27)
public String getFailMethod() {
return failMethod;
}
public void setFailMethod(String failMethod) {
this.failMethod = failMethod;
}
@ExcelField(title="ssl_ver_min",dictType="SSL_VERSION",align=2,sort=28)
public String getMin() {
return min;
}
public void setMin(String min) {
this.min = min;
}
@ExcelField(title="ssl_ver_max",dictType="SSL_VERSION",align=2,sort=29)
public String getMax() {
return max;
}
public void setMax(String max) {
this.max = max;
}
@ExcelField(title="ssl_ver_mirror_client",align=2,sort=30)
public Integer getMirrorClient() {
return mirrorClient;
}
public void setMirrorClient(Integer mirrorClient) {
this.mirrorClient = mirrorClient;
}
@ExcelField(title="ssl_ver_allow_http2",align=2,sort=31)
public Integer getAllowHttp2() {
return allowHttp2;
}
public void setAllowHttp2(Integer allowHttp2) {
this.allowHttp2 = allowHttp2;
}
@ExcelField(title="decrypt_mirror_enable",align=2,sort=32)
public Integer getEnable() {
return enable;
}
public void setEnable(Integer enable) {
this.enable = enable;
}
@ExcelField(title="decrypt_mirror_mirror_profile",align=2,sort=33)
public Integer getMirrorProfile() {
return mirrorProfile;
}
public void setMirrorProfile(Integer mirrorProfile) {
this.mirrorProfile = mirrorProfile;
}
}

View File

@@ -0,0 +1,31 @@
package com.nis.domain.configuration.template;
/**
* wx 将部分字段的标题改变,或者不需要的字段隐藏
* 隐藏方法对于不需要的字段或者方法Override该字段方法但是@ExcelField注解不需要加上了
* @author dell
*
*/
@Deprecated
public class IpAddrTemplate extends IpCfgTemplate {
@Override
public Integer getIrType() {
// TODO Auto-generated method stub
return super.getIrType();
}
@Override
public Integer getDnsStrategyId() {
// TODO Auto-generated method stub
return super.getDnsStrategyId();
}
@Override
public String getRatelimit() {
// TODO Auto-generated method stub
return super.getRatelimit();
}
}

View File

@@ -15,13 +15,13 @@ public class IpAllNotDoLogTemplate extends BasicTemplate{
protected String cfgDesc; private String cfgDesc;
protected String srcIpAddress; private String srcIpAddress;
protected String destIpAddress; private String destIpAddress;
protected String srcPort; private String srcPort;
protected String destPort; private String destPort;
protected Integer protocol; private Integer protocol;
protected Integer direction; private Integer direction;
@ExcelField(title="config_describe",align=2,sort=1) @ExcelField(title="config_describe",align=2,sort=1)
public String getCfgDesc() { public String getCfgDesc() {

View File

@@ -8,6 +8,7 @@
*/ */
package com.nis.domain.configuration.template; package com.nis.domain.configuration.template;
import com.google.gson.JsonObject;
import com.nis.util.excel.ExcelField; import com.nis.util.excel.ExcelField;
/** /**

View File

@@ -0,0 +1,310 @@
/**
*@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.template;
import com.nis.util.excel.ExcelField;
/**
* @Description: excel导入IP类配置
*/
@Deprecated
public class IpCfgTemplate {
/**
* @Fields serialVersionUID:TODO用一句话描述这个变量表示什么
*
* @since 1.0.0
*/
private Long cfgId;
private Integer ipType;//1
private Integer ipPattern;//2
private String srcIpAddress; //3
private String destIpAddress; //4
private Integer portPattern; //5
private String srcPort; //6
private String destPort;//7
private Integer protocol;//8
protected Integer direction;//9
private String cfgDesc;//10
private Integer requestId;//11
private String requestName;//12
private Integer isAreaEffective;//13
private String classify;//14
private String attribute;//15
private String lable;//16
private String classifyName;//17
private String attributeName;//18
private String lableName;//19
private String areaEffectiveIds;//20
private String ratelimit;//21
private Integer dnsStrategyId;//22
private Integer irType;//23
private String userRegion1;//77
private String userRegion2;//78
private String userRegion3;//79
private String userRegion4;//80
private String userRegion5;//81
/**
* userRegion1
* @return userRegion1
*/
// @ExcelField(title="userregion1",align=2,sort=77)
public String getUserRegion1() {
return userRegion1;
}
/**
* @param userRegion1 the userRegion1 to set
*/
public void setUserRegion1(String userRegion1) {
this.userRegion1 = userRegion1;
}
/**
* userRegion2
* @return userRegion2
*/
// @ExcelField(title="userregion2",align=2,sort=78)
public String getUserRegion2() {
return userRegion2;
}
/**
* @param userRegion2 the userRegion2 to set
*/
public void setUserRegion2(String userRegion2) {
this.userRegion2 = userRegion2;
}
/**
* userRegion3
* @return userRegion3
*/
// @ExcelField(title="userregion3",align=2,sort=79)
public String getUserRegion3() {
return userRegion3;
}
/**
* @param userRegion3 the userRegion3 to set
*/
public void setUserRegion3(String userRegion3) {
this.userRegion3 = userRegion3;
}
/**
* userRegion4
* @return userRegion4
*/
// @ExcelField(title="userregion4",align=2,sort=80)
public String getUserRegion4() {
return userRegion4;
}
/**
* @param userRegion4 the userRegion4 to set
*/
public void setUserRegion4(String userRegion4) {
this.userRegion4 = userRegion4;
}
/**
* userRegion5
* @return userRegion5
*/
// @ExcelField(title="userregion5",align=2,sort=81)
public String getUserRegion5() {
return userRegion5;
}
/**
* @param userRegion5 the userRegion5 to set
*/
public void setUserRegion5(String userRegion5) {
this.userRegion5 = userRegion5;
}
/**
* ratelimit
* @return ratelimit
*/
@ExcelField(title="ratelimit",align=2,sort=74)
public String getRatelimit() {
return ratelimit;
}
/**
* @param ratelimit the ratelimit to set
*/
public void setRatelimit(String ratelimit) {
this.ratelimit = ratelimit;
}
/**
* irType
* @return irType
*/
@ExcelField(title="ir_type",align=2,sort=76)
public Integer getIrType() {
return irType;
}
/**
* @param irType the irType to set
*/
public void setIrType(Integer irType) {
this.irType = irType;
}
/**
* dnsStrategyId
* @return dnsStrategyId
*/
@ExcelField(title="dns_strategy_id",align=2,sort=75)
public Integer getDnsStrategyId() {
return dnsStrategyId;
}
/**
* @param dnsStrategyId the dnsStrategyId to set
*/
public void setDnsStrategyId(Integer dnsStrategyId) {
this.dnsStrategyId = dnsStrategyId;
}
@ExcelField(title="ip_type",align=2,sort=1)
public Integer getIpType() {
return ipType;
}
public void setIpType(Integer ipType) {
this.ipType = ipType;
}
@ExcelField(title="ip_pattern",align=2,sort=2)
public Integer getIpPattern() {
return ipPattern;
}
public void setIpPattern(Integer ipPattern) {
this.ipPattern = ipPattern;
}
@ExcelField(title="client_ip",align=2,sort=3)
public String getSrcIpAddress() {
return srcIpAddress;
}
public void setSrcIpAddress(String srcIpAddress) {
this.srcIpAddress = srcIpAddress;
}
@ExcelField(title="server_ip",align=2,sort=4)
public String getDestIpAddress() {
return destIpAddress;
}
public void setDestIpAddress(String destIpAddress) {
this.destIpAddress = destIpAddress;
}
@ExcelField(title="port_pattern",align=2,sort=5)
public Integer getPortPattern() {
return portPattern;
}
public void setPortPattern(Integer portPattern) {
this.portPattern = portPattern;
}
@ExcelField(title="client_port",align=2,sort=6)
public String getSrcPort() {
return srcPort;
}
public void setSrcPort(String srcPort) {
this.srcPort = srcPort;
}
@ExcelField(title="server_port",align=2,sort=7)
public String getDestPort() {
return destPort;
}
public void setDestPort(String destPort) {
this.destPort = destPort;
}
public Long getCfgId() {
return cfgId;
}
public void setCfgId(Long cfgId) {
this.cfgId = cfgId;
}
@ExcelField(title="direction",align=2,sort=8)
public Integer getDirection() {
return direction;
}
public void setDirection(Integer direction) {
this.direction = direction;
}
@ExcelField(title="config_describe",align=2,sort=11)
public String getCfgDesc() {
return cfgDesc;
}
public void setCfgDesc(String cfgDesc) {
this.cfgDesc = cfgDesc;
}
@ExcelField(title="letter",align=2,sort=13)
public Integer getRequestId() {
return requestId;
}
public void setRequestId(Integer requestId) {
this.requestId = requestId;
}
public String getRequestName() {
return requestName;
}
public void setRequestName(String requestName) {
this.requestName = requestName;
}
public Integer getIsAreaEffective() {
return isAreaEffective;
}
public void setIsAreaEffective(Integer isAreaEffective) {
this.isAreaEffective = isAreaEffective;
}
@ExcelField(title="classification",align=2,sort=71)
public String getClassify() {
return classify;
}
public void setClassify(String classify) {
this.classify = classify;
}
@ExcelField(title="attribute",align=2,sort=72)
public String getAttribute() {
return attribute;
}
public void setAttribute(String attribute) {
this.attribute = attribute;
}
@ExcelField(title="label",align=2,sort=73)
public String getLable() {
return lable;
}
public void setLable(String lable) {
this.lable = lable;
}
public String getClassifyName() {
return classifyName;
}
public void setClassifyName(String classifyName) {
this.classifyName = classifyName;
}
public String getAttributeName() {
return attributeName;
}
public void setAttributeName(String attributeName) {
this.attributeName = attributeName;
}
public String getLableName() {
return lableName;
}
public void setLableName(String lableName) {
this.lableName = lableName;
}
// @ExcelField(title="area_effective",align=2,sort=70)
public String getAreaEffectiveIds() {
return areaEffectiveIds;
}
public void setAreaEffectiveIds(String areaEffectiveIds) {
this.areaEffectiveIds = areaEffectiveIds;
}
@ExcelField(title="protocol",align=2,sort=9)
public Integer getProtocol() {
return protocol;
}
public void setProtocol(Integer protocol) {
this.protocol = protocol;
}
}

View File

@@ -1,20 +0,0 @@
package com.nis.domain.configuration.template;
import com.nis.util.excel.ExcelField;
public class IpCommCfgTemplate extends IpAllNotDoLogTemplate{
@ExcelField(title="group_name",align=2,sort=10)
private String groupName;
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
}

View File

@@ -0,0 +1,47 @@
package com.nis.domain.configuration.template;
import com.nis.util.excel.ExcelField;
/**
* wx 将部分字段的标题改变,或者不需要的字段隐藏
* 隐藏方法对于不需要的字段或者方法Override该字段方法但是@ExcelField注解不需要加上了
* @author dell
*
*/
@Deprecated
public class IpMultiplexPolicyTemplate extends IpCfgTemplate {
@Override
@ExcelField(title="IP",align=2,sort=3)
public String getSrcIpAddress() {
return super.getSrcIpAddress();
}
@ExcelField(title="port",align=2,sort=6)
@Override
public String getSrcPort() {
// TODO Auto-generated method stub
return super.getSrcPort();
}
@Override
@ExcelField(title="group_name",align=2,sort=75)
public Integer getDnsStrategyId() {
// TODO Auto-generated method stub
return super.getDnsStrategyId();
}
@Override
public String getRatelimit() {
// TODO Auto-generated method stub
return super.getRatelimit();
}
@Override
public String getDestPort() {
// TODO Auto-generated method stub
return super.getDestPort();
}
@Override
public String getDestIpAddress() {
// TODO Auto-generated method stub
return super.getDestIpAddress();
}
}

View File

@@ -0,0 +1,31 @@
package com.nis.domain.configuration.template;
/**
* wx 将部分字段的标题改变,或者不需要的字段隐藏
* 隐藏方法对于不需要的字段或者方法Override该字段方法但是@ExcelField注解不需要加上了
* @author dell
*
*/
@Deprecated
public class IpsecTemplate extends IpCfgTemplate {
@Override
public Integer getIrType() {
// TODO Auto-generated method stub
return super.getIrType();
}
@Override
public Integer getDnsStrategyId() {
// TODO Auto-generated method stub
return super.getDnsStrategyId();
}
@Override
public String getRatelimit() {
// TODO Auto-generated method stub
return super.getRatelimit();
}
}

View File

@@ -1,23 +0,0 @@
package com.nis.domain.configuration.template;
import com.nis.util.excel.ExcelField;
/**
* 域名公共组配置 导入模板
* @author dell
*
*/
public class ScriberIdCommCfgTemplate extends StringAllNotDoLogTemplate{
@ExcelField(title="group_name",align=2,sort=10)
private String groupName;
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
}

View File

@@ -0,0 +1,37 @@
package com.nis.domain.configuration.template;
/**
* wx 将部分字段的标题改变,或者不需要的字段隐藏
* 隐藏方法对于不需要的字段或者方法Override该字段方法但是@ExcelField注解不需要加上了
* @author dell
*
*/
@Deprecated
public class TunnelIpTemplate extends IpCfgTemplate {
@Override
public Integer getIrType() {
// TODO Auto-generated method stub
return super.getIrType();
}
@Override
public Integer getDnsStrategyId() {
// TODO Auto-generated method stub
return super.getDnsStrategyId();
}
@Override
public String getRatelimit() {
// TODO Auto-generated method stub
return super.getRatelimit();
}
@Override
public Integer getProtocol() {
// TODO Auto-generated method stub
return 0;
}
}

View File

@@ -1,23 +0,0 @@
package com.nis.domain.configuration.template;
import com.nis.util.excel.ExcelField;
/**
* URL公共组配置 导入模板
* @author dell
*
*/
public class UrlCommCfgTemplate extends StringAllNotDoLogTemplate{
@ExcelField(title="group_name",align=2,sort=10)
private String groupName;
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
}

View File

@@ -0,0 +1,66 @@
package com.nis.domain.configuration.template;
/**
* wx 将部分字段的标题改变,或者不需要的字段隐藏
* 隐藏方法对于不需要的字段或者方法Override该字段方法但是@ExcelField注解不需要加上了
* @author dell
*
*/
@Deprecated
public class WhiteListIpTemplate extends IpCfgTemplate {
@Override
public Integer getDirection() {
// TODO Auto-generated method stub
return 0;
}
@Override
public Integer getProtocol() {
// TODO Auto-generated method stub
return 0;
}
@Override
public Integer getIrType() {
// TODO Auto-generated method stub
return super.getIrType();
}
@Override
public Integer getDnsStrategyId() {
// TODO Auto-generated method stub
return super.getDnsStrategyId();
}
@Override
public Integer getRequestId() {
// TODO Auto-generated method stub
return super.getRequestId();
}
@Override
public String getClassify() {
// TODO Auto-generated method stub
return super.getClassify();
}
@Override
public String getAttribute() {
// TODO Auto-generated method stub
return super.getAttribute();
}
@Override
public String getLable() {
// TODO Auto-generated method stub
return super.getLable();
}
@Override
public String getRatelimit() {
// TODO Auto-generated method stub
return super.getRatelimit();
}
}

View File

@@ -1,116 +0,0 @@
package com.nis.domain.dashboard;
import com.nis.domain.report.BaseReport;
import com.nis.util.excel.ExcelField;
public class ConfigStatistic extends BaseReport<ConfigStatistic>{
private static final long serialVersionUID = 8905927100915123026L;
@ExcelField(title="cfg_id",sort=1)
private String cfgId;
@ExcelField(title="config_describe",sort=2)
private String cfgDesc;
private String serviceId;
private String tableName;//表名
private String beginDate;
private String endDate;
private String area;//区域
private String operator;//运营商
private String chartType;//图表类型
public String getBeginDate() {
return beginDate;
}
public void setBeginDate(String beginDate) {
this.beginDate = beginDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getCfgId() {
return cfgId;
}
public void setCfgId(String cfgId) {
this.cfgId = cfgId;
}
public String getCfgDesc() {
return cfgDesc;
}
public void setCfgDesc(String cfgDesc) {
this.cfgDesc = cfgDesc;
}
public String getServiceId() {
return serviceId;
}
public void setServiceId(String serviceId) {
this.serviceId = serviceId;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public Long getSum() {
return sum;
}
public void setSum(Long sum) {
this.sum = sum;
}
public Integer getService() {
return service;
}
public void setService(Integer service) {
this.service = service;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
public String getChartType() {
return chartType;
}
public void setChartType(String chartType) {
this.chartType = chartType;
}
}

View File

@@ -1,94 +0,0 @@
package com.nis.domain.dashboard.codedic;
import java.io.Serializable;
import java.util.Date;
public class CodeDomainDic implements Serializable{
/**
*
*/
private static final long serialVersionUID = 8878203808371459079L;
private Integer id;
private String websiteServiceId;
private String domain;
private String topicId;
private Date createTime;
private String creatorId;
private Integer isValid;
private String ican;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getWebsiteServiceId() {
return websiteServiceId;
}
public void setWebsiteServiceId(String websiteServiceId) {
this.websiteServiceId = websiteServiceId;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public String getTopicId() {
return topicId;
}
public void setTopicId(String topicId) {
this.topicId = topicId;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getCreatorId() {
return creatorId;
}
public void setCreatorId(String creatorId) {
this.creatorId = creatorId;
}
public Integer getIsValid() {
return isValid;
}
public void setIsValid(Integer isValid) {
this.isValid = isValid;
}
public String getIcan() {
return ican;
}
public void setIcan(String ican) {
this.ican = ican;
}
}

View File

@@ -6,7 +6,7 @@ public class NtcCollectRadiusLog extends BaseLogEntity<NtcCollectRadiusLog> {
private static final long serialVersionUID = -4947912502754359817L; private static final long serialVersionUID = -4947912502754359817L;
@ExcelField(title="code",dictType="MESSAGE_TYPE",sort=10) @ExcelField(title="message_type",dictType="MESSAGE_TYPE",sort=10)
protected Integer code; protected Integer code;
@ExcelField(title="nas_ip",sort=15) @ExcelField(title="nas_ip",sort=15)
protected String nasIp; protected String nasIp;

View File

@@ -1,736 +0,0 @@
package com.nis.domain.log;
import com.google.gson.annotations.Expose;
import com.nis.domain.BaseEntity;
import com.nis.util.excel.ExcelField;
/**
* (日志 代理HTTP 操控 实体类
*
*/
public class PxyHttpManipulationLog extends BaseEntity<PxyHttpManipulationLog>{
private static final long serialVersionUID = -3046458130302949428L;
@ExcelField(title="found_time",sort=5)
protected String foundTime; //发现时间timestamp
@ExcelField(title="recv_time",sort=6)
protected String recvTime; //接收时间timestamp
@ExcelField(title="transport_layer_protocol",dictType="LOG_PROTOCOL",sort=30)
protected String transProto; //协议类型从字典LOG_PROTOCOL取值
@ExcelField(title="addr_type",dictType="IP_TYPE",sort=35)
protected Integer addrType; //ip地址类型从字典IP_TYPE取值
@ExcelField(title="URL",sort=8)
private String url;
@ExcelField(title="host",sort=8)
private String host;//主机地址
@ExcelField(title="domain_name",sort=8)
private String domain;//域名
@ExcelField(title="category",sort=8)
private String category;//域名分类
@ExcelField(title="req_line",sort=9)
private String reqLine;
@ExcelField(title="res_line",sort=10)
private String resLine;
@ExcelField(title="PXY_CACHE_HTTP_COOKIE",sort=11)
private String cookie;
@ExcelField(title="referer",sort=12)
private String referer;
@ExcelField(title="user_agent",sort=13)
private String userAgent;
@ExcelField(title="content_len",sort=14)
private String contentLen;
@ExcelField(title="content_type",sort=15)
private String contentType;
@ExcelField(title="set_cookie",sort=16)
private String setCookie;
@ExcelField(title="req_header",sort=17)
private String reqHeader;
@ExcelField(title="resp_header",sort=18)
private String respHeader;
@ExcelField(title="req_body",sort=78)
private String reqBody;
@ExcelField(title="resp_body",sort=79)
private String respBody;
// @ExcelField(title="website",sort=8)
// private String website;
@ExcelField(title="cfg_id",sort=1)
private Integer policyId;//
@ExcelField(title="app_proto",sort=31)
private String appProto;//应用协议类型
@ExcelField(title="startTime",sort=5)
private String startTime;//会话创建时间
@ExcelField(title="endTime",sort=5)
private String endTime;//会话结束时间
@Expose
@ExcelField(title="server_ip",sort=40)
protected String serverIp; //服务端ip地址
@Expose
@ExcelField(title="client_ip",sort=41)
protected String clientIp; //客户端ip地址
@Expose
@ExcelField(title="server_port",sort=42)
protected String serverPort; //服务端ip端口
@Expose
@ExcelField(title="client_port",sort=43)
protected String clientPort; //客户端ip端口
@ExcelField(title="entrance_id",dictType="ENTRANCE",sort=7)
protected Integer entranceId; //出入口编号
@ExcelField(title="deviceid",dictType="DEVICE",sort=50)
protected Integer deviceId; //串联设备编号
@ExcelField(title="direction",dictType="LOG_DIRECTION",sort=55)
protected Integer direction; //传输方向 0域内->域外1域外->域内从字典LOG_DIRECTION取值
@ExcelField(title="stream_type",dictType="LOG_STREAM_TYPE",sort=65)
protected Integer streamDir; //流类型 0c2s1s2c2double从字典LOG_STREAMTYPE取值
@ExcelField(title="clj_ip",sort=27)
protected String capIp; //处理机IP
@ExcelField(title="nest_addr_list",sort=66)
protected String addrList; //嵌套地址列表
@ExcelField(title="server_locate",sort=67)
protected String serverLocation;// 服务端地址定位信息
@ExcelField(title="client_locate",sort=68)
protected String clientLocation;// 客户端地址定位信息
@ExcelField(title="s_asn",sort=70)
protected String clientAsn;//客户端ASN
@ExcelField(title="d_asn",sort=71)
protected String serverAsn;//服务端ASN
@ExcelField(title="s_subscribe_id",sort=73)
protected String subscribeId;//客户端用户名
@ExcelField(title="scene_file",sort=77)
protected String sceneFile;//现场日志文件地址
@ExcelField(title="isp",sort=80)
protected String isp;//运营商
protected Integer service; //配置表的serviceId
protected Integer functionId;
@ExcelField(title="action",dictType="SERVICE_ACTION",sort=2)
protected Integer action;
//新增字段
@ExcelField(title="encap_type",dictType="ENCAP_TYPE",sort=52)
protected Integer encapType;//原始二层封装格式
@ExcelField(title="link_id",dictType="LINK",sort=51)
protected Integer linkId;//串联设备链路号
@ExcelField(title="inner_smac",sort=58)
protected String innerSmac;//MAC_IN_MAC的内层源MAC
@ExcelField(title="inner_dmac",sort=59)
protected String innerDmac;//MAC_IN_MAC的内层目标MAC
//自定义字段
protected String date;//配置界面日志总量查询时间
protected String seltype;//选中类型,页面搜索用
protected String searchFoundStartTime;//开始时间格式为yyyy-mm-dd hh24:mi:ss
protected String searchFoundEndTime;//结束时间,格式同上
protected String isLogTotalSearch;//由配置界面跳转日志查询标识
protected String orderBy;//排序参数
protected Integer cfgId;
protected String fields;
protected Integer compileId;//
protected String startRecvTime;//开始时间
protected String endRecvTime; //结束时间
@ExcelField(title="con_duration_ms",sort=81)
protected Integer conDurationMs;//通信时长
protected String reqBodyKey;//请求体转储文件KEY
protected String resBodyKey;//应答体转储文件KEY
@ExcelField(title="version",sort=82)
protected String version;//版本
@ExcelField(title="sni",sort=83)
protected String sni;//
@ExcelField(title="san",sort=84)
protected String san;
@ExcelField(title="cn",sort=85)
protected String cn;
@ExcelField(title="social_app",sort=86)
protected String appId;//app
// @ExcelField(title="social_app",sort=86)
protected String appName;//app
@ExcelField(title="protocol",sort=87)
protected String protocolId;//协议
// @ExcelField(title="protocol",sort=87)
protected String protocolName;//协议
@ExcelField(title="con_latency_ms",sort=88)
protected Integer conLatencyMs;//握手延迟
@ExcelField(title="pinning",dictType="PINNING",sort=89)
protected Integer pinningst;//pinning状态
@ExcelField(title="intercept_state",dictType="INTERCEPT_STATE",sort=90)
protected Integer interceptState;//拦截状态
@ExcelField(title="ssl_server_side_latency",sort=91)
protected Integer sslServerSideLatency;//服务器侧ssl建立延迟
@ExcelField(title="ssl_client_side_latency",sort=92)
protected Integer sslClientSideLatency;//客户端侧ssl建立延迟
@ExcelField(title="ssl_server_side_version",dictType="SSL_VERSION",sort=93)
protected String sslServerSideVersion;//服务端侧ssl版本
@ExcelField(title="ssl_client_side_version",dictType="SSL_VERSION",sort=94)
protected String sslClientSideVersion;//客户端侧ssl版本
@ExcelField(title="ssl_cert_verify",dictType="SSL_CERT_VERIFY",sort=95)
protected Integer sslCertVerify;//证书校验结果
@ExcelField(title="stream_trace_id",sort=96)
protected String streamTraceId;//流的追踪ID
@ExcelField(title="ssl_error",sort=97)
protected String sslError;//ssl错误信息
@ExcelField(title="c2s_pkt_num",sort=98)
protected Integer c2sPktNum;//c2s包数
@ExcelField(title="s2c_pkt_num",sort=99)
protected Integer s2cPktNum;//s2c包数
@ExcelField(title="c2s_byte_num",sort=100)
protected Integer c2sByteNum;//c2s字节数
@ExcelField(title="s2c_byte_num",sort=101)
protected Integer s2cByteNum;//s2c字节数
@ExcelField(title="nas_ip",sort=102)
protected String nasIp;//ISN接入的IP
@ExcelField(title="framed_ip",sort=103)
protected String framedIp;//用户IP地址
@ExcelField(title="account",sort=104)
protected String account;//用户名
@ExcelField(title="packet_type",dictType="MESSAGE_TYPE",sort=105)
protected Integer packetType;//报文类型
protected String dIp;
protected String sIp;
public String getProtocolName() {
return protocolName;
}
public void setProtocolName(String protocolName) {
this.protocolName = protocolName;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getdIp() {
return dIp;
}
public void setdIp(String dIp) {
this.dIp = dIp;
}
public String getsIp() {
return sIp;
}
public void setsIp(String sIp) {
this.sIp = sIp;
}
public String getAppProto() {
return appProto;
}
public void setAppProto(String appProto) {
this.appProto = appProto;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getReqLine() {
return reqLine;
}
public void setReqLine(String reqLine) {
this.reqLine = reqLine;
}
public String getResLine() {
return resLine;
}
public void setResLine(String resLine) {
this.resLine = resLine;
}
public String getCookie() {
return cookie;
}
public void setCookie(String cookie) {
this.cookie = cookie;
}
public String getReferer() {
return referer;
}
public void setReferer(String referer) {
this.referer = referer;
}
public String getUserAgent() {
return userAgent;
}
public void setUserAgent(String userAgent) {
this.userAgent = userAgent;
}
public String getContentLen() {
return contentLen;
}
public void setContentLen(String contentLen) {
this.contentLen = contentLen;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public String getSetCookie() {
return setCookie;
}
public void setSetCookie(String setCookie) {
this.setCookie = setCookie;
}
public String getReqHeader() {
return reqHeader;
}
public void setReqHeader(String reqHeader) {
this.reqHeader = reqHeader;
}
public String getRespHeader() {
return respHeader;
}
public void setRespHeader(String respHeader) {
this.respHeader = respHeader;
}
public String getReqBody() {
return reqBody;
}
public void setReqBody(String reqBody) {
this.reqBody = reqBody;
}
public String getRespBody() {
return respBody;
}
public void setRespBody(String respBody) {
this.respBody = respBody;
}
// public String getWebsite() {
// return website;
// }
// public void setWebsite(String website) {
// this.website = website;
// }
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getIsp() {
return isp;
}
public void setIsp(String isp) {
this.isp = isp;
}
public Integer getPolicyId() {
return policyId;
}
public void setPolicyId(Integer policyId) {
this.policyId = policyId;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getServerIp() {
return serverIp;
}
public void setServerIp(String serverIp) {
this.serverIp = serverIp;
}
public String getClientIp() {
return clientIp;
}
public void setClientIp(String clientIp) {
this.clientIp = clientIp;
}
public String getServerPort() {
return serverPort;
}
public void setServerPort(String serverPort) {
this.serverPort = serverPort;
}
public String getClientPort() {
return clientPort;
}
public void setClientPort(String clientPort) {
this.clientPort = clientPort;
}
public String getServerLocation() {
return serverLocation;
}
public void setServerLocation(String serverLocation) {
this.serverLocation = serverLocation;
}
public String getClientLocation() {
return clientLocation;
}
public void setClientLocation(String clientLocation) {
this.clientLocation = clientLocation;
}
public String getClientAsn() {
return clientAsn;
}
public void setClientAsn(String clientAsn) {
this.clientAsn = clientAsn;
}
public String getServerAsn() {
return serverAsn;
}
public void setServerAsn(String serverAsn) {
this.serverAsn = serverAsn;
}
public String getSubscribeId() {
return subscribeId;
}
public void setSubscribeId(String subscribeId) {
this.subscribeId = subscribeId;
}
public Integer getConDurationMs() {
return conDurationMs;
}
public void setConDurationMs(Integer conDurationMs) {
this.conDurationMs = conDurationMs;
}
public String getReqBodyKey() {
return reqBodyKey;
}
public void setReqBodyKey(String reqBodyKey) {
this.reqBodyKey = reqBodyKey;
}
public String getResBodyKey() {
return resBodyKey;
}
public void setResBodyKey(String resBodyKey) {
this.resBodyKey = resBodyKey;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getSni() {
return sni;
}
public void setSni(String sni) {
this.sni = sni;
}
public String getSan() {
return san;
}
public void setSan(String san) {
this.san = san;
}
public String getCn() {
return cn;
}
public void setCn(String cn) {
this.cn = cn;
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getProtocolId() {
return protocolId;
}
public void setProtocolId(String protocolId) {
this.protocolId = protocolId;
}
public Integer getConLatencyMs() {
return conLatencyMs;
}
public void setConLatencyMs(Integer conLatencyMs) {
this.conLatencyMs = conLatencyMs;
}
public Integer getPinningst() {
return pinningst;
}
public void setPinningst(Integer pinningst) {
this.pinningst = pinningst;
}
public Integer getC2sPktNum() {
return c2sPktNum;
}
public void setC2sPktNum(Integer c2sPktNum) {
this.c2sPktNum = c2sPktNum;
}
public Integer getS2cPktNum() {
return s2cPktNum;
}
public void setS2cPktNum(Integer s2cPktNum) {
this.s2cPktNum = s2cPktNum;
}
public Integer getC2sByteNum() {
return c2sByteNum;
}
public void setC2sByteNum(Integer c2sByteNum) {
this.c2sByteNum = c2sByteNum;
}
public Integer getS2cByteNum() {
return s2cByteNum;
}
public void setS2cByteNum(Integer s2cByteNum) {
this.s2cByteNum = s2cByteNum;
}
public String getNasIp() {
return nasIp;
}
public void setNasIp(String nasIp) {
this.nasIp = nasIp;
}
public String getFramedIp() {
return framedIp;
}
public void setFramedIp(String framedIp) {
this.framedIp = framedIp;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public Integer getPacketType() {
return packetType;
}
public void setPacketType(Integer packetType) {
this.packetType = packetType;
}
public Integer getCompileId() {
return compileId;
}
public void setCompileId(Integer compileId) {
this.compileId = compileId;
}
public String getStartRecvTime() {
return startRecvTime;
}
public void setStartRecvTime(String startRecvTime) {
this.startRecvTime = startRecvTime;
}
public String getEndRecvTime() {
return endRecvTime;
}
public void setEndRecvTime(String endRecvTime) {
this.endRecvTime = endRecvTime;
}
public String getFoundTime() {
return foundTime;
}
public void setFoundTime(String foundTime) {
this.foundTime = foundTime;
}
public String getRecvTime() {
return recvTime;
}
public void setRecvTime(String recvTime) {
this.recvTime = recvTime;
}
public String getTransProto() {
return transProto;
}
public void setTransProto(String transProto) {
this.transProto = transProto;
}
public Integer getAddrType() {
return addrType;
}
public void setAddrType(Integer addrType) {
this.addrType = addrType;
}
public Integer getEntranceId() {
return entranceId;
}
public void setEntranceId(Integer entranceId) {
this.entranceId = entranceId;
}
public Integer getDeviceId() {
return deviceId;
}
public void setDeviceId(Integer deviceId) {
this.deviceId = deviceId;
}
public Integer getDirection() {
return direction;
}
public void setDirection(Integer direction) {
this.direction = direction;
}
public Integer getStreamDir() {
return streamDir;
}
public void setStreamDir(Integer streamDir) {
this.streamDir = streamDir;
}
public String getCapIp() {
return capIp;
}
public void setCapIp(String capIp) {
this.capIp = capIp;
}
public String getAddrList() {
return addrList;
}
public void setAddrList(String addrList) {
this.addrList = addrList;
}
public String getSceneFile() {
return sceneFile;
}
public void setSceneFile(String sceneFile) {
this.sceneFile = sceneFile;
}
public Integer getService() {
return service;
}
public void setService(Integer service) {
this.service = service;
}
public Integer getFunctionId() {
return functionId;
}
public void setFunctionId(Integer functionId) {
this.functionId = functionId;
}
public Integer getAction() {
return action;
}
public void setAction(Integer action) {
this.action = action;
}
public Integer getEncapType() {
return encapType;
}
public void setEncapType(Integer encapType) {
this.encapType = encapType;
}
public Integer getLinkId() {
return linkId;
}
public void setLinkId(Integer linkId) {
this.linkId = linkId;
}
public String getInnerSmac() {
return innerSmac;
}
public void setInnerSmac(String innerSmac) {
this.innerSmac = innerSmac;
}
public String getInnerDmac() {
return innerDmac;
}
public void setInnerDmac(String innerDmac) {
this.innerDmac = innerDmac;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getSeltype() {
return seltype;
}
public void setSeltype(String seltype) {
this.seltype = seltype;
}
public String getSearchFoundStartTime() {
return searchFoundStartTime;
}
public void setSearchFoundStartTime(String searchFoundStartTime) {
this.searchFoundStartTime = searchFoundStartTime;
}
public String getSearchFoundEndTime() {
return searchFoundEndTime;
}
public void setSearchFoundEndTime(String searchFoundEndTime) {
this.searchFoundEndTime = searchFoundEndTime;
}
public String getIsLogTotalSearch() {
return isLogTotalSearch;
}
public void setIsLogTotalSearch(String isLogTotalSearch) {
this.isLogTotalSearch = isLogTotalSearch;
}
public String getOrderBy() {
return orderBy;
}
public void setOrderBy(String orderBy) {
this.orderBy = orderBy;
}
public Integer getInterceptState() {
return interceptState;
}
public void setInterceptState(Integer interceptState) {
this.interceptState = interceptState;
}
public Integer getSslServerSideLatency() {
return sslServerSideLatency;
}
public void setSslServerSideLatency(Integer sslServerSideLatency) {
this.sslServerSideLatency = sslServerSideLatency;
}
public Integer getSslClientSideLatency() {
return sslClientSideLatency;
}
public void setSslClientSideLatency(Integer sslClientSideLatency) {
this.sslClientSideLatency = sslClientSideLatency;
}
public String getSslServerSideVersion() {
return sslServerSideVersion;
}
public void setSslServerSideVersion(String sslServerSideVersion) {
this.sslServerSideVersion = sslServerSideVersion;
}
public String getSslClientSideVersion() {
return sslClientSideVersion;
}
public void setSslClientSideVersion(String sslClientSideVersion) {
this.sslClientSideVersion = sslClientSideVersion;
}
public Integer getSslCertVerify() {
return sslCertVerify;
}
public void setSslCertVerify(Integer sslCertVerify) {
this.sslCertVerify = sslCertVerify;
}
public String getStreamTraceId() {
return streamTraceId;
}
public void setStreamTraceId(String streamTraceId) {
this.streamTraceId = streamTraceId;
}
public String getSslError() {
return sslError;
}
public void setSslError(String sslError) {
this.sslError = sslError;
}
public Integer getCfgId() {
return cfgId;
}
public void setCfgId(Integer cfgId) {
this.cfgId = cfgId;
}
public String getFields() {
return fields;
}
public void setFields(String fields) {
this.fields = fields;
}
}

View File

@@ -1,140 +0,0 @@
package com.nis.domain.maat;
import java.io.Serializable;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* 管控策略动作参数
*/
public class ManipulatActionParam implements Serializable{
private static final long serialVersionUID = 7282481538239386968L;
@Expose
private String method;
@Expose
private Integer code;
@Expose
private String to;
@Expose
private String message;
@Expose
private Integer html_profile;
@Expose
private List<ReplaceCfg> rules;
public static class ReplaceCfg{
@Expose
private String search_in;
@Expose
private String find;
@Expose
private String replace_with;
public String getSearch_in() {
return search_in;
}
public void setSearch_in(String search_in) {
this.search_in = search_in;
}
public String getFind() {
return find;
}
public void setFind(String find) {
this.find = find;
}
public String getReplace_with() {
return replace_with;
}
public void setReplace_with(String replace_with) {
this.replace_with = replace_with;
}
}
@Expose
private Integer hijack_profile;
@Expose
private Integer insert_profile;
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getTo() {
return to;
}
public void setTo(String to) {
this.to = to;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Integer getHtml_profile() {
return html_profile;
}
public void setHtml_profile(Integer html_profile) {
this.html_profile = html_profile;
}
public List<ReplaceCfg> getRules() {
return rules;
}
public void setRules(List<ReplaceCfg> rules) {
this.rules = rules;
}
public Integer getHijack_profile() {
return hijack_profile;
}
public void setHijack_profile(Integer hijack_profile) {
this.hijack_profile = hijack_profile;
}
public Integer getInsert_profile() {
return insert_profile;
}
public void setInsert_profile(Integer insert_profile) {
this.insert_profile = insert_profile;
}
}

View File

@@ -9,7 +9,6 @@
package com.nis.domain.report; package com.nis.domain.report;
import com.nis.domain.BaseEntity; import com.nis.domain.BaseEntity;
import com.nis.util.excel.ExcelField;
/** /**
* @ClassName: BaseReportLog.java * @ClassName: BaseReportLog.java
@@ -26,7 +25,6 @@ public class BaseReport<T> extends BaseEntity<T>{
*/ */
private static final long serialVersionUID = -6190203013788730697L; private static final long serialVersionUID = -6190203013788730697L;
@ExcelField(title="config_log_total",sort=3)
protected Long sum; protected Long sum;
protected Integer service; protected Integer service;
protected String reportTime; protected String reportTime;

View File

@@ -30,15 +30,13 @@ public class SpecificServiceHostCfg extends BaseEntity<SpecificServiceHostCfg>{
@Expose @Expose
private Integer protocol; //protocol 协议 int N 6表示tcp,17表示udp0表示任意 private Integer protocol; //protocol 协议 int N 6表示tcp,17表示udp0表示任意
@Expose @Expose
private Integer srcIpPattern; //ip格式 private Integer ipPattern; //ip格式
private Integer destIpPattern; //ip格式
@Expose @Expose
private String srcIpAddress; //源客户端IP地址 private String srcIpAddress; //源客户端IP地址
@Expose @Expose
private String destIpAddress; //目的服务器IP地址 private String destIpAddress; //目的服务器IP地址
@Expose @Expose
private Integer srcPortPattern; //端口格式 private Integer portPattern; //端口格式
private Integer destPortPattern; //端口格式
@Expose @Expose
private String srcPort; //源(客户端)端口 private String srcPort; //源(客户端)端口
@Expose @Expose
@@ -116,33 +114,19 @@ public class SpecificServiceHostCfg extends BaseEntity<SpecificServiceHostCfg>{
public void setDestPort(String destPort) { public void setDestPort(String destPort) {
this.destPort = destPort; this.destPort = destPort;
} }
@ExcelField(title="src_ip_pattern",align=2,sort=21,fieldType=Integer.class) @ExcelField(title="ip_pattern",align=2,sort=21,fieldType=Integer.class)
public Integer getSrcIpPattern() { public Integer getIpPattern() {
return srcIpPattern; return ipPattern;
} }
public void setSrcIpPattern(Integer srcIpPattern) { public void setIpPattern(Integer ipPattern) {
this.srcIpPattern = srcIpPattern; this.ipPattern = ipPattern;
} }
@ExcelField(title="dest_ip_pattern",align=2,sort=22,fieldType=Integer.class) @ExcelField(title="port_pattern",align=2,sort=40,fieldType=Integer.class)
public Integer getDestIpPattern() { public Integer getPortPattern() {
return destIpPattern; return portPattern;
} }
public void setDestIpPattern(Integer destIpPattern) { public void setPortPattern(Integer portPattern) {
this.destIpPattern = destIpPattern; this.portPattern = portPattern;
}
@ExcelField(title="src_port_pattern",align=2,sort=40,fieldType=Integer.class)
public Integer getSrcPortPattern() {
return srcPortPattern;
}
public void setSrcPortPattern(Integer srcPortPattern) {
this.srcPortPattern = srcPortPattern;
}
@ExcelField(title="dest_port_pattern",align=2,sort=41,fieldType=Integer.class)
public Integer getDestPortPattern() {
return destPortPattern;
}
public void setDestPortPattern(Integer destPortPattern) {
this.destPortPattern = destPortPattern;
} }
@ExcelField(title="direction",align=2,sort=110) @ExcelField(title="direction",align=2,sort=110)
public Integer getDirection() { public Integer getDirection() {

View File

@@ -330,7 +330,7 @@ public class ScheduleCfgJob implements Job {
Calendar invalidCal=Calendar.getInstance(); Calendar invalidCal=Calendar.getInstance();
invalidCal.setTime(invalidTime); invalidCal.setTime(invalidTime);
invalidCal.add(Calendar.MINUTE, 2); invalidCal.add(Calendar.MINUTE, 2);
long invalidTimes=invalidCal.getTime().getTime(); long invalidTimes=validStartCal.getTime().getTime();
long currentTimes=new Date().getTime(); long currentTimes=new Date().getTime();
//开始时间设置为今天已过时,则将开始时间加上周期 //开始时间设置为今天已过时,则将开始时间加上周期
if((currentTimes-validStartTimes) > 0) { if((currentTimes-validStartTimes) > 0) {

View File

@@ -7,7 +7,6 @@ import com.nis.domain.dashboard.SysIspInfo;
import com.nis.domain.dashboard.codedic.CodeAppDic; import com.nis.domain.dashboard.codedic.CodeAppDic;
import com.nis.domain.dashboard.codedic.CodeBehaviorTypeDic; import com.nis.domain.dashboard.codedic.CodeBehaviorTypeDic;
import com.nis.domain.dashboard.codedic.CodeBrowserTypeDic; import com.nis.domain.dashboard.codedic.CodeBrowserTypeDic;
import com.nis.domain.dashboard.codedic.CodeDomainDic;
import com.nis.domain.dashboard.codedic.CodeOsTypeDic; import com.nis.domain.dashboard.codedic.CodeOsTypeDic;
import com.nis.domain.dashboard.codedic.CodeProtocolTypeDic; import com.nis.domain.dashboard.codedic.CodeProtocolTypeDic;
import com.nis.domain.dashboard.codedic.CodeServiceTypeDic; import com.nis.domain.dashboard.codedic.CodeServiceTypeDic;
@@ -15,7 +14,6 @@ import com.nis.domain.dashboard.codedic.CodeWebServiceDic;
import com.nis.web.dao.dashboard.codedic.CodeAppDicDao; import com.nis.web.dao.dashboard.codedic.CodeAppDicDao;
import com.nis.web.dao.dashboard.codedic.CodeBehaviorTypeDicDao; import com.nis.web.dao.dashboard.codedic.CodeBehaviorTypeDicDao;
import com.nis.web.dao.dashboard.codedic.CodeBrowserTypeDicDao; import com.nis.web.dao.dashboard.codedic.CodeBrowserTypeDicDao;
import com.nis.web.dao.dashboard.codedic.CodeDomainDicDao;
import com.nis.web.dao.dashboard.codedic.CodeOsTypeDicDao; import com.nis.web.dao.dashboard.codedic.CodeOsTypeDicDao;
import com.nis.web.dao.dashboard.codedic.CodeProtocolTypeDicDao; import com.nis.web.dao.dashboard.codedic.CodeProtocolTypeDicDao;
import com.nis.web.dao.dashboard.codedic.CodeResult; import com.nis.web.dao.dashboard.codedic.CodeResult;
@@ -33,7 +31,6 @@ public class CodeDicUtils {
private final static CodeServiceTypeDicDao codeServiceTypeDicDao = SpringContextHolder.getBean(CodeServiceTypeDicDao.class); private final static CodeServiceTypeDicDao codeServiceTypeDicDao = SpringContextHolder.getBean(CodeServiceTypeDicDao.class);
private final static CodeWebServiceDicDao codeWebServiceDicDao = SpringContextHolder.getBean(CodeWebServiceDicDao.class); private final static CodeWebServiceDicDao codeWebServiceDicDao = SpringContextHolder.getBean(CodeWebServiceDicDao.class);
private final static CodeSysIspInfoDicDao codeSysIspInfoDicDao = SpringContextHolder.getBean(CodeSysIspInfoDicDao.class); private final static CodeSysIspInfoDicDao codeSysIspInfoDicDao = SpringContextHolder.getBean(CodeSysIspInfoDicDao.class);
private final static CodeDomainDicDao codeDomainDicDao = SpringContextHolder.getBean(CodeDomainDicDao.class);
private static final String APP_CODE="appCode"; private static final String APP_CODE="appCode";
@@ -45,7 +42,6 @@ public class CodeDicUtils {
private static final String WEB_CODE="webCode"; private static final String WEB_CODE="webCode";
private static final String ISP_CODE="ispCode"; private static final String ISP_CODE="ispCode";
private static final String DOMAIN_CODE="domainCode";
/** /**
* 适用于大屏图表标签显示 * 适用于大屏图表标签显示
*/ */
@@ -182,23 +178,6 @@ public class CodeDicUtils {
} }
} }
return result; return result;
}else if (name.equals(DOMAIN_CODE)) {
// List<CodeWebServiceDic> codeDicList = (List<CodeWebServiceDic>) CacheUtils.get(WEB_CODE);
// if(StringUtil.isEmpty(codeDicList)){
// codeDicList = codeWebServiceDicDao.getCodeDicList();
// CacheUtils.put(WEB_CODE, codeDicList);
// }
List<CodeDomainDic> codeDicList = codeDomainDicDao.getCodeDicList();
if(codeDicList!=null&&codeDicList.size()>0){
for (int i = 0; i < codeDicList.size(); i++) {
CodeResult codeResult = new CodeResult();
codeResult.setItem(codeDicList.get(i).getDomain());
codeResult.setCode(String.valueOf(codeDicList.get(i).getId()));
result.add(codeResult);
}
}
return result;
} }
return result; return result;
} }

View File

@@ -1,17 +1,11 @@
package com.nis.util; package com.nis.util;
import java.lang.reflect.Field; import java.util.ArrayList;
import java.lang.reflect.Type; import java.util.Date;
import java.text.SimpleDateFormat; import java.util.HashMap;
import java.util.*; import java.util.List;
import java.util.Map;
import com.google.gson.*;
import com.google.gson.reflect.TypeToken;
import com.nis.domain.FunctionServiceDict;
import com.nis.domain.configuration.*;
import com.nis.web.service.BaseService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringEscapeUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -21,6 +15,13 @@ import com.google.common.collect.Lists;
import com.googlecode.ipv6.IPv6Address; import com.googlecode.ipv6.IPv6Address;
import com.googlecode.ipv6.IPv6Network; import com.googlecode.ipv6.IPv6Network;
import com.nis.domain.basics.AsnIpCfg; import com.nis.domain.basics.AsnIpCfg;
import com.nis.domain.configuration.AppIpCfg;
import com.nis.domain.configuration.BaseCfg;
import com.nis.domain.configuration.BaseIpCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.domain.configuration.FileDigestCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.maat.MaatCfg.DigestCfg; import com.nis.domain.maat.MaatCfg.DigestCfg;
import com.nis.domain.maat.MaatCfg.GroupCfg; import com.nis.domain.maat.MaatCfg.GroupCfg;
import com.nis.domain.maat.MaatCfg.IpCfg; import com.nis.domain.maat.MaatCfg.IpCfg;
@@ -232,6 +233,7 @@ public class ConfigConvertUtil {
* @param dstList * @param dstList
* @param srcList * @param srcList
* @param cfgType1为IP类型2为字符串类型3为增强字符串4数值类型5摘要类,6回调类[但字符串类域配置和增强字符串域配置在接口参数中同属于strRegionList] * @param cfgType1为IP类型2为字符串类型3为增强字符串4数值类型5摘要类,6回调类[但字符串类域配置和增强字符串域配置在接口参数中同属于strRegionList]
* @param baseCfg配置基本信息
* @param groupRelationList * @param groupRelationList
* 配置分组列表 * 配置分组列表
* @return * @return
@@ -393,45 +395,31 @@ public class ConfigConvertUtil {
*/ */
public static List<IpCfg> ipConvert(IpCfg dstIp, BaseIpCfg srcIp) { public static List<IpCfg> ipConvert(IpCfg dstIp, BaseIpCfg srcIp) {
List<IpCfg> ipConvertList = Lists.newArrayList(); List<IpCfg> ipConvertList = Lists.newArrayList();
List<IpCfg> tempList = Lists.newArrayList(); boolean isRange = ((srcIp.getIpPattern() != null && srcIp.getIpPattern() == 2)
List<IpCfg> tempList1 = Lists.newArrayList(); || (srcIp.getSrcIpAddress() != null && srcIp.getSrcIpAddress().indexOf("-") > -1)
if (srcIp.getIpType().equals(4)) {// IP V4 || (srcIp.getDestIpAddress() != null && srcIp.getDestIpAddress().indexOf("-") > -1));
if(srcIp.getSrcIpPattern().equals(2)) {//源IP范围 if (isRange) {
if (srcIp.getSrcIpAddress() != null) { List<IpCfg> tempList = Lists.newArrayList();
String startIpPart = srcIp.getSrcIpAddress().split("-")[0]; List<IpCfg> tempList1 = Lists.newArrayList();
String endIpPart = srcIp.getSrcIpAddress().split("-")[1]; if (srcIp.getIpType().intValue() == 4) {
Integer startNum = Integer.parseInt(startIpPart.split("\\.")[3]); if (srcIp.getSrcIpAddress() != null) {
Integer endNum = Integer.parseInt(endIpPart.split("\\.")[3]); String startIpPart = srcIp.getSrcIpAddress().split("-")[0];
for (int i = startNum; i <= endNum; i++) { String endIpPart = srcIp.getSrcIpAddress().split("-")[1];
IpCfg tempIp = new IpCfg(); Integer startNum = Integer.parseInt(startIpPart.split("\\.")[3]);
BeanUtils.copyProperties(dstIp, tempIp); Integer endNum = Integer.parseInt(endIpPart.split("\\.")[3]);
tempIp.setSrcIp(startIpPart.substring(0, startIpPart.lastIndexOf(".") + 1) + i); for (int i = startNum; i <= endNum; i++) {
tempIp.setSrcIpMask("255.255.255.255"); IpCfg tempIp = new IpCfg();
tempList.add(tempIp); BeanUtils.copyProperties(dstIp, tempIp);
} tempIp.setSrcIp(startIpPart.substring(0, startIpPart.lastIndexOf(".") + 1) + i);
}else { tempIp.setSrcIpMask("255.255.255.255");
dstIp.setSrcIp("0.0.0.0"); tempList.add(tempIp);
dstIp.setSrcIpMask("255.255.255.255");
tempList.add(dstIp);
} }
}else if(srcIp.getSrcIpPattern().equals(1)){
Integer srcMaskNum = Integer.parseInt(srcIp.getSrcIpAddress().split("/")[1]);
if (srcMaskNum == 0) {
dstIp.setSrcIpMask("0.0.0.0");
} else { } else {
dstIp.setSrcIpMask(IpUtil.convertMask(srcMaskNum)); dstIp.setSrcIp("0.0.0.0");
dstIp.setSrcIpMask("255.255.255.255");
tempList.add(dstIp);
} }
dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]); if (srcIp.getDestIpAddress() != null) {
tempList.add(dstIp);
}else if(srcIp.getSrcIpPattern().equals(3)){
dstIp.setSrcIp(srcIp.getSrcIpAddress());
dstIp.setSrcIpMask("255.255.255.255");
tempList.add(dstIp);
}else {
throw new RuntimeException("Unsupported IP Pattern " + srcIp.getSrcIpPattern());
}
if (srcIp.getDestIpAddress() != null) {
if(srcIp.getDestIpPattern().equals(2)) {
String startIpPart = srcIp.getDestIpAddress().split("-")[0]; String startIpPart = srcIp.getDestIpAddress().split("-")[0];
String endIpPart = srcIp.getDestIpAddress().split("-")[1]; String endIpPart = srcIp.getDestIpAddress().split("-")[1];
Integer startNum = Integer.parseInt(startIpPart.split("\\.")[3]); Integer startNum = Integer.parseInt(startIpPart.split("\\.")[3]);
@@ -451,93 +439,217 @@ public class ConfigConvertUtil {
} }
} }
tempList.clear(); tempList.clear();
}else if(srcIp.getDestIpPattern().equals(1)) { } else {
Integer dstMaskNum = Integer.parseInt(srcIp.getDestIpAddress().split("/")[1]);
for (IpCfg _cfg : tempList) { for (IpCfg _cfg : tempList) {
IpCfg tempIp = new IpCfg(); _cfg.setDstIp("0.0.0.0");
BeanUtils.copyProperties(_cfg, tempIp); _cfg.setSrcIpMask("255.255.255.255");
if (dstMaskNum == 0) { convertPortValues(_cfg, srcIp);
tempIp.setDstIpMask("0.0.0.0");
} else {
tempIp.setDstIpMask(IpUtil.convertMask(dstMaskNum));
}
tempIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]);
if (!tempIp.getSrcIp().equals(tempIp.getDstIp())) {
// 处理
convertPortValues(tempIp, srcIp);
tempList1.add(tempIp);
}
} }
tempList.clear();
}else {
for (IpCfg _cfg : tempList) {
IpCfg tempIp = new IpCfg();
BeanUtils.copyProperties(_cfg, tempIp);
tempIp.setDstIp(srcIp.getDestIpAddress());
if (!tempIp.getSrcIp().equals(tempIp.getDstIp())) {
tempIp.setDstIpMask("255.255.255.255");
// 处理
convertPortValues(tempIp, srcIp);
tempList1.add(tempIp);
}
}
tempList.clear();
} }
}else { if (tempList1.size() > 0) {
for (IpCfg _cfg : tempList) { ipConvertList.addAll(tempList1);
_cfg.setDstIp("0.0.0.0"); } else {
_cfg.setSrcIpMask("255.255.255.255"); ipConvertList.addAll(tempList);
convertPortValues(_cfg, srcIp);
} }
} } else if (srcIp.getIpType().intValue() == 6) {
if (tempList1.size() > 0) { if (srcIp.getSrcIpAddress() != null) {
ipConvertList.addAll(tempList1);
} else {
ipConvertList.addAll(tempList);
}
}else if(srcIp.getIpType().equals(6)){// IP V6
if (srcIp.getSrcIpAddress() != null) {
if(srcIp.getSrcIpPattern().equals(2)) {
IPv6Address address1 = IPv6Address.fromString(srcIp.getSrcIpAddress().split("-")[0]); IPv6Address address1 = IPv6Address.fromString(srcIp.getSrcIpAddress().split("-")[0]);
IPv6Address address2 = IPv6Address.fromString(srcIp.getSrcIpAddress().split("-")[1]); IPv6Address address2 = IPv6Address.fromString(srcIp.getSrcIpAddress().split("-")[1]);
IPv6Network network = IPv6Network.fromTwoAddresses(address1, address2); IPv6Network network = IPv6Network.fromTwoAddresses(address1, address2);
dstIp.setSrcIp(address1.toString()); dstIp.setSrcIp(address1.toString());
dstIp.setSrcIpMask(network.getNetmask().asAddress().toString()); dstIp.setSrcIpMask(network.getNetmask().asAddress().toString());
}else if(srcIp.getSrcIpPattern().equals(1)){// IP/掩码 } else {
IPv6Network strangeNetwork = IPv6Network.fromString(srcIp.getSrcIpAddress()); dstIp.setSrcIp("::");
dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]);
dstIp.setSrcIpMask(strangeNetwork.getNetmask().asAddress().toString());
}else {// IP
dstIp.setSrcIp(srcIp.getSrcIpAddress());
dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
} }
} else { if (srcIp.getDestIpAddress() != null) {
dstIp.setSrcIp("::");
dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
}
if (srcIp.getDestIpAddress() != null) {
if(srcIp.getDestIpPattern().equals(2)) {
IPv6Address address1 = IPv6Address.fromString(srcIp.getDestIpAddress().split("-")[0]); IPv6Address address1 = IPv6Address.fromString(srcIp.getDestIpAddress().split("-")[0]);
IPv6Address address2 = IPv6Address.fromString(srcIp.getDestIpAddress().split("-")[1]); IPv6Address address2 = IPv6Address.fromString(srcIp.getDestIpAddress().split("-")[1]);
IPv6Network network = IPv6Network.fromTwoAddresses(address1, address2); IPv6Network network = IPv6Network.fromTwoAddresses(address1, address2);
dstIp.setDstIp(address1.toString()); dstIp.setDstIp(address1.toString());
dstIp.setDstIpMask(network.getNetmask().asAddress().toString()); dstIp.setDstIpMask(network.getNetmask().asAddress().toString());
}else if(srcIp.getDestIpPattern().equals(1)) {// IP/掩码 } else {
IPv6Network strangeNetwork = IPv6Network.fromString(srcIp.getDestIpAddress()); dstIp.setDstIp("::");
dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]);
dstIp.setDstIpMask(strangeNetwork.getNetmask().asAddress().toString());
}else {// IP
dstIp.setDstIp(srcIp.getDestIpAddress());
dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
} }
ipConvertList.add(dstIp);
} else { } else {
dstIp.setDstIp("::"); throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); }
} else {
if (srcIp.getSrcIpAddress() != null) {
if (srcIp.getSrcIpAddress().indexOf("/") != -1) {
if (srcIp.getIpType() == 4 /* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4目的ip为ipv6
Integer srcMaskNum = Integer.parseInt(srcIp.getSrcIpAddress().split("/")[1]);
if (srcMaskNum == 0) {
dstIp.setSrcIpMask("0.0.0.0");
} else {
dstIp.setSrcIpMask(IpUtil.convertMask(srcMaskNum));
}
dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]);
} else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6目的ip为ipv4
IPv6Network strangeNetwork = IPv6Network.fromString(srcIp.getSrcIpAddress());
dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]);
dstIp.setSrcIpMask(strangeNetwork.getNetmask().asAddress().toString());
} /*
* else { Pattern
* patternV4Subnet=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP); Pattern
* patternV6Subnet=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP); Matcher
* matchernV4Subnet=patternV4Subnet.matcher(srcIp.getSrcIpAddress()); Matcher
* matcherV6Subnet=patternV6Subnet.matcher(srcIp.getSrcIpAddress());
* if(matchernV4Subnet.matches()) { Integer srcMaskNum =
* Integer.parseInt(srcIp.getSrcIpAddress().split("/")[1]); if(srcMaskNum==0){
* dstIp.setSrcIpMask("0.0.0.0"); }else{
* dstIp.setSrcIpMask(IpUtil.convertMask(srcMaskNum)); }
* dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]); }else
* if(matcherV6Subnet.matches()){ IPv6Network strangeNetwork =
* IPv6Network.fromString(srcIp.getSrcIpAddress());
* dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]);
* dstIp.setSrcIpMask(strangeNetwork.getNetmask().asAddress().toString()); }else
* { throw new RuntimeException("Invalid IP/subnet mask format"); } }
*/
else {
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
}
} else {
if (srcIp.getIpType() == 4/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4目的ip为ipv6
dstIp.setSrcIp(srcIp.getSrcIpAddress());
dstIp.setSrcIpMask("255.255.255.255");
} else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6目的ip为ipv4
dstIp.setSrcIp(srcIp.getSrcIpAddress());
dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
} /*
* else {//all Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
* Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP); Matcher
* matcherV4=patternV4.matcher(srcIp.getSrcIpAddress()); Matcher
* matcherV6=patternV6.matcher(srcIp.getSrcIpAddress()); if(matcherV4.matches())
* { dstIp.setSrcIp(srcIp.getSrcIpAddress());
* dstIp.setSrcIpMask("255.255.255.255"); }else if(matcherV6.matches()) {
* dstIp.setSrcIp(srcIp.getSrcIpAddress());
* dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); }else { throw
* new RuntimeException("Invalid IP format"); } }
*/
else {
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
}
}
} else {
if (srcIp.getIpType() == 4/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4目的ip为ipv6
dstIp.setSrcIp(srcIp.getSrcIpAddress());
dstIp.setSrcIpMask("255.255.255.255");
} else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6目的ip为ipv4
dstIp.setSrcIp(srcIp.getSrcIpAddress());
dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
} /*
* else {//all dstIp.setSrcIp(srcIp.getSrcIpAddress());
* dstIp.setSrcIpMask("255.255.255.255"); }
*/
else {
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
}
}
if (srcIp.getDestIpAddress() != null) {
if (srcIp.getDestIpAddress().indexOf("/") != -1) {
if (srcIp.getIpType() == 4/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6目的ip为ipv4
Integer dstMaskNum = Integer.parseInt(srcIp.getDestIpAddress().split("/")[1]);
if (dstMaskNum == 0) {
dstIp.setDstIpMask("0.0.0.0");
} else {
dstIp.setDstIpMask(IpUtil.convertMask(dstMaskNum));
;
}
dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]);
} else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4目的ip为ipv6
IPv6Network strangeNetwork = IPv6Network.fromString(srcIp.getDestIpAddress());
dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]);
dstIp.setDstIpMask(strangeNetwork.getNetmask().asAddress().toString());
} /*
* else { Pattern
* patternV4Subnet=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP); Pattern
* patternV6Subnet=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP); Matcher
* matchernV4Subnet=patternV4Subnet.matcher(srcIp.getDestIpAddress()); Matcher
* matcherV6Subnet=patternV6Subnet.matcher(srcIp.getDestIpAddress());
* if(matchernV4Subnet.matches()) { Integer dstMaskNum =
* Integer.parseInt(srcIp.getDestIpAddress().split("/")[1]); if(dstMaskNum==0){
* dstIp.setDstIpMask("0.0.0.0"); }else{
* dstIp.setDstIpMask(IpUtil.convertMask(dstMaskNum));; }
* dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]); }else
* if(matcherV6Subnet.matches()){ IPv6Network strangeNetwork =
* IPv6Network.fromString(srcIp.getDestIpAddress());
* dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]);
* dstIp.setDstIpMask(strangeNetwork.getNetmask().asAddress().toString()); }else
* { throw new RuntimeException("Invalid IP/subnet mask format"); } }
*/
else {
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
}
} else {
if (srcIp.getIpType() == 4/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6目的ip为ipv4
dstIp.setDstIp(srcIp.getDestIpAddress());
dstIp.setDstIpMask("255.255.255.255");
} else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4目的ip为ipv6
dstIp.setDstIp(srcIp.getDestIpAddress());
dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
} /*
* else {//all Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
* Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP); Matcher
* matcherV4=patternV4.matcher(srcIp.getDestIpAddress()); Matcher
* matcherV6=patternV6.matcher(srcIp.getDestIpAddress());
* if(matcherV4.matches()) { dstIp.setDstIp(srcIp.getDestIpAddress());
* dstIp.setDstIpMask("255.255.255.255"); }else if(matcherV6.matches()) {
* dstIp.setDstIp(srcIp.getDestIpAddress());
* dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); }else { throw
* new RuntimeException("invalid ip format"); } }
*/
else {
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
}
}
} else {
if (srcIp.getIpType() == 4/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6目的ip为ipv4
dstIp.setDstIp(srcIp.getDestIpAddress());
dstIp.setDstIpMask("255.255.255.255");
} else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4目的ip为ipv6
dstIp.setDstIp(srcIp.getDestIpAddress());
dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
} /*
* else {//all dstIp.setDstIp(srcIp.getDestIpAddress());
* dstIp.setDstIpMask("255.255.255.255"); }
*/
else {
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
}
}
if (srcIp.getSrcPort() != null) {
if (srcIp.getSrcPort().indexOf("/") != -1) {
String srcMaskNum = srcIp.getSrcPort().split("/")[1];
dstIp.setSrcPortMask(srcMaskNum);
dstIp.setSrcPort(srcIp.getSrcPort().split("/")[0]);
} else {
dstIp.setSrcPort(srcIp.getSrcPort());
dstIp.setSrcPortMask("65535");
}
} else {
dstIp.setSrcPort("0");
dstIp.setSrcPortMask("65535");
}
if (srcIp.getDestPort() != null) {
if (srcIp.getDestPort().indexOf("/") != -1) {
String dstMaskNum = srcIp.getDestPort().split("/")[1];
dstIp.setDstPortMask(dstMaskNum);
dstIp.setDstPort(srcIp.getDestPort().split("/")[0]);
} else {
dstIp.setDstPort(srcIp.getDestPort());
dstIp.setDstPortMask("65535");
}
} else {
dstIp.setDstPort("0");
dstIp.setDstPortMask("65535");
} }
convertPortValues(dstIp, srcIp);
ipConvertList.add(dstIp); ipConvertList.add(dstIp);
}else {
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
} }
return ipConvertList; return ipConvertList;
} }
@@ -575,411 +687,4 @@ public class ConfigConvertUtil {
dstIp.setDstPortMask("65535"); dstIp.setDstPortMask("65535");
} }
} }
/**
*Obj 组maat配置转换
* @param <T>
* @param <T>
* @param dstList
* @param srcList
* @param cfgType1为IP类型2为字符串类型3为增强字符串4数值类型5摘要类,6回调类[但字符串类域配置和增强字符串域配置在接口参数中同属于strRegionList]
* @param baseCfg配置基本信息
* @param groupRelationList
* 配置分组列表
* @return
*/
public static <T> Map<String, List> objGroupCfgConvert(Map<Integer,FunctionServiceDict> dictMap,List dstList, List<T> srcList, Integer cfgType, BaseCfg baseCfg,
List groupRelationList, Map<String,Object> maatTableMap, Set<Integer> groupIdSet) {
long start=System.currentTimeMillis(),end=0l;
Map<String, List> map = new HashMap();
if (cfgType == 1) {
List numRegionList = new ArrayList();
int pos=0;
Set<Integer> numGroupVals = new HashSet<>();
List<Integer> regionIdList = calRangeIps(srcList);//ConfigServiceUtil.getId(3, srcList.size());
for (int i = 0; i < srcList.size(); i++) {
T srcCfg = srcList.get(i);
BaseIpCfg baseIpCfg = new BaseIpCfg();
BeanUtils.copyProperties(srcCfg, baseIpCfg);
IpCfg cfg = new IpCfg();
BeanUtils.copyProperties(baseIpCfg, cfg);
// 区域IP配置多条IP配置属于同一个分组其他业务配置IP一条配置一个分组
// if(groupId==0 || !cfg.getCfgType().equals(Constants.AREA_REGION)){
if (!groupIdSet.contains(baseIpCfg.getGroupId())) {
GroupCfg group = new GroupCfg();
//groupId = ConfigServiceUtil.getId(2, 1).get(0);
group.setGroupId(baseIpCfg.getGroupId());
group.setCompileId(baseCfg.getCompileId());
group.setAuditTime(baseCfg.getAuditTime());
group.setIsValid(baseCfg.getIsValid());
groupRelationList.add(group);
groupIdSet.add(baseIpCfg.getGroupId());
}
cfg.setGroupId(baseIpCfg.getGroupId());
cfg.setAuditTime(baseCfg.getAuditTime());
cfg.setIsValid(baseCfg.getIsValid());
if(maatTableMap.containsKey("ipMaatTable")){
Map<String,String> ipMaatTable=(Map<String,String>)maatTableMap.get("ipMaatTable");
cfg.setCfgType(ipMaatTable.get(baseIpCfg.getGroupId().toString()));
}
List<IpCfg> cfgs = ipConvert(cfg, baseIpCfg);
if (cfgs.size() > 1) {
List<Integer> ids =regionIdList.subList(pos,pos+cfgs.size());
//支持range????
for (int j = 1; j < cfgs.size(); j++) {
cfgs.get(j).setRegionId(ids.get(j-1));
}
pos+=cfgs.size();
}
dstList.addAll(cfgs);
// 如果protocolId非空非零需要构造数值型域配置多条相同协议的IP只需要一条数值域配置目前没有不同协议IP&情况)
//分组复用每个IP组还需要不同的数值域组么 answer:一个就行了
if (baseCfg!=null&&baseCfg.getServiceId()!=null&&baseCfg.getServiceId()>0&&dictMap.containsKey(baseCfg.getServiceId())) {
FunctionServiceDict dict=dictMap.get(baseCfg.getServiceId());
Integer protocolId=dict.getProtocolId();
if (protocolId>0&&!numGroupVals.contains(protocolId)) {
GroupCfg group1 = new GroupCfg();
group1.setGroupId(ConfigServiceUtil.getId(2, 1).get(0));
group1.setCompileId(baseCfg.getCompileId());
group1.setAuditTime(baseCfg.getAuditTime());
group1.setIsValid(baseCfg.getIsValid());
groupRelationList.add(group1);
NumBoundaryCfg numCfg = new NumBoundaryCfg();
numCfg.initDefaultValue();
numCfg.setLowBoundary(protocolId);
numCfg.setUpBoundary(protocolId);
numCfg.setRegionId(ConfigServiceUtil.getId(3, 1).get(0));
numCfg.setAuditTime(baseCfg.getAuditTime());
numCfg.setGroupId(group1.getGroupId());
numCfg.setIsValid(baseCfg.getIsValid());
if(maatTableMap.containsKey("protocolMaatTable")){
numCfg.setCfgType(maatTableMap.get("protocolMaatTable").toString());
}
numRegionList.add(numCfg);
map.put("numRegionList", numRegionList);
numGroupVals.add(protocolId);
}
}
}
regionIdList.clear();
} else if (cfgType == 2 || cfgType == 3) {
//List<Integer> groupIdList = ConfigServiceUtil.getId(2, srcList.size());
//List<Integer> regionIdList = ConfigServiceUtil.getId(3, srcList.size());
for (int i = 0; i < srcList.size(); i++) {
BaseStringCfg baserStringCfg=new BaseStringCfg();
BeanUtils.copyProperties(srcList.get(i),baserStringCfg);
if(!groupIdSet.contains(baserStringCfg.getGroupId())){
GroupCfg group = new GroupCfg();
group.setGroupId(baserStringCfg.getGroupId());
group.setCompileId(baseCfg.getCompileId());
group.setAuditTime(baseCfg.getAuditTime());
group.setIsValid(baseCfg.getIsValid());
groupRelationList.add(group);
groupIdSet.add(baserStringCfg.getGroupId());
}
StringCfg cfg = new StringCfg();
BeanUtils.copyProperties(srcList.get(i), cfg);
cfg.setGroupId(baserStringCfg.getGroupId());
cfg.setRegionId(baserStringCfg.getRegionId());
cfg.setAuditTime(baseCfg.getAuditTime());
cfg.setIsValid(baseCfg.getIsValid());
// 处理配置关键字转译
cfg.setCfgKeywords(keywordsEscape(cfg.getCfgKeywords()));
// 增强字符串转换
cfg.setDistrict(keywordsEscape(cfg.getDistrict()));
if(maatTableMap.containsKey("stringMaatTable")){
Map<String,String> stringMaatTable=(Map<String,String>)maatTableMap.get("stringMaatTable");
cfg.setCfgType(stringMaatTable.get(baserStringCfg.getGroupId().toString()));
}
dstList.add(cfg);
}
} else if (cfgType == 4) {
// List<Integer> groupIdList = ConfigServiceUtil.getId(2, srcList.size());
// List<Integer> regionIdList = ConfigServiceUtil.getId(3, srcList.size());
for (int i = 0; i < srcList.size(); i++) {
// 一条业务配置创建一个分组
NumBoundaryCfg cfg = new NumBoundaryCfg();
BeanUtils.copyProperties(srcList.get(i), cfg);
if(!groupIdSet.contains(cfg.getGroupId())){
GroupCfg group = new GroupCfg();
group.setGroupId(cfg.getGroupId());
group.setCompileId(baseCfg.getCompileId());
group.setAuditTime(baseCfg.getAuditTime());
group.setIsValid(baseCfg.getIsValid());
groupRelationList.add(group);
groupIdSet.add(cfg.getGroupId());
}
cfg.setGroupId(cfg.getGroupId());
cfg.setRegionId(cfg.getRegionId());
cfg.setAuditTime(baseCfg.getAuditTime());
cfg.setIsValid(baseCfg.getIsValid());
dstList.add(cfg);
}
} else if (cfgType == 5) {
//List<Integer> groupIdList = ConfigServiceUtil.getId(2, srcList.size());
//List<Integer> regionIdList = ConfigServiceUtil.getId(3, srcList.size());
for (int i = 0; i < srcList.size(); i++) {
// 一条业务配置创建一个分组
com.nis.domain.maat.MaatCfg.DigestCfg cfg = new com.nis.domain.maat.MaatCfg.DigestCfg();
BeanUtils.copyProperties(srcList.get(i), cfg);
if(!groupIdSet.contains(cfg.getGroupId())){
GroupCfg group = new GroupCfg();
group.setGroupId(cfg.getGroupId());
group.setCompileId(baseCfg.getCompileId());
group.setAuditTime(baseCfg.getAuditTime());
group.setIsValid(baseCfg.getIsValid());
groupRelationList.add(group);
groupIdSet.add(cfg.getGroupId());
}
cfg.setGroupId(cfg.getGroupId());
cfg.setRegionId(cfg.getRegionId());
cfg.setAuditTime(baseCfg.getAuditTime());
cfg.setIsValid(baseCfg.getIsValid());
dstList.add(cfg);
}
} else {
dstList.addAll(srcList);
}
map.put("groupList", groupRelationList);
map.put("dstList", dstList);
end=System.currentTimeMillis();
logger.info("objGroupCfgConvert cost:"+(end-start));
return map;
}
/**
* 转换成字符串
*
* @param obj
* @return
*/
public static <T> String gsonToJson(T obj) {
Gson gson = new GsonBuilder().disableHtmlEscaping().excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
@Override
public JsonElement serialize(Date src, Type type, JsonSerializationContext context) {
String format = "yyyy-MM-dd HH:mm:ss";
long time = ((Date) src).getTime();
SimpleDateFormat sdf = new SimpleDateFormat(format);
return new JsonPrimitive(sdf.format(time));
}
}).create();
return gson.toJson(obj);
}
/**
* 字符串转成对象
*
* @param jsonString
* @param cls
* @return
*/
public static <T> T gsonFromJson(String jsonString, Class<T> cls) {
Gson gson = new GsonBuilder().registerTypeAdapter(new TypeToken<Map>() {
}.getType(), new BaseService.MapTypeAdapter()).registerTypeAdapter(new TypeToken<List>() {
}.getType(), new BaseService.MapTypeAdapter()).create();
return gson.fromJson(jsonString, cls);
}
/**
* 公共分组生成默认自定义域
* @param userRegionMap
* @param serviceId
* @return
*/
public static String generateCommonGroupDefaultUserRegion(Map<String,Object> userRegionMap,Integer serviceId){
if(userRegionMap==null){
userRegionMap=new HashMap<>();
}
if(serviceId.equals(576)){
userRegionMap.put("method","block");
userRegionMap.put("code",404);
userRegionMap.put("message","");
userRegionMap.put("html_profile",0);
return gsonToJson(userRegionMap);
}else if(serviceId.equals(512)){
if(userRegionMap.isEmpty()){
//keyring
userRegionMap.put("keyring", 1);
Map<String,Object> map = new HashMap();
//exclusions
map.put("ev_cert", 0);
map.put("cert_transparency", 0);
map.put("pinning", 1);
map.put("client_cert_req", 1);
map.put("protocol_errors", 1);
userRegionMap.put("exclusions", map);
//cert_verify
Map<String,Object> map1=new HashMap<>();
map=new HashMap<>();
map.put("cn",1);
map.put("issuer",1);
map.put("self-signed",1);
map.put("expiration",1);
map1.put("approach", map);
userRegionMap.put("cert_verify", map1);
//ssl_ver
map=new HashMap<>();
map.put("mirror_client", 1);
map.put("allow_http2", 1);
// map.put("min", "ssl3");
// map.put("max", "tls13");
userRegionMap.put("ssl_ver", map);
//decrypt_mirror
map=new HashMap<>();
map.put("enable", 0);
userRegionMap.put("decrypt_mirror", map);
}
return gsonToJson(userRegionMap);
}else if(serviceId.equals(592)){
return "{}";
}else{
return "0";
}
}
public static Map<String,Object> convertCommonGroupMaatTable(CfgIndexInfo cfgIndexInfo, List<Map<String, Object>> cfgList){
Map<String,Object> maatTableMap=new HashMap<>();
Map<String,Object> commonGroupIds= MapUtils.isEmpty(cfgIndexInfo.getUserRegion())?(Map<String,Object>)gsonFromJson(cfgIndexInfo.getCommonGroupIds(),Map.class):cfgIndexInfo.getUserRegion();
for (Map<String, Object> map : cfgList) {
String cfgType = map.get("cfgType").toString();
if (cfgType.equals("1")) {
if(commonGroupIds.containsKey("ipGroup")&&map.containsKey("maatTable")){
Map<String,String> ipMaatMap=new HashMap<>();
for(String group:commonGroupIds.get("ipGroup").toString().split(",")){
if(StringUtils.isNotBlank(group)){
ipMaatMap.put(group,map.get("maatTable").toString());
}
}
maatTableMap.put("ipMaatTable",ipMaatMap);
}
if(map.containsKey("protocolMaatTable")){
maatTableMap.put("protocolMaatTable",map.get("protocolMaatTable").toString());
}
} else if (cfgType.equals("2")) {
String _maatTable = map.containsKey("maatTable")?map.get("maatTable").toString():null;
Map<String,String> stringMaatMap=new HashMap<>();
if(StringUtils.isNotBlank(_maatTable)){
if(commonGroupIds.containsKey("urlGroup")&&_maatTable.toUpperCase().contains("URL")){
for(String group:commonGroupIds.get("urlGroup").toString().split(",")){
if(StringUtils.isNotBlank(group)){
stringMaatMap.put(group,_maatTable);
}
}
}
if(commonGroupIds.containsKey("domainGroup")&&_maatTable.toUpperCase().contains("DOMAIN")){
for(String group:commonGroupIds.get("domainGroup").toString().split(",")){
if(StringUtils.isNotBlank(group)){
stringMaatMap.put(group,_maatTable);
}
}
}
if(commonGroupIds.containsKey("subscribeIdGroup")&&_maatTable.toUpperCase().contains("SUBSCRIBE_ID")){
for(String group:commonGroupIds.get("subscribeIdGroup").toString().split(",")){
if(StringUtils.isNotBlank(group)){
stringMaatMap.put(group,_maatTable);
}
}
}
}
if(maatTableMap.containsKey("stringMaatTable")){
((Map<String,String>)maatTableMap.get("stringMaatTable")).putAll(stringMaatMap);
}else{
maatTableMap.put("stringMaatTable",stringMaatMap);
}
}
}
return maatTableMap;
}
/**
* 获取obj-list-group业务的function_service_dict
* @param functionId
* @return
*/
public static Map<Integer,FunctionServiceDict> objGetServiceDict(Integer functionId){
Map<Integer,FunctionServiceDict> dictMap=new HashMap<>();
ServiceConfigTemplateUtil util=new ServiceConfigTemplateUtil();
List<Map<String,Object>> list=util.getServiceListByFunctionId(functionId);
for(Map<String,Object> map:list){
if(map.containsKey("serviceIds")){
String serviceIds=map.get("serviceIds").toString();
for(String serviceId:serviceIds.split(",")){
List<Map<String,Object>> _mapList=util.getServiceListByServiceId(Integer.parseInt(serviceId));
for(Map<String,Object> _map:_mapList){
if(_map.containsKey("functionId")){
List<FunctionServiceDict> dictList=DictUtils.getFunctionServiceDictList(Integer.parseInt(_map.get("functionId").toString()));
for(FunctionServiceDict dict:dictList){
dictMap.put(dict.getServiceId(),dict);
}
}
}
}
}else{
if(map.containsKey("functionId")){
List<FunctionServiceDict> dictList=DictUtils.getFunctionServiceDictList(Integer.parseInt(map.get("functionId").toString()));
for(FunctionServiceDict dict:dictList){
dictMap.put(dict.getServiceId(),dict);
}
}
}
}
return dictMap;
}
public static <T>List<Integer> calRangeIps(List<T> srcList ){
List<Integer> regionIdsList=new ArrayList<>();
int total=0;
//通过反射获取IP的src ip地址目的IP地址
Class clazz=null;
Field srcIpAddressField=null,destIpAddressField=null,ipTypeFild=null;
for(T instance:srcList){
if(clazz==null&&srcIpAddressField==null&&destIpAddressField==null){
try {
clazz=instance.getClass();
srcIpAddressField=clazz.getDeclaredField("srcIpAddress");
srcIpAddressField.setAccessible(true);
destIpAddressField=clazz.getDeclaredField("destIpAddress");
destIpAddressField.setAccessible(true);
ipTypeFild=clazz.getDeclaredField("ipType");
ipTypeFild.setAccessible(true);
} catch (NoSuchFieldException e) {
return regionIdsList;
}
}
try {
String srcIpAddressValue=(String)srcIpAddressField.get(instance);
String destIpAddressValue=(String)destIpAddressField.get(instance);
Integer ipType=(Integer)ipTypeFild.get(instance);
if(ipType.equals(4)){
long left=1,right=1;
if(srcIpAddressValue.indexOf("-")>-1){
String[] srcIpAddressValueArray=srcIpAddressValue.split("-");
int startPos=0,endPos=0;
startPos=Integer.parseInt(srcIpAddressValueArray[0].split("\\.")[3]);
endPos=Integer.parseInt(srcIpAddressValueArray[1].split("\\.")[3]);
left=endPos-startPos+1;
}
if(destIpAddressValue.indexOf("-")>-1){
String[] destIpAddressValueArray=destIpAddressValue.split("-");
int startPos=0,endPos=0;
startPos=Integer.parseInt(destIpAddressValueArray[0].split("\\.")[3]);
endPos=Integer.parseInt(destIpAddressValueArray[1].split("\\.")[3]);
right=endPos-startPos+1;
}
total+=left*right;
}else{
continue;
}
} catch (IllegalAccessException e) {
e.printStackTrace();
return regionIdsList;
}
}
if(total>0){
regionIdsList=ConfigServiceUtil.getId(3,total);
}
return regionIdsList;
}
} }

View File

@@ -133,7 +133,6 @@ public class ConfigServiceUtil {
result=response.readEntity(String.class); result=response.readEntity(String.class);
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("request_service_failed",e);
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>"); throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
} }
if(response != null && response.getStatus() == 200){ if(response != null && response.getStatus() == 200){
@@ -190,7 +189,6 @@ public class ConfigServiceUtil {
result=response.readEntity(String.class); result=response.readEntity(String.class);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>"); throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
} }
if(response != null && response.getStatus() == 200){ if(response != null && response.getStatus() == 200){
@@ -236,7 +234,6 @@ public class ConfigServiceUtil {
result=response.readEntity(String.class); result=response.readEntity(String.class);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>"); throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
} }
if(response != null && response.getStatus() == 200){ if(response != null && response.getStatus() == 200){
@@ -246,7 +243,6 @@ public class ConfigServiceUtil {
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result); throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
logger.error("postCallbackCfg()",e); logger.error("postCallbackCfg()",e);
throw e; throw e;
}finally { }finally {
@@ -282,7 +278,6 @@ public class ConfigServiceUtil {
result=response.readEntity(String.class); result=response.readEntity(String.class);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>"); throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
} }
if(response != null && response.getStatus() == 200){ if(response != null && response.getStatus() == 200){
@@ -330,7 +325,6 @@ public class ConfigServiceUtil {
result=response.readEntity(String.class); result=response.readEntity(String.class);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>"); throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
} }
if(response != null && response.getStatus() == 200){ if(response != null && response.getStatus() == 200){
@@ -380,7 +374,6 @@ public class ConfigServiceUtil {
result=response.readEntity(String.class); result=response.readEntity(String.class);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>"); throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
} }
if(response !=null && response.getStatus() == 200){ if(response !=null && response.getStatus() == 200){
@@ -424,7 +417,6 @@ public class ConfigServiceUtil {
// bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class); // bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
//获取响应结果 //获取响应结果
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result); throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
} }
} catch (Exception e) { } catch (Exception e) {
@@ -459,7 +451,6 @@ public class ConfigServiceUtil {
result=response.readEntity(String.class); result=response.readEntity(String.class);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>"); throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
} }
if(response !=null && response.getStatus() == 200){ if(response !=null && response.getStatus() == 200){
@@ -968,7 +959,6 @@ public class ConfigServiceUtil {
return result; return result;
} }
public static void main(String[] args) { public static void main(String[] args) {
try { try {
// getId(1,1); // getId(1,1);

View File

@@ -8,17 +8,6 @@ import java.util.regex.Pattern;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
public final class Constants { public final class Constants {
/**
* json打印长度
*/
public static Integer JSON_PRINT_LENTH=Configurations.getIntProperty("json_print_length", 100000);
/**
* obj group list group type
*/
public static Integer IP_OBJ_GROUP_TYPE=Configurations.getIntProperty("ip_obj_group_type", 5);
public static Integer URL_OBJ_GROUP_TYPE=Configurations.getIntProperty("url_obj_group_type", 7);
public static Integer SUBID_OBJ_GROUP_TYPE=Configurations.getIntProperty("subid_obj_group_type", 9);
public static Integer DOMAIN_OBJ_GROUP_TYPE=Configurations.getIntProperty("domain_obj_group_type", 8);
/** /**
* 导入条数限制 * 导入条数限制
*/ */
@@ -196,22 +185,6 @@ public final class Constants {
* DNS 策略组KEY * DNS 策略组KEY
*/ */
public static final String CACHE_DNSGROUP_DICT = "dnsGroupDict"; public static final String CACHE_DNSGROUP_DICT = "dnsGroupDict";
/**
* IP公共组缓存KEY
*/
public static final String CACHE_IPGROUP_DICT = "ipComGroupDict";
/**
* URL公共组缓存KEY
*/
public static final String CACHE_URLGROUP_DICT = "urlComGroupDict";
/**
* Domain公共组缓存KEY
*/
public static final String CACHE_DOMAINGROUP_DICT = "domainComGroupDict";
/**
* ScriberId公共组缓存KEY
*/
public static final String CACHE_SCRIBERGROUP_DICT = "scriberComGroupDict";
/** /**
* 词典数据分类 * 词典数据分类
*/ */
@@ -349,18 +322,56 @@ public final class Constants {
// public static final boolean IS_USE_HIVE_DB = // public static final boolean IS_USE_HIVE_DB =
// Configurations.getBooleanProperty("isUseHiveDb", true); // Configurations.getBooleanProperty("isUseHiveDb", true);
/**
* 是否获取数据中心查询记录的总条数
*/
public static final boolean IS_GET_HIVECOUNT = Configurations.getBooleanProperty("isGetHiveCount", true);
/**
* 是否获取数据中心[神通]查询记录的总条数
*/
public static final boolean IS_SELECT_CLUSTER = Configurations.getBooleanProperty("isSelectCluster", false);
/**
* 神通数据库A的数据最早时间
*/
public static final Long CLUSTER_A_START_TIME = Configurations.getLongProperty("clusterAStartTime", new Date().getTime());
/**
* 神通数据库B的数据最早时间
*/
public static final Long CLUSTER_B_START_TIME = Configurations.getLongProperty("clusterBStartTime", new Date().getTime());
/** /**
* 每次获取数据中心多少条数据,咱们在对获取的数据进行分页处理 * 每次获取数据中心多少条数据,咱们在对获取的数据进行分页处理
*/ */
public static final Long EVERY_GETHIVEDATANUM = Configurations.getLongProperty("everyGetHiveDataNum", 10000); public static final Long EVERY_GETHIVEDATANUM = Configurations.getLongProperty("everyGetHiveDataNum", 10000);
/**
* 是否开启基础校验
*/
public static final boolean BASE_VALIDATE = Configurations.getBooleanProperty("baseValidate", true);
public static final Long DATACENTER_TIME = Configurations.getLongProperty("dataCenterTime", 48); public static final Long DATACENTER_TIME = Configurations.getLongProperty("dataCenterTime", 48);
/**
* 是否开启业务校验
*/
public static final boolean SERVICE_VALIDATE = Configurations.getBooleanProperty("serviceValidate", true);
/**
* 日志本地存储时间
*/
public static final Long LOG_LOCAL_TIME = Configurations.getLongProperty("logLocalTime", 48);
/**
* 实时统计默认时间
*/
public static final Long REPORT_LOCAL_TIME = Configurations.getLongProperty("reportLocalTime", 1);
/** /**
* 日志是否从hive中查询 * 日志是否从hive中查询
*/ */
public static final boolean SEL_FROM_HIVE = Configurations.getBooleanProperty("selFromHive", true);
public static final boolean ONLY_SEL_FROM_HIVE = Configurations.getBooleanProperty("onlySelFromHive", true); public static final boolean ONLY_SEL_FROM_HIVE = Configurations.getBooleanProperty("onlySelFromHive", true);
/** /**
@@ -374,6 +385,12 @@ public final class Constants {
*/ */
public static final String SEARCH_DATEFORMAT = Configurations.getStringProperty("search.dateformat", public static final String SEARCH_DATEFORMAT = Configurations.getStringProperty("search.dateformat",
"yyyy-MM-dd HH:mm:ss"); "yyyy-MM-dd HH:mm:ss");
public static final String SEARCH_ES_HOSTANDPORT_A = Configurations.getStringProperty("search.eshostandport_A",
null);
public static final String SEARCH_ES_HOSTANDPORT_B = Configurations.getStringProperty("search.eshostandport_B",
null);
public static final String SEARCH_ES_HOSTANDPORT_C = Configurations.getStringProperty("search.eshostandport_C",
null);
/** /**
* 数据中心A版数据库名称,程序中每次查询时使用的数据库名称 use HIVEADBNAME * 数据中心A版数据库名称,程序中每次查询时使用的数据库名称 use HIVEADBNAME
*/ */
@@ -390,7 +407,6 @@ public final class Constants {
public static final String FILE_UPLOAD_CFG = Configurations.getStringProperty("fileUploadCfg","fileUploadSources"); public static final String FILE_UPLOAD_CFG = Configurations.getStringProperty("fileUploadCfg","fileUploadSources");
public static final String FILE_DIGEST_CFG=Configurations.getStringProperty("fileDigestCfg","fileDigestSources"); public static final String FILE_DIGEST_CFG=Configurations.getStringProperty("fileDigestCfg","fileDigestSources");
public static final String CONFIG_ID_SOURCES=Configurations.getStringProperty("configIdSources","configPzIdSources"); public static final String CONFIG_ID_SOURCES=Configurations.getStringProperty("configIdSources","configPzIdSources");
public static final String DEL_ALL_CFG=Configurations.getStringProperty("delAllCfg","delAllConfig");
//日志查询接口URL //日志查询接口URL
public static final String LOG_BASE_URL = Configurations.getStringProperty("logBaseUrl",""); public static final String LOG_BASE_URL = Configurations.getStringProperty("logBaseUrl","");
public static final String NTC_SERVICE_REPORT=Configurations.getStringProperty("ntcServiceReport","ntcServiceReport"); public static final String NTC_SERVICE_REPORT=Configurations.getStringProperty("ntcServiceReport","ntcServiceReport");
@@ -724,14 +740,8 @@ public final class Constants {
public static final String CERT_FILE_PATH=Configurations.getStringProperty("cert_file_path", ""); public static final String CERT_FILE_PATH=Configurations.getStringProperty("cert_file_path", "");
//证书校验文件 //证书校验文件
public static final String CERT_VALIDATE_FILE=Configurations.getStringProperty("cert_validate_file", "x509"); public static final String CERT_VALIDATE_FILE=Configurations.getStringProperty("cert_validate_file", "x509");
public static final String CA_CERT_FILE=Configurations.getStringProperty("ca_cert_file", "cacert.sh");
public static final String CA_CERT_DIR=Configurations.getStringProperty("ca_cert_dir", "/home/cacert/");
//证书校验成功关键字 //证书校验成功关键字
public static final String CERT_VALIDATE_SUCCESS_INFO=Configurations.getStringProperty("cert_validate_success_info", "x509"); public static final String CERT_VALIDATE_SUCCESS_INFO=Configurations.getStringProperty("cert_validate_success_info", "x509");
//内置证书的isser
public static final String KEYRING_BUILT_IN_ISSER=Configurations.getStringProperty("keyring_built_in_isser", "||CN=Tango Secure Gateway CA, O=Maserati Solution||CN=Tango Secure Gateway CA UNTRUST, O=Maserati Solution||");
//内置证书的指纹
public static final String KEYRING_BUILT_IN_FINGERPRINT=Configurations.getStringProperty("keyring_built_in_fingerprint", "||ee23abb40085901c12f574d610153c008d49e6a0||3475833f1a9525b4ad7fbee06dfa3e4a8de0c1e0||");
/** /**
* 一些正则的pattern预先编译,避免多次编译 * 一些正则的pattern预先编译,避免多次编译
*/ */
@@ -828,46 +838,4 @@ public final class Constants {
* 管理员用户预警查询服务配置总量接口 * 管理员用户预警查询服务配置总量接口
*/ */
public static final String CONFIG_BY_SERVICE = Configurations.getStringProperty("getConfigByService",""); public static final String CONFIG_BY_SERVICE = Configurations.getStringProperty("getConfigByService","");
/**
* 获取配置统计页面列表的配置总量接口
*/
public static final String NTC_PZ_COUNT_REPORT = Configurations.getStringProperty("ntcPzCountReport","");
/**
* 查询的是流量统计菜单-配置统计中BandWidth统计的数据接口
*/
public static final String TRAFFIC_BANDWIDTH_TRANS_THREE_NEW=Configurations.getStringProperty("trafficBandwidthTransThreeNew","trafficBandwidthTransThreeNew");
/**
* 查询的是流量统计菜单-配置统计中RulesType统计的数据接口
*/
public static final String NTC_ACTION_ENTRANCE_REPORT_NEW=Configurations.getStringProperty("ntcActionEntranceReportNew","ntcActionEntranceReportNew");
/**
* 查询的是流量统计菜单-配置统计中Protocol统计的数据接口
*/
public static final String TRAFFIC_PROTOCOL_STATISTIC_NEW=Configurations.getStringProperty("trafficProtocolStatisticNew","trafficProtocolStatisticNew");
/**
* 查询的是流量统计菜单-配置统计中APP统计的数据接口
*/
public static final String TRAFFIC_APP_STATISTIC_NEW=Configurations.getStringProperty("trafficAppStatisticNew","trafficAppStatisticNew");
/**
* 查询的是流量统计菜单-配置统计中Domains统计的数据接口
*/
public static final String TRAFFIC_DOMAIN_STATISTIC_NEW=Configurations.getStringProperty("trafficDomainStatisticNew","trafficDomainStatisticNew");
/**
* 查询的是流量统计菜单-配置统计中ClientIP统计的数据接口
*/
public static final String TRAFFIC_SOURCE_IP_STATISTIC_NEW=Configurations.getStringProperty("trafficSourceIPStatisticNew","trafficSourceIPStatisticNew");
/**
* 查询的是流量统计菜单-配置统计中ServerIP统计的数据接口
*/
public static final String TRAFFIC_DEST_IP_STATISTIC_NEW=Configurations.getStringProperty("trafficDestIPStatisticNew","trafficDestIPStatisticNew");
/**
* 查询的是流量统计菜单-配置统计中SubscriberID统计的数据接口
*/
public static final String TRAFFIC_SUBSCRIBER_ID_STATISTIC_NEW=Configurations.getStringProperty("trafficSubscriberIDStatisticNew","trafficSubscriberIDStatisticNew");
/**
* HTTP(S)操控日志接口
*/
public static final String POLICY_EVENT=Configurations.getStringProperty("policyevent","policyevent");
} }

View File

@@ -14,14 +14,12 @@ import com.nis.domain.FunctionRegionDict;
import com.nis.domain.FunctionServiceDict; import com.nis.domain.FunctionServiceDict;
import com.nis.domain.SysDataDictionaryItem; import com.nis.domain.SysDataDictionaryItem;
import com.nis.domain.SysDataDictionaryName; import com.nis.domain.SysDataDictionaryName;
import com.nis.domain.basics.CommonGroupInfo;
import com.nis.domain.basics.PolicyGroupInfo; import com.nis.domain.basics.PolicyGroupInfo;
import com.nis.domain.basics.SysDictInfo; import com.nis.domain.basics.SysDictInfo;
import com.nis.domain.configuration.DnsResStrategy; import com.nis.domain.configuration.DnsResStrategy;
import com.nis.web.dao.FunctionRegionDictDao; import com.nis.web.dao.FunctionRegionDictDao;
import com.nis.web.dao.FunctionServiceDictDao; import com.nis.web.dao.FunctionServiceDictDao;
import com.nis.web.dao.SysDictDao; import com.nis.web.dao.SysDictDao;
import com.nis.web.dao.basics.CommonGroupManageDao;
import com.nis.web.dao.basics.PolicyGroupInfoDao; import com.nis.web.dao.basics.PolicyGroupInfoDao;
import com.nis.web.dao.basics.SysDictInfoDao; import com.nis.web.dao.basics.SysDictInfoDao;
import com.nis.web.dao.configuration.DnsResStrategyDao; import com.nis.web.dao.configuration.DnsResStrategyDao;
@@ -44,7 +42,6 @@ public class DictUtils {
private final static FunctionServiceDictDao functionServiceDictDao = SpringContextHolder.getBean(FunctionServiceDictDao.class); private final static FunctionServiceDictDao functionServiceDictDao = SpringContextHolder.getBean(FunctionServiceDictDao.class);
private final static DnsResStrategyDao dnsResStrategyDao = SpringContextHolder.getBean(DnsResStrategyDao.class); private final static DnsResStrategyDao dnsResStrategyDao = SpringContextHolder.getBean(DnsResStrategyDao.class);
private final static PolicyGroupInfoDao policyGroupInfoDao = SpringContextHolder.getBean(PolicyGroupInfoDao.class); private final static PolicyGroupInfoDao policyGroupInfoDao = SpringContextHolder.getBean(PolicyGroupInfoDao.class);
private final static CommonGroupManageDao commonGroupManageDao = SpringContextHolder.getBean(CommonGroupManageDao.class);
public static Map<String, List<SysDataDictionaryItem>> getDictData() { public static Map<String, List<SysDataDictionaryItem>> getDictData() {
@@ -404,38 +401,4 @@ public class DictUtils {
} }
return null; return null;
} }
/**
* 获取公共组字典缓存
*/
/*public static List<CommonGroupInfo> getCommonGroups(Integer groupType){
String dictKey = Constants.CACHE_IPGROUP_DICT;
if(groupType.equals(7)) {
dictKey = Constants.CACHE_URLGROUP_DICT;
}else if(groupType.equals(8)) {
dictKey = Constants.CACHE_DOMAINGROUP_DICT;
}else if(groupType.equals(9)) {
dictKey = Constants.CACHE_SCRIBERGROUP_DICT;
}
List<CommonGroupInfo> allDictList = (List<CommonGroupInfo>)CacheUtils.get(dictKey);
if(StringUtil.isEmpty(allDictList)){
allDictList = commonGroupManageDao.findCommonGroupInfosByType(groupType);
CacheUtils.put(dictKey, allDictList);
}
return allDictList;
}
public static CommonGroupInfo getCommonGroups(Integer groupId, Integer groupType){
List<CommonGroupInfo> allDictList = getCommonGroups(groupType);
if(StringUtil.isEmpty(allDictList)){
}else {
for(CommonGroupInfo group:allDictList) {
if(group.getServiceGroupId().equals(groupId)) {
return group;
}
}
}
return null;
}*/
} }

View File

@@ -1,17 +1,13 @@
package com.nis.util; package com.nis.util;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Type; import java.util.ArrayList;
import java.text.SimpleDateFormat; import java.util.Arrays;
import java.util.*; import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.gson.*;
import com.google.gson.reflect.TypeToken;
import com.nis.domain.FunctionServiceDict;
import com.nis.domain.basics.*;
import com.nis.domain.configuration.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.config.IniSecurityManagerFactory; import org.apache.shiro.config.IniSecurityManagerFactory;
@@ -23,9 +19,26 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.nis.domain.basics.AsnIpCfg;
import com.nis.domain.callback.InlineIp; import com.nis.domain.callback.InlineIp;
import com.nis.domain.configuration.AppPolicyCfg;
import com.nis.domain.configuration.AvFileSampleCfg;
import com.nis.domain.configuration.AvSignSampleCfg;
import com.nis.domain.configuration.BaseCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.domain.configuration.DdosIpCfg;
import com.nis.domain.configuration.DnsIpCfg;
import com.nis.domain.configuration.DnsResStrategy;
import com.nis.domain.configuration.FileDigestCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.PxyObjKeyring;
import com.nis.domain.configuration.PxyObjSpoofingIpPool;
import com.nis.domain.configuration.PxyObjTrustedCaCert;
import com.nis.domain.configuration.PxyObjTrustedCaCrl;
import com.nis.domain.maat.MaatCfg; import com.nis.domain.maat.MaatCfg;
import com.nis.domain.maat.ManipulatActionParam;
import com.nis.domain.maat.ToMaatBean; import com.nis.domain.maat.ToMaatBean;
import com.nis.domain.maat.ToMaatResult; import com.nis.domain.maat.ToMaatResult;
import com.nis.domain.maat.ToUpdateMaatBeanStatus; import com.nis.domain.maat.ToUpdateMaatBeanStatus;
@@ -78,7 +91,6 @@ public class SchedulerTaskUtil {
String tableName = service.get("tableName").toString(); String tableName = service.get("tableName").toString();
String serviceType = service.get("serviceType").toString(); String serviceType = service.get("serviceType").toString();
String className = service.get("className").toString(); String className = service.get("className").toString();
String functionId= service.get("functionId").toString();
BaseCfg entity = new BaseCfg(); BaseCfg entity = new BaseCfg();
entity.setServiceId(serviceId); entity.setServiceId(serviceId);
entity.setTableName(tableName); entity.setTableName(tableName);
@@ -108,14 +120,6 @@ public class SchedulerTaskUtil {
List<BaseStringCfg> strList = new ArrayList(); List<BaseStringCfg> strList = new ArrayList();
List<ComplexkeywordCfg> complexStrList = new ArrayList(); List<ComplexkeywordCfg> complexStrList = new ArrayList();
List<com.nis.domain.configuration.NumBoundaryCfg> numList = new ArrayList(); List<com.nis.domain.configuration.NumBoundaryCfg> numList = new ArrayList();
//公共分组
boolean isCommonGroup=false;
List<IpCommCfg> ipCommCfgList=new ArrayList<>();
List<UrlCommCfg> urlCommCfgList=new ArrayList<>();
List<ScriberIdCommCfg> scriberIdCommCfgList=new ArrayList<>();
List<DomainCommCfg> domainCommCfgList=new ArrayList<>();
Map<String,Object> commGroupMap=new HashMap<>();
Set<Integer> groupIdSet=new HashSet<>();
List<FileDigestCfg> fileList = new ArrayList(); List<FileDigestCfg> fileList = new ArrayList();
maatBean = new ToMaatBean(); maatBean = new ToMaatBean();
configCompileList = new ArrayList(); configCompileList = new ArrayList();
@@ -127,71 +131,39 @@ public class SchedulerTaskUtil {
List<Map<String,Object>> userRegionList = (List<Map<String, Object>>) service.get("userRegionList"); List<Map<String,Object>> userRegionList = (List<Map<String, Object>>) service.get("userRegionList");
entity.setCompileId(compileId); entity.setCompileId(compileId);
compileIds.add(compileId); compileIds.add(compileId);
Map<Integer, FunctionServiceDict> serviceDictMap=ConfigConvertUtil.objGetServiceDict(Integer.parseInt(functionId));
//查询配置 //查询配置
if("cfg_index_info".equals(tableName)){ if("cfg_index_info".equals(tableName)){
List<CfgIndexInfo> list = configSynchronizationDao.getCfgIndexList(entity); List<CfgIndexInfo> list = configSynchronizationDao.getCfgIndexList(entity);
if(CollectionUtils.isNotEmpty(list)&&StringUtils.isNotBlank(list.get(0).getCommonGroupIds())){
isCommonGroup=true;
}
if(isIssueContent.equals(1)){ if(isIssueContent.equals(1)){
//用于存储自定义域为关键字的业务key=compileIdvalue=keyword. //用于存储自定义域为关键字的业务key=compileIdvalue=keyword.
Map<Integer, BaseStringCfg> keywordMap=new HashMap<>(); Map<Integer, BaseStringCfg> keywordMap=new HashMap<>();
//查询子域配置详情 //查询子域配置详情
if(cfgList!=null){ if(cfgList!=null){
if(isCommonGroup){ for(Map<String,Object> m:cfgList){
groupIdSet=new HashSet<>(); String regionTable = m.get("tableName").toString();
commGroupMap=ConfigConvertUtil.gsonFromJson(list.get(0).getCommonGroupIds(),Map.class); if("1".equals(m.get("cfgType"))){
//将组中的域设置到cfg_index_info中 ipList.addAll(configSynchronizationDao.getIpPortList(regionTable, compileIds));
covertCommongroupIdsMap(commGroupMap,"ipGroup",list.get(0),configSynchronizationDao,IpCommCfg.class); }else if("2".equals(m.get("cfgType"))){
if(CollectionUtils.isNotEmpty(list.get(0).getIpCommGroupCfgList())){ strList.addAll(configSynchronizationDao.getStrList(regionTable,compileIds));
ipCommCfgList.addAll(list.get(0).getIpCommGroupCfgList()); //512/521/514/1026业务的用户自定义域取DOMAIN_STR取自Keyword
} if(entity.getServiceId()==512
covertCommongroupIdsMap(commGroupMap,"urlGroup",list.get(0),configSynchronizationDao,UrlCommCfg.class); ||entity.getServiceId()==521
if(CollectionUtils.isNotEmpty(list.get(0).getUrlCommGroupList())){ ||entity.getServiceId()==514
urlCommCfgList.addAll(list.get(0).getUrlCommGroupList()); ||entity.getServiceId()==1026) {
} keywordMap=configSynchronizationDao.getCompileIdWithKeyword(regionTable, compileIds);
covertCommongroupIdsMap(commGroupMap,"subscribeIdGroup",list.get(0),configSynchronizationDao,ScriberIdCommCfg.class);
if(CollectionUtils.isNotEmpty(list.get(0).getScriberIdCommGroupList())){
scriberIdCommCfgList.addAll(list.get(0).getScriberIdCommGroupList());
}
covertCommongroupIdsMap(commGroupMap,"domainGroup",list.get(0),configSynchronizationDao,DomainCommCfg.class);
if(CollectionUtils.isNotEmpty(list.get(0).getDomainCommGroupList())){
domainCommCfgList.addAll(list.get(0).getDomainCommGroupList());
}
}else{
for(Map<String,Object> m:cfgList){
String regionTable = m.get("tableName").toString();
if("1".equals(m.get("cfgType"))){
ipList.addAll(configSynchronizationDao.getIpPortList(regionTable, compileIds));
}else if("2".equals(m.get("cfgType"))){
strList.addAll(configSynchronizationDao.getStrList(regionTable,compileIds));
//512/521/514/1026业务的用户自定义域取DOMAIN_STR取自Keyword
if(/*entity.getServiceId()==512
||*/entity.getServiceId()==521
||entity.getServiceId()==514
||entity.getServiceId()==1026) {
keywordMap=configSynchronizationDao.getCompileIdWithKeyword(regionTable, compileIds);
}
}else if("3".equals(m.get("cfgType"))){
complexStrList.addAll(configSynchronizationDao.getComplexStrList(regionTable,compileIds));
}else if("4".equals(m.get("cfgType"))){
}else if("5".equals(m.get("cfgType"))){
fileList.addAll(configSynchronizationDao.getFileDigestList(regionTable, compileIds));
} }
}else if("3".equals(m.get("cfgType"))){
complexStrList.addAll(configSynchronizationDao.getComplexStrList(regionTable,compileIds));
}else if("4".equals(m.get("cfgType"))){
}else if("5".equals(m.get("cfgType"))){
fileList.addAll(configSynchronizationDao.getFileDigestList(regionTable, compileIds));
} }
} }
} }
//批量获取regionId,groupId(相同编译下的IP类配置多条ip只获取一个组号分组复用的域配置不需要重新获取regionId,groupId //批量获取regionId,groupId(相同编译下的IP类配置多条ip只获取一个组号分组复用的域配置不需要重新获取regionId,groupId
List<Integer> regionIds=new ArrayList<>(),groupIds=new ArrayList<>(); List<Integer> regionIds = ConfigServiceUtil.getId(3, ipList.size()+strList.size()+complexStrList.size()+numList.size()+fileList.size());
if(!isCommonGroup){ List<Integer> groupIds = ConfigServiceUtil.getId(2, ipList.size()+strList.size()+complexStrList.size()+numList.size()+fileList.size());
regionIds = ConfigServiceUtil.getId(3, ipList.size()+strList.size()+complexStrList.size()+numList.size()+fileList.size());
groupIds = ConfigServiceUtil.getId(2, ipList.size()+strList.size()+complexStrList.size()+numList.size()+fileList.size());
}
entity.setIsValid(isValid);//将最新的配置状态赋给配置对象 entity.setIsValid(isValid);//将最新的配置状态赋给配置对象
entity.setAuditTime(updateTime); entity.setAuditTime(updateTime);
for(CfgIndexInfo cfg:list){ for(CfgIndexInfo cfg:list){
@@ -201,236 +173,150 @@ public class SchedulerTaskUtil {
numRegionList = new ArrayList(); numRegionList = new ArrayList();
digestRegionList = new ArrayList(); digestRegionList = new ArrayList();
areaIpRegionList = new ArrayList(); areaIpRegionList = new ArrayList();
if(StringUtils.isNotBlank(cfg.getCommonGroupIds())){//公共分组 List list1 = new ArrayList();
//处理自定义域 List<BaseStringCfg> list2 = new ArrayList();
StringBuffer userRegion = new StringBuffer(); List<ComplexkeywordCfg> list3 = new ArrayList();
userRegion.append(ConfigConvertUtil.generateCommonGroupDefaultUserRegion(null,cfg.getServiceId())); List<com.nis.domain.configuration.NumBoundaryCfg> list4 = new ArrayList();
//子配置 List<FileDigestCfg> list5 = new ArrayList();
Map<String,Object> maatTableMap=ConfigConvertUtil.convertCommonGroupMaatTable(cfg,cfgList); String userRegion = "";
//IP公共分组 //处理自定义域
if(CollectionUtils.isNotEmpty(cfg.getIpCommGroupCfgList())){ if(userRegionList!=null){
IpPortCfg _cfg = new IpPortCfg(); for(Map<String,Object> n:userRegionList){
BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId","menuNameCode"}); Object userRegionPosition = n.get("userRegionPosition");
Map<String,List> map = ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,ipRegionList,cfg.getIpCommGroupCfgList(),1,_cfg,groupRelationList,maatTableMap,groupIdSet); if(userRegionPosition!=null && (userRegionPosition.toString().equals("1")||userRegionPosition.toString().equals("0"))){
groupRelationList=map.get("groupList"); //通过反射机制获取自定义域字段值
ipRegionList=map.get("dstList"); String regionColumn = n.get("regionColumn").toString();
if(map.get("numRegionList")!=null){ String regionKey = n.get("regionKey").toString();
numRegionList.addAll(map.get("numRegionList")); Object value = "";
} Class aClass = null;
if(userRegionPosition.toString().equals(("0"))){
} aClass = BaseCfg.class;
//URL公共分组 }else{
if(CollectionUtils.isNotEmpty(cfg.getUrlCommGroupList())){ aClass = CfgIndexInfo.class;
CommonStringCfg _cfg = new CommonStringCfg(); }
BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId","menuNameCode"}); if(entity.getServiceId().equals(517)||entity.getServiceId().equals(560)){//代理替换策略
Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfg.getUrlCommGroupList(),2,_cfg,groupRelationList,maatTableMap,groupIdSet); String[] regionArray = regionColumn.split(",");
groupRelationList=map.get("groupList"); for(int r=0;r<regionArray.length;r++){
strRegionList=map.get("dstList"); Field field = aClass.getDeclaredField(regionArray[r]);
} field.setAccessible(true);
//账号公共分组 if(n.get("regionKey").equals("substitute")){
if(CollectionUtils.isNotEmpty(cfg.getScriberIdCommGroupList())){ value += "/"+BaseService.replaceContentEscape(field.get(cfg)==null?"":field.get(cfg).toString());//自定义域以/分割时的处理
CommonStringCfg _cfg = new CommonStringCfg(); }else{
BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId","menuNameCode"}); value += BaseService.replaceContentEscape(field.get(cfg)==null?"":field.get(cfg).toString());
Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfg.getScriberIdCommGroupList(),2,_cfg,groupRelationList,maatTableMap,groupIdSet);
groupRelationList=map.get("groupList");
strRegionList=map.get("dstList");
}
//域名公共分组
if(CollectionUtils.isNotEmpty(cfg.getDomainCommGroupList())){
CommonStringCfg _cfg = new CommonStringCfg();
BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId","menuNameCode"});
Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfg.getDomainCommGroupList(),2,_cfg,groupRelationList,maatTableMap,groupIdSet);
groupRelationList=map.get("groupList");
strRegionList=map.get("dstList");
}
BeanUtils.copyProperties(cfg, maatCfg);
if(cfg.getServiceId().equals(512)){
maatCfg.setAction(2);
}else{
maatCfg.setAction(cfg.getAction());
}
maatCfg.setAuditTime(StringUtil.isEmpty(entity.getAuditTime()) ? cfg.getAuditTime():entity.getAuditTime());
maatCfg.setIpRegionList(ipRegionList);
maatCfg.setStrRegionList(strRegionList);
maatCfg.setNumRegionList(numRegionList);
maatCfg.setDigestRegionList(digestRegionList);
maatCfg.setGroupRelationList(groupRelationList);
maatCfg.setGroupNum(groupRelationList.size());
maatCfg.setAreaIpRegionList(areaIpRegionList);
maatCfg.setIsValid(entity.getIsValid());
if(!StringUtil.isEmpty(userRegion.toString())){
maatCfg.setUserRegion(userRegion.toString());
}
configCompileList.add(maatCfg);
}else{//非公共分组
List list1 = new ArrayList();
List<BaseStringCfg> list2 = new ArrayList();
List<ComplexkeywordCfg> list3 = new ArrayList();
List<com.nis.domain.configuration.NumBoundaryCfg> list4 = new ArrayList();
List<FileDigestCfg> list5 = new ArrayList();
String userRegion = "";
//处理自定义域
if(userRegionList!=null){
for(Map<String,Object> n:userRegionList){
Object userRegionPosition = n.get("userRegionPosition");
if(userRegionPosition!=null && (userRegionPosition.toString().equals("1")||userRegionPosition.toString().equals("0"))){
//通过反射机制获取自定义域字段值
String regionColumn = n.get("regionColumn").toString();
String regionKey = n.get("regionKey").toString();
Object value = "";
Class aClass = null;
if(userRegionPosition.toString().equals(("0"))){
aClass = BaseCfg.class;
}else{
aClass = CfgIndexInfo.class;
}
if(entity.getServiceId().equals(517)||entity.getServiceId().equals(560)){//代理替换策略
String[] regionArray = regionColumn.split(",");
for(int r=0;r<regionArray.length;r++){
Field field = aClass.getDeclaredField(regionArray[r]);
field.setAccessible(true);
if(n.get("regionKey").equals("substitute")){
value += "/"+BaseService.replaceContentEscape(field.get(cfg)==null?"":field.get(cfg).toString());//自定义域以/分割时的处理
}else{
value += BaseService.replaceContentEscape(field.get(cfg)==null?"":field.get(cfg).toString());
}
} }
userRegion += n.get("regionKey")+"="+value+Constants.USER_REGION_SPLIT;
}else{ }
/*if(regionKey.equals("keyring_id") && StringUtil.isEmpty(value)){ userRegion += n.get("regionKey")+"="+value+Constants.USER_REGION_SPLIT;
}else{
if(regionKey.equals("keyring_id") && StringUtil.isEmpty(value)){
value = "0"; value = "0";
}else*/ if(regionKey.equals("DOMAIN_STR")) { }else if(regionKey.equals("DOMAIN_STR")) {
if(!StringUtil.isEmpty(keywordMap) && !StringUtil.isEmpty(keywordMap.get(cfg.getCompileId()))) { if(!StringUtil.isEmpty(keywordMap) && !StringUtil.isEmpty(keywordMap.get(cfg.getCompileId()))) {
value = keywordMap.get(cfg.getCompileId()).getCfgKeywords(); value = keywordMap.get(cfg.getCompileId()).getCfgKeywords();
}
}else if(regionKey.equals("DOMAIN_ID")) {
if(!StringUtil.isEmpty(keywordMap) && !StringUtil.isEmpty(keywordMap.get(cfg.getCompileId()))) {
value = cfg.getCompileId();
}
}else {
Field field = aClass.getDeclaredField(regionColumn);
field.setAccessible(true);
value = field.get(cfg);
} }
if(!StringUtil.isEmpty(value)){ }else if(regionKey.equals("DOMAIN_ID")) {
if(StringUtil.isEmpty(n.get("regionKey"))){ if(!StringUtil.isEmpty(keywordMap) && !StringUtil.isEmpty(keywordMap.get(cfg.getCompileId()))) {
userRegion = value.toString(); value = cfg.getCompileId();
}else{ }
userRegion += n.get("regionKey")+"="+value+Constants.USER_REGION_SPLIT;
} }else {
Field field = aClass.getDeclaredField(regionColumn);
field.setAccessible(true);
value = field.get(cfg);
}
if(!StringUtil.isEmpty(value)){
if(StringUtil.isEmpty(n.get("regionKey"))){
userRegion = value.toString();
}else{
userRegion += n.get("regionKey")+"="+value+Constants.USER_REGION_SPLIT;
} }
} }
} }
} }
if(userRegion.endsWith(Constants.USER_REGION_SPLIT)){
userRegion = userRegion.substring(0, userRegion.length()-1);
}
} }
// Proxy Block --xml无法描述的user_region if(userRegion.endsWith(Constants.USER_REGION_SPLIT)){
if(entity.getServiceId().equals(576)) { userRegion = userRegion.substring(0, userRegion.length()-1);
ManipulatActionParam actionParam = new ManipulatActionParam();
actionParam.setMethod("block");
actionParam.setCode(Integer.valueOf(cfg.getUserRegion1()));
actionParam.setMessage(!StringUtil.isBlank(cfg.getUserRegion2()) ? cfg.getUserRegion2():"");
actionParam.setHtml_profile(Integer.valueOf(!StringUtil.isBlank(cfg.getUserRegion3()) ? cfg.getUserRegion3():"0"));
userRegion = StringEscapeUtils.unescapeJson(BaseService.gsonToJson(actionParam));
} }
// Proxy Manipulate
if(entity.getServiceId().equals(656)) {
userRegion = BaseService.setUserRegionOfMantipulateCfg(cfg, userRegion);
}
//Intercept Policy、http(s) 监测 、http(s) 白名单
else if(entity.getServiceId().equals(521) || entity.getServiceId().equals(592)
|| entity.getServiceId().equals(750)) {
userRegion="{}";
}
for(AsnIpCfg ip:asnIpList){//asn不需要再次获取regionId,groupId
if(ip.getAsnIpGroup().toString().equals(cfg.getUserRegion4())){//根据组号对应
ip.setIsValid(entity.getIsValid());
ip.setAuditTime(StringUtil.isEmpty(entity.getAuditTime()) ? cfg.getAuditTime():entity.getAuditTime());
list1.add(ip);
}
}
//ip spoofing
if(cfg.getServiceId().equals(518)){
//IP仿冒策略
//仿冒IP池配置匹配下发或者取消
PxyObjSpoofingIpPool pool=new PxyObjSpoofingIpPool();
pool.setCfgId(Long.valueOf(cfg.getUserRegion3()));
// pxyObjSpoofingIpPoolDao.update(pool);
pool = configSynchronizationDao.getPxyObjSpoofingIpPool(pool.getCfgId());
pool.setIsValid(entity.getIsValid());
pool.setIsAudit(entity.getIsAudit());
pool.setAuditorId(entity.getAuditorId());
pool.setAuditTime(entity.getAuditTime());
List<PxyObjSpoofingIpPool> poolList = new ArrayList<PxyObjSpoofingIpPool>();
String json="";
String areaEffectiveIds="0";
if(isValid==1){
pool.setAreaEffectiveIds(areaEffectiveIds);
pool.setGroupId(pool.getCfgId().intValue());//界面端的配置ID作为策略分组ID
poolList.add(pool);
//调用服务接口下发配置数据
json=BaseService.gsonToJson(poolList);
logger.info("欺骗IP池配置下发配置参数"+json);
//调用服务接口下发配置
try {
ToMaatResult result = ConfigServiceUtil.postCallbackCfg(json);
if(result!=null){
logger.info("欺骗IP池配置下发响应信息"+result.getMsg());
}
} catch (Exception e) {
logger.error("欺骗IP池配置配置下发失败",e);
throw e;
}
}
}
if(list1.size()>0){
GroupCfg groupCfg=new GroupCfg();
groupCfg.setCompileId(cfg.getCompileId());
groupCfg.setGroupId(Integer.parseInt(cfg.getUserRegion4()));
groupCfg.setIsValid(entity.getIsValid());
groupCfg.setAuditTime(StringUtil.isEmpty(entity.getAuditTime()) ? cfg.getAuditTime():entity.getAuditTime());
groupRelationList.add(groupCfg);
ipRegionList.addAll(ConfigConvertUtil.groupReuseCfgAddRemoveConvert(list1,Constants.VALID_YES,null));
}else if(!StringUtil.isEmpty(asnGroupIds)) {
GroupCfg groupCfg=new GroupCfg();
groupCfg.setCompileId(cfg.getCompileId());
groupCfg.setGroupId(Integer.parseInt(cfg.getUserRegion4()));
groupCfg.setIsValid(entity.getIsValid());
groupCfg.setAuditTime(StringUtil.isEmpty(entity.getAuditTime()) ? cfg.getAuditTime():entity.getAuditTime());
groupRelationList.add(groupCfg);
ipRegionList.addAll(ipRegionList);
}
//配置域转换
userRegion = ConfigConvertUtil.configCovert(ipList,strList,complexStrList,
numList,fileList,regionIds,groupIds,entity,cfg.getCompileId(),
StringUtil.isEmpty(entity.getAuditTime()) ? cfg.getAuditTime():entity.getAuditTime(),
groupRelationList,ipRegionList,strRegionList,numRegionList,digestRegionList,areaIpRegionList,userRegion);
BeanUtils.copyProperties(cfg, maatCfg);
maatCfg.setAction(cfg.getAction());
maatCfg.setAuditTime(StringUtil.isEmpty(entity.getAuditTime()) ? cfg.getAuditTime():entity.getAuditTime());
maatCfg.setIpRegionList(ipRegionList);
maatCfg.setStrRegionList(strRegionList);
maatCfg.setNumRegionList(numRegionList);
maatCfg.setDigestRegionList(digestRegionList);
maatCfg.setGroupRelationList(groupRelationList);
maatCfg.setGroupNum(groupRelationList.size());
maatCfg.setAreaIpRegionList(areaIpRegionList);
maatCfg.setIsValid(entity.getIsValid());
if(!StringUtil.isEmpty(userRegion)){
maatCfg.setUserRegion(userRegion);
}
configCompileList.add(maatCfg);
} }
for(AsnIpCfg ip:asnIpList){//asn不需要再次获取regionId,groupId
if(ip.getAsnIpGroup().toString().equals(cfg.getUserRegion4())){//根据组号对应
ip.setIsValid(entity.getIsValid());
ip.setAuditTime(StringUtil.isEmpty(entity.getAuditTime()) ? cfg.getAuditTime():entity.getAuditTime());
list1.add(ip);
}
}
//ip spoofing
if(cfg.getServiceId().equals(518)){
//IP仿冒策略
//仿冒IP池配置匹配下发或者取消
PxyObjSpoofingIpPool pool=new PxyObjSpoofingIpPool();
pool.setCfgId(Long.valueOf(cfg.getUserRegion3()));
// pxyObjSpoofingIpPoolDao.update(pool);
pool = configSynchronizationDao.getPxyObjSpoofingIpPool(pool.getCfgId());
pool.setIsValid(entity.getIsValid());
pool.setIsAudit(entity.getIsAudit());
pool.setAuditorId(entity.getAuditorId());
pool.setAuditTime(entity.getAuditTime());
List<PxyObjSpoofingIpPool> poolList = new ArrayList<PxyObjSpoofingIpPool>();
String json="";
String areaEffectiveIds="0";
if(isValid==1){
pool.setAreaEffectiveIds(areaEffectiveIds);
pool.setGroupId(pool.getCfgId().intValue());//界面端的配置ID作为策略分组ID
poolList.add(pool);
//调用服务接口下发配置数据
json=BaseService.gsonToJson(poolList);
logger.info("欺骗IP池配置下发配置参数"+json);
//调用服务接口下发配置
try {
ToMaatResult result = ConfigServiceUtil.postCallbackCfg(json);
if(result!=null){
logger.info("欺骗IP池配置下发响应信息"+result.getMsg());
}
} catch (Exception e) {
logger.error("欺骗IP池配置配置下发失败",e);
throw e;
}
}
}
if(list1.size()>0){
GroupCfg groupCfg=new GroupCfg();
groupCfg.setCompileId(cfg.getCompileId());
groupCfg.setGroupId(Integer.parseInt(cfg.getUserRegion4()));
groupCfg.setIsValid(entity.getIsValid());
groupCfg.setAuditTime(StringUtil.isEmpty(entity.getAuditTime()) ? cfg.getAuditTime():entity.getAuditTime());
groupRelationList.add(groupCfg);
ipRegionList.addAll(ConfigConvertUtil.groupReuseCfgAddRemoveConvert(list1,Constants.VALID_YES,null));
}else if(!StringUtil.isEmpty(asnGroupIds)) {
GroupCfg groupCfg=new GroupCfg();
groupCfg.setCompileId(cfg.getCompileId());
groupCfg.setGroupId(Integer.parseInt(cfg.getUserRegion4()));
groupCfg.setIsValid(entity.getIsValid());
groupCfg.setAuditTime(StringUtil.isEmpty(entity.getAuditTime()) ? cfg.getAuditTime():entity.getAuditTime());
groupRelationList.add(groupCfg);
ipRegionList.addAll(ipRegionList);
}
//配置域转换
userRegion = ConfigConvertUtil.configCovert(ipList,strList,complexStrList,
numList,fileList,regionIds,groupIds,entity,cfg.getCompileId(),
StringUtil.isEmpty(entity.getAuditTime()) ? cfg.getAuditTime():entity.getAuditTime(),
groupRelationList,ipRegionList,strRegionList,numRegionList,digestRegionList,areaIpRegionList,userRegion);
BeanUtils.copyProperties(cfg, maatCfg);
maatCfg.setAction(cfg.getAction());
maatCfg.setAuditTime(StringUtil.isEmpty(entity.getAuditTime()) ? cfg.getAuditTime():entity.getAuditTime());
maatCfg.setIpRegionList(ipRegionList);
maatCfg.setStrRegionList(strRegionList);
maatCfg.setNumRegionList(numRegionList);
maatCfg.setDigestRegionList(digestRegionList);
maatCfg.setGroupRelationList(groupRelationList);
maatCfg.setGroupNum(groupRelationList.size());
maatCfg.setAreaIpRegionList(areaIpRegionList);
maatCfg.setIsValid(entity.getIsValid());
if(!StringUtil.isEmpty(userRegion)){
maatCfg.setUserRegion(userRegion);
}
configCompileList.add(maatCfg);
} }
maatBean.setConfigCompileList(configCompileList); maatBean.setConfigCompileList(configCompileList);
maatBean.setAuditTime(new Date()); maatBean.setAuditTime(new Date());
@@ -438,11 +324,7 @@ public class SchedulerTaskUtil {
maatBean.setVersion(Constants.MAAT_VERSION); maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.INSERT_ACTION); maatBean.setOpAction(Constants.INSERT_ACTION);
String json=BaseService.gsonToJson(maatBean); String json=BaseService.gsonToJson(maatBean);
if(json.length()<Constants.JSON_PRINT_LENTH){ logger.info("定时任务修改NTC/PROXY策略的MAAT配置内容"+json);
logger.info("定时任务修改NTC/PROXY策略的MAAT配置内容"+json);
}else{
logger.info("定时任务修改NTC/PROXY策略的MAAT配置内容超过"+Constants.JSON_PRINT_LENTH+",不打印");
}
//调用服务接口修改配置内容与状态 //调用服务接口修改配置内容与状态
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json); ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
if(result!=null){ if(result!=null){
@@ -1116,28 +998,5 @@ public class SchedulerTaskUtil {
} }
public static void main(String[] args) { public static void main(String[] args) {
}
private void covertCommongroupIdsMap(Map commGroupMap,String key,CfgIndexInfo cfg,ConfigSynchronizationDao configSynchronizationDao,Class clazz){
if(commGroupMap.containsKey(key)){
String groups=commGroupMap.get(key).toString();
List<Integer> _groupIds=new ArrayList<>();
for(String group:groups.split(",")){
if(StringUtils.isNotBlank(group)){
_groupIds.add(Integer.parseInt(group));
}
}
if(_groupIds.size()>0){
if("IpCommCfg".equals(clazz.getSimpleName())){
cfg.setIpCommGroupCfgList(configSynchronizationDao.getIpCommCfgPortList(_groupIds));
}else if("UrlCommCfg".equals(clazz.getSimpleName())){
cfg.setUrlCommGroupList(configSynchronizationDao.getUrlCommCfgPortList(_groupIds));
}else if("ScriberIdCommCfg".equals(clazz.getSimpleName())){
cfg.setScriberIdCommGroupList(configSynchronizationDao.getSubscribeIdCommCfgPortList(_groupIds));
}else if("DomainCommCfg".equals(clazz.getSimpleName())){
cfg.setDomainCommGroupList(configSynchronizationDao.getDomainCommCfgPortList(_groupIds));
}
}
}
} }
} }

View File

@@ -306,31 +306,12 @@ public class ExcelCsv {
dict="block_drop"; dict="block_drop";
val = msgProp.getProperty(dict,dict); val = msgProp.getProperty(dict,dict);
} }
if ("action".equals(ef.title()) && dict.equals("action_reject")
&& (Reflections.invokeGetter(e, "service").toString().equals("35")
|| Reflections.invokeGetter(e, "service").toString().equals("33")
|| Reflections.invokeGetter(e, "service").toString().equals("36"))) {
dict="block_drop";
val = msgProp.getProperty(dict,dict);
}
//ip spoofing redirect动作修改为Spoofing //ip spoofing redirect动作修改为Spoofing
if(ef.title().equals("block_type") if(ef.title().equals("block_type")
&& (Reflections.invokeGetter(e, "serviceId").toString().equals("518"))) { && (Reflections.invokeGetter(e, "serviceId").toString().equals("518"))) {
dict="action_spoofing"; dict="action_spoofing";
val = msgProp.getProperty(dict,dict); val = msgProp.getProperty(dict,dict);
} }
//http(s) manipulate 导出action修改为Manipulate
if(ef.title().equals("block_type")
&& dict.equals("action_redirect")
&& (Reflections.invokeGetter(e, "serviceId").toString().equals("656"))) {
dict="action_manipulate";
val = msgProp.getProperty(dict,dict);
}
if(ef.title().equals("action")
&& dict.equals("action_redirect")) {
dict="action_manipulate";
val = msgProp.getProperty(dict,dict);
}
} }
} }

View File

@@ -23,7 +23,6 @@ import java.util.Set;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellStyle;
@@ -40,7 +39,6 @@ import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.apache.poi.xssf.usermodel.XSSFRichTextString; import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
@@ -50,9 +48,7 @@ import com.nis.domain.SysDataDictionaryItem;
import com.nis.domain.basics.PolicyGroupInfo; import com.nis.domain.basics.PolicyGroupInfo;
import com.nis.domain.basics.ServiceDictInfo; import com.nis.domain.basics.ServiceDictInfo;
import com.nis.domain.basics.SysDictInfo; import com.nis.domain.basics.SysDictInfo;
import com.nis.domain.callback.ProxyFileTrafficMirrorCfg;
import com.nis.domain.configuration.DnsResStrategy; import com.nis.domain.configuration.DnsResStrategy;
import com.nis.domain.configuration.PxyObjKeyring;
import com.nis.util.Constants; import com.nis.util.Constants;
import com.nis.util.DictUtils; import com.nis.util.DictUtils;
import com.nis.util.Encodes; import com.nis.util.Encodes;
@@ -61,8 +57,6 @@ import com.nis.util.StringUtil;
import com.nis.web.dao.basics.PolicyGroupInfoDao; import com.nis.web.dao.basics.PolicyGroupInfoDao;
import com.nis.web.dao.basics.SysDictInfoDao; import com.nis.web.dao.basics.SysDictInfoDao;
import com.nis.web.dao.configuration.DnsResStrategyDao; import com.nis.web.dao.configuration.DnsResStrategyDao;
import com.nis.web.dao.configuration.ProxyFileTrafficMirrorDao;
import com.nis.web.dao.configuration.PxyObjKeyringDao;
import com.nis.web.service.SpringContextHolder; import com.nis.web.service.SpringContextHolder;
/** /**
@@ -77,8 +71,6 @@ public class ExportExcel {
private static DnsResStrategyDao dnsResStrategyDao = SpringContextHolder.getBean(DnsResStrategyDao.class); private static DnsResStrategyDao dnsResStrategyDao = SpringContextHolder.getBean(DnsResStrategyDao.class);
private static PolicyGroupInfoDao policyGroupInfoDao = SpringContextHolder.getBean(PolicyGroupInfoDao.class); private static PolicyGroupInfoDao policyGroupInfoDao = SpringContextHolder.getBean(PolicyGroupInfoDao.class);
private static SysDictInfoDao sysDictInfoDao = SpringContextHolder.getBean(SysDictInfoDao.class); private static SysDictInfoDao sysDictInfoDao = SpringContextHolder.getBean(SysDictInfoDao.class);
private static PxyObjKeyringDao pxyObjKeyringDao = SpringContextHolder.getBean(PxyObjKeyringDao.class);
private static ProxyFileTrafficMirrorDao proxyFileDao = SpringContextHolder.getBean(ProxyFileTrafficMirrorDao.class);
/** /**
* 工作薄对象 * 工作薄对象
@@ -273,9 +265,6 @@ public class ExportExcel {
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n"; commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++; index++;
//1、非空 //1、非空
commentStr=commentStr+""+msgProp.getProperty("https_url_format_tip")+"\n";
index++;
//1、非空
commentStr=commentStr+""+msgProp.getProperty("required")+"\n"; commentStr=commentStr+""+msgProp.getProperty("required")+"\n";
index++; index++;
} }
@@ -302,7 +291,7 @@ public class ExportExcel {
} }
} }
/*** HTTP(s)替换 搜索区域 ***/ /*** HTTP(s)替换 搜索区域 ***/
if(("replace_zone".equals(headerStr)) && (region.getFunctionId().equals(209) || region.getAction().equals(80))){ if(("replace_zone".equals(headerStr)) && (region.getFunctionId().equals(209))){
commentStr=""; commentStr="";
List<SysDataDictionaryItem> dict=DictUtils.getDictList("CONTROL_REPLACE_ZONE"); List<SysDataDictionaryItem> dict=DictUtils.getDictList("CONTROL_REPLACE_ZONE");
if(dict !=null && dict.size()>0){ if(dict !=null && dict.size()>0){
@@ -465,27 +454,18 @@ public class ExportExcel {
} }
} }
// IP、URL、Domain和ScriberId公共组 if("ip_group".equals(headerStr)) {
if("group_name".equals(headerStr)) {
commentStr=""; commentStr="";
List<PolicyGroupInfo> list = null; //查询dns fake ip policyGroup列表
if(region.getFunctionId().equals(605)) { List<PolicyGroupInfo> list=policyGroupInfoDao.findPolicyGroupInfosByType(5);
list=policyGroupInfoDao.findPolicyGroupInfosByType(Constants.IP_OBJ_GROUP_TYPE); if(!StringUtil.isEmpty(list)){
}else if(region.getFunctionId().equals(606)) { for (PolicyGroupInfo policyGroupInfo : list) {
list=policyGroupInfoDao.findPolicyGroupInfosByType(Constants.URL_OBJ_GROUP_TYPE); commentStr=commentStr+policyGroupInfo.getServiceGroupId()+""+policyGroupInfo.getGroupName()+"\n";
}else if(region.getFunctionId().equals(607)) { index++;
list=policyGroupInfoDao.findPolicyGroupInfosByType(Constants.DOMAIN_OBJ_GROUP_TYPE); }
}else if(region.getFunctionId().equals(608)) {
list=policyGroupInfoDao.findPolicyGroupInfosByType(Constants.SUBID_OBJ_GROUP_TYPE);
}
if(!StringUtil.isEmpty(list)){
for (PolicyGroupInfo policyGroupInfo : list) {
commentStr=commentStr+policyGroupInfo.getGroupName()+"\n";
index++;
} }
} commentStr=msgProp.getProperty("select")+":\n"+commentStr;
commentStr=msgProp.getProperty("select")+":\n"+commentStr; index++;
index++;
} }
if("isp".equals(headerStr)) { if("isp".equals(headerStr)) {
commentStr=""; commentStr="";
@@ -603,393 +583,7 @@ public class ExportExcel {
commentStr=commentStr+""+msgProp.getProperty("ip_check")+"(IPv4)\n"; commentStr=commentStr+""+msgProp.getProperty("ip_check")+"(IPv4)\n";
index++; index++;
} }
/**********************************************************************pxy intercept************************************************************************************************************/
//pxy intercept
if("pxy_intercept_monit_keyring".equals(headerStr)) {
commentStr="";
List<PxyObjKeyring> certificateList=pxyObjKeyringDao.findList(null,1,1,"ip");
if(CollectionUtils.isNotEmpty(certificateList)) {
for (PxyObjKeyring certificate : certificateList) {
commentStr=commentStr+certificate.getCompileId()+""+certificate.getCfgDesc()+"\n";
index++;
}
}
if(StringUtil.isEmpty(headerStr)){
headerStr="";
commentStr="";
}else{
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
index++;
commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
/*//2、默认值说明
commentStr=commentStr+"▶"+msgProp.getProperty("default_value")+":0\n";
index++;*/
index++;
}
}
//ev_cert
if("exclusions_ev_cert".equals(headerStr)) {
commentStr="";
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
commentStr+=1+""+msgProp.getProperty("yes")+"\n";
index++;
commentStr+=0+""+msgProp.getProperty("no")+"\n";
index++;
if(StringUtil.isEmpty(headerStr)){
headerStr="";
commentStr="";
}else{
index++;
commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
//2、默认值说明
commentStr=commentStr+""+msgProp.getProperty("default_value")+":0\n";
index++;
index++;
}
}
//cert_transparency
if("exclusions_cert_transparency".equals(headerStr)) {
commentStr="";
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
commentStr+=1+""+msgProp.getProperty("yes")+"\n";
index++;
commentStr+=0+""+msgProp.getProperty("no")+"\n";
index++;
if(StringUtil.isEmpty(headerStr)){
headerStr="";
commentStr="";
}else{
index++;
commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
//2、默认值说明
commentStr=commentStr+""+msgProp.getProperty("default_value")+":0\n";
index++;
index++;
}
}
//client_cert_req
if("exclusions_client_cert_req".equals(headerStr)) {
commentStr="";
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
commentStr+=1+""+msgProp.getProperty("yes")+"\n";
index++;
commentStr+=0+""+msgProp.getProperty("no")+"\n";
index++;
if(StringUtil.isEmpty(headerStr)){
headerStr="";
commentStr="";
}else{
index++;
commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
//2、默认值说明
commentStr=commentStr+""+msgProp.getProperty("default_value")+":1\n";
index++;
index++;
}
}
//pinning
if("exclusions_pinning".equals(headerStr)) {
commentStr="";
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
commentStr+=1+""+msgProp.getProperty("yes")+"\n";
index++;
commentStr+=0+""+msgProp.getProperty("no")+"\n";
index++;
if(StringUtil.isEmpty(headerStr)){
headerStr="";
commentStr="";
}else{
index++;
commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
//2、默认值说明
commentStr=commentStr+""+msgProp.getProperty("default_value")+":1\n";
index++;
index++;
}
}
//pinning
if("exclusions_protocol_errors".equals(headerStr)) {
commentStr="";
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
commentStr+=1+""+msgProp.getProperty("yes")+"\n";
index++;
commentStr+=0+""+msgProp.getProperty("no")+"\n";
index++;
if(StringUtil.isEmpty(headerStr)){
headerStr="";
commentStr="";
}else{
index++;
commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
//2、默认值说明
commentStr=commentStr+""+msgProp.getProperty("default_value")+":1\n";
index++;
index++;
}
}
//cn
if("cert_verify_approach_cn".equals(headerStr)) {
commentStr="";
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
commentStr+=1+""+msgProp.getProperty("yes")+"\n";
index++;
commentStr+=0+""+msgProp.getProperty("no")+"\n";
index++;
if(StringUtil.isEmpty(headerStr)){
headerStr="";
commentStr="";
}else{
index++;
commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
//2、默认值说明
commentStr=commentStr+""+msgProp.getProperty("default_value")+":1\n";
index++;
index++;
}
}
//issuer
if("cert_verify_approach_issuer".equals(headerStr)) {
commentStr="";
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
commentStr+=1+""+msgProp.getProperty("yes")+"\n";
index++;
commentStr+=0+""+msgProp.getProperty("no")+"\n";
index++;
if(StringUtil.isEmpty(headerStr)){
headerStr="";
commentStr="";
}else{
index++;
commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
//2、默认值说明
commentStr=commentStr+""+msgProp.getProperty("default_value")+":1\n";
index++;
index++;
}
}
//self-signed
if("cert_verify_approach_self_signed".equals(headerStr)) {
commentStr="";
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
commentStr+=1+""+msgProp.getProperty("yes")+"\n";
index++;
commentStr+=0+""+msgProp.getProperty("no")+"\n";
index++;
if(StringUtil.isEmpty(headerStr)){
headerStr="";
commentStr="";
}else{
index++;
commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
//2、默认值说明
commentStr=commentStr+""+msgProp.getProperty("default_value")+":1\n";
index++;
index++;
}
}
//expiration
if("cert_verify_approach_expiration".equals(headerStr)) {
commentStr="";
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
commentStr+=1+""+msgProp.getProperty("yes")+"\n";
index++;
commentStr+=0+""+msgProp.getProperty("no")+"\n";
index++;
if(StringUtil.isEmpty(headerStr)){
headerStr="";
commentStr="";
}else{
index++;
commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
//2、默认值说明
commentStr=commentStr+""+msgProp.getProperty("default_value")+":1\n";
index++;
index++;
}
}
//fail_method
if("cert_verify_fail_method".equals(headerStr)) {
commentStr="";
defaultValue="pass-through";
List<SysDataDictionaryItem> failMethods=DictUtils.getDictList("FAIL_METHOD");
if(CollectionUtils.isNotEmpty(failMethods)){
for (SysDataDictionaryItem failMethod : failMethods) {
commentStr=commentStr+failMethod.getItemCode()+""+msgProp.getProperty(failMethod.getItemValue(),failMethod.getItemValue())+""+"\n";
index++;
}
if(StringUtil.isEmpty(commentStr)){
headerStr="";
commentStr="";
}
if(StringUtil.isEmpty(defaultValue)){
defaultValue = region.getConfigDirection().split(",")[0];
}
}
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
//1、默认值说明
if(!StringUtil.isEmpty(defaultValue)){
commentStr=commentStr+""+msgProp.getProperty("default_value")+":"+defaultValue+"\n";
index++;
}
}
//fail_method
if("ssl_ver_mirror_client".equals(headerStr)) {
commentStr="";
defaultValue="1";
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
commentStr+=1+""+msgProp.getProperty("yes")+"\n";
index++;
commentStr+=0+""+msgProp.getProperty("no")+"\n";
index++;
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
//1、默认值说明
if(!StringUtil.isEmpty(defaultValue)){
commentStr=commentStr+""+msgProp.getProperty("default_value")+":"+defaultValue+"\n";
index++;
}
commentStr=commentStr+""+msgProp.getProperty("ssl_ver_mirror_client_on","if the mirror client option value is '1', the min SSL version and the max SSL version will be ignored")+"\n";
index++;
}
//min
if("ssl_ver_min".equals(headerStr)) {
commentStr="";
defaultValue="ssl3";
List<SysDataDictionaryItem> sslversions=DictUtils.getDictList("SSL_VERSION");
if(CollectionUtils.isNotEmpty(sslversions)){
for (SysDataDictionaryItem sslversion : sslversions) {
commentStr=commentStr+sslversion.getItemCode()+""+msgProp.getProperty(sslversion.getItemValue(),sslversion.getItemValue())+""+"\n";
index++;
}
if(StringUtil.isEmpty(commentStr)){
headerStr="";
commentStr="";
}
}
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
//1、默认值说明
if(!StringUtil.isEmpty(defaultValue)){
commentStr=commentStr+""+msgProp.getProperty("default_value")+":"+defaultValue+"\n";
index++;
}
}
//max
if("ssl_ver_max".equals(headerStr)) {
commentStr="";
defaultValue="tls13";
List<SysDataDictionaryItem> sslversions=DictUtils.getDictList("SSL_VERSION");
if(CollectionUtils.isNotEmpty(sslversions)){
for (SysDataDictionaryItem sslversion : sslversions) {
commentStr=commentStr+sslversion.getItemCode()+""+msgProp.getProperty(sslversion.getItemValue(),sslversion.getItemValue())+""+"\n";
index++;
}
if(StringUtil.isEmpty(commentStr)){
headerStr="";
commentStr="";
}
}
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
//1、默认值说明
if(!StringUtil.isEmpty(defaultValue)){
commentStr=commentStr+""+msgProp.getProperty("default_value")+":"+defaultValue+"\n";
index++;
}
}
//allow_http2
if("ssl_ver_allow_http2".equals(headerStr)) {
commentStr="";
defaultValue="1";
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
commentStr+=1+""+msgProp.getProperty("yes")+"\n";
index++;
commentStr+=0+""+msgProp.getProperty("no")+"\n";
index++;
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
//1、默认值说明
if(!StringUtil.isEmpty(defaultValue)){
commentStr=commentStr+""+msgProp.getProperty("default_value")+":"+defaultValue+"\n";
index++;
}
index++;
}
if("decrypt_mirror_enable".equals(headerStr)) {
commentStr="";
defaultValue="0";
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
commentStr+=1+""+msgProp.getProperty("yes")+"\n";
index++;
commentStr+=0+""+msgProp.getProperty("no")+"\n";
index++;
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
//1、默认值说明
if(!StringUtil.isEmpty(defaultValue)){
commentStr=commentStr+""+msgProp.getProperty("default_value")+":"+defaultValue+"\n";
index++;
}
commentStr=commentStr+""+msgProp.getProperty("decrypt_mirror_enable_on","if the enable option value is '1', the Mirror profile is needed")+"\n";
index++;
}
if("decrypt_mirror_mirror_profile".equals(headerStr)) {
commentStr="";
List<ProxyFileTrafficMirrorCfg> mirrorProfileList=proxyFileDao.findMirrorList(null,1,1);
if(CollectionUtils.isNotEmpty(mirrorProfileList)) {
for (ProxyFileTrafficMirrorCfg mirrorProfile : mirrorProfileList) {
commentStr=commentStr+mirrorProfile.getCompileId()+""+mirrorProfile.getCfgDesc()+"\n";
index++;
}
}
if(StringUtil.isEmpty(headerStr)){
headerStr="";
commentStr="";
}else{
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
index++;
commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
/*//2、默认值说明
commentStr=commentStr+"▶"+msgProp.getProperty("default_value")+":0\n";
index++;*/
index++;
}
}
/**********************************************************************pxy intercept************************************************************************************************************/
if(region.getRegionType().equals(1)){//IP配置 if(region.getRegionType().equals(1)){//IP配置
//ip配置需要导入的信息srcIp srcPort destIp destPort Protocol Direction //ip配置需要导入的信息srcIp srcPort destIp destPort Protocol Direction
//确定需要导入的srcIp srcPort destIp destPort信息 //确定需要导入的srcIp srcPort destIp destPort信息
@@ -1003,28 +597,25 @@ public class ExportExcel {
commentStr=""; commentStr="";
} }
}else{ }else{
String[] ipPatterns=region.getConfigIpPattern().split(";");
if("client_ip".equals(headerStr)){ if("client_ip".equals(headerStr)){
Assert.isTrue(ipPatterns.length==2);
String srcIpPattern=ipPatterns[0];
if(((","+region.getConfigIpPortShow()+",").indexOf(",1,") > -1) ){ if(((","+region.getConfigIpPortShow()+",").indexOf(",1,") > -1) ){
commentStr=""; commentStr="";
if((","+region.getConfigIpType()+",").indexOf(",4,") > -1){ if((","+region.getConfigIpType()+",").indexOf(",4,") > -1){
if((","+srcIpPattern+",").indexOf(",3,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){
commentStr=commentStr+Constants.IPV4_DEFAULT_IP_VALUE+"IPv4"+"\n"; commentStr=commentStr+Constants.IPV4_DEFAULT_IP_VALUE+"IPv4"+"\n";
if(StringUtil.isEmpty(defaultValue)){ if(StringUtil.isEmpty(defaultValue)){
defaultValue=Constants.IPV4_DEFAULT_IP_VALUE; defaultValue=Constants.IPV4_DEFAULT_IP_VALUE;
} }
index++; index++;
} }
if((","+srcIpPattern+",").indexOf(",2,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){
commentStr=commentStr+Constants.IPV4_DEFAULT_IP_RANGE_VALUE+""+msgProp.getProperty("ipv4_range_tip")+""+"\n"; commentStr=commentStr+Constants.IPV4_DEFAULT_IP_RANGE_VALUE+""+msgProp.getProperty("ipv4_range_tip")+""+"\n";
if(StringUtil.isEmpty(defaultValue)){ if(StringUtil.isEmpty(defaultValue)){
defaultValue=Constants.IPV4_DEFAULT_IP_RANGE_VALUE; defaultValue=Constants.IPV4_DEFAULT_IP_RANGE_VALUE;
} }
index++; index++;
} }
if((","+srcIpPattern+",").indexOf(",1,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){
commentStr=commentStr+Constants.IPV4_DEFAULT_IP_SUBNET_VALUE+""+msgProp.getProperty("ipv4_subnet_tip")+""+"\n"; commentStr=commentStr+Constants.IPV4_DEFAULT_IP_SUBNET_VALUE+""+msgProp.getProperty("ipv4_subnet_tip")+""+"\n";
if(StringUtil.isEmpty(defaultValue)){ if(StringUtil.isEmpty(defaultValue)){
defaultValue=Constants.IPV4_DEFAULT_IP_SUBNET_VALUE; defaultValue=Constants.IPV4_DEFAULT_IP_SUBNET_VALUE;
@@ -1033,21 +624,21 @@ public class ExportExcel {
} }
} }
if((","+region.getConfigIpType()+",").indexOf(",6,") > -1){ if((","+region.getConfigIpType()+",").indexOf(",6,") > -1){
if((","+srcIpPattern+",").indexOf(",3,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){
commentStr=commentStr+Constants.IPV6_DEFAULT_IP_VALUE+"IPv6"+"\n"; commentStr=commentStr+Constants.IPV6_DEFAULT_IP_VALUE+"IPv6"+"\n";
if(StringUtil.isEmpty(defaultValue)){ if(StringUtil.isEmpty(defaultValue)){
defaultValue=Constants.IPV6_DEFAULT_IP_VALUE; defaultValue=Constants.IPV6_DEFAULT_IP_VALUE;
} }
index++; index++;
} }
if((","+srcIpPattern+",").indexOf(",2,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){
commentStr=commentStr+Constants.IPV6_DEFAULT_IP_RANGE_VALUE+""+msgProp.getProperty("ipv6_range_tip")+""+"\n"; commentStr=commentStr+Constants.IPV6_DEFAULT_IP_RANGE_VALUE+""+msgProp.getProperty("ipv6_range_tip")+""+"\n";
if(StringUtil.isEmpty(defaultValue)){ if(StringUtil.isEmpty(defaultValue)){
defaultValue=Constants.IPV6_DEFAULT_IP_RANGE_VALUE; defaultValue=Constants.IPV6_DEFAULT_IP_RANGE_VALUE;
} }
index++; index++;
} }
if((","+srcIpPattern+",").indexOf(",1,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){
commentStr=commentStr+Constants.IPV6_DEFAULT_IP_SUBNET_VALUE+""+msgProp.getProperty("ipv6_subnet_tip")+""+"\n\n"; commentStr=commentStr+Constants.IPV6_DEFAULT_IP_SUBNET_VALUE+""+msgProp.getProperty("ipv6_subnet_tip")+""+"\n\n";
if(StringUtil.isEmpty(defaultValue)){ if(StringUtil.isEmpty(defaultValue)){
defaultValue=Constants.IPV6_DEFAULT_IP_SUBNET_VALUE; defaultValue=Constants.IPV6_DEFAULT_IP_SUBNET_VALUE;
@@ -1096,12 +687,12 @@ public class ExportExcel {
,msgProp.getProperty("serverip"))+"\n"; ,msgProp.getProperty("serverip"))+"\n";
index++; index++;
index++; index++;
commentStr=commentStr+""+String.format(msgProp.getProperty("the_same_ip_type"))+"\n"; commentStr=commentStr+""+String.format(msgProp.getProperty("the_same_ip_type_pattern"))+"\n";
index++; index++;
index++; index++;
} }
//4、IP Range 开始IP和结束IP必须在同一网段 //4、IP Range 开始IP和结束IP必须在同一网段
if(((","+srcIpPattern+",").indexOf(",2,") > -1)){ if(((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1)){
commentStr=commentStr+""+msgProp.getProperty("ip_range")+","+msgProp.getProperty("ip_range_bit_field")+"\n"; commentStr=commentStr+""+msgProp.getProperty("ip_range")+","+msgProp.getProperty("ip_range_bit_field")+"\n";
index++; index++;
index++; index++;
@@ -1112,7 +703,7 @@ public class ExportExcel {
} }
//6、IPv4 Mask 掩码范围16-32 //6、IPv4 Mask 掩码范围16-32
if(((","+srcIpPattern+",").indexOf(",1,") > -1)){ if(((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1)){
if(((","+region.getConfigIpType()+",").indexOf(",4,") > -1)){ if(((","+region.getConfigIpType()+",").indexOf(",4,") > -1)){
commentStr=commentStr+""+msgProp.getProperty("ipv4_subnet_tip")+","+msgProp.getProperty("ipv4_mask_range_tip")+"\n"; commentStr=commentStr+""+msgProp.getProperty("ipv4_subnet_tip")+","+msgProp.getProperty("ipv4_mask_range_tip")+"\n";
index++; index++;
@@ -1128,25 +719,24 @@ public class ExportExcel {
} }
if("server_ip".equals(headerStr)){ if("server_ip".equals(headerStr)){
String destIpPattern=ipPatterns[1];
if((","+region.getConfigIpPortShow()+",").indexOf(",3,") > -1){ if((","+region.getConfigIpPortShow()+",").indexOf(",3,") > -1){
commentStr=""; commentStr="";
if((","+region.getConfigIpType()+",").indexOf(",4,") > -1){ if((","+region.getConfigIpType()+",").indexOf(",4,") > -1){
if((","+destIpPattern+",").indexOf(",3,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){
commentStr=commentStr+Constants.IPV4_DEFAULT_IP_VALUE+"IPv4"+"\n"; commentStr=commentStr+Constants.IPV4_DEFAULT_IP_VALUE+"IPv4"+"\n";
if(StringUtil.isEmpty(defaultValue)){ if(StringUtil.isEmpty(defaultValue)){
defaultValue=Constants.IPV4_DEFAULT_IP_VALUE; defaultValue=Constants.IPV4_DEFAULT_IP_VALUE;
} }
index++; index++;
} }
if((","+destIpPattern+",").indexOf(",2,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){
commentStr=commentStr+Constants.IPV4_DEFAULT_IP_RANGE_VALUE+""+msgProp.getProperty("ipv4_range_tip")+""+"\n"; commentStr=commentStr+Constants.IPV4_DEFAULT_IP_RANGE_VALUE+""+msgProp.getProperty("ipv4_range_tip")+""+"\n";
if(StringUtil.isEmpty(defaultValue)){ if(StringUtil.isEmpty(defaultValue)){
defaultValue=Constants.IPV4_DEFAULT_IP_RANGE_VALUE; defaultValue=Constants.IPV4_DEFAULT_IP_RANGE_VALUE;
} }
index++; index++;
} }
if((","+destIpPattern+",").indexOf(",1,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){
commentStr=commentStr+Constants.IPV4_DEFAULT_IP_SUBNET_VALUE+""+msgProp.getProperty("ipv4_subnet_tip")+""+"\n"; commentStr=commentStr+Constants.IPV4_DEFAULT_IP_SUBNET_VALUE+""+msgProp.getProperty("ipv4_subnet_tip")+""+"\n";
if(StringUtil.isEmpty(defaultValue)){ if(StringUtil.isEmpty(defaultValue)){
defaultValue=Constants.IPV4_DEFAULT_IP_SUBNET_VALUE; defaultValue=Constants.IPV4_DEFAULT_IP_SUBNET_VALUE;
@@ -1155,21 +745,21 @@ public class ExportExcel {
} }
} }
if((","+region.getConfigIpType()+",").indexOf(",6,") > -1){ if((","+region.getConfigIpType()+",").indexOf(",6,") > -1){
if((","+destIpPattern+",").indexOf(",3,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){
commentStr=commentStr+Constants.IPV6_DEFAULT_IP_VALUE+"IPv6"+"\n"; commentStr=commentStr+Constants.IPV6_DEFAULT_IP_VALUE+"IPv6"+"\n";
if(StringUtil.isEmpty(defaultValue)){ if(StringUtil.isEmpty(defaultValue)){
defaultValue=Constants.IPV6_DEFAULT_IP_VALUE; defaultValue=Constants.IPV6_DEFAULT_IP_VALUE;
} }
index++; index++;
} }
if((","+destIpPattern+",").indexOf(",2,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){
commentStr=commentStr+Constants.IPV6_DEFAULT_IP_RANGE_VALUE+""+msgProp.getProperty("ipv6_range_tip")+""+"\n"; commentStr=commentStr+Constants.IPV6_DEFAULT_IP_RANGE_VALUE+""+msgProp.getProperty("ipv6_range_tip")+""+"\n";
if(StringUtil.isEmpty(defaultValue)){ if(StringUtil.isEmpty(defaultValue)){
defaultValue=Constants.IPV6_DEFAULT_IP_RANGE_VALUE; defaultValue=Constants.IPV6_DEFAULT_IP_RANGE_VALUE;
} }
index++; index++;
} }
if((","+destIpPattern+",").indexOf(",1,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){
commentStr=commentStr+Constants.IPV6_DEFAULT_IP_SUBNET_VALUE+""+msgProp.getProperty("ipv6_subnet_tip")+""+"\n\n"; commentStr=commentStr+Constants.IPV6_DEFAULT_IP_SUBNET_VALUE+""+msgProp.getProperty("ipv6_subnet_tip")+""+"\n\n";
if(StringUtil.isEmpty(defaultValue)){ if(StringUtil.isEmpty(defaultValue)){
defaultValue=Constants.IPV6_DEFAULT_IP_SUBNET_VALUE; defaultValue=Constants.IPV6_DEFAULT_IP_SUBNET_VALUE;
@@ -1202,12 +792,12 @@ public class ExportExcel {
,msgProp.getProperty("serverip"))+"\n"; ,msgProp.getProperty("serverip"))+"\n";
index++; index++;
index++; index++;
commentStr=commentStr+""+String.format(msgProp.getProperty("the_same_ip_type"))+"\n"; commentStr=commentStr+""+String.format(msgProp.getProperty("the_same_ip_type_pattern"))+"\n";
index++; index++;
index++; index++;
} }
//4、IP Range 开始IP和结束IP必须在同一网段 //4、IP Range 开始IP和结束IP必须在同一网段
if(((","+destIpPattern+",").indexOf(",2,") > -1)){ if(((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1)){
commentStr=commentStr+""+msgProp.getProperty("ip_range")+","+msgProp.getProperty("ip_range_bit_field")+"\n"; commentStr=commentStr+""+msgProp.getProperty("ip_range")+","+msgProp.getProperty("ip_range_bit_field")+"\n";
index++; index++;
index++; index++;
@@ -1218,7 +808,7 @@ public class ExportExcel {
} }
//6、IPv4 Mask 掩码范围16-32 //6、IPv4 Mask 掩码范围16-32
if(((","+destIpPattern+",").indexOf(",1,") > -1)){ if(((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1)){
if(((","+region.getConfigIpType()+",").indexOf(",4,") > -1)){ if(((","+region.getConfigIpType()+",").indexOf(",4,") > -1)){
commentStr=commentStr+""+msgProp.getProperty("ipv4_subnet_tip")+","+msgProp.getProperty("ipv4_mask_range_tip")+"\n"; commentStr=commentStr+""+msgProp.getProperty("ipv4_subnet_tip")+","+msgProp.getProperty("ipv4_mask_range_tip")+"\n";
index++; index++;
@@ -1244,20 +834,17 @@ public class ExportExcel {
}else{ }else{
protocol=region.getConfigProtocol(); protocol=region.getConfigProtocol();
} }
String[] portPatterns=region.getConfigPortPattern().split(";");
Assert.isTrue(portPatterns.length==2);
if("client_port".equals(headerStr)){ if("client_port".equals(headerStr)){
String srcPortPattern=portPatterns[0];
if(((","+region.getConfigIpPortShow()+",").indexOf(",2,") > -1)){ if(((","+region.getConfigIpPortShow()+",").indexOf(",2,") > -1)){
commentStr=""; commentStr="";
if((","+srcPortPattern+",").indexOf(",1,") > -1){ if((","+region.getConfigPortPattern()+",").indexOf(",1,") > -1){
commentStr=commentStr+Constants.PORT_DEFAULT+"Port"+"\n"; commentStr=commentStr+Constants.PORT_DEFAULT+"Port"+"\n";
if(StringUtil.isEmpty(defaultValue)){ if(StringUtil.isEmpty(defaultValue)){
defaultValue=Constants.PORT_DEFAULT; defaultValue=Constants.PORT_DEFAULT;
} }
index++; index++;
} }
if((","+srcPortPattern+",").indexOf(",2,") > -1){ if((","+region.getConfigPortPattern()+",").indexOf(",2,") > -1){
commentStr=commentStr+Constants.PORT_MASK_DEFAULT+"Port/"+msgProp.getProperty("port_mask")+""+"\n\n"; commentStr=commentStr+Constants.PORT_MASK_DEFAULT+"Port/"+msgProp.getProperty("port_mask")+""+"\n\n";
if(StringUtil.isEmpty(defaultValue)){ if(StringUtil.isEmpty(defaultValue)){
defaultValue=Constants.PORT_MASK_DEFAULT; defaultValue=Constants.PORT_MASK_DEFAULT;
@@ -1283,11 +870,11 @@ public class ExportExcel {
index++; index++;
} }
//2、源端口、目的端口格式必须一致 //2、源端口、目的端口格式必须一致
// if(((","+region.getConfigIpPortShow()+",").indexOf(",2,") > -1) && ((","+region.getConfigIpPortShow()+",").indexOf(",4,") > -1)){ if(((","+region.getConfigIpPortShow()+",").indexOf(",2,") > -1) && ((","+region.getConfigIpPortShow()+",").indexOf(",4,") > -1)){
// commentStr=commentStr+"▶"+msgProp.getProperty("the_same_port_pattern")+"\n"; commentStr=commentStr+""+msgProp.getProperty("the_same_port_pattern")+"\n";
// index++; index++;
// index++; index++;
// } }
//3、端口和端口掩码范围0-65535 //3、端口和端口掩码范围0-65535
commentStr=commentStr+""+msgProp.getProperty("port_mask_comment_tip")+"\n"; commentStr=commentStr+""+msgProp.getProperty("port_mask_comment_tip")+"\n";
index++; index++;
@@ -1322,17 +909,16 @@ public class ExportExcel {
} }
} }
if("server_port".equals(headerStr)){ if("server_port".equals(headerStr)){
String destPortPattern=portPatterns[1];
if((","+region.getConfigIpPortShow()+",").indexOf(",4,") > -1){ if((","+region.getConfigIpPortShow()+",").indexOf(",4,") > -1){
commentStr=""; commentStr="";
if((","+destPortPattern+",").indexOf(",1,") > -1){ if((","+region.getConfigPortPattern()+",").indexOf(",1,") > -1){
commentStr=commentStr+Constants.PORT_DEFAULT+"Port"+"\n"; commentStr=commentStr+Constants.PORT_DEFAULT+"Port"+"\n";
if(StringUtil.isEmpty(defaultValue)){ if(StringUtil.isEmpty(defaultValue)){
defaultValue=Constants.PORT_DEFAULT; defaultValue=Constants.PORT_DEFAULT;
} }
index++; index++;
} }
if((","+destPortPattern+",").indexOf(",2,") > -1){ if((","+region.getConfigPortPattern()+",").indexOf(",2,") > -1){
commentStr=commentStr+Constants.PORT_MASK_DEFAULT+"Port/"+msgProp.getProperty("port_mask")+""+"\n\n"; commentStr=commentStr+Constants.PORT_MASK_DEFAULT+"Port/"+msgProp.getProperty("port_mask")+""+"\n\n";
if(StringUtil.isEmpty(defaultValue)){ if(StringUtil.isEmpty(defaultValue)){
defaultValue=Constants.PORT_MASK_DEFAULT; defaultValue=Constants.PORT_MASK_DEFAULT;
@@ -1358,11 +944,11 @@ public class ExportExcel {
index++; index++;
} }
//2、源端口、目的端口格式必须一致 //2、源端口、目的端口格式必须一致
// if(((","+region.getConfigIpPortShow()+",").indexOf(",2,") > -1) && ((","+region.getConfigIpPortShow()+",").indexOf(",4,") > -1)){ if(((","+region.getConfigIpPortShow()+",").indexOf(",2,") > -1) && ((","+region.getConfigIpPortShow()+",").indexOf(",4,") > -1)){
// commentStr=commentStr+"▶"+msgProp.getProperty("the_same_port_pattern")+"\n"; commentStr=commentStr+""+msgProp.getProperty("the_same_port_pattern")+"\n";
// index++; index++;
// index++; index++;
// } }
//3、端口和端口掩码范围0-65535 //3、端口和端口掩码范围0-65535
commentStr=commentStr+""+msgProp.getProperty("port_mask_comment_tip")+"\n"; commentStr=commentStr+""+msgProp.getProperty("port_mask_comment_tip")+"\n";
index++; index++;
@@ -1572,17 +1158,11 @@ public class ExportExcel {
headerStr=""; headerStr="";
commentStr=""; commentStr="";
}else{ }else{
if((region.getAction()!=null) && (region.getAction()==85 || region.getAction()==90)) { for (String districtStr : region.getConfigDistrict().split(",")) {
commentStr=commentStr+"Content-Type"+"\n"; commentStr=commentStr+districtStr+"\n";
index++; index++;
defaultValue="Content-Type";
}else {
for (String districtStr : region.getConfigDistrict().split(",")) {
commentStr=commentStr+districtStr+"\n";
index++;
}
defaultValue=region.getConfigDistrict().split(",")[0];
} }
defaultValue=region.getConfigDistrict().split(",")[0];
} }
if(StringUtil.isEmpty(commentStr)){ if(StringUtil.isEmpty(commentStr)){
headerStr=""; headerStr="";
@@ -1838,7 +1418,7 @@ public class ExportExcel {
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n"; commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++; index++;
//2、默认值说明 //2、默认值说明
if(region.getFunctionId().equals(200) || region.getFunctionId().equals(607)) { if(region.getFunctionId().equals(200)) {
commentStr=commentStr+""+msgProp.getProperty("default_value")+":1\n"; commentStr=commentStr+""+msgProp.getProperty("default_value")+":1\n";
}else { }else {
commentStr=commentStr+""+msgProp.getProperty("default_value")+":0\n"; commentStr=commentStr+""+msgProp.getProperty("default_value")+":0\n";
@@ -2719,38 +2299,15 @@ public class ExportExcel {
dict="block_drop"; dict="block_drop";
val = msgProp.getProperty(dict,dict); val = msgProp.getProperty(dict,dict);
} }
if ("action".equals(ef.title()) && dict.equals("action_reject")
&& (Reflections.invokeGetter(e, "service").toString().equals("35")
|| Reflections.invokeGetter(e, "service").toString().equals("33")
|| Reflections.invokeGetter(e, "service").toString().equals("36"))) {
dict="block_drop";
val = msgProp.getProperty(dict,dict);
}
//ip spoofing redirect动作修改为Spoofing //ip spoofing redirect动作修改为Spoofing
if(ef.title().equals("block_type") if(ef.title().equals("block_type")
&& (Reflections.invokeGetter(e, "serviceId").toString().equals("518"))) { && (Reflections.invokeGetter(e, "serviceId").toString().equals("518"))) {
dict="action_spoofing"; dict="action_spoofing";
val = msgProp.getProperty(dict,dict); val = msgProp.getProperty(dict,dict);
} }
//http(s) manipulate 导出action修改为Manipulate
if(ef.title().equals("block_type")
&& dict.equals("action_redirect")
&& (Reflections.invokeGetter(e, "serviceId").toString().equals("656"))) {
dict="action_manipulate";
val = msgProp.getProperty(dict,dict);
}
if(ef.title().equals("action")
&& dict.equals("action_redirect")) {
dict="action_manipulate";
val = msgProp.getProperty(dict,dict);
}
} }
} }
if(ef.title().equals("do_log")
&& (Reflections.invokeGetter(e, "serviceId").toString().equals("512"))) {
val = "";
}
if(ef.title().equals("whether_area_block")&&!StringUtil.isEmpty(val)){ if(ef.title().equals("whether_area_block")&&!StringUtil.isEmpty(val)){
Integer whetherAreaBlock=Integer.parseInt(valStr); Integer whetherAreaBlock=Integer.parseInt(valStr);
if(whetherAreaBlock.equals(0)){ if(whetherAreaBlock.equals(0)){
@@ -2801,7 +2358,7 @@ public class ExportExcel {
} }
} }
end=System.currentTimeMillis(); end=System.currentTimeMillis();
System.err.println("setDataList cost:"+(end-start)); log.info("setDataList cost:"+(end-start));
return this; return this;
} }
/** /**
@@ -2927,8 +2484,8 @@ public class ExportExcel {
/** /**
* 构造函数 * 构造函数
* @param msgProp 国际化配置 * @param msgProp 国际化配置
* @param titleList sheet名称 * @param title sheet名称
* @param clsMap 实体对象通过annotation.ExportField获取标题 * @param cls 实体对象通过annotation.ExportField获取标题
* @param type 导出类型1:导出数据2导出模板 * @param type 导出类型1:导出数据2导出模板
* @param groups 导入分组 * @param groups 导入分组
* @return * @return

View File

@@ -488,11 +488,11 @@ public class ImportBigExcel extends XLSXCovertCSVReader{
if (valType == String.class){ if (valType == String.class){
String s = String.valueOf(val.toString().trim()); String s = String.valueOf(val.toString().trim());
//0.0.0.0表示任意IP的含义 //0.0.0.0表示任意IP的含义
// if(StringUtils.endsWith(s, ".0") && !s.endsWith("0.0.0.0")){ if(StringUtils.endsWith(s, ".0") && !s.endsWith("0.0.0.0")){
// val = StringUtils.substringBefore(s, ".0"); val = StringUtils.substringBefore(s, ".0");
// }else{ }else{
val=val == null ? "" : StringEscapeUtils.escapeHtml4(val.toString().trim()); val=val == null ? "" : StringEscapeUtils.escapeHtml4(val.toString().trim());
// } }
}else if (valType == Integer.class){ }else if (valType == Integer.class){
val = Double.valueOf(val.toString().trim()).intValue(); val = Double.valueOf(val.toString().trim()).intValue();
}else if (valType == Long.class){ }else if (valType == Long.class){

View File

@@ -91,10 +91,6 @@ public class CheckComplexStringFormatThread implements Callable<String>{
throw new RuntimeException("Found String region,but mulityKeywords is Empty"); throw new RuntimeException("Found String region,but mulityKeywords is Empty");
} }
String dirtrictP = regionDict.getConfigDistrict(); String dirtrictP = regionDict.getConfigDistrict();
// 代理-操控业务hijack、insert
if("85".equals(regionDict.getAction()+"") || "90".equals(regionDict.getAction()+"")) {
dirtrictP = "Content-Type";
}
StringBuffer errTip = new StringBuffer(); StringBuffer errTip = new StringBuffer();
Pattern pattern = Pattern.compile("\t|\r|\n|\b|\f"); Pattern pattern = Pattern.compile("\t|\r|\n|\b|\f");
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
@@ -131,7 +127,7 @@ public class CheckComplexStringFormatThread implements Callable<String>{
} }
} }
// 代理HTTP(s)阻断 // 代理HTTP(s)阻断
if (regionDict.getFunctionId().equals(207) || "16".equals(regionDict.getAction()+"")) { if (regionDict.getFunctionId().equals(207)) {
if(StringUtils.isBlank(baseStringCfg.getUserRegion1())) { if(StringUtils.isBlank(baseStringCfg.getUserRegion1())) {
baseStringCfg.setUserRegion1("404"); baseStringCfg.setUserRegion1("404");
} }
@@ -157,7 +153,7 @@ public class CheckComplexStringFormatThread implements Callable<String>{
} }
// 代理 HTTP(s)重定向 // 代理 HTTP(s)重定向
if (regionDict.getFunctionId().equals(208) || "48".equals(regionDict.getAction()+"")) { if (regionDict.getFunctionId().equals(208)) {
if(StringUtils.isBlank(baseStringCfg.getUserRegion1())) { if(StringUtils.isBlank(baseStringCfg.getUserRegion1())) {
baseStringCfg.setUserRegion1("302"); baseStringCfg.setUserRegion1("302");
} }
@@ -192,7 +188,7 @@ public class CheckComplexStringFormatThread implements Callable<String>{
} }
} }
// 代理HTTP(s)替换 // 代理HTTP(s)替换
if (regionDict.getFunctionId().equals(209) || "80".equals(regionDict.getAction()+"")) { if (regionDict.getFunctionId().equals(209)) {
if(StringUtils.isBlank(baseStringCfg.getUserRegion1())) { if(StringUtils.isBlank(baseStringCfg.getUserRegion1())) {
baseStringCfg.setUserRegion1("http_resp_body"); baseStringCfg.setUserRegion1("http_resp_body");
} }

View File

@@ -1,9 +1,7 @@
package com.nis.util.excel.thread; package com.nis.util.excel.thread;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
@@ -21,17 +19,10 @@ import com.beust.jcommander.internal.Sets;
import com.nis.domain.FunctionRegionDict; import com.nis.domain.FunctionRegionDict;
import com.nis.domain.FunctionServiceDict; import com.nis.domain.FunctionServiceDict;
import com.nis.domain.SysDataDictionaryItem; import com.nis.domain.SysDataDictionaryItem;
import com.nis.domain.basics.CommonGroupInfo;
import com.nis.domain.basics.PolicyGroupInfo;
import com.nis.domain.callback.ProxyFileTrafficMirrorCfg;
import com.nis.domain.configuration.BaseStringCfg; import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.PxyObjKeyring; import com.nis.domain.configuration.IpPortCfg;
import com.nis.util.Constants; import com.nis.util.Constants;
import com.nis.util.DictUtils; import com.nis.util.DictUtils;
import com.nis.web.dao.configuration.ProxyFileTrafficMirrorDao;
import com.nis.web.dao.configuration.PxyObjKeyringDao;
import com.nis.web.service.BaseService;
import com.nis.web.service.SpringContextHolder;
public class CheckStringFormatThread implements Callable<String>{ public class CheckStringFormatThread implements Callable<String>{
private Logger logger=Logger.getLogger(CheckStringFormatThread.class); private Logger logger=Logger.getLogger(CheckStringFormatThread.class);
@@ -41,8 +32,6 @@ public class CheckStringFormatThread implements Callable<String>{
// private DnsResStrategyDao dnsResStrategyDao; // private DnsResStrategyDao dnsResStrategyDao;
private FunctionServiceDict serviceDict; private FunctionServiceDict serviceDict;
private FunctionRegionDict regionDict; private FunctionRegionDict regionDict;
private static PxyObjKeyringDao pxyObjKeyringDao = SpringContextHolder.getBean(PxyObjKeyringDao.class);
private static ProxyFileTrafficMirrorDao proxyFileDao = SpringContextHolder.getBean(ProxyFileTrafficMirrorDao.class);
public CheckStringFormatThread(FunctionServiceDict serviceDict,FunctionRegionDict regionDict,Properties prop,BlockingQueue<? extends Object> srcQueue,BlockingQueue<BaseStringCfg<?>> destQueue) { public CheckStringFormatThread(FunctionServiceDict serviceDict,FunctionRegionDict regionDict,Properties prop,BlockingQueue<? extends Object> srcQueue,BlockingQueue<BaseStringCfg<?>> destQueue) {
this.serviceDict=serviceDict; this.serviceDict=serviceDict;
this.regionDict=regionDict; this.regionDict=regionDict;
@@ -102,16 +91,6 @@ public class CheckStringFormatThread implements Callable<String>{
StringBuffer errTip = new StringBuffer(); StringBuffer errTip = new StringBuffer();
Pattern pattern = Pattern.compile("\t|\r|\n|\b|\f"); Pattern pattern = Pattern.compile("\t|\r|\n|\b|\f");
Pattern domainPattern = Pattern.compile("^[a-zA-Z0-9.-]*$"); Pattern domainPattern = Pattern.compile("^[a-zA-Z0-9.-]*$");
List<SysDataDictionaryItem> sslversions = new ArrayList<>();
List<SysDataDictionaryItem> failmethods = new ArrayList<>();
List<PxyObjKeyring> certificateList=new ArrayList<>();
List<ProxyFileTrafficMirrorCfg> mirrorProfileList=new ArrayList<>();
if(serviceDict!=null&&serviceDict.getServiceId().equals(512)) {
certificateList=pxyObjKeyringDao.findList(null,1,1,"ip");
sslversions=DictUtils.getDictList("SSL_VERSION");
failmethods=DictUtils.getDictList("FAIL_METHOD");
mirrorProfileList=proxyFileDao.findMirrorList(null, 1, 1);
}
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
StringBuffer errInfo = new StringBuffer(); StringBuffer errInfo = new StringBuffer();
BaseStringCfg baseStringCfg = new BaseStringCfg(); BaseStringCfg baseStringCfg = new BaseStringCfg();
@@ -125,20 +104,14 @@ public class CheckStringFormatThread implements Callable<String>{
errInfo.append(prop.getProperty("config_describe")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("max_length")+":128") + ";"); errInfo.append(prop.getProperty("config_describe")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("max_length")+":128") + ";");
} }
if(regionDict.getFunctionId().equals(606) || regionDict.getFunctionId().equals(607) || regionDict.getFunctionId().equals(608)) {
if(StringUtils.isBlank(baseStringCfg.getGroupName())) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("group_name")) + ";");
}
}
if(regionDict.getFunctionId().equals(200)) { if(regionDict.getFunctionId().equals(200)) {
if(!serviceDict.getAction().equals(2)) { if(!serviceDict.getAction().equals(1)) {
baseStringCfg.setDoLog(0); baseStringCfg.setDoLog(0);
} }
} }
// doLog属性检验 // doLog属性检验
this.validDoLog(baseStringCfg,errInfo); this.validDoLog(baseStringCfg,errInfo);
if (regionDict.getRegionType().equals(2)) { if (regionDict.getRegionType().equals(2)) {
if (regionDict.getFunctionId().equals(510) && "p2p_hash".equals(regionDict.getConfigServiceType())) { if (regionDict.getFunctionId().equals(510) && "p2p_hash".equals(regionDict.getConfigServiceType())) {
String userRegion1 = baseStringCfg.getUserRegion1(); String userRegion1 = baseStringCfg.getUserRegion1();
@@ -159,7 +132,7 @@ public class CheckStringFormatThread implements Callable<String>{
} }
// 代理-域名拦截 // 代理-域名拦截
if (regionDict.getFunctionId().equals(200) && "intercept_domain".equals(regionDict.getConfigServiceType())) { if (regionDict.getFunctionId().equals(200) && "intercept_domain".equals(regionDict.getConfigServiceType())) {
/*if(serviceDict.getAction().equals(1)) { if(serviceDict.getAction().equals(1)) {
if(StringUtils.isBlank(baseStringCfg.getUserRegion5())) { if(StringUtils.isBlank(baseStringCfg.getUserRegion5())) {
baseStringCfg.setUserRegion5("1"); baseStringCfg.setUserRegion5("1");
} }
@@ -179,7 +152,7 @@ public class CheckStringFormatThread implements Callable<String>{
} }
} }
}else*/ if(serviceDict.getAction().equals(64)) { }else if(serviceDict.getAction().equals(64)) {
baseStringCfg.setUserRegion1("0");// limit_rate_type限速方式默认值 baseStringCfg.setUserRegion1("0");// limit_rate_type限速方式默认值
if(StringUtils.isBlank(baseStringCfg.getUserRegion2())) { if(StringUtils.isBlank(baseStringCfg.getUserRegion2())) {
baseStringCfg.setUserRegion2("0.1"); baseStringCfg.setUserRegion2("0.1");
@@ -204,7 +177,7 @@ public class CheckStringFormatThread implements Callable<String>{
} }
// 代理HTTP(s)阻断 // 代理HTTP(s)阻断
if (regionDict.getFunctionId().equals(207) || "16".equals(regionDict.getAction()+"")) { if (regionDict.getFunctionId().equals(207)) {
if(StringUtils.isBlank(baseStringCfg.getUserRegion1())) { if(StringUtils.isBlank(baseStringCfg.getUserRegion1())) {
baseStringCfg.setUserRegion1("404"); baseStringCfg.setUserRegion1("404");
} }
@@ -230,7 +203,7 @@ public class CheckStringFormatThread implements Callable<String>{
} }
// 代理 HTTP(s)重定向 // 代理 HTTP(s)重定向
if (regionDict.getFunctionId().equals(208) || "48".equals(regionDict.getAction()+"")) { if (regionDict.getFunctionId().equals(208)) {
if(StringUtils.isBlank(baseStringCfg.getUserRegion1())) { if(StringUtils.isBlank(baseStringCfg.getUserRegion1())) {
baseStringCfg.setUserRegion1("302"); baseStringCfg.setUserRegion1("302");
} }
@@ -265,7 +238,7 @@ public class CheckStringFormatThread implements Callable<String>{
} }
} }
// 代理HTTP(s)替换 // 代理HTTP(s)替换
if (regionDict.getFunctionId().equals(209) || "80".equals(regionDict.getAction()+"")) { if (regionDict.getFunctionId().equals(209)) {
if(StringUtils.isBlank(baseStringCfg.getUserRegion1())) { if(StringUtils.isBlank(baseStringCfg.getUserRegion1())) {
baseStringCfg.setUserRegion1("http_resp_body"); baseStringCfg.setUserRegion1("http_resp_body");
} }
@@ -304,7 +277,7 @@ public class CheckStringFormatThread implements Callable<String>{
} }
String keyword = baseStringCfg.getCfgKeywords(); String keyword = baseStringCfg.getCfgKeywords();
if (!regionDict.getFunctionId().equals(403) && !regionDict.getFunctionId().equals(200) && !regionDict.getFunctionId().equals(607)) {// 201域名拦截 if (!regionDict.getFunctionId().equals(403) && !regionDict.getFunctionId().equals(200)) {// 201域名拦截
if (StringUtils.isBlank(keyword)) { if (StringUtils.isBlank(keyword)) {
errInfo.append( errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("key_word") + " ") + ";"); String.format(prop.getProperty("can_not_null"), prop.getProperty("key_word") + " ") + ";");
@@ -521,252 +494,6 @@ public class CheckStringFormatThread implements Callable<String>{
} }
} }
if(serviceDict!=null&&serviceDict.getServiceId().equals(512)) {
Integer kering=baseStringCfg.getKeyring();
Integer evCet=baseStringCfg.getEvCert();
Integer certTransparency=baseStringCfg.getCertTransparency();
Integer clientCertReq=baseStringCfg.getClientCertReq();
Integer pinning=baseStringCfg.getPinning();
Integer protocolErrors=baseStringCfg.getProtocolErrors();
Integer cn=baseStringCfg.getCn();
Integer issuer=baseStringCfg.getIssuer();
Integer selfSigned=baseStringCfg.getSelfSigned();
Integer expiration=baseStringCfg.getExpiration();
String failMethod=baseStringCfg.getFailMethod();
String min=baseStringCfg.getMin();
String max=baseStringCfg.getMax();
Integer mirrorClient=baseStringCfg.getMirrorClient();
Integer allowHttp2=baseStringCfg.getAllowHttp2();
Integer enable=baseStringCfg.getEnable();
Integer mirrorProfile=baseStringCfg.getMirrorProfile();
Map<String,Object> userRegionMap=new HashMap<>();
Map<String,Object> map=new HashMap<>();
if(kering!=null) {
boolean has=false;
for(PxyObjKeyring keyring:certificateList) {
if(keyring.getCompileId().toString().equals(kering.toString())) {
has=true;
break;
}
}
if(has) {
userRegionMap.put("keyring", kering);
}else {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("pxy_intercept_monit_keyring") + " ") + ";");
}
}else {
userRegionMap.put("keyring", 1);
}
if(evCet!=null) {
if(evCet!=0&&evCet!=1) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("exclusions_ev_cert","exclusions ev cert") + " ") + ";");
}else {
map.put("ev_cert", evCet);
}
}else {
map.put("ev_cert", 0);
}
if(certTransparency!=null) {
if(certTransparency!=0&&certTransparency!=1) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("exclusions_cert_transparency","exclusions cert transparency") + " ") + ";");
}else {
map.put("cert_transparency", certTransparency);
}
}else {
map.put("cert_transparency", 0);
}
if(clientCertReq!=null) {
if(clientCertReq!=0&&clientCertReq!=1) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("exclusions_client_cert_req","exclusions client cert req") + " ") + ";");
}else {
map.put("client_cert_req", clientCertReq);
}
}else {
map.put("client_cert_req", 1);
}
if(pinning!=null) {
if(pinning!=0&&pinning!=1) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("exclusions_pinning","exclusions pinning") + " ") + ";");
}else {
map.put("pinning", pinning);
}
}else {
map.put("pinning", 1);
}
if(protocolErrors!=null) {
if(protocolErrors!=0&&protocolErrors!=1) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("exclusions_protocol_errors","exclusions protocol errors") + " ") + ";");
}else {
map.put("protocol_errors", protocolErrors);
}
}else {
map.put("protocol_errors", 1);
}
userRegionMap.put("exclusions", map);
map=new HashMap<>();
Map<String,Object> map1=new HashMap<>();
if(cn!=null) {
if(cn!=0&&cn!=1) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("cert_verify_approach_cn","cert verify approach cn") + " ") + ";");
}else {
map1.put("cn", cn);
}
}else {
map1.put("cn", 1);
}
if(issuer!=null) {
if(issuer!=0&&issuer!=1) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("cert_verify_approach_issuer","cert verify approach issuer") + " ") + ";");
}else {
map1.put("issuer", issuer);
}
}else {
map1.put("issuer", 1);
}
if(selfSigned!=null) {
if(selfSigned!=0&&selfSigned!=1) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("cert_verify_approach_self_signed","cert verify approach self signed") + " ") + ";");
}else {
map1.put("self-signed", selfSigned);
}
}else {
map1.put("self-signed", 1);
}
if(expiration!=null) {
if(expiration!=0&&expiration!=1) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("cert_verify_approach_expiration","cert verify approach expiration") + " ") + ";");
}else {
map1.put("expiration", expiration);
}
}else {
map1.put("expiration", 1);
}
map.put("approach", map1);
if(StringUtils.isBlank(failMethod)) {
map.put("fail_method", "pass-through");
}else {
boolean has=false;
for(SysDataDictionaryItem fail: failmethods) {
if(fail.getItemCode().equals(failMethod)) {
has=true;
break;
}
}
if(!has) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("cert_verify_fail_method","cert verify fail method") + " ") + ";");
}
map.put("fail_method", failMethod);
}
userRegionMap.put("cert_verify", map);
map=new HashMap<>();
if(mirrorClient==null) {
mirrorClient=1;
map.put("mirror_client", 1);
}else {
if(mirrorClient!=0&&mirrorClient!=1) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("ssl_ver_mirror_client","SSL version mirror client") + " ") + ";");
}else {
map.put("mirror_client", mirrorClient);
}
}
if(allowHttp2==null) {
allowHttp2=1;
map.put("allow_http2", allowHttp2);
}else {
if(allowHttp2!=0&&allowHttp2!=1) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("ssl_ver_allow_http2","SSL version allow http2") + " ") + ";");
}else {
map.put("allow_http2", allowHttp2);
}
}
if(mirrorClient==0) {
int minSort=0,maxSort=0;
if(StringUtils.isBlank(min)) {
min="ssl3";
}
if(StringUtils.isBlank(max)) {
max="tls13";
}
for(SysDataDictionaryItem sslversion: sslversions) {
if(sslversion.getItemCode().equals(min)) {
minSort=sslversion.getItemSort();
}
if(sslversion.getItemCode().equals(max)) {
maxSort=sslversion.getItemSort();
}
}
if(minSort==0) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("ssl_ver_min","min SSL version") + " ") + ";");
}
if(maxSort==0) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("ssl_ver_max","max SSL version") + " ") + ";");
}
if(minSort>maxSort) {
errInfo.append(prop.getProperty("min_should_less_than_max","the min SSL version should less than the max SSL version") + ";");
}
map.put("min", min);
map.put("max", max);
}
userRegionMap.put("ssl_ver", map);
map=new HashMap<>();
if(enable==null) {
enable=0;
map.put("enable", 0);
}else {
if(enable!=0&&enable!=1) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("decrypt_mirror_enable","decrypt mirror enable") + " ") + ";");
}else {
map.put("enable", enable);
}
}
//enable==1的时候才设置mirror_profile
if(enable==1) {
if(mirrorProfile==null) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("decrypt_mirror_mirror_profile") + " ") + ";");
}else {
boolean has=false;
for(ProxyFileTrafficMirrorCfg _mirrorProfile:mirrorProfileList) {
if(_mirrorProfile.getCompileId().toString().equals(mirrorProfile.toString())) {
has=true;
break;
}
}
if(has) {
map.put("mirror_profile", mirrorProfile);
}else {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("decrypt_mirror_mirror_profile") + " ") + ";");
}
map.put("mirror_profile", mirrorProfile);
}
}
userRegionMap.put("decrypt_mirror", map);
baseStringCfg.setUserRegion1(BaseService.gsonToJson(userRegionMap));
}
if (errInfo.toString().length() > 0) {// if (errInfo.toString().length() > 0) {//
errTip.append(String.format(prop.getProperty("line"), baseStringCfg.getIndex()) + ","); errTip.append(String.format(prop.getProperty("line"), baseStringCfg.getIndex()) + ",");
errTip.append(errInfo); errTip.append(errInfo);

View File

@@ -86,10 +86,7 @@ public class HttpClientUtil {
throw new ConnectException("流量统计服务接口连接错误"+response); throw new ConnectException("流量统计服务接口连接错误"+response);
} }
} catch (Exception e) { } catch (Exception e) {
// e.printStackTrace(); throw e;
logger.error("获取消息失败,相应内容如下: " + response);
logger.error("获取消息失败 ", e);
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:");
}finally { }finally {
if (response != null) { if (response != null) {
try { try {

File diff suppressed because it is too large Load Diff

View File

@@ -209,6 +209,8 @@ public class SystemController extends BaseController{
public boolean clearPolicies(HttpServletRequest request, HttpServletResponse response) { public boolean clearPolicies(HttpServletRequest request, HttpServletResponse response) {
try { try {
systemService.clearPolicies(); systemService.clearPolicies();
/*ArrayList<Object> list = Lists.newArrayList();
System.out.println(list.get(6));*/
return true; return true;
} catch (Exception e) { } catch (Exception e) {
logger.error("Clear Policies Error",e); logger.error("Clear Policies Error",e);

View File

@@ -1,158 +0,0 @@
package com.nis.web.controller.basics;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.nis.domain.Page;
import com.nis.domain.basics.CommonGroupInfo;
import com.nis.util.Constants;
import com.nis.util.LogUtils;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.service.basics.CommonGroupManageService;
/**
* 公共组管理
*/
@Controller
@RequestMapping(value = "${adminPath}/basics/commonGroup")
public class CommonGroupManageController extends BaseController {
@Autowired
private CommonGroupManageService commonGroupManageService;
@RequestMapping(value = {"list"})
public String policyGroupList(CommonGroupInfo cfg, Model model, HttpServletRequest request, HttpServletResponse response) {
if(cfg == null)cfg=new CommonGroupInfo();
Page<CommonGroupInfo> pageCondition = new Page<CommonGroupInfo>(request, response,"r");
Page page = commonGroupManageService.findCommonGroupInfoList(pageCondition,cfg);
model.addAttribute("cfg", cfg);
model.addAttribute("page", page);
return "/basics/commonGroupList";
}
@RequestMapping(value={"/form"})
public String form(Integer groupType,String ids,Model model,String doAction,RedirectAttributes redirectAttributes) {
CommonGroupInfo groupInfo = new CommonGroupInfo();
if(!StringUtil.isEmpty(ids)){
groupInfo = commonGroupManageService.getById(Integer.parseInt(ids));
}
//groupInfo.setGroupType(groupType);
model.addAttribute("_cfg", groupInfo);
return "/basics/commonGroupForm";
}
@RequestMapping(value = "saveOrUpdate")
public String saveOrUpdate(CommonGroupInfo cfg, Model model, RedirectAttributes redirectAttributes,
String itType,Integer groupType,HttpServletRequest request) {
try {
commonGroupManageService.saveOrUpdate(cfg);
addMessage(redirectAttributes,"success","save_success");
} catch (Exception e) {
logger.error("新增失败",e);
addMessage(redirectAttributes,"error","save_failed");
LogUtils.saveLog(request, null, e, null);
}
return "redirect:" + adminPath + "/basics/commonGroup/list";
}
@RequestMapping(value={"delete"})
public String delete(RedirectAttributes redirectAttributes, String groupTypes, String ids, int isValid,HttpServletRequest request) {
try {
commonGroupManageService.deldete(ids, isValid, groupTypes);
addMessage(redirectAttributes,"success","delete_success");
} catch (Exception e) {
logger.error("删除失败",e);
addMessage(redirectAttributes,"error","delete_failed");
LogUtils.saveLog(request, null, e, null);
}
return "redirect:" + adminPath + "/basics/commonGroup/list";
}
@ResponseBody
@RequestMapping(value="ajaxCheckIsLastOneCfg",method=RequestMethod.POST)
public List<Integer> ajaxCheckIsLastOneCfg(Model model, String grouIdAndCfgId, Integer groupType){
return commonGroupManageService.ajaxCheckIsLastOneCfg(grouIdAndCfgId, groupType);
}
@ResponseBody
@RequestMapping(value="ajaxGetGroupInfoByType",method=RequestMethod.GET)
public List<CommonGroupInfo> ajaxGetGroupInfoByType(Integer groupType){
return commonGroupManageService.findCommonGroupInfosByType(groupType);
}
// 数据导出
@RequestMapping(value = "exportGroup")
public void exportGroup(Model model,@ModelAttribute("cfg")CommonGroupInfo entity,String ids,RedirectAttributes redirectAttributes,
HttpServletRequest request,HttpServletResponse response){
try {
entity.setMenuNameCode("common_group_manage");
List<String> titleList=new ArrayList<String>();
Map<String, Class<?>> classMap=new HashMap<String, Class<?>>();
Map<String, List> dataMap=new HashMap<String, List>();
Map<String, String> noExportMap=new HashMap<String, String>();
List<CommonGroupInfo> list = new ArrayList<CommonGroupInfo>();
if (!StringUtil.isEmpty(ids)) {
list = commonGroupManageService.findGroupInfoList(ids);
} else {
Page<CommonGroupInfo> pageInfo=new Page<CommonGroupInfo>(request, response,"r");
pageInfo.setPageNo(1);
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
Page page = commonGroupManageService.findCommonGroupInfoList(pageInfo,entity);
list=page.getList();
}
titleList.add(entity.getMenuNameCode());
classMap.put(entity.getMenuNameCode(), CommonGroupInfo.class);
String cfgIndexInfoNoExport=",config_describe,cfg_id,block_type,do_log,action,valid_identifier,is_audit"
+ ",auditor,audit_time,letter,whether_area_block,classification,attribute,label"
+",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,";
// 时间过滤
if (entity.getSearch_create_time_start() == null ) {
cfgIndexInfoNoExport = ",config_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_edit_time_start() == null) {
cfgIndexInfoNoExport = ",edit_time" + cfgIndexInfoNoExport;
}
if (!StringUtil.isEmpty(entity.gethColumns())) {
cfgIndexInfoNoExport = "," + entity.gethColumns() + "," + cfgIndexInfoNoExport;
}
noExportMap.put(entity.getMenuNameCode(),cfgIndexInfoNoExport);
dataMap.put(entity.getMenuNameCode(), list);
String timeRange = initTimeMap(entity);
noExportMap.put("timeRange", timeRange);
if ("csv".equals(entity.getExType())) {
this._exportCsv(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
}
} catch (Exception e) {
logger.error("Group export failed",e);
addMessage(redirectAttributes,"error","export_failed");
LogUtils.saveLog(request, null, e, null);
}
}
}

View File

@@ -1,318 +0,0 @@
package com.nis.web.controller.basics;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jets3t.service.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.beust.jcommander.internal.Lists;
import com.nis.domain.FunctionRegionDict;
import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page;
import com.nis.domain.basics.CommonGroupInfo;
import com.nis.domain.basics.DomainCommCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.template.DomainCommCfgTemplate;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.ConfigServiceUtil;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.StringUtil;
import com.nis.util.excel.ImportBigExcel;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
import com.nis.web.service.basics.DomainCommGroupService;
@Controller
@RequestMapping(value = "${adminPath}/basics/domain")
public class DomainCommGroupController extends BaseController{
@Autowired
private DomainCommGroupService domainCommGroupService;
@RequestMapping(value = {"/list"})
public String list(Model model, @ModelAttribute("cfg")DomainCommCfg entity, HttpServletRequest request,HttpServletResponse response){
Page<DomainCommCfg> page = domainCommGroupService.findPage(new Page<DomainCommCfg>(request, response,"r"), entity);
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(entity.getFunctionId());
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(entity.getFunctionId());
List<CommonGroupInfo> groupInfos = commonGroupManageService.findCommonGroupInfosByType(Constants.DOMAIN_OBJ_GROUP_TYPE);
model.addAttribute("page", page);
model.addAttribute("regionList", regionList);
model.addAttribute("serviceList", serviceList);
model.addAttribute("policyGroupInfos", groupInfos);
return "/basics/domainCommGroupList";
}
@RequestMapping(value = {"/addForm"})
public String addForm(Model model, @ModelAttribute("cfg")CfgIndexInfo cfg, RedirectAttributes redirectAttributes,
HttpServletRequest request, HttpServletResponse response){
initFormCondition(model,cfg);
/* List<CommonGroupInfo> groupInfos=commonGroupManageService.findCommonGroupInfosByType(Constants.DOMAIN_OBJ_GROUP_TYPE);
model.addAttribute("policyGroupInfos", groupInfos);*/
model.addAttribute("_cfg", cfg);
return "/basics/domainCommGroupFormAdd";
}
@RequestMapping(value = {"/save"})
public String save(Model model, @ModelAttribute("cfg")CfgIndexInfo cfg,RedirectAttributes redirectAttributes,
HttpServletRequest request,HttpServletResponse response){
try{
domainCommGroupService.saveCommGroupCfg(cfg);
addMessage(redirectAttributes,"success","save_success");
}catch(Exception e){
logger.error("信息保存失败",e);
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error",e.getMessage());
}else {
addMessage(redirectAttributes,"error","save_failed");
}
}
return "redirect:" + adminPath +"/basics/domain/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"/updateForm"})
public String updateForm(Model model,HttpServletRequest request
,HttpServletResponse response,String ids,@ModelAttribute("cfg")DomainCommCfg cfg
,RedirectAttributes redirectAttributes){
cfg = domainCommGroupService.get(Long.parseLong(ids));
initUpdateFormCondition(model,cfg);
List<CommonGroupInfo> groupInfos=commonGroupManageService.findCommonGroupInfosByType(Constants.DOMAIN_OBJ_GROUP_TYPE);
model.addAttribute("policyGroupInfos", groupInfos);
model.addAttribute("_cfg", cfg);
return "/basics/domainCommGroupFormUpdate";
}
@RequestMapping(value = {"/update"})
public String update(Model model,HttpServletRequest request,HttpServletResponse response,@ModelAttribute("cfg")DomainCommCfg cfg,RedirectAttributes redirectAttributes){
try{
domainCommGroupService.update(cfg);
addMessage(redirectAttributes,"success","save_success");
}catch(Exception e){
logger.error("信息保存失败",e);
addMessage(redirectAttributes,"error","save_failed");
}
return "redirect:" + adminPath +"/basics/domain/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"/delete"})
public String delete(String groupIds, String ids, Integer functionId, RedirectAttributes redirectAttributes,
HttpServletRequest request, HttpServletResponse response, @ModelAttribute("cfg")DomainCommCfg cfg){
try{
domainCommGroupService.delete(ids, groupIds, cfg, request, response);
addMessage(redirectAttributes,"success","delete_success");
}catch(Exception e){
logger.error("Delete failed",e);
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error",e.getMessage());
}else {
addMessage(redirectAttributes,"error","delete_failed");
}
}
return "redirect:" + adminPath +"/basics/domain/list?functionId="+functionId;
}
// 批量删除前获取提示信息
@ResponseBody
@RequestMapping(value="ajaxCheckIsLastOneCfgBatch",method=RequestMethod.POST)
public List<Integer> ajaxCheckIsLastOneCfgBatch(Model model, DomainCommCfg searchCfg){
return domainCommGroupService.ajaxCheckIsLastOneCfgBatch(searchCfg);
}
// 数据导入
@RequestMapping(value = "import", method=RequestMethod.POST)
public String importIp(HttpServletRequest request,HttpServletResponse response,RedirectAttributes redirectAttributes,
@RequestParam("files") MultipartFile[] files, Integer serviceDictId ,Integer requestId ,String attribute ,String classify
,String regionDictIds ,String importPath) {
logger.warn("import start...");
long start=System.currentTimeMillis();
ImportBigExcel ei=null;
try {
FunctionServiceDict serviceDict = DictUtils.getFunctionServiceDict(serviceDictId);
StringBuffer errTip=new StringBuffer();
BlockingQueue<BaseStringCfg<?>> stringCfgs =null;
for (int i = 0; i < files.length; i++) {
MultipartFile file = files[i];
ei = new ImportBigExcel(file, 0, 1);
FunctionRegionDict regionDict = DictUtils.getFunctionRegionDict(Integer.parseInt(regionDictIds.split(",")[i]));
//加载模板
loadTemplate(ei,regionDict, serviceDict);
//------------------------------------check format start----------------------------
if (regionDict.getRegionType().equals(2)) {
BlockingQueue<DomainCommCfgTemplate> list = ei.getDataList(DomainCommCfgTemplate.class );
stringCfgs = this.checkStringCfgMulity(errTip, serviceDict, regionDict, list);
}
//删除文件
if(ei.getUploadFile()!=null&&ei.getUploadFile().exists()) {
ei.getUploadFile().delete();
}
//------------------------------------check format end----------------------------
Date date = new Date();
//String isSend = request.getParameter("isSend")==null?"":request.getParameter("isSend");
if (regionDict.getRegionType().equals(2)) {
List<BaseStringCfg<?>> _stringCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
while(!stringCfgs.isEmpty()) {
stringCfgs.drainTo(_stringCfgs, Constants.MAAT_JSON_SEND_SIZE);
List<Integer> regionIds = Lists.newArrayList(_stringCfgs.size());
try {
regionIds = ConfigServiceUtil.getId(3,_stringCfgs.size());
} catch (Exception e) {
logger.error("获取域ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
int index = 0;
Set<String> countSet = new HashSet<String>();
for (BaseStringCfg<?> cfg : _stringCfgs) {
cfg.setAction(serviceDict==null?null:serviceDict.getAction());
cfg.setCfgRegionCode(regionDict.getConfigRegionCode());
cfg.setCfgType(regionDict.getConfigRegionValue());
cfg.setCreateTime(date);
cfg.setCreatorId(UserUtils.getUser().getId());
//cfg.setDoLog(2);
cfg.setCompileId(0);
cfg.setFunctionId(regionDict.getFunctionId());
cfg.setIsAudit(Constants.AUDIT_NOT_YET);
cfg.setIsValid(Constants.VALID_NO);
cfg.setIsAreaEffective(0);
cfg.setLable("0");
cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId);
cfg.setAttribute(attribute);
cfg.setClassify(classify);
cfg.setServiceId(serviceDict==null?null:serviceDict.getServiceId());
cfg.setTableName("domain_comm_cfg");
cfg.setRegionId(regionIds.get(index));
cfg.setGroupName(cfg.getGroupName().toUpperCase());
countSet.add(cfg.getGroupName());
index++;
}
List<CommonGroupInfo> insertGroupList = new ArrayList<CommonGroupInfo>();
Map<String, Integer> groupIdMap = commonGroupManageService.getCountByGroupName(countSet, insertGroupList, Constants.DOMAIN_OBJ_GROUP_TYPE); // 调用服务接口获取GroupId
domainCommGroupService.saveAndSend(regionDict, serviceDict, _stringCfgs, groupIdMap, insertGroupList);
_stringCfgs.clear();
}
}
}
if(errTip.toString().length()>0) {
addMessage(redirectAttributes,"error", errTip.toString());
}
} catch (Exception e) {
if(ei!=null) {
if(ei.getUploadFile().exists()) {
ei.getUploadFile().delete();
}
}
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error", "request_service_failed");
}else if(e instanceof ServiceException) {
addMessage(redirectAttributes,"error", e.getMessage());
}else if(e instanceof IndexOutOfBoundsException){
addMessage(redirectAttributes,"error", "template_error");
}else {
addMessage(redirectAttributes,"error", "import_failed");
}
logger.error("import failed", e);
}
long end=System.currentTimeMillis();
logger.warn("import finish,cost:"+(end-start));
return "redirect:" + adminPath+ importPath;
}
// 数据导出
@RequestMapping(value = "/exportGroupInfo")
public void exportGroupInfo(Model model,HttpServletRequest request,HttpServletResponse response,
@ModelAttribute("cfg")DomainCommCfg entity,String ids,RedirectAttributes redirectAttributes){
try {
List<String> titleList=new ArrayList<String>();
Map<String, Class<?>> classMap=new HashMap<String, Class<?>>();
Map<String, List> dataMap=new HashMap<String, List>();
Map<String, String> noExportMap=new HashMap<String, String>();
List<DomainCommCfg> list = new ArrayList<DomainCommCfg>();
if (!StringUtil.isEmpty(ids)) {
list = domainCommGroupService.findByPage(ids);
} else {
Page<DomainCommCfg> pageInfo=new Page<DomainCommCfg>(request, response,"r");
pageInfo.setPageNo(1);
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
Page<DomainCommCfg> page = domainCommGroupService.findPage(pageInfo, entity);
list=page.getList();
}
CommonGroupInfo groupInfo = new CommonGroupInfo();
for (DomainCommCfg cfg : list) {
groupInfo.setServiceGroupId(cfg.getGroupId());
CommonGroupInfo commonGroupInfo = commonGroupManageService.getGroupInfo(groupInfo);
cfg.setGroupName(commonGroupInfo.getGroupName());
}
titleList.add(entity.getMenuNameCode());
classMap.put(entity.getMenuNameCode(), DomainCommCfg.class);
String cfgIndexInfoNoExport=",block_type,do_log,action,letter,whether_area_block,classification,attribute,label"
+ ",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,asn_no,"
+ "is_hex,is_case_insenstive,cfg_id,is_audit,auditor,valid_identifier,";
// 时间过滤
if (entity.getSearch_create_time_start() == null ) {
cfgIndexInfoNoExport = ",config_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_edit_time_start() == null) {
cfgIndexInfoNoExport = ",edit_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_audit_time_start() == null) {
cfgIndexInfoNoExport = ",audit_time" + cfgIndexInfoNoExport;
}
if (!StringUtil.isEmpty(entity.gethColumns())) {
cfgIndexInfoNoExport = "," + entity.gethColumns() + "," + cfgIndexInfoNoExport;
}
noExportMap.put(entity.getMenuNameCode(),cfgIndexInfoNoExport);
dataMap.put(entity.getMenuNameCode(), list);
String timeRange = initTimeMap(entity);
noExportMap.put("timeRange", timeRange);
if ("csv".equals(entity.getExType())) {
this._exportCsv(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
}
} catch (Exception e) {
logger.error("domainGroupConfig export failed",e);
addMessage(redirectAttributes,"error","export_failed");
}
}
}

View File

@@ -1,326 +0,0 @@
package com.nis.web.controller.basics;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jets3t.service.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.beust.jcommander.internal.Lists;
import com.nis.domain.FunctionRegionDict;
import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page;
import com.nis.domain.basics.CommonGroupInfo;
import com.nis.domain.basics.IpCommCfg;
import com.nis.domain.configuration.BaseIpCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.template.IpCommCfgTemplate;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.ConfigServiceUtil;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.StringUtil;
import com.nis.util.excel.ImportBigExcel;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
import com.nis.web.service.basics.IpCommGroupCfgService;
@Controller
@RequestMapping(value = "${adminPath}/basics/ip")
public class IpCommGroupController extends BaseController {
@Autowired
private IpCommGroupCfgService ipCommGroupCfgService;
@RequestMapping(value = { "/list" })
public String list(Model model, @ModelAttribute("cfg") IpCommCfg entity, HttpServletRequest request, HttpServletResponse response) {
Page<IpCommCfg> page = ipCommGroupCfgService.findPage(new Page<IpCommCfg>(request, response, "r"),entity);
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(entity.getFunctionId());
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(entity.getFunctionId());
List<CommonGroupInfo> policyGroupInfos=commonGroupManageService.findCommonGroupInfosByType(Constants.IP_OBJ_GROUP_TYPE);
model.addAttribute("page", page);
model.addAttribute("regionList", regionList);
model.addAttribute("serviceList", serviceList);
model.addAttribute("policyGroupInfos", policyGroupInfos);
return "/basics/ipCommonGroupCfgList";
}
@RequestMapping(value = { "/addForm" })
public String addForm(Model model, @ModelAttribute("cfg") CfgIndexInfo cfg, RedirectAttributes redirectAttributes,
HttpServletRequest request, HttpServletResponse response) {
cfg.setGroupType(5);
initFormCondition(model, cfg);
/*List<CommonGroupInfo> groupInfos=commonGroupManageService.findCommonGroupInfosByType(5);
model.addAttribute("policyGroupInfos", groupInfos);*/
model.addAttribute("_cfg", cfg);
return "/basics/ipCommGroupFormAdd";
}
@RequestMapping(value = { "/save" })
@RequiresPermissions(value = { "ip:common:config" })
public String save(Model model, @ModelAttribute("cfg") CfgIndexInfo cfg, RedirectAttributes redirectAttributes,
HttpServletRequest request, HttpServletResponse response) {
try {
ipCommGroupCfgService.saveIpCommGroupCfg(cfg);
addMessage(redirectAttributes, "success", "save_success");
} catch (Exception e) {
logger.error("信息保存失败", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", e.getMessage());
} else {
addMessage(redirectAttributes, "error", "save_failed");
}
}
return "redirect:" + adminPath + "/basics/ip/list?functionId=" + cfg.getFunctionId();
}
@RequestMapping(value = { "/updateForm" })
public String updateForm(Model model, @ModelAttribute("cfg") IpCommCfg cfg, RedirectAttributes redirectAttributes, String ids,
HttpServletRequest request, HttpServletResponse response) {
cfg = ipCommGroupCfgService.get(Long.parseLong(ids));
cfg.setGroupType(5);
initUpdateFormCondition(model, cfg);
List<CommonGroupInfo> groupInfos = commonGroupManageService.findCommonGroupInfosByType(Constants.IP_OBJ_GROUP_TYPE);
model.addAttribute("policyGroupInfos", groupInfos);
model.addAttribute("_cfg", cfg);
return "/basics/ipCommGroupFormUpdate";
}
@RequestMapping(value = { "/update" })
@RequiresPermissions(value = { "ip:common:config" })
public String update(Model model, @ModelAttribute("cfg") IpCommCfg cfg, RedirectAttributes redirectAttributes,
HttpServletRequest request, HttpServletResponse response) {
try {
ipCommGroupCfgService.update(cfg);
addMessage(redirectAttributes, "success", "save_success");
} catch (Exception e) {
logger.error("信息保存失败", e);
addMessage(redirectAttributes, "error", "save_failed");
}
return "redirect:" + adminPath + "/basics/ip/list?functionId=" + cfg.getFunctionId();
}
@RequestMapping(value = { "/delete" })
@RequiresPermissions(value = { "ip:common:config" })
public String delete(String groupIds, String ids, Integer functionId, RedirectAttributes redirectAttributes,
HttpServletRequest request, HttpServletResponse response, @ModelAttribute("cfg")IpCommCfg cfg) {
try {
ipCommGroupCfgService.delete(ids, groupIds, cfg, request, response);
addMessage(redirectAttributes, "success", "delete_success");
} catch (Exception e) {
logger.error("Delete failed", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", e.getMessage());
} else {
addMessage(redirectAttributes, "error", "delete_failed");
}
}
return "redirect:" + adminPath + "/basics/ip/list?functionId=" + functionId;
}
// 批量删除前获取提示信息
@ResponseBody
@RequestMapping(value="ajaxCheckIsLastOneCfgBatch",method=RequestMethod.POST)
public List<Integer> ajaxCheckIsLastOneCfgBatch(Model model, IpCommCfg searchCfg){
return ipCommGroupCfgService.ajaxCheckIsLastOneCfgBatch(searchCfg);
}
// 数据导出
@RequestMapping(value = "/exportIpComm")
public void exportIpCommonCfg(Model model, @ModelAttribute("cfg") IpCommCfg entity, String ids, RedirectAttributes redirectAttributes,
HttpServletRequest request, HttpServletResponse response) {
try {
List<String> titleList = new ArrayList<String>();
Map<String, Class<?>> classMap = new HashMap<String, Class<?>>();
Map<String, List> dataMap = new HashMap<String, List>();
Map<String, String> noExportMap = new HashMap<String, String>();
List<IpCommCfg> list = new ArrayList<IpCommCfg>();
if (!StringUtil.isEmpty(ids)) {
list = ipCommGroupCfgService.findByPage(ids);
} else {
Page<IpCommCfg> pageInfo = new Page<IpCommCfg>(request, response, "r");
pageInfo.setPageNo(1);
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
Page<IpCommCfg> page = ipCommGroupCfgService.findPage(pageInfo, entity);
list = page.getList();
}
CommonGroupInfo groupInfo = new CommonGroupInfo();
for (IpCommCfg cfg : list) {
groupInfo.setServiceGroupId(cfg.getGroupId());
CommonGroupInfo commonGroupInfo = commonGroupManageService.getGroupInfo(groupInfo);
cfg.setGroupName(commonGroupInfo.getGroupName());
}
titleList.add(entity.getMenuNameCode());
classMap.put(entity.getMenuNameCode(), IpCommCfg.class);
String cfgIndexInfoNoExport = ",block_type,do_log,action"
+ ",letter,whether_area_block,classification,attribute,label,userregion1,userregion2,userregion3,userregion4,userregion5"
+ ",cfg_id,is_audit,auditor,valid_identifier,ir_type,";
// 时间过滤
if (entity.getSearch_create_time_start() == null) {
cfgIndexInfoNoExport = ",config_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_edit_time_start() == null) {
cfgIndexInfoNoExport = ",edit_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_audit_time_start() == null) {
cfgIndexInfoNoExport = ",audit_time" + cfgIndexInfoNoExport;
}
if (!StringUtil.isEmpty(entity.gethColumns())) {
cfgIndexInfoNoExport = "," + entity.gethColumns() + "," + cfgIndexInfoNoExport;
}
noExportMap.put(entity.getMenuNameCode(), cfgIndexInfoNoExport);
dataMap.put(entity.getMenuNameCode(), list);
String timeRange = initTimeMap(entity);
noExportMap.put("timeRange", timeRange);
if ("csv".equals(entity.getExType())) {
this._exportCsv(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
}
} catch (Exception e) {
logger.error("IpCommGroupCfg export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
}
}
// 数据导入
@RequestMapping(value = "import", method=RequestMethod.POST)
public String importIp(HttpServletRequest request,HttpServletResponse response,RedirectAttributes redirectAttributes,
@RequestParam("files") MultipartFile[] files, Integer serviceDictId ,Integer requestId ,String attribute ,String classify
,String regionDictIds ,String importPath) {
logger.warn("import start...");
long start=System.currentTimeMillis();
ImportBigExcel ei=null;
try {
FunctionServiceDict serviceDict = DictUtils.getFunctionServiceDict(serviceDictId);
StringBuffer errTip=new StringBuffer();
BlockingQueue<BaseIpCfg> ipPortCfgs =null;
for (int i = 0; i < files.length; i++) {
MultipartFile file = files[i];
ei = new ImportBigExcel(file, 0, 1);
FunctionRegionDict regionDict = DictUtils.getFunctionRegionDict(Integer.parseInt(regionDictIds.split(",")[i]));
//加载模板
loadTemplate(ei,regionDict, serviceDict);
//------------------------------------check format start----------------------------
if (regionDict.getRegionType().equals(1)) {// IP
BlockingQueue<IpCommCfgTemplate> list = ei.getDataList(IpCommCfgTemplate.class );
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict, null,null, list);
}
//删除文件
if(ei.getUploadFile()!=null&&ei.getUploadFile().exists()) {
ei.getUploadFile().delete();
}
//------------------------------------check format end----------------------------
Date date = new Date();
//String isSend = request.getParameter("isSend")==null?"":request.getParameter("isSend");
if (regionDict.getRegionType().equals(1)) {// IP
List<BaseIpCfg> _ipPortCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
while(!ipPortCfgs.isEmpty()) {
ipPortCfgs.drainTo(_ipPortCfgs, Constants.MAAT_JSON_SEND_SIZE);
List<Integer> regionIds = Lists.newArrayList(_ipPortCfgs.size());
try {
regionIds = ConfigServiceUtil.getId(3,_ipPortCfgs.size());
} catch (Exception e) {
logger.error("获取域ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
int index = 0;
Set<String> countSet = new HashSet<String>();
for (BaseIpCfg cfg : _ipPortCfgs) {
cfg.setAction(serviceDict==null?null:serviceDict.getAction());
cfg.setCfgRegionCode(regionDict.getConfigRegionCode());
cfg.setCfgType(regionDict.getConfigRegionValue());
cfg.setCreateTime(date);
cfg.setCreatorId(UserUtils.getUser().getId());
//cfg.setDoLog(2);
cfg.setCompileId(0);
cfg.setFunctionId(regionDict.getFunctionId());
cfg.setIsAudit(Constants.AUDIT_NOT_YET);
cfg.setIsValid(Constants.VALID_NO);
cfg.setIsAreaEffective(0);
cfg.setLable("0");
cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId);
cfg.setAttribute(attribute);
cfg.setClassify(classify);
cfg.setServiceId(serviceDict==null?null:serviceDict.getServiceId());
cfg.setTableName("ip_comm_cfg");
cfg.setRegionId(regionIds.get(index));
cfg.setGroupName(cfg.getGroupName().toUpperCase());
countSet.add(cfg.getGroupName());
index++;
}
List<CommonGroupInfo> insertGroupList = new ArrayList<CommonGroupInfo>();
Map<String, Integer> groupIdMap = commonGroupManageService.getCountByGroupName(countSet, insertGroupList, Constants.IP_OBJ_GROUP_TYPE); // 调用服务接口获取GroupId
ipCommGroupCfgService.saveAndSend(regionDict, serviceDict, _ipPortCfgs, groupIdMap, insertGroupList);
_ipPortCfgs.clear();
}
}
}
if(errTip.toString().length()>0) {
addMessage(redirectAttributes,"error", errTip.toString());
}
} catch (Exception e) {
if(ei!=null) {
if(ei.getUploadFile().exists()) {
ei.getUploadFile().delete();
}
}
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error", "request_service_failed");
}else if(e instanceof ServiceException) {
addMessage(redirectAttributes,"error", e.getMessage());
}else if(e instanceof IndexOutOfBoundsException){
addMessage(redirectAttributes,"error", "template_error");
}else {
addMessage(redirectAttributes,"error", "import_failed");
}
logger.error("import failed", e);
}
long end=System.currentTimeMillis();
logger.warn("import finish,cost:"+(end-start));
return "redirect:" + adminPath+ importPath;
}
}

View File

@@ -1,318 +0,0 @@
package com.nis.web.controller.basics;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jets3t.service.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.beust.jcommander.internal.Lists;
import com.nis.domain.FunctionRegionDict;
import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page;
import com.nis.domain.basics.CommonGroupInfo;
import com.nis.domain.basics.ScriberIdCommCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.template.ScriberIdCommCfgTemplate;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.ConfigServiceUtil;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.StringUtil;
import com.nis.util.excel.ImportBigExcel;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
import com.nis.web.service.basics.ScriberIdCommGroupService;
@Controller
@RequestMapping(value = "${adminPath}/basics/scriberId")
public class ScriberIdCommGroupController extends BaseController{
@Autowired
private ScriberIdCommGroupService scriberIdCommGroupService;
@RequestMapping(value = {"/list"})
public String list(Model model, @ModelAttribute("cfg")ScriberIdCommCfg entity, HttpServletRequest request,HttpServletResponse response){
Page<ScriberIdCommCfg> page = scriberIdCommGroupService.findPage(new Page<ScriberIdCommCfg>(request, response,"r"), entity);
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(entity.getFunctionId());
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(entity.getFunctionId());
List<CommonGroupInfo> groupInfos = commonGroupManageService.findCommonGroupInfosByType(Constants.SUBID_OBJ_GROUP_TYPE);
model.addAttribute("page", page);
model.addAttribute("regionList", regionList);
model.addAttribute("serviceList", serviceList);
model.addAttribute("policyGroupInfos", groupInfos);
return "/basics/scriberidCommGroupList";
}
@RequestMapping(value = {"/addForm"})
public String addForm(Model model, @ModelAttribute("cfg")CfgIndexInfo cfg, RedirectAttributes redirectAttributes,
HttpServletRequest request, HttpServletResponse response){
initFormCondition(model,cfg);
/*List<CommonGroupInfo> groupInfos=commonGroupManageService.findCommonGroupInfosByType(Constants.SUBID_OBJ_GROUP_TYPE);
model.addAttribute("policyGroupInfos", groupInfos);*/
model.addAttribute("_cfg", cfg);
return "/basics/scriberidCommGroupFormAdd";
}
@RequestMapping(value = {"/save"})
public String save(Model model, @ModelAttribute("cfg")CfgIndexInfo cfg,RedirectAttributes redirectAttributes,
HttpServletRequest request,HttpServletResponse response){
try{
scriberIdCommGroupService.saveCommGroupCfg(cfg);
addMessage(redirectAttributes,"success","save_success");
}catch(Exception e){
logger.error("信息保存失败",e);
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error",e.getMessage());
}else {
addMessage(redirectAttributes,"error","save_failed");
}
}
return "redirect:" + adminPath +"/basics/scriberId/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"/updateForm"})
public String updateForm(Model model,HttpServletRequest request
,HttpServletResponse response,String ids,@ModelAttribute("cfg")ScriberIdCommCfg cfg
,RedirectAttributes redirectAttributes){
cfg = scriberIdCommGroupService.get(Long.parseLong(ids));
initUpdateFormCondition(model,cfg);
List<CommonGroupInfo> groupInfos=commonGroupManageService.findCommonGroupInfosByType(Constants.SUBID_OBJ_GROUP_TYPE);
model.addAttribute("policyGroupInfos", groupInfos);
model.addAttribute("_cfg", cfg);
return "/basics/scriberidCommGroupFormUpdate";
}
@RequestMapping(value = {"/update"})
public String update(Model model,HttpServletRequest request,HttpServletResponse response,@ModelAttribute("cfg")ScriberIdCommCfg cfg,RedirectAttributes redirectAttributes){
try{
scriberIdCommGroupService.update(cfg);
addMessage(redirectAttributes,"success","save_success");
}catch(Exception e){
logger.error("信息保存失败",e);
addMessage(redirectAttributes,"error","save_failed");
}
return "redirect:" + adminPath +"/basics/scriberId/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"/delete"})
public String delete(String groupIds, String ids, Integer functionId, RedirectAttributes redirectAttributes,
HttpServletRequest request, HttpServletResponse response, @ModelAttribute("cfg")ScriberIdCommCfg cfg){
try{
scriberIdCommGroupService.delete(ids, groupIds, cfg, request, response);
addMessage(redirectAttributes,"success","delete_success");
}catch(Exception e){
logger.error("Delete failed",e);
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error",e.getMessage());
}else {
addMessage(redirectAttributes,"error","delete_failed");
}
}
return "redirect:" + adminPath +"/basics/scriberId/list?functionId="+functionId;
}
// 批量删除前获取提示信息
@ResponseBody
@RequestMapping(value="ajaxCheckIsLastOneCfgBatch",method=RequestMethod.POST)
public List<Integer> ajaxCheckIsLastOneCfgBatch(Model model, ScriberIdCommCfg searchCfg){
return scriberIdCommGroupService.ajaxCheckIsLastOneCfgBatch(searchCfg);
}
// 数据导入
@RequestMapping(value = "import", method=RequestMethod.POST)
public String importIp(HttpServletRequest request,HttpServletResponse response,RedirectAttributes redirectAttributes,
@RequestParam("files") MultipartFile[] files, Integer serviceDictId ,Integer requestId ,String attribute ,String classify
,String regionDictIds ,String importPath) {
logger.warn("import start...");
long start=System.currentTimeMillis();
ImportBigExcel ei=null;
try {
FunctionServiceDict serviceDict = DictUtils.getFunctionServiceDict(serviceDictId);
StringBuffer errTip=new StringBuffer();
BlockingQueue<BaseStringCfg<?>> stringCfgs =null;
for (int i = 0; i < files.length; i++) {
MultipartFile file = files[i];
ei = new ImportBigExcel(file, 0, 1);
FunctionRegionDict regionDict = DictUtils.getFunctionRegionDict(Integer.parseInt(regionDictIds.split(",")[i]));
//加载模板
loadTemplate(ei,regionDict, serviceDict);
//------------------------------------check format start----------------------------
if (regionDict.getRegionType().equals(2)) {
BlockingQueue<ScriberIdCommCfgTemplate> list = ei.getDataList(ScriberIdCommCfgTemplate.class );
stringCfgs = this.checkStringCfgMulity(errTip, serviceDict, regionDict, list);
}
//删除文件
if(ei.getUploadFile()!=null&&ei.getUploadFile().exists()) {
ei.getUploadFile().delete();
}
//------------------------------------check format end----------------------------
Date date = new Date();
//String isSend = request.getParameter("isSend")==null?"":request.getParameter("isSend");
if (regionDict.getRegionType().equals(2)) {
List<BaseStringCfg<?>> _stringCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
while(!stringCfgs.isEmpty()) {
stringCfgs.drainTo(_stringCfgs, Constants.MAAT_JSON_SEND_SIZE);
List<Integer> regionIds = Lists.newArrayList(_stringCfgs.size());
try {
regionIds = ConfigServiceUtil.getId(3,_stringCfgs.size());
} catch (Exception e) {
logger.error("获取域ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
int index = 0;
Set<String> countSet = new HashSet<String>();
for (BaseStringCfg<?> cfg : _stringCfgs) {
cfg.setAction(serviceDict==null?null:serviceDict.getAction());
cfg.setCfgRegionCode(regionDict.getConfigRegionCode());
cfg.setCfgType(regionDict.getConfigRegionValue());
cfg.setCreateTime(date);
cfg.setCreatorId(UserUtils.getUser().getId());
//cfg.setDoLog(2);
cfg.setCompileId(0);
cfg.setFunctionId(regionDict.getFunctionId());
cfg.setIsAudit(Constants.AUDIT_NOT_YET);
cfg.setIsValid(Constants.VALID_NO);
cfg.setIsAreaEffective(0);
cfg.setLable("0");
cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId);
cfg.setAttribute(attribute);
cfg.setClassify(classify);
cfg.setServiceId(serviceDict==null?null:serviceDict.getServiceId());
cfg.setTableName("scriberid_comm_cfg");
cfg.setRegionId(regionIds.get(index));
cfg.setGroupName(cfg.getGroupName().toUpperCase());
countSet.add(cfg.getGroupName());
index++;
}
List<CommonGroupInfo> insertGroupList = new ArrayList<CommonGroupInfo>();
Map<String, Integer> groupIdMap = commonGroupManageService.getCountByGroupName(countSet, insertGroupList, Constants.SUBID_OBJ_GROUP_TYPE); // 调用服务接口获取GroupId
scriberIdCommGroupService.saveAndSend(regionDict, serviceDict, _stringCfgs, groupIdMap, insertGroupList);
_stringCfgs.clear();
}
}
}
if(errTip.toString().length()>0) {
addMessage(redirectAttributes,"error", errTip.toString());
}
} catch (Exception e) {
if(ei!=null) {
if(ei.getUploadFile().exists()) {
ei.getUploadFile().delete();
}
}
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error", "request_service_failed");
}else if(e instanceof ServiceException) {
addMessage(redirectAttributes,"error", e.getMessage());
}else if(e instanceof IndexOutOfBoundsException){
addMessage(redirectAttributes,"error", "template_error");
}else {
addMessage(redirectAttributes,"error", "import_failed");
}
logger.error("import failed", e);
}
long end=System.currentTimeMillis();
logger.warn("import finish,cost:"+(end-start));
return "redirect:" + adminPath+ importPath;
}
// 数据导出
@RequestMapping(value = "/exportGroupInfo")
public void exportGroupInfo(Model model,HttpServletRequest request,HttpServletResponse response,
@ModelAttribute("cfg")ScriberIdCommCfg entity,String ids,RedirectAttributes redirectAttributes){
try {
List<String> titleList=new ArrayList<String>();
Map<String, Class<?>> classMap=new HashMap<String, Class<?>>();
Map<String, List> dataMap=new HashMap<String, List>();
Map<String, String> noExportMap=new HashMap<String, String>();
List<ScriberIdCommCfg> list = new ArrayList<ScriberIdCommCfg>();
if (!StringUtil.isEmpty(ids)) {
list = scriberIdCommGroupService.findByPage(ids);
} else {
Page<ScriberIdCommCfg> pageInfo=new Page<ScriberIdCommCfg>(request, response,"r");
pageInfo.setPageNo(1);
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
Page<ScriberIdCommCfg> page = scriberIdCommGroupService.findPage(pageInfo, entity);
list=page.getList();
}
CommonGroupInfo groupInfo = new CommonGroupInfo();
for (ScriberIdCommCfg cfg : list) {
groupInfo.setServiceGroupId(cfg.getGroupId());
CommonGroupInfo commonGroupInfo = commonGroupManageService.getGroupInfo(groupInfo);
cfg.setGroupName(commonGroupInfo.getGroupName());
}
titleList.add(entity.getMenuNameCode());
classMap.put(entity.getMenuNameCode(), ScriberIdCommCfg.class);
String cfgIndexInfoNoExport=",block_type,do_log,action,letter,whether_area_block,classification,attribute,label"
+ ",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,asn_no,"
+ "is_hex,is_case_insenstive,cfg_id,is_audit,auditor,valid_identifier,";
// 时间过滤
if (entity.getSearch_create_time_start() == null ) {
cfgIndexInfoNoExport = ",config_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_edit_time_start() == null) {
cfgIndexInfoNoExport = ",edit_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_audit_time_start() == null) {
cfgIndexInfoNoExport = ",audit_time" + cfgIndexInfoNoExport;
}
if (!StringUtil.isEmpty(entity.gethColumns())) {
cfgIndexInfoNoExport = "," + entity.gethColumns() + "," + cfgIndexInfoNoExport;
}
noExportMap.put(entity.getMenuNameCode(),cfgIndexInfoNoExport);
dataMap.put(entity.getMenuNameCode(), list);
String timeRange = initTimeMap(entity);
noExportMap.put("timeRange", timeRange);
if ("csv".equals(entity.getExType())) {
this._exportCsv(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
}
} catch (Exception e) {
logger.error("scriberidGroupConfig export failed",e);
addMessage(redirectAttributes,"error","export_failed");
}
}
}

View File

@@ -1,318 +0,0 @@
package com.nis.web.controller.basics;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jets3t.service.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.beust.jcommander.internal.Lists;
import com.nis.domain.FunctionRegionDict;
import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page;
import com.nis.domain.basics.CommonGroupInfo;
import com.nis.domain.basics.UrlCommCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.template.UrlCommCfgTemplate;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.ConfigServiceUtil;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.StringUtil;
import com.nis.util.excel.ImportBigExcel;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
import com.nis.web.service.basics.UrlCommGroupService;
@Controller
@RequestMapping(value = "${adminPath}/basics/url")
public class UrlCommGroupController extends BaseController{
@Autowired
private UrlCommGroupService urlCommGroupService;
@RequestMapping(value = {"/list"})
public String list(Model model, @ModelAttribute("cfg")UrlCommCfg entity, HttpServletRequest request,HttpServletResponse response){
Page<UrlCommCfg> page = urlCommGroupService.findPage(new Page<UrlCommCfg>(request, response,"r"), entity);
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(entity.getFunctionId());
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(entity.getFunctionId());
List<CommonGroupInfo> groupInfos = commonGroupManageService.findCommonGroupInfosByType(Constants.URL_OBJ_GROUP_TYPE);
model.addAttribute("page", page);
model.addAttribute("regionList", regionList);
model.addAttribute("serviceList", serviceList);
model.addAttribute("policyGroupInfos", groupInfos);
return "/basics/urlCommGroupList";
}
@RequestMapping(value = {"/addForm"})
public String addForm(Model model, @ModelAttribute("cfg")CfgIndexInfo cfg, RedirectAttributes redirectAttributes,
HttpServletRequest request, HttpServletResponse response){
initFormCondition(model,cfg);
/*List<CommonGroupInfo> groupInfos=commonGroupManageService.findCommonGroupInfosByType(Constants.URL_OBJ_GROUP_TYPE);
model.addAttribute("policyGroupInfos", groupInfos);*/
model.addAttribute("_cfg", cfg);
return "/basics/urlCommGroupFormAdd";
}
@RequestMapping(value = {"/save"})
public String save(Model model, @ModelAttribute("cfg")CfgIndexInfo cfg,RedirectAttributes redirectAttributes,
HttpServletRequest request,HttpServletResponse response){
try{
urlCommGroupService.saveUrlCommGroupCfg(cfg);
addMessage(redirectAttributes,"success","save_success");
}catch(Exception e){
logger.error("信息保存失败",e);
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error",e.getMessage());
}else {
addMessage(redirectAttributes,"error","save_failed");
}
}
return "redirect:" + adminPath +"/basics/url/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"/updateForm"})
public String updateForm(Model model,HttpServletRequest request
,HttpServletResponse response,String ids,@ModelAttribute("cfg")UrlCommCfg cfg
,RedirectAttributes redirectAttributes){
cfg = urlCommGroupService.get(Long.parseLong(ids));
initUpdateFormCondition(model,cfg);
List<CommonGroupInfo> groupInfos=commonGroupManageService.findCommonGroupInfosByType(Constants.URL_OBJ_GROUP_TYPE);
model.addAttribute("policyGroupInfos", groupInfos);
model.addAttribute("_cfg", cfg);
return "/basics/urlCommGroupFormUpdate";
}
@RequestMapping(value = {"/update"})
public String update(Model model,HttpServletRequest request,HttpServletResponse response,@ModelAttribute("cfg")UrlCommCfg cfg,RedirectAttributes redirectAttributes){
try{
urlCommGroupService.update(cfg);
addMessage(redirectAttributes,"success","save_success");
}catch(Exception e){
logger.error("信息保存失败",e);
addMessage(redirectAttributes,"error","save_failed");
}
return "redirect:" + adminPath +"/basics/url/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"/delete"})
public String delete(String groupIds, String ids, Integer functionId, RedirectAttributes redirectAttributes,
HttpServletRequest request, HttpServletResponse response, @ModelAttribute("cfg")UrlCommCfg cfg){
try{
urlCommGroupService.delete(ids, groupIds, cfg, request, response);
addMessage(redirectAttributes,"success","delete_success");
}catch(Exception e){
logger.error("Delete failed",e);
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error",e.getMessage());
}else {
addMessage(redirectAttributes,"error","delete_failed");
}
}
return "redirect:" + adminPath +"/basics/url/list?functionId="+functionId;
}
// 批量删除前获取提示信息
@ResponseBody
@RequestMapping(value="ajaxCheckIsLastOneCfgBatch",method=RequestMethod.POST)
public List<Integer> ajaxCheckIsLastOneCfgBatch(Model model, UrlCommCfg searchCfg){
return urlCommGroupService.ajaxCheckIsLastOneCfgBatch(searchCfg);
}
// 数据导入
@RequestMapping(value = "import", method=RequestMethod.POST)
public String importIp(HttpServletRequest request,HttpServletResponse response,RedirectAttributes redirectAttributes,
@RequestParam("files") MultipartFile[] files, Integer serviceDictId ,Integer requestId ,String attribute ,String classify
,String regionDictIds ,String importPath) {
logger.warn("import start...");
long start=System.currentTimeMillis();
ImportBigExcel ei=null;
try {
FunctionServiceDict serviceDict = DictUtils.getFunctionServiceDict(serviceDictId);
StringBuffer errTip=new StringBuffer();
BlockingQueue<BaseStringCfg<?>> stringCfgs =null;
for (int i = 0; i < files.length; i++) {
MultipartFile file = files[i];
ei = new ImportBigExcel(file, 0, 1);
FunctionRegionDict regionDict = DictUtils.getFunctionRegionDict(Integer.parseInt(regionDictIds.split(",")[i]));
//加载模板
loadTemplate(ei,regionDict, serviceDict);
//------------------------------------check format start----------------------------
if (regionDict.getRegionType().equals(2)) {
BlockingQueue<UrlCommCfgTemplate> list = ei.getDataList(UrlCommCfgTemplate.class );
stringCfgs = this.checkStringCfgMulity(errTip, serviceDict, regionDict, list);
}
//删除文件
if(ei.getUploadFile()!=null&&ei.getUploadFile().exists()) {
ei.getUploadFile().delete();
}
//------------------------------------check format end----------------------------
Date date = new Date();
//String isSend = request.getParameter("isSend")==null?"":request.getParameter("isSend");
if (regionDict.getRegionType().equals(2)) {
List<BaseStringCfg<?>> _stringCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
while(!stringCfgs.isEmpty()) {
stringCfgs.drainTo(_stringCfgs, Constants.MAAT_JSON_SEND_SIZE);
List<Integer> regionIds = Lists.newArrayList(_stringCfgs.size());
try {
regionIds = ConfigServiceUtil.getId(3,_stringCfgs.size());
} catch (Exception e) {
logger.error("获取域ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
int index = 0;
Set<String> countSet = new HashSet<String>();
for (BaseStringCfg<?> cfg : _stringCfgs) {
cfg.setAction(serviceDict==null?null:serviceDict.getAction());
cfg.setCfgRegionCode(regionDict.getConfigRegionCode());
cfg.setCfgType(regionDict.getConfigRegionValue());
cfg.setCreateTime(date);
cfg.setCreatorId(UserUtils.getUser().getId());
//cfg.setDoLog(2);
cfg.setCompileId(0);
cfg.setFunctionId(regionDict.getFunctionId());
cfg.setIsAudit(Constants.AUDIT_NOT_YET);
cfg.setIsValid(Constants.VALID_NO);
cfg.setIsAreaEffective(0);
cfg.setLable("0");
cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId);
cfg.setAttribute(attribute);
cfg.setClassify(classify);
cfg.setServiceId(serviceDict==null?null:serviceDict.getServiceId());
cfg.setTableName("url_comm_cfg");
cfg.setRegionId(regionIds.get(index));
cfg.setGroupName(cfg.getGroupName().toUpperCase());
countSet.add(cfg.getGroupName());
index++;
}
List<CommonGroupInfo> insertGroupList = new ArrayList<CommonGroupInfo>();
Map<String, Integer> groupIdMap = commonGroupManageService.getCountByGroupName(countSet, insertGroupList, Constants.URL_OBJ_GROUP_TYPE); // 调用服务接口获取GroupId
urlCommGroupService.saveAndSend(regionDict, serviceDict, _stringCfgs, groupIdMap, insertGroupList);
_stringCfgs.clear();
}
}
}
if(errTip.toString().length()>0) {
addMessage(redirectAttributes,"error", errTip.toString());
}
} catch (Exception e) {
if(ei!=null) {
if(ei.getUploadFile().exists()) {
ei.getUploadFile().delete();
}
}
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error", "request_service_failed");
}else if(e instanceof ServiceException) {
addMessage(redirectAttributes,"error", e.getMessage());
}else if(e instanceof IndexOutOfBoundsException){
addMessage(redirectAttributes,"error", "template_error");
}else {
addMessage(redirectAttributes,"error", "import_failed");
}
logger.error("import failed", e);
}
long end=System.currentTimeMillis();
logger.warn("import finish,cost:"+(end-start));
return "redirect:" + adminPath+ importPath;
}
// 数据导出
@RequestMapping(value = "/exportUrlComm")
public void exportUrlComm(Model model,HttpServletRequest request,HttpServletResponse response,
@ModelAttribute("cfg")UrlCommCfg entity,String ids,RedirectAttributes redirectAttributes){
try {
List<String> titleList=new ArrayList<String>();
Map<String, Class<?>> classMap=new HashMap<String, Class<?>>();
Map<String, List> dataMap=new HashMap<String, List>();
Map<String, String> noExportMap=new HashMap<String, String>();
List<UrlCommCfg> list = new ArrayList<UrlCommCfg>();
if (!StringUtil.isEmpty(ids)) {
list = urlCommGroupService.findByPage(ids);
} else {
Page<UrlCommCfg> pageInfo=new Page<UrlCommCfg>(request, response,"r");
pageInfo.setPageNo(1);
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
Page<UrlCommCfg> page = urlCommGroupService.findPage(pageInfo, entity);
list=page.getList();
}
CommonGroupInfo groupInfo = new CommonGroupInfo();
for (UrlCommCfg cfg : list) {
groupInfo.setServiceGroupId(cfg.getGroupId());
CommonGroupInfo commonGroupInfo = commonGroupManageService.getGroupInfo(groupInfo);
cfg.setGroupName(commonGroupInfo.getGroupName());
}
titleList.add(entity.getMenuNameCode());
classMap.put(entity.getMenuNameCode(), UrlCommCfg.class);
String cfgIndexInfoNoExport=",block_type,do_log,action,letter,whether_area_block,classification,attribute,label"
+ ",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,asn_no,"
+ "is_hex,is_case_insenstive,cfg_id,is_audit,auditor,valid_identifier,";
// 时间过滤
if (entity.getSearch_create_time_start() == null ) {
cfgIndexInfoNoExport = ",config_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_edit_time_start() == null) {
cfgIndexInfoNoExport = ",edit_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_audit_time_start() == null) {
cfgIndexInfoNoExport = ",audit_time" + cfgIndexInfoNoExport;
}
if (!StringUtil.isEmpty(entity.gethColumns())) {
cfgIndexInfoNoExport = "," + entity.gethColumns() + "," + cfgIndexInfoNoExport;
}
noExportMap.put(entity.getMenuNameCode(),cfgIndexInfoNoExport);
dataMap.put(entity.getMenuNameCode(), list);
String timeRange = initTimeMap(entity);
noExportMap.put("timeRange", timeRange);
if ("csv".equals(entity.getExType())) {
this._exportCsv(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
}
} catch (Exception e) {
logger.error("urlGroupConfig export failed",e);
addMessage(redirectAttributes,"error","export_failed");
}
}
}

View File

@@ -126,9 +126,9 @@ public class AppCfgController extends BaseController {
*/ */
@RequestMapping(value = "ajaxAppName", method = RequestMethod.POST) @RequestMapping(value = "ajaxAppName", method = RequestMethod.POST)
@ResponseBody @ResponseBody
public List<Map<String, String>> ajaxAppName(Model model, String ids,Integer cfgType) { public List<Map<String, String>> ajaxAppName(Model model, String ids) {
List<Map<String, String>> dataList = new ArrayList<>(); List<Map<String, String>> dataList = new ArrayList<>();
List<SpecificServiceCfg> serviceList = specificServiceCfgService.getBySpecServiceCodes(ids,cfgType); List<SpecificServiceCfg> serviceList = specificServiceCfgService.getBySpecServiceCodes(ids);
Map<String, String> appMap = new HashMap<>(); Map<String, String> appMap = new HashMap<>();
Map<String, String> behavMap = new HashMap<>(); Map<String, String> behavMap = new HashMap<>();
for (SpecificServiceCfg cfg : serviceList) { for (SpecificServiceCfg cfg : serviceList) {
@@ -192,24 +192,6 @@ public class AppCfgController extends BaseController {
public String policyCfgForm(Model model, String ids, AppPolicyCfg entity) { public String policyCfgForm(Model model, String ids, AppPolicyCfg entity) {
if (StringUtils.isNotBlank(ids)) { if (StringUtils.isNotBlank(ids)) {
entity = appCfgService.getAppPolicyCfg(Long.parseLong(ids), null); entity = appCfgService.getAppPolicyCfg(Long.parseLong(ids), null);
// 查找社交应用的所有有效一级特定服务
SpecificServiceCfg appSpec = new SpecificServiceCfg();
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(entity.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
entity.setSpecServiceId(app.getSpecServiceId());
}
initUpdateFormCondition(model, entity); initUpdateFormCondition(model, entity);
} else { } else {
initFormCondition(model, entity); initFormCondition(model, entity);
@@ -374,22 +356,8 @@ public class AppCfgController extends BaseController {
Page<AppIpCfg> searchPage = new Page<AppIpCfg>(request, response, "r"); Page<AppIpCfg> searchPage = new Page<AppIpCfg>(request, response, "r");
Page<AppIpCfg> page = appCfgService.findAppIpList(searchPage, cfg); Page<AppIpCfg> page = appCfgService.findAppIpList(searchPage, cfg);
for (AppIpCfg entity : page.getList()) { for (AppIpCfg entity : page.getList()) {
// 查找社交应用的所有有效一级特定服务 SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
SpecificServiceCfg appSpec = new SpecificServiceCfg(); entity.setAppName(app.getSpecServiceName());
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(entity.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
entity.setAppName(app.getSpecServiceName());
}
} }
model.addAttribute("page", page); model.addAttribute("page", page);
initPageCondition(model, cfg); initPageCondition(model, cfg);
@@ -409,24 +377,6 @@ public class AppCfgController extends BaseController {
public String ipCfgForm(Model model, String ids, AppIpCfg entity) { public String ipCfgForm(Model model, String ids, AppIpCfg entity) {
if (StringUtils.isNotBlank(ids)) { if (StringUtils.isNotBlank(ids)) {
entity = appCfgService.getAppIpCfg(Long.parseLong(ids)); entity = appCfgService.getAppIpCfg(Long.parseLong(ids));
// 查找社交应用的所有有效一级特定服务
SpecificServiceCfg appSpec = new SpecificServiceCfg();
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(entity.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
entity.setSpecServiceId(app.getSpecServiceId());
}
initUpdateFormCondition(model, entity); initUpdateFormCondition(model, entity);
} else { } else {
initFormCondition(model, entity); initFormCondition(model, entity);
@@ -601,22 +551,8 @@ public class AppCfgController extends BaseController {
Page<AppHttpCfg> searchPage = new Page<AppHttpCfg>(request, response, "r"); Page<AppHttpCfg> searchPage = new Page<AppHttpCfg>(request, response, "r");
Page<AppHttpCfg> page = appCfgService.findAppHttpList(searchPage, cfg); Page<AppHttpCfg> page = appCfgService.findAppHttpList(searchPage, cfg);
for (AppHttpCfg entity : page.getList()) { for (AppHttpCfg entity : page.getList()) {
// 查找社交应用的所有有效一级特定服务 SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
SpecificServiceCfg appSpec = new SpecificServiceCfg(); entity.setAppName(app.getSpecServiceName());
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(entity.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
entity.setAppName(app.getSpecServiceName());
}
// entity.setCfgKeywords(entity.getCfgKeywords().replace(Constants.KEYWORD_EXPR, // entity.setCfgKeywords(entity.getCfgKeywords().replace(Constants.KEYWORD_EXPR,
// "&")); // "&"));
} }
@@ -638,24 +574,6 @@ public class AppCfgController extends BaseController {
public String httpCfgForm(Model model, String ids, AppHttpCfg entity) { public String httpCfgForm(Model model, String ids, AppHttpCfg entity) {
if (StringUtils.isNotBlank(ids)) { if (StringUtils.isNotBlank(ids)) {
entity = appCfgService.getAppHttpCfg(Long.parseLong(ids)); entity = appCfgService.getAppHttpCfg(Long.parseLong(ids));
// 查找社交应用的所有有效一级特定服务
SpecificServiceCfg appSpec = new SpecificServiceCfg();
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(entity.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
entity.setSpecServiceId(app.getSpecServiceId());
}
initUpdateFormCondition(model, entity); initUpdateFormCondition(model, entity);
} else { } else {
initFormCondition(model, entity); initFormCondition(model, entity);
@@ -796,22 +714,8 @@ public class AppCfgController extends BaseController {
Page<AppDomainCfg> searchPage = new Page<AppDomainCfg>(request, response, "r"); Page<AppDomainCfg> searchPage = new Page<AppDomainCfg>(request, response, "r");
Page<AppDomainCfg> page = appCfgService.findAppDomainList(searchPage, cfg); Page<AppDomainCfg> page = appCfgService.findAppDomainList(searchPage, cfg);
for (AppDomainCfg entity : page.getList()) { for (AppDomainCfg entity : page.getList()) {
// 查找社交应用的所有有效一级特定服务 SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
SpecificServiceCfg appSpec = new SpecificServiceCfg(); entity.setAppName(app.getSpecServiceName());
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(entity.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
entity.setAppName(app.getSpecServiceName());
}
} }
model.addAttribute("page", page); model.addAttribute("page", page);
initPageCondition(model, cfg); initPageCondition(model, cfg);
@@ -831,24 +735,6 @@ public class AppCfgController extends BaseController {
public String domainCfgForm(Model model, String ids, AppDomainCfg entity) { public String domainCfgForm(Model model, String ids, AppDomainCfg entity) {
if (StringUtils.isNotBlank(ids)) { if (StringUtils.isNotBlank(ids)) {
entity = appCfgService.getAppDomainCfg(Long.parseLong(ids)); entity = appCfgService.getAppDomainCfg(Long.parseLong(ids));
// 查找社交应用的所有有效一级特定服务
SpecificServiceCfg appSpec = new SpecificServiceCfg();
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(entity.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
entity.setSpecServiceId(app.getSpecServiceId());
}
initUpdateFormCondition(model, entity); initUpdateFormCondition(model, entity);
} else { } else {
initFormCondition(model, entity); initFormCondition(model, entity);
@@ -1011,22 +897,8 @@ public class AppCfgController extends BaseController {
Page<AppByteCfg> searchPage = new Page<AppByteCfg>(request, response, "r"); Page<AppByteCfg> searchPage = new Page<AppByteCfg>(request, response, "r");
Page<AppByteCfg> page = appCfgService.findAppByteList(searchPage, cfg); Page<AppByteCfg> page = appCfgService.findAppByteList(searchPage, cfg);
for (AppByteCfg entity : page.getList()) { for (AppByteCfg entity : page.getList()) {
// 查找社交应用的所有有效一级特定服务 SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
SpecificServiceCfg appSpec = new SpecificServiceCfg(); entity.setAppName(app.getSpecServiceName());
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(entity.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
entity.setAppName(app.getSpecServiceName());
}
} }
model.addAttribute("page", page); model.addAttribute("page", page);
initPageCondition(model, cfg); initPageCondition(model, cfg);
@@ -1046,24 +918,6 @@ public class AppCfgController extends BaseController {
public String byteCfgForm(Model model, String ids, AppByteCfg entity) { public String byteCfgForm(Model model, String ids, AppByteCfg entity) {
if (StringUtils.isNotBlank(ids)) { if (StringUtils.isNotBlank(ids)) {
entity = appCfgService.getAppByteCfg(Long.parseLong(ids)); entity = appCfgService.getAppByteCfg(Long.parseLong(ids));
// 查找社交应用的所有有效一级特定服务
SpecificServiceCfg appSpec = new SpecificServiceCfg();
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(entity.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
entity.setSpecServiceId(app.getSpecServiceId());
}
initUpdateFormCondition(model, entity); initUpdateFormCondition(model, entity);
} else { } else {
initFormCondition(model, entity); initFormCondition(model, entity);
@@ -1180,22 +1034,8 @@ public class AppCfgController extends BaseController {
Page<AppSslCertCfg> searchPage = new Page<AppSslCertCfg>(request, response, "r"); Page<AppSslCertCfg> searchPage = new Page<AppSslCertCfg>(request, response, "r");
Page<AppSslCertCfg> page = appCfgService.findAppSslList(searchPage, cfg); Page<AppSslCertCfg> page = appCfgService.findAppSslList(searchPage, cfg);
for (AppSslCertCfg entity : page.getList()) { for (AppSslCertCfg entity : page.getList()) {
// 查找社交应用的所有有效一级特定服务 SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
SpecificServiceCfg appSpec = new SpecificServiceCfg(); entity.setAppName(app.getSpecServiceName());
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(entity.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
entity.setAppName(app.getSpecServiceName());
}
} }
model.addAttribute("page", page); model.addAttribute("page", page);
initPageCondition(model, cfg); initPageCondition(model, cfg);
@@ -1215,24 +1055,6 @@ public class AppCfgController extends BaseController {
public String sslCfgForm(Model model, String ids, AppSslCertCfg entity) { public String sslCfgForm(Model model, String ids, AppSslCertCfg entity) {
if (StringUtils.isNotBlank(ids)) { if (StringUtils.isNotBlank(ids)) {
entity = appCfgService.getAppSslCfg(Long.parseLong(ids)); entity = appCfgService.getAppSslCfg(Long.parseLong(ids));
// 查找社交应用的所有有效一级特定服务
SpecificServiceCfg appSpec = new SpecificServiceCfg();
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(entity.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
entity.setSpecServiceId(app.getSpecServiceId());
}
initUpdateFormCondition(model, entity); initUpdateFormCondition(model, entity);
} else { } else {
initFormCondition(model, entity); initFormCondition(model, entity);
@@ -1262,13 +1084,7 @@ public class AppCfgController extends BaseController {
entity.setAppCode(specificService.getSpecServiceCode()); entity.setAppCode(specificService.getSpecServiceCode());
} }
appCfgService.saveOrUpdateAppSslCfg(entity); appCfgService.saveOrUpdateAppSslCfg(entity);
//配置仅保存 addMessage(redirectAttributes, "success", "save_success");
if(StringUtil.isEmpty(entity.getIsValid()) || entity.getIsValid()!=1) {
addMessage(redirectAttributes, "success", "save_success");
}else {
//配置直接生效
addMessage(redirectAttributes, "success", "audit_success");
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
logger.error("saveAppSslCfg failed", e); logger.error("saveAppSslCfg failed", e);
@@ -1380,9 +1196,7 @@ public class AppCfgController extends BaseController {
Page<AppTcpCfg> page = appCfgService.findAppTcpList(searchPage, cfg); Page<AppTcpCfg> page = appCfgService.findAppTcpList(searchPage, cfg);
for (AppTcpCfg entity : page.getList()) { for (AppTcpCfg entity : page.getList()) {
SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId()); SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
if(app!=null){ entity.setAppName(app.getSpecServiceName());
entity.setAppName(app.getSpecServiceName());
}
} }
model.addAttribute("page", page); model.addAttribute("page", page);
initPageCondition(model, cfg); initPageCondition(model, cfg);
@@ -1402,24 +1216,6 @@ public class AppCfgController extends BaseController {
public String tcpCfgForm(Model model, String ids, AppTcpCfg entity) { public String tcpCfgForm(Model model, String ids, AppTcpCfg entity) {
if (StringUtils.isNotBlank(ids)) { if (StringUtils.isNotBlank(ids)) {
entity = appCfgService.getAppTcpCfg(Long.parseLong(ids)); entity = appCfgService.getAppTcpCfg(Long.parseLong(ids));
// 查找社交应用的所有有效一级特定服务
SpecificServiceCfg appSpec = new SpecificServiceCfg();
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(entity.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
entity.setSpecServiceId(app.getSpecServiceId());
}
initUpdateFormCondition(model, entity); initUpdateFormCondition(model, entity);
} else { } else {
initFormCondition(model, entity); initFormCondition(model, entity);
@@ -1535,22 +1331,8 @@ public class AppCfgController extends BaseController {
Page<AppHeaderCfg> searchPage = new Page<AppHeaderCfg>(request, response, "r"); Page<AppHeaderCfg> searchPage = new Page<AppHeaderCfg>(request, response, "r");
Page<AppHeaderCfg> page = appCfgService.findAppHeaderList(searchPage, cfg); Page<AppHeaderCfg> page = appCfgService.findAppHeaderList(searchPage, cfg);
for (AppHeaderCfg entity : page.getList()) { for (AppHeaderCfg entity : page.getList()) {
// 查找社交应用的所有有效一级特定服务 SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
SpecificServiceCfg appSpec = new SpecificServiceCfg(); entity.setAppName(app.getSpecServiceName());
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(entity.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
entity.setAppName(app.getSpecServiceName());
}
} }
model.addAttribute("page", page); model.addAttribute("page", page);
initPageCondition(model, cfg); initPageCondition(model, cfg);
@@ -1570,24 +1352,6 @@ public class AppCfgController extends BaseController {
public String headerCfgForm(Model model, String ids, AppHeaderCfg entity) { public String headerCfgForm(Model model, String ids, AppHeaderCfg entity) {
if (StringUtils.isNotBlank(ids)) { if (StringUtils.isNotBlank(ids)) {
entity = appCfgService.getAppHeaderCfg(Long.parseLong(ids)); entity = appCfgService.getAppHeaderCfg(Long.parseLong(ids));
// 查找社交应用的所有有效一级特定服务
SpecificServiceCfg appSpec = new SpecificServiceCfg();
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(entity.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
entity.setSpecServiceId(app.getSpecServiceId());
}
initUpdateFormCondition(model, entity); initUpdateFormCondition(model, entity);
} else { } else {
initFormCondition(model, entity); initFormCondition(model, entity);
@@ -2084,20 +1848,8 @@ public class AppCfgController extends BaseController {
logTotal.put("sum",0L); logTotal.put("sum",0L);
logTotals.add(logTotal); logTotals.add(logTotal);
} }
// 查找社交应用的所有有效一级特定服务 SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(policy.getSpecServiceId());
SpecificServiceCfg appSpec = new SpecificServiceCfg(); if (app != null) {
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(policy.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
policy.setSocialName(app.getSpecServiceName()); policy.setSocialName(app.getSpecServiceName());
} }
} }
@@ -2307,9 +2059,7 @@ public class AppCfgController extends BaseController {
for (AppIpCfg appIp : ipLists) { for (AppIpCfg appIp : ipLists) {
SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(appIp.getSpecServiceId()); SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(appIp.getSpecServiceId());
if(app!=null){ appIp.setAppName(app.getSpecServiceName());
appIp.setAppName(app.getSpecServiceName());
}
} }
titleList.add(entity.getMenuNameCode()); titleList.add(entity.getMenuNameCode());
classMap.put(entity.getMenuNameCode(), AppIpCfg.class); classMap.put(entity.getMenuNameCode(), AppIpCfg.class);
@@ -2382,22 +2132,8 @@ public class AppCfgController extends BaseController {
http.setIsCaseInsenstive(0); http.setIsCaseInsenstive(0);
} }
http.setCfgKeywords(Functions.replace(http.getCfgKeywords(), "***and***", " ")); http.setCfgKeywords(Functions.replace(http.getCfgKeywords(), "***and***", " "));
// 查找社交应用的所有有效一级特定服务 SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(http.getSpecServiceId());
SpecificServiceCfg appSpec = new SpecificServiceCfg(); http.setAppName(app.getSpecServiceName());
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(http.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
http.setAppName(app.getSpecServiceName());
}
} }
titleList.add(entity.getMenuNameCode()); titleList.add(entity.getMenuNameCode());
@@ -2469,22 +2205,8 @@ public class AppCfgController extends BaseController {
}else{ }else{
domain.setIsCaseInsenstive(0); domain.setIsCaseInsenstive(0);
} }
// 查找社交应用的所有有效一级特定服务 SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(domain.getSpecServiceId());
SpecificServiceCfg appSpec = new SpecificServiceCfg(); domain.setAppName(app.getSpecServiceName());
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(domain.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
domain.setAppName(app.getSpecServiceName());
}
} }
titleList.add(entity.getMenuNameCode()); titleList.add(entity.getMenuNameCode());
@@ -2558,22 +2280,8 @@ public class AppCfgController extends BaseController {
ssl.setIsCaseInsenstive(0); ssl.setIsCaseInsenstive(0);
} }
ssl.setCfgKeywords(Functions.replace(ssl.getCfgKeywords(), "***and***", " ")); ssl.setCfgKeywords(Functions.replace(ssl.getCfgKeywords(), "***and***", " "));
// 查找社交应用的所有有效一级特定服务 SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(ssl.getSpecServiceId());
SpecificServiceCfg appSpec = new SpecificServiceCfg(); ssl.setAppName(app.getSpecServiceName());
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(ssl.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
ssl.setAppName(app.getSpecServiceName());
}
} }
titleList.add(entity.getMenuNameCode()); titleList.add(entity.getMenuNameCode());
classMap.put(entity.getMenuNameCode(), AppSslCertCfg.class); classMap.put(entity.getMenuNameCode(), AppSslCertCfg.class);

View File

@@ -87,22 +87,8 @@ public class AppFeatureCfgController extends BaseController {
Page<AppFeatureIndex> searchPage = new Page<AppFeatureIndex>(request, response, "r"); Page<AppFeatureIndex> searchPage = new Page<AppFeatureIndex>(request, response, "r");
Page<AppFeatureIndex> page = appMultiFeatureCfgService.findAppFeatureIndexList(searchPage, cfg); Page<AppFeatureIndex> page = appMultiFeatureCfgService.findAppFeatureIndexList(searchPage, cfg);
for (AppFeatureIndex entity : page.getList()) { for (AppFeatureIndex entity : page.getList()) {
// 查找社交应用的所有有效一级特定服务 SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
SpecificServiceCfg appSpec = new SpecificServiceCfg(); entity.setAppName(app.getSpecServiceName());
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(entity.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
entity.setAppName(app.getSpecServiceName());
}
} }
model.addAttribute("page", page); model.addAttribute("page", page);
initPageCondition(model, cfg); initPageCondition(model, cfg);
@@ -129,24 +115,6 @@ public class AppFeatureCfgController extends BaseController {
entity.getFunctionId(), null)); entity.getFunctionId(), null));
entity.setNumCfgList( entity.setNumCfgList(
appMultiFeatureCfgService.getAppTcpCfg(entity.getCompileId(), entity.getFunctionId(), null)); appMultiFeatureCfgService.getAppTcpCfg(entity.getCompileId(), entity.getFunctionId(), null));
// 查找社交应用的所有有效一级特定服务
SpecificServiceCfg appSpec = new SpecificServiceCfg();
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(entity.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
entity.setSpecServiceId(app.getSpecServiceId());
}
initUpdateFormCondition(model, entity); initUpdateFormCondition(model, entity);
} else { } else {
initFormCondition(model, entity); initFormCondition(model, entity);
@@ -383,22 +351,8 @@ public class AppFeatureCfgController extends BaseController {
} }
for (AppFeatureIndex feature : ipLists) { for (AppFeatureIndex feature : ipLists) {
// 查找社交应用的所有有效一级特定服务 SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(feature.getSpecServiceId());
SpecificServiceCfg appSpec = new SpecificServiceCfg(); feature.setAppName(app.getSpecServiceName());
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(feature.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
feature.setAppName(app.getSpecServiceName());
}
} }
String cfgIndexInfoNoExport = ",letter,whether_area_block,classification,attribute,label,do_log,block_type,client_port,ir_type,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,"; String cfgIndexInfoNoExport = ",letter,whether_area_block,classification,attribute,label,do_log,block_type,client_port,ir_type,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
String appComplexNoExport = ",do_log,block_type,config_describe,valid_identifier,is_audit,creator,creator" String appComplexNoExport = ",do_log,block_type,config_describe,valid_identifier,is_audit,creator,creator"
@@ -408,7 +362,7 @@ public class AppFeatureCfgController extends BaseController {
String ipPortInfoNoExport = ",do_log,block_type,config_describe,valid_identifier,is_audit,creator,creator" String ipPortInfoNoExport = ",do_log,block_type,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time" + ",config_time,editor,edit_time,auditor,audit_time"
+ ",letter,whether_area_block,classification,attribute,label" + ",letter,whether_area_block,classification,attribute,label"
+ ",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,group_name,client_ip,src_ip_pattern,client_port,src_port_pattern,"; + ",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,group_name,";
// 时间过滤 // 时间过滤
if (entity.getSearch_create_time_start() == null && entity.getSearch_create_time_end() == null) { if (entity.getSearch_create_time_start() == null && entity.getSearch_create_time_end() == null) {

View File

@@ -24,7 +24,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.nis.domain.Page; import com.nis.domain.Page;
import com.nis.domain.SysDataDictionaryItem;
import com.nis.domain.configuration.AppPolicyCfg; import com.nis.domain.configuration.AppPolicyCfg;
import com.nis.domain.configuration.BaseStringCfg; import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CfgIndexInfo; import com.nis.domain.configuration.CfgIndexInfo;
@@ -37,7 +36,6 @@ import com.nis.exceptions.CallExternalProceduresException;
import com.nis.exceptions.MaatConvertException; import com.nis.exceptions.MaatConvertException;
import com.nis.util.ConfigServiceUtil; import com.nis.util.ConfigServiceUtil;
import com.nis.util.Constants; import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.LogUtils; import com.nis.util.LogUtils;
import com.nis.util.StringUtil; import com.nis.util.StringUtil;
import com.nis.web.controller.BaseController; import com.nis.web.controller.BaseController;
@@ -132,25 +130,6 @@ public class BasicProtocolController extends BaseController {
public String policyCfgForm(Model model, String ids, AppPolicyCfg entity) { public String policyCfgForm(Model model, String ids, AppPolicyCfg entity) {
if (StringUtils.isNotBlank(ids)) { if (StringUtils.isNotBlank(ids)) {
entity = appCfgService.getAppPolicyCfg(Long.parseLong(ids), null); entity = appCfgService.getAppPolicyCfg(Long.parseLong(ids), null);
// 查找社交应用的所有有效一级特定服务
SpecificServiceCfg appSpec = new SpecificServiceCfg();
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_BASIC_PROTOCOL.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(entity.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
entity.setSpecServiceId(app.getSpecServiceId());
}
initUpdateFormCondition(model, entity); initUpdateFormCondition(model, entity);
} else { } else {
initFormCondition(model, entity); initFormCondition(model, entity);
@@ -344,20 +323,8 @@ public class BasicProtocolController extends BaseController {
logTotal.put("sum",0L); logTotal.put("sum",0L);
logTotals.add(logTotal); logTotals.add(logTotal);
} }
// 查找社交应用的所有有效一级特定服务 TODO SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(policy.getSpecServiceId());
SpecificServiceCfg appSpec = new SpecificServiceCfg(); if (app != null) {
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_BASIC_PROTOCOL.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(policy.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
policy.setAppName(app.getSpecServiceName()); policy.setAppName(app.getSpecServiceName());
} }

View File

@@ -8,8 +8,10 @@
*/ */
package com.nis.web.controller.configuration; package com.nis.web.controller.configuration;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
@@ -17,22 +19,38 @@ import java.util.Properties;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.axis2.databinding.types.soapencoding.Array;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.nis.domain.FunctionRegionDict;
import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page; import com.nis.domain.Page;
import com.nis.domain.basics.ServiceDictInfo; import com.nis.domain.basics.ServiceDictInfo;
import com.nis.domain.configuration.BaseIpCfg; import com.nis.domain.configuration.BaseIpCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.HttpBodyCfg;
import com.nis.domain.configuration.HttpReqHeadCfg;
import com.nis.domain.configuration.HttpResHeadCfg;
import com.nis.domain.configuration.HttpUrlCfg; import com.nis.domain.configuration.HttpUrlCfg;
import com.nis.domain.configuration.template.IpAllTemplate;
import com.nis.domain.configuration.template.IpCfgTemplate;
import com.nis.domain.specific.ConfigGroupInfo;
import com.nis.domain.configuration.IpPortCfg; import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.NtcSubscribeIdCfg;
import com.nis.exceptions.MaatConvertException; import com.nis.exceptions.MaatConvertException;
import com.nis.util.Constants; import com.nis.util.Constants;
import com.nis.util.DateUtils; import com.nis.util.DateUtils;
import com.nis.util.DictUtils;
import com.nis.util.StringUtil; import com.nis.util.StringUtil;
import com.nis.util.excel.ExportExcel; import com.nis.util.excel.ExportExcel;
import com.nis.util.excel.ImportExcel;
import com.nis.web.controller.BaseController; import com.nis.web.controller.BaseController;
import com.nis.web.dao.configuration.IpCfgDao;
import com.nis.web.security.UserUtils;
/** /**
* @ClassName: CommonController.java * @ClassName: CommonController.java
@@ -270,7 +288,15 @@ public class CommonController extends BaseController {
e.printStackTrace(); e.printStackTrace();
} }
}*/ }*/
public void _importFileTemplate(HttpServletRequest request,HttpServletResponse response,
RedirectAttributes redirectAttributes,Integer functionId,Integer cfgRegionCode) {
this.importCfgTemplate(request, response, redirectAttributes, functionId, cfgRegionCode);
}
@Deprecated
public void _importFileTemplate(HttpServletRequest request,HttpServletResponse response,
RedirectAttributes redirectAttributes,Integer functionId,Integer cfgRegionCode,Class clazz) {
this.importCfgTemplate(request, response, redirectAttributes, functionId, cfgRegionCode,clazz);
}
//ip配置导出 //ip配置导出
public void _exportIp(String columns,Model model,HttpServletRequest request,HttpServletResponse response, public void _exportIp(String columns,Model model,HttpServletRequest request,HttpServletResponse response,
IpPortCfg entity,String ids,RedirectAttributes redirectAttributes){ IpPortCfg entity,String ids,RedirectAttributes redirectAttributes){

View File

@@ -56,7 +56,7 @@ public class ConfigSynchronizationController extends BaseController {
Map<String,Integer> map = new HashMap(); Map<String,Integer> map = new HashMap();
map.put("syncStatus", cmd); map.put("syncStatus", cmd);
JSONObject result = ConfigServiceUtil.configSyncCmd(BaseService.gsonToJson(map)); JSONObject result = ConfigServiceUtil.configSyncCmd(BaseService.gsonToJson(map));
// JSONObject result=JSONObject.fromObject("{\"status\": 201,\"businessCode\": 2001000,\"reason\":\"数据获取操作成功\",\"msg\": \"根据配置id获取对应的编译,组,域等信息成功\",\"fromuri\": \"/galaxy-service/service/cfg/v1/getAllKVByCompileId\",\"traceCode\": \"2019031211285044813363\",\"data\": [{\"service\":\"ntc\",\"status\":0,\"opTime\":\"2016-11-22 08:31:27\"}]}"); //JSONObject result=JSONObject.fromObject("{\"status\": 201,\"businessCode\": 2001000,\"reason\":\"数据获取操作成功\",\"msg\": \"根据配置id获取对应的编译,组,域等信息成功\",\"fromuri\": \"/galaxy-service/service/cfg/v1/getAllKVByCompileId\",\"traceCode\": \"2019031211285044813363\",\"data\": [{\"service\":\"ntc\",\"status\":0,\"opTime\":\"2016-11-22 08:31:27\"}]}");
if(result.get("status").equals(201)){//响应成功 if(result.get("status").equals(201)){//响应成功
if(cmd.equals(1)){//同步 if(cmd.equals(1)){//同步
SysDataDictionaryName sysDictName = new SysDataDictionaryName(); SysDataDictionaryName sysDictName = new SysDataDictionaryName();

View File

@@ -151,24 +151,6 @@ public class EncryptedTunnelBehaviorController extends BaseController {
public String policyCfgForm(Model model, String ids, AppPolicyCfg entity) { public String policyCfgForm(Model model, String ids, AppPolicyCfg entity) {
if (StringUtils.isNotBlank(ids)) { if (StringUtils.isNotBlank(ids)) {
entity = appCfgService.getAppPolicyCfg(Long.parseLong(ids), null); entity = appCfgService.getAppPolicyCfg(Long.parseLong(ids), null);
// 查找社交应用的所有有效一级特定服务
SpecificServiceCfg appSpec = new SpecificServiceCfg();
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_ENCRYPTED_TUNNEL_BEHAVIOR.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(entity.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
entity.setSpecServiceId(app.getSpecServiceId());
}
initUpdateFormCondition(model, entity); initUpdateFormCondition(model, entity);
} else { } else {
initFormCondition(model, entity); initFormCondition(model, entity);
@@ -365,20 +347,8 @@ public class EncryptedTunnelBehaviorController extends BaseController {
logTotal.put("sum",0L); logTotal.put("sum",0L);
logTotals.add(logTotal); logTotals.add(logTotal);
} }
// 查找社交应用的所有有效一级特定服务 TODO SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(policy.getSpecServiceId());
SpecificServiceCfg appSpec = new SpecificServiceCfg(); if (app != null) {
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_ENCRYPTED_TUNNEL_BEHAVIOR.equals(dict.getItemValue())) {
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
appSpec.setIsValid(Constants.VALID_YES);
appSpec.setIsLeaf(0);
appSpec.setSpecServiceCode(policy.getAppCode());
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
if (!StringUtil.isEmpty(appList)) {
SpecificServiceCfg app = appList.get(0);
policy.setBehaviorName(app.getSpecServiceName()); policy.setBehaviorName(app.getSpecServiceName());
} }
} }

View File

@@ -1,617 +0,0 @@
package com.nis.web.controller.configuration;
import com.nis.domain.Page;
import com.nis.domain.basics.PolicyGroupInfo;
import com.nis.domain.configuration.BaseCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.ObjGroupCfg;
import com.nis.exceptions.CallExternalProceduresException;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.*;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
@Controller
@RequestMapping("${adminPath}/objgroup")
public class ObjectGroupController extends BaseController {
@RequestMapping(value = { "/list" })
public String list(Model model, @ModelAttribute("cfg") CfgIndexInfo cfg, HttpServletRequest request,
HttpServletResponse response,String tip){
Page<CfgIndexInfo> searchPage=new Page<CfgIndexInfo>(request,response,"a");
Page<CfgIndexInfo> page = objectGroupService.getPolicyListList(searchPage, cfg);
model.addAttribute("page", page);
if(StringUtils.isNotBlank(tip)){
addMessage("error",model,tip);
}
initPageCondition(model,cfg);
return "/cfg/objgroup/list";
}
@RequestMapping(value = { "/form" })
@RequiresPermissions(value = { "objgroup:config" })
public String form(Model model, String ids, CfgIndexInfo entity) {
List<PolicyGroupInfo> ipGroups=new ArrayList<>();
List<PolicyGroupInfo> urlGroups=new ArrayList<>();
List<PolicyGroupInfo> subscribeIdGroups=new ArrayList<>();
List<PolicyGroupInfo> domainGroups=new ArrayList<>();
//查询所有可选择没有被其他配置引用并且组下有域配置的组ud_flag=1
ipGroups=policyGroupInfoService.findPolicyGroupInfosByTypeforUD(Constants.IP_OBJ_GROUP_TYPE,1);
urlGroups=policyGroupInfoService.findPolicyGroupInfosByTypeforUD(Constants.URL_OBJ_GROUP_TYPE,1);
subscribeIdGroups=policyGroupInfoService.findPolicyGroupInfosByTypeforUD(Constants.SUBID_OBJ_GROUP_TYPE,1);
domainGroups=policyGroupInfoService.findPolicyGroupInfosByTypeforUD(Constants.DOMAIN_OBJ_GROUP_TYPE,1);
if (StringUtils.isNotBlank(ids)) {
entity = objectGroupService.getObjectGroupCfg(Long.parseLong(ids), null);
initUpdateFormCondition(model, entity);
//查询配置引用到的分组,加到对应的组下(维持选中选项)
if(MapUtils.isNotEmpty(entity.getUserRegion())){
for(Map.Entry<String,Object> e:entity.getUserRegion().entrySet()){
if(e.getKey().equals("ipGroup")&&StringUtils.isNotBlank(e.getValue().toString())){
List<PolicyGroupInfo> _ipGrpups=policyGroupInfoService.findPolicyByServiceGroupInfoList(e.getValue().toString());
if(CollectionUtils.isNotEmpty(_ipGrpups)){
ipGroups.addAll(_ipGrpups);
}
}else if(e.getKey().equals("urlGroup")&&StringUtils.isNotBlank(e.getValue().toString())){
List<PolicyGroupInfo> _urlGrpups=policyGroupInfoService.findPolicyByServiceGroupInfoList(e.getValue().toString());
if(CollectionUtils.isNotEmpty(_urlGrpups)){
urlGroups.addAll(_urlGrpups);
}
}else if(e.getKey().equals("subscribeIdGroup")&&StringUtils.isNotBlank(e.getValue().toString())){
List<PolicyGroupInfo> _subscribeIdGroups=policyGroupInfoService.findPolicyByServiceGroupInfoList(e.getValue().toString());
if(CollectionUtils.isNotEmpty(_subscribeIdGroups)){
subscribeIdGroups.addAll(_subscribeIdGroups);
}
}else if(e.getKey().equals("domainGroup")&&StringUtils.isNotBlank(e.getValue().toString())){
List<PolicyGroupInfo> _domainGroups=policyGroupInfoService.findPolicyByServiceGroupInfoList(e.getValue().toString());
if(CollectionUtils.isNotEmpty(_domainGroups)){
domainGroups.addAll(_domainGroups);
}
}
}
}
} else {
initFormCondition(model, entity);
}
model.addAttribute("ipGroups", ipGroups);
model.addAttribute("urlGroups", urlGroups);
model.addAttribute("subscribeIdGroups", subscribeIdGroups);
model.addAttribute("domainGroups", domainGroups);
model.addAttribute("_cfg", entity);
return "/cfg/objgroup/form";
}
@RequestMapping(value = {"saveOrUpdate"})
@RequiresPermissions(value={"objgroup:config"})
public String saveOrUpdate(Model model, HttpServletRequest request, HttpServletResponse response,
@ModelAttribute("cfg")CfgIndexInfo cfg, RedirectAttributes redirectAttributes){
try{
String ipGroup=formatMultSelect(request.getParameterValues("ipGroup")),
subscribeIdGroup=formatMultSelect(request.getParameterValues("subscribeIdGroup")),
domainGroup=formatMultSelect(request.getParameterValues("domainGroup")),
urlGroup=formatMultSelect(request.getParameterValues("urlGroup"));
Map<String,Object> map = new HashMap();
if(StringUtils.isNotBlank(ipGroup)&&StringUtils.isNotBlank(ipGroup.replaceAll(",",""))){
map.put("ipGroup", ipGroup);
}
if(StringUtils.isNotBlank(subscribeIdGroup)&&StringUtils.isNotBlank(subscribeIdGroup.replaceAll(",",""))){
map.put("subscribeIdGroup", subscribeIdGroup);
}
if(StringUtils.isNotBlank(domainGroup)&&StringUtils.isNotBlank(domainGroup.replaceAll(",",""))){
map.put("domainGroup", domainGroup);
}
if(StringUtils.isNotBlank(urlGroup)&&StringUtils.isNotBlank(urlGroup.replaceAll(",",""))){
map.put("urlGroup", urlGroup);
}
cfg.setUserRegion(map);
objectGroupService.saveOrUpdate(cfg);
//配置仅保存
if(StringUtil.isEmpty(cfg.getIsValid()) || cfg.getIsValid()!=1) {
addMessage(redirectAttributes, "success", "save_success");
}else {
//配置直接生效
addMessage(redirectAttributes, "success", "audit_success");
}
} catch (MaatConvertException e) {
logger.error("对象组配置下发失败:",e);
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} catch (CallExternalProceduresException e) {
logger.error("调用外部程序出错:",e);
addMessage(redirectAttributes, "error", "call_external_procedures_failed");
LogUtils.saveLog(request, null, e, null);
} catch (Exception e) {
logger.error("对象组配置保存失败:",e);
addMessage(redirectAttributes, "error", "save_failed");
LogUtils.saveLog(request, null, e, null);
}
return "redirect:" + adminPath +"/objgroup/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"updateValid"})
@RequiresPermissions(value={"objgroup:config"})
public String delete(Integer isAudit,Integer isValid,String ids,Integer functionId, RedirectAttributes redirectAttributes,
HttpServletRequest request, HttpServletResponse response, @ModelAttribute("cfg")CfgIndexInfo cfg){
try {
if (!StringUtil.isEmpty(ids)) {
objectGroupService.updatePolicyValid(isValid,ids,functionId);
}else {
// 批量删除
Page<CfgIndexInfo> searchPage = new Page<CfgIndexInfo>(request, response, "a");
deleteAll(searchPage, functionId, cfg);
}
addMessage(redirectAttributes, "success", "delete_success");
} catch (Exception e) {
logger.error("配置删除失败:", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} else {
addMessage(redirectAttributes, "error", "delete_failed");
LogUtils.saveLog(request, null, e, null);
}
}
return "redirect:" + adminPath +"/objgroup/list?functionId="+functionId;
}
/**
* 界面批量删除当前检索条件下的配置
* @param page
* @param functionId
* @param entity
* @throws Exception
*/
public void deleteAll(Page page,Integer functionId, Object entity)throws Exception {
long start=System.currentTimeMillis();
page.setOrderBy("");
page.setPageSize(Constants.MAAT_JSON_SEND_SIZE);
page.setPageNo(1);
page.setLastPage(false);
CfgIndexInfo searchCfg = new CfgIndexInfo();
// 传递检索条件
if(entity != null && (entity instanceof CfgIndexInfo)) {
BeanUtils.copyProperties(entity, searchCfg);
searchCfg.setFunctionId(functionId);
}
BaseCfg batchCfg = new BaseCfg();
batchCfg.setTableName(CfgIndexInfo.getTablename());
batchCfg.setIsValid(-1);
batchCfg.setIsAudit(0);
batchCfg.setEditTime(new Date());
batchCfg.setEditorId(UserUtils.getUser().getId());
//cfg_index_info表中存有servicdId
boolean hasData = true;
while(hasData){
page.setPageNo(1);
page.setLastPage(false);
List<CfgIndexInfo> list = getDataList(page,searchCfg); //获取主配置表数据
if(CollectionUtils.isNotEmpty(list)){
StringBuffer serviceGroupIds=new StringBuffer();
List<BaseCfg> baseCfgList=new ArrayList<>();
for (CfgIndexInfo cfg : list) {
if(cfg.getUserRegion()!=null){
for (Object val:cfg.getUserRegion().values()) {
if(StringUtils.isNotBlank(val.toString())){
if(val.toString().startsWith(",")){
serviceGroupIds.append(val.toString().substring(1));
}else{
serviceGroupIds.append(val.toString());
}
}
}
}
BaseCfg baseCfg=new BaseCfg();
BeanUtils.copyProperties(cfg, baseCfg);
baseCfgList.add(baseCfg);
}
if(StringUtils.isNotBlank(serviceGroupIds)&&serviceGroupIds.lastIndexOf(",")==(serviceGroupIds.toString().length()-1)){
serviceGroupIds.deleteCharAt(serviceGroupIds.toString().length()-1);
}
hasData = objectGroupService.batchDeleteMaatData(page, batchCfg, baseCfgList, hasData,serviceGroupIds.toString());
}else{
hasData = false;
}
}
long end=System.currentTimeMillis();
logger.warn("配置批量删除耗时:"+(end-start));
}
public List getDataList(Page searchPage
,CfgIndexInfo searchCfg
){
BaseCfg baseCfg=new BaseCfg<>();
if(!StringUtil.isEmpty(searchCfg)) {
BeanUtils.copyProperties(searchCfg, baseCfg);
}
Page pageResult=new Page();
pageResult=objectGroupService.getPolicyListList(searchPage,searchCfg);
return pageResult.getList();
}
@RequestMapping(value = {"audit"})
@RequiresPermissions(value={"objgroup:confirm"})
public String audit(Model model,@ModelAttribute("cfg") CfgIndexInfo cfg,
Integer isValid,
Integer isAudit,
String ids,
Integer functionId,
RedirectAttributes redirectAttributes,
HttpServletResponse response,
HttpServletRequest request) {
Properties props=this.getMsgProp();
if(!StringUtil.isEmpty(ids)){
CfgIndexInfo entity = new CfgIndexInfo();
String[] idArray = ids.split(",");
StringBuffer tip=new StringBuffer();
for(String id :idArray){
entity = objectGroupService.getObjectGroupCfg(Long.parseLong(id),null);
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setAuditorId(UserUtils.getUser().getId());
entity.setAuditTime(new Date());
entity.setFunctionId(functionId);
try {
if(StringUtils.isBlank(entity.getCommonGroupIds())){
tip.append(String.format(props.getProperty("no_common_group","The configuration ID of %s does not have an group;"),entity.getCompileId()));
tip.append("<br/>");
}else{
objectGroupService.auditPolicy(entity,isAudit,Constants.INSERT_ACTION);
}
if(tip.toString().length()>0){
addMessage(redirectAttributes,"error", tip.toString());
}else{
addMessage(redirectAttributes,"success", "audit_success");
}
} catch ( Exception e) {
logger.error("策略对象组下发失败:"+e);
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error","request_service_failed");
LogUtils.saveLog(request, null, e, null);
}else {
addMessage(redirectAttributes,"error","audit_failed");
LogUtils.saveLog(request, null, e, null);
}
}
}
}else {
Page<CfgIndexInfo> searchPage=new Page<CfgIndexInfo>(request,response,"r");
Page<CfgIndexInfo> auditPage=new Page<CfgIndexInfo>(request,response,"r");
String tip=null;
try {
BeanUtils.copyProperties(searchPage, auditPage);
tip= auditAll(auditPage,isValid , cfg,props);
if(tip.toString().length()>0){
addMessage(redirectAttributes,"error", tip.toString());
}else{
addMessage(redirectAttributes,"success", "audit_success");
}
} catch (Exception e) {
logger.error("策略对象组下发失败:",e);
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
}else {
addMessage(redirectAttributes,"error", "audit_failed");
LogUtils.saveLog(request, null, e, null);
}
}
//无法保存状态
return list(model, cfg, request, response,tip);
}
return "redirect:" + adminPath +"/objgroup/list?functionId="+functionId;
}
private String formatMultSelect(Object requestParameter){
if(StringUtil.isEmpty(requestParameter)){
return null;
}else if(requestParameter.getClass().isArray()){
String[] array=(String[])requestParameter;
StringBuffer buf=new StringBuffer(",");
for(String param:array){
buf.append(param).append(",");
}
return buf.toString().length()==1?null:buf.toString();
}else{
return ","+requestParameter.toString()+",";
}
}
@RequestMapping(value = { "/ajaxGetNames" })
@ResponseBody
public Map<String,Map<String,String>> ajaxGetNames(Model model, @RequestParam(required=true,value="groupIds")String group) {
String _group=group.replaceAll("\\|",",");
Map<String,Map<String,String>> datas=new HashMap<>();
datas.put("ipGroup",new HashMap<String,String>());
datas.put("urlGroup",new HashMap<String,String>());
datas.put("subscribeIdGroup",new HashMap<String,String>());
datas.put("domainGroup",new HashMap<String,String>());
if(StringUtils.isNotBlank(group)){
List<PolicyGroupInfo> infos=policyGroupInfoService.findPolicyByServiceGroupInfoList(_group);
for(PolicyGroupInfo info:infos){
for(String g:group.split("\\|")){
if(objectGroupService.indexOfContains(g,",",info.getServiceGroupId().toString())){
Map<String,String> map=null;
if(info.getGroupType().equals(Constants.IP_OBJ_GROUP_TYPE)){
map=datas.get("ipGroup");
}else if(info.getGroupType().equals(Constants.URL_OBJ_GROUP_TYPE)){
map=datas.get("urlGroup");
}else if(info.getGroupType().equals(Constants.SUBID_OBJ_GROUP_TYPE)){
map=datas.get("subscribeIdGroup");
}else if(info.getGroupType().equals(Constants.DOMAIN_OBJ_GROUP_TYPE)){
map=datas.get("domainGroup");
}
map.put(g,map.containsKey(g)?map.get(g)+info.getGroupName()+",":info.getGroupName()+",");
}
}
}
}
//删除最后的逗号
for(Map<String,String> m:datas.values()){
for(Map.Entry<String,String> e:m.entrySet()){
if(e.getValue().endsWith(",")){
m.put(e.getKey(),e.getValue().substring(0,e.getValue().length()-1));
}
}
}
return datas;
}
//http配置导出
@RequestMapping(value = "exportObjGroup")
public void exportdomain(Model model, HttpServletRequest request, HttpServletResponse response,
@ModelAttribute("cfg") ObjGroupCfg entity, String ids, RedirectAttributes redirectAttributes){
try {
//export data info
List<String> titleList=new ArrayList<String>();
Map<String, Class<?>> classMap=new HashMap<String, Class<?>>();
Map<String, List> dataMap=new HashMap<String, List>();
Map<String, String> noExportMap = new HashMap<String, String>();
List<ObjGroupCfg> lists = new ArrayList<ObjGroupCfg>();
Properties msgProp = getMsgProp();
// 导出选中记录
if (!StringUtil.isEmpty(ids)) {
lists = objectGroupService.getObjGroupList(ids,msgProp,entity.getFunctionId());
} else {
Page<ObjGroupCfg> pageInfo=new Page<ObjGroupCfg>(request, response,"a");
pageInfo.setPageNo(1);
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
Page<ObjGroupCfg> page = objectGroupService.getObjGroup(pageInfo, entity,msgProp);
lists = page.getList();
}
for(ObjGroupCfg c:lists){
if(StringUtils.isNotBlank(c.getIpGroup())&&c.getIpGroup().startsWith(",")){
c.setIpGroup(c.getIpGroup().substring(1));
}
if(StringUtils.isNotBlank(c.getUrlGroup())&&c.getUrlGroup().startsWith(",")){
c.setUrlGroup(c.getUrlGroup().substring(1));
}
if(StringUtils.isNotBlank(c.getSubscribeIdGroup())&&c.getSubscribeIdGroup().startsWith(",")){
c.setSubscribeIdGroup(c.getSubscribeIdGroup().substring(1));
}
if(StringUtils.isNotBlank(c.getDomainGroup())&&c.getDomainGroup().startsWith(",")){
c.setDomainGroup(c.getDomainGroup().substring(1));
}
}
titleList.add(entity.getMenuNameCode());
classMap.put(entity.getMenuNameCode(), ObjGroupCfg.class);
String cfgIndexInfoNoExport=",policy_name,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
// 时间过滤
if (entity.getSearch_create_time_start() == null) {
cfgIndexInfoNoExport = ",config_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_edit_time_start() == null) {
cfgIndexInfoNoExport = ",edit_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_audit_time_start() == null) {
cfgIndexInfoNoExport = ",audit_time" + cfgIndexInfoNoExport;
}
if (!StringUtil.isEmpty(entity.gethColumns())) {
cfgIndexInfoNoExport = "," + entity.gethColumns() + "," + cfgIndexInfoNoExport;
}
noExportMap.put(entity.getMenuNameCode(),cfgIndexInfoNoExport);
dataMap.put(entity.getMenuNameCode(), lists);
String timeRange = initTimeMap(entity);
noExportMap.put("timeRange", timeRange);
if ("csv".equals(entity.getExType())) {
this._exportCsv(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
}
} catch (Exception e) {
logger.error("Obj group export failed",e);
addMessage(redirectAttributes,"error", "export_failed");
LogUtils.saveLog(request, null, e, null);
}
}
/**
* 批量审核
* @param page
* @param auditType
* @param entity
* @return
*/
public String auditAll(Page page,Integer auditType,CfgIndexInfo entity,Properties props)throws Exception {
StringBuffer tip=new StringBuffer();
long start=System.currentTimeMillis();
page.setOrderBy("");
page.setPageSize(Constants.MAAT_JSON_SEND_SIZE);
page.setPageNo(1);
page.setLastPage(false);
//携带审核状态信息的BaseCfg
BaseCfg auditBatchCfg=new BaseCfg();
//携带审核条件的BaseCfg
CfgIndexInfo searchCfg=new CfgIndexInfo();
if(entity != null && (entity instanceof CfgIndexInfo)) {
BeanUtils.copyProperties(entity, auditBatchCfg);
BeanUtils.copyProperties(entity, searchCfg);
}
auditType = (Integer)Reflections.invokeGetter(entity, "isAudit");
//全部审核通过,只查询当前条件下的所有未审核的配置 -批量审核通过/不通过
if(auditType.equals(1) || auditType.equals(2)) {
if(auditType.equals(1)) {
auditBatchCfg.setIsAudit(1);
auditBatchCfg.setIsValid(1);
}else {
auditBatchCfg.setIsAudit(2);
auditBatchCfg.setIsValid(0);
}
auditBatchCfg.setAuditTime(new Date());
auditBatchCfg.setAuditorId(UserUtils.getUser().getId());
}else {
auditBatchCfg.setIsAudit(3);
auditBatchCfg.setIsValid(0);
auditBatchCfg.setAuditTime(new Date());
auditBatchCfg.setAuditorId(UserUtils.getUser().getId());
}
ServiceConfigTemplateUtil serviceTemplate = new ServiceConfigTemplateUtil();
Integer functionId=0;
if(auditBatchCfg != null && !StringUtil.isEmpty(auditBatchCfg.getFunctionId())) {
functionId=auditBatchCfg.getFunctionId();
}
List<Map<String,Object>> serviceList = serviceTemplate.getServiceListByFunctionId(functionId);
for(Map<String,Object> service:serviceList){
String tableNameXml = service.get("tableName").toString(); // 获取业务主配置表
String serviceTypeXml = service.get("serviceType").toString(); // 业务类型 1maat 2callback
String classNameXml = service.get("className").toString(); // 主配置Java类
String serviceIdXml = service.get("id").toString(); // service字典表 service_id字段
String serviceIds=service.get("serviceIds").toString();
auditBatchCfg.setServiceId(Integer.valueOf(serviceIdXml));
auditBatchCfg.setTableName(tableNameXml);
//searchCfg.setServiceId(Integer.valueOf(serviceIdXml));
searchCfg.setTableName(tableNameXml);
if("1".equals(serviceTypeXml)){//maat类配置
if(StringUtils.isNotBlank(serviceIds)) {//公共分组
// 存放域配置类型 及 对应表名
Map<Integer,List<Map<String,Object>>> childrenCfgMap=new HashMap<>();
Map<Integer,List<Map<String,Object>>> childrenUserRegionMap=new HashMap<>();
for(String _serviceId:serviceIds.split(",")){
if(StringUtils.isNotBlank(_serviceId)){
Map<String,Object> subService=serviceTemplate.getServiceListByServiceId(Integer.parseInt(_serviceId)).get(0);
childrenCfgMap.put(Integer.parseInt(_serviceId),(List<Map<String,Object>>)subService.get("cfgList"));
}
}
if(childrenCfgMap.size()>0){
for(Map.Entry e:childrenCfgMap.entrySet()){
boolean hasData = true;
while(hasData){
page.setPageNo(1);
page.setLastPage(false);
searchCfg.setServiceId(Integer.parseInt(e.getKey().toString()));
auditBatchCfg.setServiceId(Integer.parseInt(e.getKey().toString()));
List<CfgIndexInfo> list = getDataList(page,searchCfg,null,null,null); // 通过ServiceId获取cfg_index_info主配置表数据
for(CfgIndexInfo info:list){
if(StringUtils.isBlank(info.getCommonGroupIds())){
tip.append(String.format(props.getProperty("no_common_group","The configuration ID of %s does not have an group;"),info.getCompileId()));
tip.append("<br/>");
}
}
if(!StringUtil.isEmpty(list)){
//配置生效处理 复用全量下发
if(auditBatchCfg.getIsAudit().equals(1)) {
hasData = configSynchronizationService.auditObjGroupListMaatData(childrenCfgMap,childrenUserRegionMap,page,auditBatchCfg,list,hasData,true);
}else {
List<BaseCfg> BaseCfgList=new ArrayList<>();
if(!StringUtil.isEmpty(list)) {
for (CfgIndexInfo cfg : list) {
BaseCfg baseCfg=new BaseCfg();
BeanUtils.copyProperties(cfg, baseCfg);
BaseCfgList.add(baseCfg);
}
}
if(auditBatchCfg.getIsAudit().equals(2)) {// 配置批量审核不通过
hasData = commonPolicyService.batchUnApproveObjGroupListatData(page, auditBatchCfg, BaseCfgList, hasData);
}else {// 配置失效处理 批量处理
hasData = commonPolicyService.auditObjGroupListMaatData(tableNameXml, page, auditBatchCfg, BaseCfgList, hasData);
}
}
}else{
hasData = false;
}
}
}
}
}
}
}
//批量审核通过时如果没有携带isValid检索条件返回界面需要将isValid置为null
if(!StringUtil.isEmpty(entity)) {
BaseCfg base=(BaseCfg)entity ;
base.setBatchAuditValue("");
base.setBatchValidValue("");
//配置目标状态1 1 生效,isAudit条件置为1有selType条件,且不是isValid不改没有sel改为isValid并且为1
if(base.getIsAudit()==1 && base.getIsValid()==1){
base.setIsAudit(1);
if(!StringUtil.isEmpty(base.getSeltype()) && !base.getSeltype().equals("isValid")) {
base.setIsValid(null);
}else{
base.setIsValid(1);
base.setSeltype("isValid");
}
}
//配置目标状态2 0 不通过,isAudit条件置为2有selType条件,且不是isValid不改没有sel改为isValid并且为0
if(base.getIsAudit()==2 && base.getIsValid()==0){
base.setIsAudit(2);
if(!StringUtil.isEmpty(base.getSeltype()) && !base.getSeltype().equals("isValid")) {
base.setIsValid(null);
}else{
base.setIsValid(0);
base.setSeltype("isValid");
}
}
//配置目标状态3 0 取消
if(base.getIsAudit()==3 && base.getIsValid()==0){
base.setIsAudit(3);
if(!StringUtil.isEmpty(base.getSeltype()) && !base.getSeltype().equals("isValid")) {
base.setIsValid(null);
}else{
base.setIsValid(0);
base.setSeltype("isValid");
}
}
BeanUtils.copyProperties(base, entity);
}
long end=System.currentTimeMillis();
logger.warn("配置批量生效/失效耗时:"+(end-start));
return tip.toString();
}
@RequestMapping(value = { "ajaxSubList"})
public String ajaxSubList(Model model, Long cfgId, Integer index, Integer compileId) {
CfgIndexInfo cfg = objectGroupService.getObjectGroupCfg(cfgId, null);
List<String[]> tabList = new ArrayList();
model.addAttribute("_cfg", cfg);
model.addAttribute("index", index);
model.addAttribute("tabList", tabList);
return "/cfg/objgroup/subList";
}
}

View File

@@ -250,7 +250,7 @@ public class DnsIpCfgController extends BaseController {
} }
titleList.add(entity.getMenuNameCode()); titleList.add(entity.getMenuNameCode());
classMap.put(entity.getMenuNameCode(), DnsIpCfg.class); classMap.put(entity.getMenuNameCode(), DnsIpCfg.class);
String cfgIndexInfoNoExport = ",log_total,whether_area_block,client_ip,src_ip_pattern,src_port_pattern,dest_port_pattern,client_port,server_port,ir_type,direction,protocol,do_log,client_port,ir_type,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,"; String cfgIndexInfoNoExport = ",log_total,whether_area_block,client_ip,port_pattern,client_port,server_port,ir_type,direction,protocol,do_log,client_port,ir_type,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
// 时间过滤 // 时间过滤
if (entity.getSearch_create_time_start() == null && entity.getSearch_create_time_end() == null) { if (entity.getSearch_create_time_start() == null && entity.getSearch_create_time_end() == null) {

View File

@@ -40,6 +40,7 @@ import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.IpReuseDnatPolicyCfg; import com.nis.domain.configuration.IpReuseDnatPolicyCfg;
import com.nis.domain.configuration.IpReusePolicyCfg; import com.nis.domain.configuration.IpReusePolicyCfg;
import com.nis.domain.configuration.UserManage; import com.nis.domain.configuration.UserManage;
import com.nis.domain.configuration.template.IpMultiplexPolicyTemplate;
import com.nis.exceptions.MaatConvertException; import com.nis.exceptions.MaatConvertException;
import com.nis.util.ConfigServiceUtil; import com.nis.util.ConfigServiceUtil;
import com.nis.util.Constants; import com.nis.util.Constants;
@@ -120,6 +121,26 @@ public class IpMultiplexController extends CommonController {
return "redirect:" + adminPath + "/manipulation/ipmulitiplex/list?functionId=" + cfg.getFunctionId(); return "redirect:" + adminPath + "/manipulation/ipmulitiplex/list?functionId=" + cfg.getFunctionId();
} }
// ip配置导入
/*
* @RequestMapping(value = "/import", method=RequestMethod.POST) public
* String importIp(String cfgName,RedirectAttributes redirectAttributes,
*
* @RequestParam("file") MultipartFile file,IpPortCfg cfg) {
* this._importIp(cfgName,redirectAttributes,
* file,cfg,IpMultiplexPolicyTemplate.class);
* redirectAttributes.addAttribute("urlPrefix","/manipulation/ipmulitiplex")
* ; redirectAttributes.addAttribute("requiresPermissionPrefix",
* "ip:mulitiplex"); return "redirect:" + adminPath
* +"/manipulation/ipmulitiplex/list?functionId="+cfg.getFunctionId(); }
*/
// ip模板下载
@RequestMapping(value = "import/template")
public void importFileTemplate(HttpServletRequest request, HttpServletResponse response,
RedirectAttributes redirectAttributes, Integer functionId, Integer cfgRegionCode) {
this._importFileTemplate(request, response, redirectAttributes, functionId, cfgRegionCode,
IpMultiplexPolicyTemplate.class);
}
// ip配置导出 // ip配置导出
@RequestMapping(value = "export") @RequestMapping(value = "export")

View File

@@ -112,7 +112,20 @@ public class RatelimitController extends CommonController {
redirectAttributes.addAttribute("requiresPermissionPrefix","domain:ratelimit"); redirectAttributes.addAttribute("requiresPermissionPrefix","domain:ratelimit");
return "redirect:" + adminPath +"/manipulation/ratelimit/domain/list?functionId="+cfg.getFunctionId(); return "redirect:" + adminPath +"/manipulation/ratelimit/domain/list?functionId="+cfg.getFunctionId();
} }
//ip配置导入
/*@RequestMapping(value = "/ip/import", method=RequestMethod.POST)
public String importIp(String cfgName,RedirectAttributes redirectAttributes,
@RequestParam("file") MultipartFile file,IpPortCfg cfg) {
this._importIp(cfgName,redirectAttributes, file,cfg,IpRateLimitTemplate.class);
redirectAttributes.addAttribute("urlPrefix","/manipulation/ratelimit/ip");
redirectAttributes.addAttribute("requiresPermissionPrefix","ip:ratelimit");
return "redirect:" + adminPath +"/manipulation/ratelimit/ip/list?functionId="+cfg.getFunctionId();
}*/
@RequestMapping(value = "/ip/import/template")
public void importFileTemplate(HttpServletRequest request,HttpServletResponse response,
RedirectAttributes redirectAttributes,Integer functionId,Integer cfgRegionCode) {
this._importFileTemplate(request, response, redirectAttributes, functionId, cfgRegionCode,IpRateLimitTemplate.class);
}
//ip配置导出 //ip配置导出
@RequestMapping(value = "/ip/export") @RequestMapping(value = "/ip/export")
public void exportIp(String columns,Model model,HttpServletRequest request,HttpServletResponse response, public void exportIp(String columns,Model model,HttpServletRequest request,HttpServletResponse response,

View File

@@ -311,13 +311,7 @@ public class AvController extends BaseController {
} }
avCfgService.saveOrUpdateAvFileSample(entity, srcFile); avCfgService.saveOrUpdateAvFileSample(entity, srcFile);
//配置仅保存 addMessage(redirectAttributes, "success", "save_success");
if(StringUtil.isEmpty(entity.getIsValid()) || entity.getIsValid()!=1) {
addMessage(redirectAttributes, "success", "save_success");
}else {
//配置直接生效
addMessage(redirectAttributes, "success", "audit_success");
}
} catch (Exception e) { } catch (Exception e) {
logger.error("文件上传失败", e); logger.error("文件上传失败", e);
e.printStackTrace(); e.printStackTrace();
@@ -345,13 +339,7 @@ public class AvController extends BaseController {
RedirectAttributes redirectAttributes, String ids, AvSignSampleCfg entity) { RedirectAttributes redirectAttributes, String ids, AvSignSampleCfg entity) {
try { try {
avCfgService.saveOrUpdateAvSignSample(entity); avCfgService.saveOrUpdateAvSignSample(entity);
//配置仅保存 addMessage(redirectAttributes, "success", "save_success");
if(StringUtil.isEmpty(entity.getIsValid()) || entity.getIsValid()!=1) {
addMessage(redirectAttributes, "success", "save_success");
}else {
//配置直接生效
addMessage(redirectAttributes, "success", "audit_success");
}
} catch (Exception e) { } catch (Exception e) {
logger.error("saveAudioSignSample failed", e); logger.error("saveAudioSignSample failed", e);
e.printStackTrace(); e.printStackTrace();
@@ -603,13 +591,7 @@ public class AvController extends BaseController {
// if(!avSignSampleCfg.getAction().equals(avSignSampleCfg.getActionOld())||!avSignSampleCfg.getIsValid().equals(avSignSampleCfg.getIsValidOld())){ // if(!avSignSampleCfg.getAction().equals(avSignSampleCfg.getActionOld())||!avSignSampleCfg.getIsValid().equals(avSignSampleCfg.getIsValidOld())){
try { try {
avCfgService.auditAvSignSample(avSignSampleCfg); avCfgService.auditAvSignSample(avSignSampleCfg);
//配置仅保存 addMessage(redirectAttributes, "success", "save_success");
if(StringUtil.isEmpty(avSignSampleCfg.getIsValid()) || avSignSampleCfg.getIsValid()!=1) {
addMessage(redirectAttributes, "success", "save_success");
}else {
//配置直接生效
addMessage(redirectAttributes, "success", "audit_success");
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
if (e instanceof MaatConvertException) { if (e instanceof MaatConvertException) {

View File

@@ -307,13 +307,7 @@ public class FileTransferCfgController extends BaseController {
logger.info("获取文件摘要响应信息:" + result); logger.info("获取文件摘要响应信息:" + result);
} }
fileTransferCfgService.saveOrUpdateFileDigestCfg(entity, result, areaCfgIds); fileTransferCfgService.saveOrUpdateFileDigestCfg(entity, result, areaCfgIds);
//配置仅保存 addMessage(redirectAttributes, "success", "save_success");
if(StringUtil.isEmpty(entity.getIsValid()) || entity.getIsValid()!=1) {
addMessage(redirectAttributes, "success", "save_success");
}else {
//配置直接生效
addMessage(redirectAttributes, "success", "audit_success");
}
} catch (MaatConvertException e) { } catch (MaatConvertException e) {
logger.error("文件摘要配置下发失败:",e); logger.error("文件摘要配置下发失败:",e);
addMessage(redirectAttributes, "error", "request_service_failed"); addMessage(redirectAttributes, "error", "request_service_failed");

View File

@@ -27,6 +27,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.nis.domain.FunctionRegionDict; import com.nis.domain.FunctionRegionDict;
import com.nis.domain.FunctionServiceDict; import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page; import com.nis.domain.Page;
import com.nis.domain.configuration.AppPolicyCfg;
import com.nis.domain.configuration.AsnKeywordCfg; import com.nis.domain.configuration.AsnKeywordCfg;
import com.nis.domain.configuration.CfgIndexInfo; import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.IpPortCfg; import com.nis.domain.configuration.IpPortCfg;
@@ -41,7 +42,6 @@ import com.nis.domain.configuration.template.DnsComplexStringTemplate;
import com.nis.domain.configuration.template.DnsFakeIpTemplate; import com.nis.domain.configuration.template.DnsFakeIpTemplate;
import com.nis.domain.configuration.template.DnsIpTemplate; import com.nis.domain.configuration.template.DnsIpTemplate;
import com.nis.domain.configuration.template.DnsResStrategyTemplate; import com.nis.domain.configuration.template.DnsResStrategyTemplate;
import com.nis.domain.configuration.template.DomainCommCfgTemplate;
import com.nis.domain.configuration.template.DomainInterceptMonitTemplate; import com.nis.domain.configuration.template.DomainInterceptMonitTemplate;
import com.nis.domain.configuration.template.DomainInterceptRateLimitTemplate; import com.nis.domain.configuration.template.DomainInterceptRateLimitTemplate;
import com.nis.domain.configuration.template.DomainInterceptTemplate; import com.nis.domain.configuration.template.DomainInterceptTemplate;
@@ -54,23 +54,19 @@ import com.nis.domain.configuration.template.HttpsRejectTemplate;
import com.nis.domain.configuration.template.HttpsReplaceComplexTemplate; import com.nis.domain.configuration.template.HttpsReplaceComplexTemplate;
import com.nis.domain.configuration.template.HttpsReplaceIpTemplate; import com.nis.domain.configuration.template.HttpsReplaceIpTemplate;
import com.nis.domain.configuration.template.HttpsReplaceTemplate; import com.nis.domain.configuration.template.HttpsReplaceTemplate;
import com.nis.domain.configuration.template.InterceptDomainTemplate;
import com.nis.domain.configuration.template.InterceptIpTemplate;
import com.nis.domain.configuration.template.IpAllNotDoLogTemplate; import com.nis.domain.configuration.template.IpAllNotDoLogTemplate;
import com.nis.domain.configuration.template.IpAllTemplate; import com.nis.domain.configuration.template.IpAllTemplate;
import com.nis.domain.configuration.template.IpCommCfgTemplate;
import com.nis.domain.configuration.template.IpPayloadTemplate; import com.nis.domain.configuration.template.IpPayloadTemplate;
import com.nis.domain.configuration.template.IpRateLimitTemplate; import com.nis.domain.configuration.template.IpRateLimitTemplate;
import com.nis.domain.configuration.template.IpSpoofingTemplate; import com.nis.domain.configuration.template.IpSpoofingTemplate;
import com.nis.domain.configuration.template.IpWhitelistTemplate; import com.nis.domain.configuration.template.IpWhitelistTemplate;
import com.nis.domain.configuration.template.P2pHashStringTemplate; import com.nis.domain.configuration.template.P2pHashStringTemplate;
import com.nis.domain.configuration.template.P2pIpTemplate; import com.nis.domain.configuration.template.P2pIpTemplate;
import com.nis.domain.configuration.template.ScriberIdCommCfgTemplate;
import com.nis.domain.configuration.template.SnatTemplate; import com.nis.domain.configuration.template.SnatTemplate;
import com.nis.domain.configuration.template.StringAllNotDoLogTemplate; import com.nis.domain.configuration.template.StringAllNotDoLogTemplate;
import com.nis.domain.configuration.template.StringAllTemplate; import com.nis.domain.configuration.template.StringAllTemplate;
import com.nis.domain.configuration.template.TopicWebsiteTemplate; import com.nis.domain.configuration.template.TopicWebsiteTemplate;
import com.nis.domain.configuration.template.UrlCommCfgTemplate; import com.nis.domain.specific.SpecificServiceCfg;
import com.nis.exceptions.MaatConvertException; import com.nis.exceptions.MaatConvertException;
import com.nis.util.Constants; import com.nis.util.Constants;
import com.nis.util.DictUtils; import com.nis.util.DictUtils;
@@ -202,7 +198,8 @@ public class IpController extends BaseController{
* *
* @param model * @param model
* @param cfg * @param cfg
* @param isAudit 审核类型 批量审核时使用1批量生效0批量失效 * @param auditType 审核类型 批量审核时使用1批量生效0批量失效
* @param isAudit
* @param isValid * @param isValid
* @param ids * @param ids
* @param functionId * @param functionId
@@ -343,12 +340,10 @@ public class IpController extends BaseController{
,Integer serviceDictId ,Integer serviceDictId
,Integer regionDictId ,Integer regionDictId
,Integer requestId ,Integer requestId
,Integer manipulatType
) { ) {
try { try {
FunctionRegionDict regionDict=DictUtils.getFunctionRegionDict(regionDictId); FunctionRegionDict regionDict=DictUtils.getFunctionRegionDict(regionDictId);
FunctionServiceDict serviceDict=DictUtils.getFunctionServiceDict(serviceDictId); FunctionServiceDict serviceDict=DictUtils.getFunctionServiceDict(serviceDictId);
regionDict.setAction(manipulatType);
exportTemplate(request,response,redirectAttributes,regionDict,serviceDict,requestId); exportTemplate(request,response,redirectAttributes,regionDict,serviceDict,requestId);
} catch (Exception e) { } catch (Exception e) {
logger.error("export_failed", e); logger.error("export_failed", e);
@@ -450,29 +445,6 @@ public class IpController extends BaseController{
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, HttpsReplaceIpTemplate.class, 2); ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, HttpsReplaceIpTemplate.class, 2);
excel.setDataList(pro,classList,null). excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose(); write(request,response, fileName).dispose();
}else if(regionDict.getFunctionId().equals(215)){// HTTP(s)操控(阻断+重定向+替换)
if(regionDict.getAction() == 16) {
List<HttpsRejectIpTemplate> classList=new ArrayList<HttpsRejectIpTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, HttpsRejectIpTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else if(regionDict.getAction() == 48) {
List<HttpsRedirectIpTemplate> classList=new ArrayList<HttpsRedirectIpTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, HttpsRedirectIpTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else if(regionDict.getAction() == 80) {
List<HttpsReplaceIpTemplate> classList=new ArrayList<HttpsReplaceIpTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, HttpsReplaceIpTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else {
List<IpAllTemplate> classList=new ArrayList<IpAllTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, IpAllTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}
}else if(regionDict.getFunctionId().equals(211)){// HTTP(s)白名单 }else if(regionDict.getFunctionId().equals(211)){// HTTP(s)白名单
List<IpAllNotDoLogTemplate> classList=new ArrayList<IpAllNotDoLogTemplate>(); List<IpAllNotDoLogTemplate> classList=new ArrayList<IpAllNotDoLogTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, IpAllNotDoLogTemplate.class, 2); ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, IpAllNotDoLogTemplate.class, 2);
@@ -484,12 +456,7 @@ public class IpController extends BaseController{
ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, IpRateLimitTemplate.class, 2); ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, IpRateLimitTemplate.class, 2);
excel.setDataList(pro,classList,null). excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose(); write(request,response, fileName).dispose();
}else if(serviceDict.getAction().equals(2)){//forward }else {
List<InterceptIpTemplate> classList=new ArrayList<InterceptIpTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, InterceptIpTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else{
List<IpAllNotDoLogTemplate> classList=new ArrayList<IpAllNotDoLogTemplate>(); List<IpAllNotDoLogTemplate> classList=new ArrayList<IpAllNotDoLogTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, IpAllNotDoLogTemplate.class, 2); ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, IpAllNotDoLogTemplate.class, 2);
excel.setDataList(pro,classList,null). excel.setDataList(pro,classList,null).
@@ -511,11 +478,6 @@ public class IpController extends BaseController{
ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, IpRateLimitTemplate.class, 2); ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, IpRateLimitTemplate.class, 2);
excel.setDataList(pro,classList,null). excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose(); write(request,response, fileName).dispose();
}else if(regionDict.getFunctionId().equals(605)){// IP Common Group
List<IpCommCfgTemplate> classList=new ArrayList<IpCommCfgTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, IpCommCfgTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else{ }else{
List<IpAllTemplate> classList=new ArrayList<IpAllTemplate>(); List<IpAllTemplate> classList=new ArrayList<IpAllTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, IpAllTemplate.class, 2); ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, IpAllTemplate.class, 2);
@@ -536,9 +498,9 @@ public class IpController extends BaseController{
excel.setDataList(pro,classList,null). excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose(); write(request,response, fileName).dispose();
}else if(regionDict.getFunctionId().equals(200)){// 拦截策略(域名) }else if(regionDict.getFunctionId().equals(200)){// 拦截策略(域名)
if(serviceDict.getAction().equals(2)){// forward if(serviceDict.getAction().equals(1)){// 监测
List<InterceptDomainTemplate> classList=new ArrayList<InterceptDomainTemplate>(); List<DomainInterceptMonitTemplate> classList=new ArrayList<DomainInterceptMonitTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, InterceptDomainTemplate.class, 2); ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, DomainInterceptMonitTemplate.class, 2);
excel.setDataList(pro,classList,null). excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose(); write(request,response, fileName).dispose();
}else if(serviceDict.getAction().equals(64)){// 限速 }else if(serviceDict.getAction().equals(64)){// 限速
@@ -567,29 +529,6 @@ public class IpController extends BaseController{
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, HttpsReplaceTemplate.class, 2); ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, HttpsReplaceTemplate.class, 2);
excel.setDataList(pro,classList,null). excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose(); write(request,response, fileName).dispose();
}else if(regionDict.getFunctionId().equals(215)){// HTTP(s)操控
if(regionDict.getAction() == 16) {
List<HttpsRejectTemplate> classList=new ArrayList<HttpsRejectTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, HttpsRejectTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else if(regionDict.getAction() == 48) {
List<HttpsRedirectTemplate> classList=new ArrayList<HttpsRedirectTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, HttpsRedirectTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else if(regionDict.getAction() == 80) {
List<HttpsReplaceTemplate> classList=new ArrayList<HttpsReplaceTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, HttpsReplaceTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else {
List<StringAllTemplate> classList=new ArrayList<StringAllTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, StringAllTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}
}else if(regionDict.getFunctionId().equals(211)){// HTTP(s)白名单 }else if(regionDict.getFunctionId().equals(211)){// HTTP(s)白名单
List<StringAllNotDoLogTemplate> classList=new ArrayList<StringAllNotDoLogTemplate>(); List<StringAllNotDoLogTemplate> classList=new ArrayList<StringAllNotDoLogTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, StringAllNotDoLogTemplate.class, 2); ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, StringAllNotDoLogTemplate.class, 2);
@@ -600,21 +539,6 @@ public class IpController extends BaseController{
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, TopicWebsiteTemplate.class, 2); ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, TopicWebsiteTemplate.class, 2);
excel.setDataList(pro,classList,null). excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose(); write(request,response, fileName).dispose();
}else if(regionDict.getFunctionId().equals(606)) {// URL Common Group
List<UrlCommCfgTemplate> classList=new ArrayList<UrlCommCfgTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, UrlCommCfgTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else if(regionDict.getFunctionId().equals(607)) {// Domain Common Group
List<DomainCommCfgTemplate> classList=new ArrayList<DomainCommCfgTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, DomainCommCfgTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else if(regionDict.getFunctionId().equals(608)) {// ScriberId Common Group
List<ScriberIdCommCfgTemplate> classList=new ArrayList<ScriberIdCommCfgTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, ScriberIdCommCfgTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else{ }else{
List<StringAllTemplate> classList=new ArrayList<StringAllTemplate>(); List<StringAllTemplate> classList=new ArrayList<StringAllTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, StringAllTemplate.class, 2); ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, StringAllTemplate.class, 2);
@@ -645,29 +569,6 @@ public class IpController extends BaseController{
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, HttpsReplaceComplexTemplate.class, 2); ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, HttpsReplaceComplexTemplate.class, 2);
excel.setDataList(pro,classList,null). excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose(); write(request,response, fileName).dispose();
}else if(regionDict.getFunctionId().equals(215)){// HTTP(s)操控
if(regionDict.getAction() == 16) {
List<HttpsRejectComplexTemplate> classList=new ArrayList<HttpsRejectComplexTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, HttpsRejectComplexTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else if(regionDict.getAction() == 48) {
List<HttpsRedirectComplexTemplate> classList=new ArrayList<HttpsRedirectComplexTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, HttpsRedirectComplexTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else if(regionDict.getAction() == 80) {
List<HttpsReplaceComplexTemplate> classList=new ArrayList<HttpsReplaceComplexTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, HttpsReplaceComplexTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}else {
List<ComplexStringAllTemplate> classList=new ArrayList<ComplexStringAllTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, ComplexStringAllTemplate.class, 2);
excel.setDataList(pro,classList,null).
write(request,response, fileName).dispose();
}
}else if(regionDict.getFunctionId().equals(211)){// HTTP(s)白名单 }else if(regionDict.getFunctionId().equals(211)){// HTTP(s)白名单
List<ComplexStringAllNotDoLogTemplate> classList=new ArrayList<ComplexStringAllNotDoLogTemplate>(); List<ComplexStringAllNotDoLogTemplate> classList=new ArrayList<ComplexStringAllNotDoLogTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, ComplexStringAllNotDoLogTemplate.class, 2); ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, ComplexStringAllNotDoLogTemplate.class, 2);
@@ -709,12 +610,9 @@ public class IpController extends BaseController{
,String attribute ,String attribute
,String classify ,String classify
,String regionDictIds ,String regionDictIds
,String importPath ,String importPath) {
,Integer manipulatType this._import(request,response,redirectAttributes, files,serviceDictId,regionDictIds,requestId,attribute,classify);
,Integer profileId) { return "redirect:" + adminPath+ importPath;
this._import(request,response,redirectAttributes, files,serviceDictId,regionDictIds,requestId,attribute,classify,manipulatType,profileId);
return "redirect:" + adminPath+ importPath;
} }
//ip配置导出 //ip配置导出
@RequestMapping(value = "exportIpAddr") @RequestMapping(value = "exportIpAddr")

View File

@@ -14,11 +14,15 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.taglibs.standard.functions.Functions;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.nis.domain.FunctionRegionDict; import com.nis.domain.FunctionRegionDict;
@@ -27,6 +31,10 @@ import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CfgIndexInfo; import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.ComplexkeywordCfg; import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.domain.configuration.DnsResStrategy; import com.nis.domain.configuration.DnsResStrategy;
import com.nis.domain.configuration.ComplexStringCfgTemplate;
import com.nis.domain.configuration.template.IpCfgTemplate;
import com.nis.domain.specific.ConfigGroupInfo;
import com.nis.domain.configuration.StringCfgTemplate;
import com.nis.domain.configuration.HttpBodyCfg; import com.nis.domain.configuration.HttpBodyCfg;
import com.nis.domain.configuration.HttpReqHeadCfg; import com.nis.domain.configuration.HttpReqHeadCfg;
import com.nis.domain.configuration.HttpResHeadCfg; import com.nis.domain.configuration.HttpResHeadCfg;
@@ -39,6 +47,7 @@ import com.nis.util.Constants;
import com.nis.util.DictUtils; import com.nis.util.DictUtils;
import com.nis.util.LogUtils; import com.nis.util.LogUtils;
import com.nis.util.StringUtil; import com.nis.util.StringUtil;
import com.nis.util.excel.ImportExcel;
import com.nis.web.controller.BaseController; import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils; import com.nis.web.security.UserUtils;
@@ -633,6 +642,13 @@ public class WebsiteController extends BaseController {
return "redirect:" + adminPath + "/ntc/website/dnsList?functionId=" + functionId; return "redirect:" + adminPath + "/ntc/website/dnsList?functionId=" + functionId;
} }
@Deprecated
// 下载导入模板
@RequestMapping(value = "import/template")
public void importFileTemplate(HttpServletRequest request, HttpServletResponse response,
RedirectAttributes redirectAttributes, Integer functionId, Integer cfgRegionCode) {
this.importCfgTemplate(request, response, redirectAttributes, functionId, cfgRegionCode);
}
// http配置导入 // http配置导入
/* /*
* @RequestMapping(value = "importHttp", method=RequestMethod.POST) public * @RequestMapping(value = "importHttp", method=RequestMethod.POST) public

View File

@@ -1,6 +1,7 @@
package com.nis.web.controller.configuration.ntc; package com.nis.web.controller.configuration.ntc;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@@ -25,11 +26,13 @@ import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.HttpUrlCfg; import com.nis.domain.configuration.HttpUrlCfg;
import com.nis.domain.configuration.IpPortCfg; import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.NtcSubscribeIdCfg; import com.nis.domain.configuration.NtcSubscribeIdCfg;
import com.nis.domain.configuration.template.WhiteListIpTemplate;
import com.nis.exceptions.MaatConvertException; import com.nis.exceptions.MaatConvertException;
import com.nis.util.Constants; import com.nis.util.Constants;
import com.nis.util.LogUtils; import com.nis.util.LogUtils;
import com.nis.util.StringUtil; import com.nis.util.StringUtil;
import com.nis.web.controller.configuration.CommonController; import com.nis.web.controller.configuration.CommonController;
import com.nis.web.security.UserUtils;
/** /**
* 白名单 * 白名单
@@ -401,6 +404,24 @@ public class WhiteListController extends CommonController {
return "redirect:" + adminPath + "/ntc/whitelist/domain/list?functionId=" + functionId; return "redirect:" + adminPath + "/ntc/whitelist/domain/list?functionId=" + functionId;
} }
// ip配置导入
/*
* @RequestMapping(value = "ip/import", method=RequestMethod.POST) public
* String importIp(String cfgName,RedirectAttributes redirectAttributes,
*
* @RequestParam("file") MultipartFile file,IpPortCfg cfg) {
* this._importIp(cfgName,redirectAttributes,
* file,cfg,WhiteListIpTemplate.class); return "redirect:" + adminPath
* +"/ntc/whitelist/ip/list?functionId="+cfg.getFunctionId(); }
*/
// ip模板下载
@RequestMapping(value = "ip/import/template")
public void importFileTemplate(HttpServletRequest request, HttpServletResponse response,
RedirectAttributes redirectAttributes, Integer functionId, Integer cfgRegionCode) {
this._importFileTemplate(request, response, redirectAttributes, functionId, cfgRegionCode,
WhiteListIpTemplate.class);
}
// ip配置导出 // ip配置导出
@RequestMapping(value = "ip/export") @RequestMapping(value = "ip/export")
public void exportIp(String columns, Model model, HttpServletRequest request, HttpServletResponse response, public void exportIp(String columns, Model model, HttpServletRequest request, HttpServletResponse response,

View File

@@ -120,6 +120,11 @@ public class ControlController extends CommonController {
redirectAttributes.addAttribute("requiresPermissionPrefix","control:ip"); redirectAttributes.addAttribute("requiresPermissionPrefix","control:ip");
return "redirect:" + adminPath +"/proxy/control/ip/list?functionId="+cfg.getFunctionId(); return "redirect:" + adminPath +"/proxy/control/ip/list?functionId="+cfg.getFunctionId();
} }
@RequestMapping(value = "/ip/import/template")
public void importFileTemplate(HttpServletRequest request,HttpServletResponse response,
RedirectAttributes redirectAttributes,Integer functionId,Integer cfgRegionCode) {
this._importFileTemplate(request, response, redirectAttributes, functionId, cfgRegionCode);
}
//ip配置导出 //ip配置导出
@RequestMapping(value = "/ip/export") @RequestMapping(value = "/ip/export")
public void exportIp(String columns,Model model,HttpServletRequest request,HttpServletResponse response, public void exportIp(String columns,Model model,HttpServletRequest request,HttpServletResponse response,

View File

@@ -157,13 +157,7 @@ public class ControlPolicyController extends BaseController{
,RedirectAttributes redirectAttributes){ ,RedirectAttributes redirectAttributes){
try{ try{
controlPolicyService.saveOrUpdate(cfg,areaCfgIds); controlPolicyService.saveOrUpdate(cfg,areaCfgIds);
//配置仅保存 addMessage(redirectAttributes,"success","save_success");
if(StringUtil.isEmpty(cfg.getIsValid()) || cfg.getIsValid()!=1) {
addMessage(redirectAttributes, "success", "save_success");
}else {
//配置直接生效
addMessage(redirectAttributes, "success", "audit_success");
}
}catch(Exception e){ }catch(Exception e){
logger.error("信息保存失败",e); logger.error("信息保存失败",e);
if(e instanceof MaatConvertException) { if(e instanceof MaatConvertException) {

View File

@@ -1,255 +0,0 @@
package com.nis.web.controller.configuration.proxy;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.common.collect.Maps;
import com.nis.domain.Page;
import com.nis.domain.callback.ProxyFileHijackCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.maat.ToMaatResult;
import com.nis.domain.maat.ToMaatResult.ResponseData;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.ConfigServiceUtil;
import com.nis.util.Constants;
import com.nis.util.FileUtils;
import com.nis.util.JsonMapper;
import com.nis.util.LogUtils;
import com.nis.util.StringUtil;
import com.nis.web.controller.configuration.CommonController;
@Controller
@RequestMapping("${adminPath}/proxy/fileHijack")
public class FileHijackController extends CommonController{
@RequestMapping(value = {"list"})
public String fileHijackList(ProxyFileHijackCfg cfg,Model model,HttpServletRequest request,HttpServletResponse response) {
Page<ProxyFileHijackCfg> page = proxyFileHijackService.findPage(new Page<ProxyFileHijackCfg>(request, response,"a"), cfg);
model.addAttribute("page", page);
model.addAttribute("cfg", cfg);
initPageCondition(model);
return "/cfg/proxy/fileHijack/list";
}
@RequestMapping(value = {"form"})
@RequiresPermissions(value={"proxy:fileHijack:config"})
public String fileform(Model model,HttpServletRequest request
,HttpServletResponse response
,@ModelAttribute("cfg")ProxyFileHijackCfg cfg
,String ids
,RedirectAttributes redirectAttributes) {
if(!StringUtil.isEmpty(ids)){
cfg = proxyFileHijackService.getCfgById(Long.valueOf(ids));
}
//初始化各字典
initFormCondition(model, cfg);
model.addAttribute("_cfg", cfg);
return "/cfg/proxy/fileHijack/form";
}
@RequiresPermissions(value={"proxy:fileHijack:config"})
@RequestMapping(value = {"saveOrUpdate"})
public String saveOrUpdate(Model model,HttpServletRequest request
,HttpServletResponse response,MultipartFile cfgFile,
@ModelAttribute("cfg")ProxyFileHijackCfg cfg,
RedirectAttributes redirectAttributes){
File file = null;
try{
if(cfgFile != null) {
String filename = cfgFile.getOriginalFilename();
String prefix = FileUtils.getPrefix(filename, false);
String suffix = FileUtils.getSuffix(filename, false);
file = File.createTempFile("file_" + prefix, FileUtils.getSuffix(filename, true));
cfgFile.transferTo(file);// 复制文件
String md5 = FileUtils.getFileMD5(file);
Map<String, Object> srcMap = Maps.newHashMap();
srcMap.put("filetype", suffix);
srcMap.put("datatype", "dbSystem");// 源文件存入数据中心
srcMap.put("createTime", new Date());
srcMap.put("key", prefix);
srcMap.put("fileName", filename);
srcMap.put("checksum", md5);
ToMaatResult result = ConfigServiceUtil.postFileCfg(null, file, JsonMapper.toJsonString(srcMap));
logger.info("proxy 劫持文件 上传响应信息:" + JsonMapper.toJsonString(result));
String path = null;
if (!StringUtil.isEmpty(result)) {
ResponseData data = result.getData();
path = data.getAccessUrl();
cfg.setPath(path);
}
}
proxyFileHijackService.saveOrUpdate(cfg);
//配置仅保存
if(StringUtil.isEmpty(cfg.getIsValid()) || cfg.getIsValid()!=1) {
addMessage(redirectAttributes, "success", "save_success");
}else {
//配置直接生效
addMessage(redirectAttributes, "success", "audit_success");
}
}catch(Exception e){
logger.error("信息保存失败",e);
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error","request_service_failed");
LogUtils.saveLog(request, null, e, null);
}else {
addMessage(redirectAttributes,"error","save_failed");
LogUtils.saveLog(request, null, e, null);
}
}finally {
if(file != null) {
file.delete();//删除临时文件
}
}
return "redirect:" + adminPath +"/proxy/fileHijack/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"delete"})
@RequiresPermissions(value={"proxy:fileHijack:config"})
public String delete(Integer isAudit, Integer isValid, String ids, Integer functionId, Model model, @ModelAttribute("cfg")ProxyFileHijackCfg cfg,
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes){
try {
if (!StringUtil.isEmpty(ids)) {
proxyFileHijackService.update(isAudit, isValid, ids, functionId);
addMessage(redirectAttributes, "success", "delete_success");
}else {
// 批量删除
Page<ProxyFileHijackCfg> searchPage = new Page<ProxyFileHijackCfg>(request, response, "a");
deleteAll(searchPage, functionId, cfg);
}
} catch (Exception e) {
logger.error("配置删除失败:", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} else {
addMessage(redirectAttributes, "error", "delete_failed");
LogUtils.saveLog(request, null, e, null);
}
}
return "redirect:" + adminPath +"/proxy/fileHijack/list?functionId="+functionId;
}
@RequestMapping(value = {"audit"})
@RequiresPermissions(value={"proxy:fileHijack:confirm"})
public String audit(Model model, @ModelAttribute("cfg") ProxyFileHijackCfg cfg, Integer isValid, Integer isAudit,
String ids, Integer functionId, RedirectAttributes redirectAttributes, HttpServletResponse response,
HttpServletRequest request) {
if (!StringUtil.isEmpty(ids)) {
String[] idArray = ids.split(",");
for (String id : idArray) {
try {
proxyFileHijackService.audit(isAudit, isValid, functionId, id);
addMessage(redirectAttributes, "success", "audit_success");
} catch (MaatConvertException e) {
logger.error(e);
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} catch (Exception e) {
logger.error(e);
addMessage(redirectAttributes, "error", "audit_failed");
LogUtils.saveLog(request, null, e, null);
}
}
} else {
Page<ProxyFileHijackCfg> searchPage = new Page<ProxyFileHijackCfg>(request, response, "a");
Page<ProxyFileHijackCfg> auditPage = new Page<ProxyFileHijackCfg>(request, response, "a");
try {
BeanUtils.copyProperties(searchPage, auditPage);
auditAll(auditPage, isValid, cfg);
addMessage(redirectAttributes, "success", "audit_success");
} catch (Exception e) {
logger.error("配置下发失败:", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} else {
addMessage(redirectAttributes, "error", "audit_failed");
LogUtils.saveLog(request, null, e, null);
}
}
return fileHijackList(cfg, model, request, response);
}
return "redirect:" + adminPath +"/proxy/fileHijack/list?functionId="+functionId;
}
@RequestMapping(value = "exportFileHijack")
public void exportPxy(Model model, HttpServletRequest request, HttpServletResponse response,
@ModelAttribute("cfg") ProxyFileHijackCfg entity, String ids, RedirectAttributes redirectAttributes) {
try {
// export data info
List<String> titleList = new ArrayList<String>();
Map<String, Class<?>> classMap = new HashMap<String, Class<?>>();
Map<String, List> dataMap = new HashMap<String, List>();
Map<String, String> noExportMap = new HashMap<String, String>();
List<ProxyFileHijackCfg> ipLists = new ArrayList<ProxyFileHijackCfg>();
// 导出选中记录
if (!StringUtil.isEmpty(ids)) {
ipLists = proxyFileHijackService.findByList(ids);
} else {
entity.setTableName(IpPortCfg.getTablename());
Page<ProxyFileHijackCfg> pageInfo = new Page<ProxyFileHijackCfg>(request, response, "a");
pageInfo.setPageNo(1);
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
Page<ProxyFileHijackCfg> page = proxyFileHijackService.findPage(pageInfo, entity);
ipLists = page.getList();
}
for (int i = 0; i < ipLists.size(); i++) {
ipLists.get(i).setProfileName(ipLists.get(i).getCfgDesc());
}
titleList.add(entity.getMenuNameCode());
classMap.put(entity.getMenuNameCode(), ProxyFileHijackCfg.class);
String cfgIndexInfoNoExport = ",config_describe,whether_area_block,block_type,do_log,client_port,ir_type,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
// 时间过滤
if (entity.getSearch_create_time_start() == null && entity.getSearch_create_time_end() == null) {
cfgIndexInfoNoExport = ",config_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_edit_time_start() == null && entity.getSearch_edit_time_end() == null) {
cfgIndexInfoNoExport = ",edit_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_audit_time_start() == null && entity.getSearch_audit_time_end() == null) {
cfgIndexInfoNoExport = ",audit_time" + cfgIndexInfoNoExport;
}
if (!StringUtil.isEmpty(entity.gethColumns())) {
cfgIndexInfoNoExport = "," + entity.gethColumns() + "," + cfgIndexInfoNoExport;
}
noExportMap.put(entity.getMenuNameCode(), cfgIndexInfoNoExport);
dataMap.put(entity.getMenuNameCode(), ipLists);
String timeRange = initTimeMap(entity);
noExportMap.put("timeRange", timeRange);
if ("csv".equals(entity.getExType())) {
this._exportCsv(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
}
} catch (Exception e) {
logger.error("proxyFileHijack export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
LogUtils.saveLog(request, null, e, null);
}
}
}

View File

@@ -1,251 +0,0 @@
package com.nis.web.controller.configuration.proxy;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.common.collect.Maps;
import com.nis.domain.Page;
import com.nis.domain.callback.ProxyFileHijackCfg;
import com.nis.domain.callback.ProxyFileInsertScriptCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.maat.ToMaatResult;
import com.nis.domain.maat.ToMaatResult.ResponseData;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.ConfigServiceUtil;
import com.nis.util.Constants;
import com.nis.util.FileUtils;
import com.nis.util.JsonMapper;
import com.nis.util.LogUtils;
import com.nis.util.StringUtil;
import com.nis.web.controller.configuration.CommonController;
@Controller
@RequestMapping("${adminPath}/proxy/fileInsertScript")
public class FileInsertScriptController extends CommonController{
@RequestMapping(value = {"list"})
public String fileInsertScriptList(ProxyFileInsertScriptCfg cfg,Model model,HttpServletRequest request,HttpServletResponse response) {
Page<ProxyFileInsertScriptCfg> page = proxyFileInsertScriptService.findPage(new Page<ProxyFileInsertScriptCfg>(request, response,"a"), cfg);
model.addAttribute("page", page);
model.addAttribute("cfg", cfg);
initPageCondition(model);
return "/cfg/proxy/fileInsertScript/list";
}
@RequestMapping(value = {"form"})
@RequiresPermissions(value={"proxy:fileInsertScript:config"})
public String fileform(Model model,HttpServletRequest request
,HttpServletResponse response
,@ModelAttribute("cfg")ProxyFileInsertScriptCfg cfg
,String ids
,RedirectAttributes redirectAttributes) {
if(!StringUtil.isEmpty(ids)){
cfg = proxyFileInsertScriptService.getCfgById(Long.valueOf(ids));
}
initFormCondition(model, cfg);
model.addAttribute("_cfg", cfg);
return "/cfg/proxy/fileInsertScript/form";
}
@RequiresPermissions(value={"proxy:fileInsertScript:config"})
@RequestMapping(value = {"saveOrUpdate"})
public String saveOrUpdate(Model model,HttpServletRequest request
,HttpServletResponse response,MultipartFile cfgFile,
@ModelAttribute("cfg")ProxyFileInsertScriptCfg cfg,
RedirectAttributes redirectAttributes){
File file = null;
try{
if(cfgFile != null) {
String filename = cfgFile.getOriginalFilename();
String prefix = FileUtils.getPrefix(filename, false);
String suffix = FileUtils.getSuffix(filename, false);
file = File.createTempFile("file_"+ prefix, FileUtils.getSuffix(filename, true));
cfgFile.transferTo(file);//复制文件
String md5 = FileUtils.getFileMD5(file);
Map<String,Object> srcMap = Maps.newHashMap();
srcMap.put("filetype", suffix);
srcMap.put("datatype", "dbSystem");//源文件存入数据中心
srcMap.put("createTime",new Date());
srcMap.put("key",prefix);
srcMap.put("fileName", filename);
srcMap.put("checksum", md5);
ToMaatResult result = ConfigServiceUtil.postFileCfg(null, file, JsonMapper.toJsonString(srcMap));
logger.info("注入脚本文件上传响应信息:"+JsonMapper.toJsonString(result));
String srcAccessUrl = null;
if(!StringUtil.isEmpty(result)){
ResponseData data = result.getData();
srcAccessUrl=data.getAccessUrl();
cfg.setPath(srcAccessUrl);
}
}
proxyFileInsertScriptService.saveOrUpdate(cfg);
//配置仅保存
if(StringUtil.isEmpty(cfg.getIsValid()) || cfg.getIsValid()!=1) {
addMessage(redirectAttributes, "success", "save_success");
}else {
//配置直接生效
addMessage(redirectAttributes, "success", "audit_success");
}
}catch(Exception e){
logger.error("信息保存失败",e);
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error","request_service_failed");
LogUtils.saveLog(request, null, e, null);
}else {
addMessage(redirectAttributes,"error","save_failed");
LogUtils.saveLog(request, null, e, null);
}
}finally {
if(file != null) {
file.delete();//删除临时文件
}
}
return "redirect:" + adminPath +"/proxy/fileInsertScript/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"audit"})
@RequiresPermissions(value={"proxy:fileInsertScript:confirm"})
public String audit(Model model, @ModelAttribute("cfg") ProxyFileInsertScriptCfg cfg, Integer isValid, Integer isAudit,
String ids, Integer functionId, RedirectAttributes redirectAttributes, HttpServletResponse response,
HttpServletRequest request) {
if (!StringUtil.isEmpty(ids)) {
String[] idArray = ids.split(",");
for (String id : idArray) {
try {
proxyFileInsertScriptService.audit(isAudit, isValid, functionId, id);
addMessage(redirectAttributes, "success", "audit_success");
} catch (MaatConvertException e) {
logger.error(e);
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} catch (Exception e) {
logger.error(e);
addMessage(redirectAttributes, "error", "audit_failed");
LogUtils.saveLog(request, null, e, null);
}
}
} else {
Page<ProxyFileInsertScriptCfg> searchPage = new Page<ProxyFileInsertScriptCfg>(request, response, "a");
Page<ProxyFileInsertScriptCfg> auditPage = new Page<ProxyFileInsertScriptCfg>(request, response, "a");
try {
BeanUtils.copyProperties(searchPage, auditPage);
auditAll(auditPage, isValid, cfg);
addMessage(redirectAttributes, "success", "audit_success");
} catch (Exception e) {
logger.error("批量配置下发失败:", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} else {
addMessage(redirectAttributes, "error", "audit_failed");
LogUtils.saveLog(request, null, e, null);
}
}
return fileInsertScriptList(cfg, model, request, response);
}
return "redirect:" + adminPath +"/proxy/fileInsertScript/list?functionId="+functionId;
}
@RequestMapping(value = {"delete"})
@RequiresPermissions(value={"proxy:fileInsertScript:config"})
public String delete(Integer isAudit, Integer isValid, String ids, Integer functionId, Model model, @ModelAttribute("cfg")ProxyFileInsertScriptCfg cfg,
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes){
try {
if (!StringUtil.isEmpty(ids)) {
proxyFileInsertScriptService.delete(isAudit, isValid, ids, functionId);
addMessage(redirectAttributes, "success", "delete_success");
}else {
// 批量删除
Page<ProxyFileInsertScriptCfg> searchPage = new Page<ProxyFileInsertScriptCfg>(request, response, "a");
deleteAll(searchPage, functionId, cfg);
}
} catch (Exception e) {
logger.error("配置删除失败:", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} else {
addMessage(redirectAttributes, "error", "delete_failed");
LogUtils.saveLog(request, null, e, null);
}
}
return "redirect:" + adminPath +"/proxy/fileInsertScript/list?functionId="+functionId;
}
@RequestMapping(value = "exportFileInsertScript")
public void exportFileHijack(Model model, HttpServletRequest request, HttpServletResponse response,
@ModelAttribute("cfg") ProxyFileInsertScriptCfg entity, String ids, RedirectAttributes redirectAttributes){
try {
// export data info
List<String> titleList = new ArrayList<String>();
Map<String, Class<?>> classMap = new HashMap<String, Class<?>>();
Map<String, List> dataMap = new HashMap<String, List>();
Map<String, String> noExportMap = new HashMap<String, String>();
List<ProxyFileInsertScriptCfg> ipLists = new ArrayList<ProxyFileInsertScriptCfg>();
// 导出选中记录
if (!StringUtil.isEmpty(ids)) {
ipLists = proxyFileInsertScriptService.findByList(ids);
} else {
entity.setTableName(IpPortCfg.getTablename());
Page<ProxyFileInsertScriptCfg> pageInfo = new Page<ProxyFileInsertScriptCfg>(request, response, "a");
pageInfo.setPageNo(1);
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
Page<ProxyFileInsertScriptCfg> page = proxyFileInsertScriptService.findPage(pageInfo, entity);
ipLists = page.getList();
}
titleList.add(entity.getMenuNameCode());
classMap.put(entity.getMenuNameCode(), ProxyFileInsertScriptCfg.class);
String cfgIndexInfoNoExport = ",config_describe,whether_area_block,block_type,do_log,client_port,ir_type,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
// 时间过滤
if (entity.getSearch_create_time_start() == null && entity.getSearch_create_time_end() == null) {
cfgIndexInfoNoExport = ",config_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_edit_time_start() == null && entity.getSearch_edit_time_end() == null) {
cfgIndexInfoNoExport = ",edit_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_audit_time_start() == null && entity.getSearch_audit_time_end() == null) {
cfgIndexInfoNoExport = ",audit_time" + cfgIndexInfoNoExport;
}
if (!StringUtil.isEmpty(entity.gethColumns())) {
cfgIndexInfoNoExport = "," + entity.gethColumns() + "," + cfgIndexInfoNoExport;
}
noExportMap.put(entity.getMenuNameCode(), cfgIndexInfoNoExport);
dataMap.put(entity.getMenuNameCode(), ipLists);
String timeRange = initTimeMap(entity);
noExportMap.put("timeRange", timeRange);
if ("csv".equals(entity.getExType())) {
this._exportCsv(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
}
} catch (Exception e) {
logger.error("proxyFileInsertScript export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
LogUtils.saveLog(request, null, e, null);
}
}
}

View File

@@ -1,286 +0,0 @@
/**
*@Title: ControlController.java
*@Package com.nis.web.controller.configuration.proxy
*@Description TODO
*@author dell
*@date 2018年6月22日 下午4:35:42
*@version 版本号
*/
package com.nis.web.controller.configuration.proxy;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.common.collect.Maps;
import com.nis.domain.Page;
import com.nis.domain.callback.ProxyFileHijackCfg;
import com.nis.domain.callback.ProxyFileResponsePageCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.maat.ToMaatResult;
import com.nis.domain.maat.ToMaatResult.ResponseData;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.ConfigServiceUtil;
import com.nis.util.Constants;
import com.nis.util.FileUtils;
import com.nis.util.JsonMapper;
import com.nis.util.LogUtils;
import com.nis.util.StringUtil;
import com.nis.web.controller.configuration.CommonController;
/**
* @ClassName: ControlController.java
* @Description: TODO
* @author (dell)
* @date 2018年6月22日 下午4:35:42
* @version V1.0
*/
@Controller
@RequestMapping("${adminPath}/proxy/fileResponsePage")
public class FileResponsePageController extends CommonController {
@RequestMapping(value = {"list"})
public String fileResponsePageList(ProxyFileResponsePageCfg cfg,Model model,HttpServletRequest request,HttpServletResponse response) {
Page<ProxyFileResponsePageCfg> page = proxyFileResponsePageService.findPage(new Page<ProxyFileResponsePageCfg>(request, response,"a"), cfg);
model.addAttribute("page", page);
model.addAttribute("cfg", cfg);
initPageCondition(model);
return "/cfg/proxy/fileResponsePage/list";
}
@RequestMapping(value = {"form"})
@RequiresPermissions(value={"proxy:fileResponsePage:config"})
public String fileform(Model model,HttpServletRequest request
,HttpServletResponse response
,@ModelAttribute("cfg")ProxyFileResponsePageCfg cfg
,String ids
,RedirectAttributes redirectAttributes) {
if(!StringUtil.isEmpty(ids)){
cfg = proxyFileResponsePageService.getCfgById(Long.valueOf(ids));
}
// initFormCondition(model);
initFormCondition(model, cfg);
model.addAttribute("_cfg", cfg);
return "/cfg/proxy/fileResponsePage/form";
}
/**
* 保存 文件
* 1、将文件上传到 service 接口
* 2、将文件信息及 1返回的结果 保存到数据库
* @param model
* @param request
* @param response
* @param cfgFile
* @param cfg
* @param redirectAttributes
* @return
*/
@RequiresPermissions(value={"proxy:fileResponsePage:config"})
@RequestMapping(value = {"saveOrUpdate"})
public String saveOrUpdate(Model model,HttpServletRequest request
,HttpServletResponse response,MultipartFile cfgFile,
@ModelAttribute("cfg")ProxyFileResponsePageCfg cfg,
RedirectAttributes redirectAttributes){
File file = null;
try{
if(cfgFile != null) {
String filename = cfgFile.getOriginalFilename();
String prefix = FileUtils.getPrefix(filename, false);
String suffix = FileUtils.getSuffix(filename, false);
file = File.createTempFile("file_"+ prefix, FileUtils.getSuffix(filename, true));
cfgFile.transferTo(file);//复制文件
String md5 = FileUtils.getFileMD5(file);
Map<String,Object> srcMap = Maps.newHashMap();
srcMap.put("filetype", suffix);
srcMap.put("datatype", "dbSystem");//源文件存入数据中心
srcMap.put("createTime",new Date());
srcMap.put("key",prefix);
srcMap.put("fileName", filename);
srcMap.put("checksum", md5);
ToMaatResult result = ConfigServiceUtil.postFileCfg(null, file, JsonMapper.toJsonString(srcMap));
logger.info("http 重定向阻断文件上传响应信息:"+JsonMapper.toJsonString(result));
String srcAccessUrl = null;
if(!StringUtil.isEmpty(result)){
ResponseData data = result.getData();
srcAccessUrl=data.getAccessUrl();
cfg.setUrl(srcAccessUrl);;
}
cfg.setMd5(md5);//文件md5值
cfg.setContentLength(file.length());//文件长度
}
proxyFileResponsePageService.saveOrUpdate(cfg);
//配置仅保存
if(StringUtil.isEmpty(cfg.getIsValid()) || cfg.getIsValid()!=1) {
addMessage(redirectAttributes, "success", "save_success");
}else {
//配置直接生效
addMessage(redirectAttributes, "success", "audit_success");
}
addMessage(redirectAttributes,"success","save_success");
}catch(Exception e){
logger.error("信息保存失败",e);
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error","request_service_failed");
LogUtils.saveLog(request, null, e, null);
}else {
addMessage(redirectAttributes,"error","save_failed");
LogUtils.saveLog(request, null, e, null);
}
}finally {
if(file != null) {
file.delete();//删除临时文件
}
}
return "redirect:" + adminPath +"/proxy/fileResponsePage/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"delete"})
@RequiresPermissions(value={"proxy:fileResponsePage:config"})
public String delete(Integer isAudit, Integer isValid, String ids, Integer functionId, Model model, @ModelAttribute("cfg")ProxyFileResponsePageCfg cfg,
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes){
try {
if (!StringUtil.isEmpty(ids)) {
proxyFileResponsePageService.update(isAudit, isValid, ids, functionId);
addMessage(redirectAttributes, "success", "delete_success");
}else {
// 批量删除
Page<ProxyFileResponsePageCfg> searchPage = new Page<ProxyFileResponsePageCfg>(request, response, "a");
deleteAll(searchPage, functionId, cfg);
}
} catch (Exception e) {
logger.error("配置删除失败:", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} else {
addMessage(redirectAttributes, "error", "delete_failed");
LogUtils.saveLog(request, null, e, null);
}
}
return "redirect:" + adminPath +"/proxy/fileResponsePage/list?functionId="+functionId;
}
@RequestMapping(value = {"audit"})
@RequiresPermissions(value={"proxy:fileResponsePage:confirm"})
public String audit(Model model, @ModelAttribute("cfg") ProxyFileResponsePageCfg cfg, Integer isValid, Integer isAudit,
String ids, Integer functionId, RedirectAttributes redirectAttributes, HttpServletResponse response,
HttpServletRequest request) {
if (!StringUtil.isEmpty(ids)) {
String[] idArray = ids.split(",");
for (String id : idArray) {
try {
proxyFileResponsePageService.audit(isAudit, isValid, functionId, id);
addMessage(redirectAttributes, "success", "audit_success");
} catch (MaatConvertException e) {
logger.error(e);
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} catch (Exception e) {
logger.error(e);
addMessage(redirectAttributes, "error", "audit_failed");
LogUtils.saveLog(request, null, e, null);
}
}
} else {
Page<ProxyFileResponsePageCfg> searchPage = new Page<ProxyFileResponsePageCfg>(request, response, "a");
Page<ProxyFileResponsePageCfg> auditPage = new Page<ProxyFileResponsePageCfg>(request, response, "a");
try {
BeanUtils.copyProperties(searchPage, auditPage);
auditAll(auditPage, isValid, cfg);
addMessage(redirectAttributes, "success", "audit_success");
} catch (Exception e) {
logger.error("配置下发失败:", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} else {
addMessage(redirectAttributes, "error", "audit_failed");
LogUtils.saveLog(request, null, e, null);
}
}
return fileResponsePageList(cfg, model, request, response);
}
return "redirect:" + adminPath +"/proxy/fileResponsePage/list?functionId="+functionId;
}
@RequestMapping(value = "exportFileResponsePage")
public void exportPxy(Model model, HttpServletRequest request, HttpServletResponse response,
@ModelAttribute("cfg") ProxyFileResponsePageCfg entity, String ids, RedirectAttributes redirectAttributes) {
try {
// export data info
List<String> titleList = new ArrayList<String>();
Map<String, Class<?>> classMap = new HashMap<String, Class<?>>();
Map<String, List> dataMap = new HashMap<String, List>();
Map<String, String> noExportMap = new HashMap<String, String>();
List<ProxyFileResponsePageCfg> ipLists = new ArrayList<ProxyFileResponsePageCfg>();
// 导出选中记录
if (!StringUtil.isEmpty(ids)) {
ipLists = proxyFileResponsePageService.findByList(ids);
} else {
entity.setTableName(IpPortCfg.getTablename());
Page<ProxyFileResponsePageCfg> pageInfo = new Page<ProxyFileResponsePageCfg>(request, response, "a");
pageInfo.setPageNo(1);
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
Page<ProxyFileResponsePageCfg> page = proxyFileResponsePageService.findPage(pageInfo, entity);
ipLists = page.getList();
}
titleList.add(entity.getMenuNameCode());
classMap.put(entity.getMenuNameCode(), ProxyFileResponsePageCfg.class);
String cfgIndexInfoNoExport = ",config_describe,whether_area_block,block_type,do_log,client_port,ir_type,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
// 时间过滤
if (entity.getSearch_create_time_start() == null && entity.getSearch_create_time_end() == null) {
cfgIndexInfoNoExport = ",config_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_edit_time_start() == null && entity.getSearch_edit_time_end() == null) {
cfgIndexInfoNoExport = ",edit_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_audit_time_start() == null && entity.getSearch_audit_time_end() == null) {
cfgIndexInfoNoExport = ",audit_time" + cfgIndexInfoNoExport;
}
if (!StringUtil.isEmpty(entity.gethColumns())) {
cfgIndexInfoNoExport = "," + entity.gethColumns() + "," + cfgIndexInfoNoExport;
}
noExportMap.put(entity.getMenuNameCode(), cfgIndexInfoNoExport);
dataMap.put(entity.getMenuNameCode(), ipLists);
String timeRange = initTimeMap(entity);
noExportMap.put("timeRange", timeRange);
if ("csv".equals(entity.getExType())) {
this._exportCsv(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
}
} catch (Exception e) {
logger.error("proxyFileHijack export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
LogUtils.saveLog(request, null, e, null);
}
}
}

View File

@@ -15,7 +15,6 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
@@ -26,7 +25,6 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.nis.domain.Page; import com.nis.domain.Page;
import com.nis.domain.callback.ProxyFileHijackCfg;
import com.nis.domain.callback.ProxyFileStrategyCfg; import com.nis.domain.callback.ProxyFileStrategyCfg;
import com.nis.domain.maat.ToMaatResult; import com.nis.domain.maat.ToMaatResult;
import com.nis.domain.maat.ToMaatResult.ResponseData; import com.nis.domain.maat.ToMaatResult.ResponseData;
@@ -120,13 +118,7 @@ public class FileStrategyController extends CommonController {
cfg.setContentLength(file.length());//文件长度 cfg.setContentLength(file.length());//文件长度
} }
proxyFileStrategyService.saveOrUpdate(cfg); proxyFileStrategyService.saveOrUpdate(cfg);
//配置仅保存 addMessage(redirectAttributes,"success","save_success");
if(StringUtil.isEmpty(cfg.getIsValid()) || cfg.getIsValid()!=1) {
addMessage(redirectAttributes, "success", "save_success");
}else {
//配置直接生效
addMessage(redirectAttributes, "success", "audit_success");
}
}catch(Exception e){ }catch(Exception e){
logger.error("信息保存失败",e); logger.error("信息保存失败",e);
if(e instanceof MaatConvertException) { if(e instanceof MaatConvertException) {
@@ -141,81 +133,27 @@ public class FileStrategyController extends CommonController {
file.delete();//删除临时文件 file.delete();//删除临时文件
} }
} }
return "redirect:" + adminPath +"/proxy/fileStrategy/list?functionId="+cfg.getFunctionId(); return "redirect:" + adminPath +"/proxy/fileStrategy/list?functionId="+cfg.getFunctionId();
} }
@RequestMapping(value = {"delete"}) @RequestMapping(value = {"delete"})
@RequiresPermissions(value={"proxy:fileStrategy:config"}) @RequiresPermissions(value={"proxy:fileStrategy:config"})
public String delete(Integer isAudit, Integer isValid, String ids, Integer functionId, Model model, @ModelAttribute("cfg")ProxyFileStrategyCfg cfg, public String delete(Integer isAudit,Integer isValid,
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes){ String ids,
try { Integer functionId,
if (!StringUtil.isEmpty(ids)) { RedirectAttributes redirectAttributes){
proxyFileStrategyService.update(isAudit, isValid, ids, functionId); proxyFileStrategyService.update(isAudit,isValid,ids,functionId);
addMessage(redirectAttributes, "success", "delete_success");
}else {
// 批量删除
Page<ProxyFileStrategyCfg> searchPage = new Page<ProxyFileStrategyCfg>(request, response, "a");
deleteAll(searchPage, functionId, cfg);
}
} catch (Exception e) {
logger.error("配置删除失败:", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} else {
addMessage(redirectAttributes, "error", "delete_failed");
LogUtils.saveLog(request, null, e, null);
}
}
return "redirect:" + adminPath +"/proxy/fileStrategy/list?functionId="+functionId; return "redirect:" + adminPath +"/proxy/fileStrategy/list?functionId="+functionId;
} }
@RequestMapping(value = {"audit"}) @RequestMapping(value = {"audit"})
@RequiresPermissions(value={"proxy:fileStrategy:confirm"}) @RequiresPermissions(value={"proxy:fileStrategy:confirm"})
public String audit(Model model, @ModelAttribute("cfg") ProxyFileStrategyCfg cfg, Integer isValid, Integer isAudit, public String audit(Integer isAudit,Integer isValid,String ids
String ids, Integer functionId, RedirectAttributes redirectAttributes, HttpServletResponse response, ,Integer functionId, RedirectAttributes redirectAttributes) {
HttpServletRequest request) { if(!StringUtil.isEmpty(ids)){
if (!StringUtil.isEmpty(ids)) { proxyFileStrategyService.audit(isAudit, isValid, functionId, ids);
String[] idArray = ids.split(","); addMessage(redirectAttributes,"success", "audit_success");
for (String id : idArray) {
try {
proxyFileStrategyService.audit(isAudit, isValid, functionId, id);
addMessage(redirectAttributes, "success", "audit_success");
} catch (MaatConvertException e) {
logger.error(e);
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} catch (Exception e) {
logger.error(e);
addMessage(redirectAttributes, "error", "audit_failed");
LogUtils.saveLog(request, null, e, null);
}
}
} else {
Page<ProxyFileStrategyCfg> searchPage = new Page<ProxyFileStrategyCfg>(request, response, "a");
Page<ProxyFileStrategyCfg> auditPage = new Page<ProxyFileStrategyCfg>(request, response, "a");
try {
BeanUtils.copyProperties(searchPage, auditPage);
auditAll(auditPage, isValid, cfg);
addMessage(redirectAttributes, "success", "audit_success");
} catch (Exception e) {
logger.error("配置下发失败:", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} else {
addMessage(redirectAttributes, "error", "audit_failed");
LogUtils.saveLog(request, null, e, null);
}
}
return fileStrategyList(cfg, model, request, response);
} }
return "redirect:" + adminPath +"/proxy/fileStrategy/list?functionId="+functionId; return "redirect:" + adminPath +"/proxy/fileStrategy/list?functionId="+functionId;
} }

View File

@@ -1,246 +0,0 @@
package com.nis.web.controller.configuration.proxy;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.common.collect.Maps;
import com.nis.domain.Page;
import com.nis.domain.callback.ProxyFileTrafficMirrorCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.maat.ToMaatResult;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.ConfigServiceUtil;
import com.nis.util.Constants;
import com.nis.util.FileUtils;
import com.nis.util.JsonMapper;
import com.nis.util.LogUtils;
import com.nis.util.StringUtil;
import com.nis.web.controller.configuration.CommonController;
@Controller
@RequestMapping("${adminPath}/proxy/fileTrafficMirror")
public class FileTrafficMirrorController extends CommonController {
@RequestMapping(value = {"list"})
public String fileTrafficMirrorList(ProxyFileTrafficMirrorCfg cfg,Model model,HttpServletRequest request,HttpServletResponse response) {
Page<ProxyFileTrafficMirrorCfg> page = proxyFileTrafficMirrorService.findPage(new Page<ProxyFileTrafficMirrorCfg>(request, response,"a"), cfg);
model.addAttribute("page", page);
model.addAttribute("cfg", cfg);
initPageCondition(model);
return "/cfg/proxy/fileTrafficMirror/list";
}
@RequestMapping(value = {"form"})
@RequiresPermissions(value={"proxy:fileTrafficMirror:config"})
public String fileform(Model model,HttpServletRequest request
,HttpServletResponse response
,@ModelAttribute("cfg")ProxyFileTrafficMirrorCfg cfg
,String ids
,RedirectAttributes redirectAttributes) {
if(!StringUtil.isEmpty(ids)){
cfg = proxyFileTrafficMirrorService.getCfgById(Long.valueOf(ids));
}
initFormCondition(model, cfg);
model.addAttribute("_cfg", cfg);
return "/cfg/proxy/fileTrafficMirror/form";
}
@RequiresPermissions(value={"proxy:fileTrafficMirror:config"})
@RequestMapping(value = {"saveOrUpdate"})
public String saveOrUpdate(Model model,HttpServletRequest request
,HttpServletResponse response,MultipartFile cfgFile,
@ModelAttribute("cfg")ProxyFileTrafficMirrorCfg cfg,
RedirectAttributes redirectAttributes){
File file = null;
try{
if(cfgFile != null) {
String filename = cfgFile.getOriginalFilename();
String prefix = FileUtils.getPrefix(filename, false);
String suffix = FileUtils.getSuffix(filename, false);
file = File.createTempFile("file_"+ prefix, suffix);
cfgFile.transferTo(file);//复制文件
String md5 = FileUtils.getFileMD5(file);
Map<String,Object> srcMap = Maps.newHashMap();
srcMap.put("filetype", suffix);
srcMap.put("datatype", "dbSystem");//源文件存入数据中心
srcMap.put("createTime",new Date());
srcMap.put("key",prefix);
srcMap.put("fileName", filename);
srcMap.put("checksum", md5);
ToMaatResult result = ConfigServiceUtil.postFileCfg(null, file, JsonMapper.toJsonString(srcMap));
logger.info("注入脚本文件上传响应信息:"+JsonMapper.toJsonString(result));
}
proxyFileTrafficMirrorService.saveOrUpdate(cfg);
//配置仅保存
if(StringUtil.isEmpty(cfg.getIsValid()) || cfg.getIsValid()!=1) {
addMessage(redirectAttributes, "success", "save_success");
}else {
//配置直接生效
addMessage(redirectAttributes, "success", "audit_success");
}
}catch(Exception e){
logger.error("信息保存失败",e);
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error","request_service_failed");
LogUtils.saveLog(request, null, e, null);
}else {
addMessage(redirectAttributes,"error","save_failed");
LogUtils.saveLog(request, null, e, null);
}
}finally {
if(file != null) {
file.delete();//删除临时文件
}
}
return "redirect:" + adminPath +"/proxy/fileTrafficMirror/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"audit"})
@RequiresPermissions(value={"proxy:fileTrafficMirror:confirm"})
public String audit(Model model, @ModelAttribute("cfg") ProxyFileTrafficMirrorCfg cfg, Integer isValid, Integer isAudit,
String ids, Integer functionId, RedirectAttributes redirectAttributes, HttpServletResponse response,
HttpServletRequest request) {
if (!StringUtil.isEmpty(ids)) {
String[] idArray = ids.split(",");
for (String id : idArray) {
try {
proxyFileTrafficMirrorService.audit(isAudit, isValid, functionId, id);
addMessage(redirectAttributes, "success", "audit_success");
} catch (MaatConvertException e) {
logger.error(e);
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} catch (Exception e) {
logger.error(e);
addMessage(redirectAttributes, "error", "audit_failed");
LogUtils.saveLog(request, null, e, null);
}
}
} else {
Page<ProxyFileTrafficMirrorCfg> searchPage = new Page<ProxyFileTrafficMirrorCfg>(request, response, "a");
Page<ProxyFileTrafficMirrorCfg> auditPage = new Page<ProxyFileTrafficMirrorCfg>(request, response, "a");
try {
BeanUtils.copyProperties(searchPage, auditPage);
auditAll(auditPage, isValid, cfg);
addMessage(redirectAttributes, "success", "audit_success");
} catch (Exception e) {
logger.error("批量配置下发失败:", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} else {
addMessage(redirectAttributes, "error", "audit_failed");
LogUtils.saveLog(request, null, e, null);
}
}
return fileTrafficMirrorList(cfg, model, request, response);
}
return "redirect:" + adminPath +"/proxy/fileTrafficMirror/list?functionId="+functionId;
}
@RequestMapping(value = {"delete"})
@RequiresPermissions(value={"proxy:fileTrafficMirror:config"})
public String delete(Integer isAudit, Integer isValid, String ids, Integer functionId, Model model, @ModelAttribute("cfg")ProxyFileTrafficMirrorCfg cfg,
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes){
try {
if (!StringUtil.isEmpty(ids)) {
proxyFileTrafficMirrorService.delete(isAudit, isValid, ids, functionId);
addMessage(redirectAttributes, "success", "delete_success");
}else {
// 批量删除
Page<ProxyFileTrafficMirrorCfg> searchPage = new Page<ProxyFileTrafficMirrorCfg>(request, response, "d");
deleteAll(searchPage, functionId, cfg);
}
} catch (Exception e) {
logger.error("配置删除失败:", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} else {
addMessage(redirectAttributes, "error", "delete_failed");
LogUtils.saveLog(request, null, e, null);
}
}
return "redirect:" + adminPath +"/proxy/fileTrafficMirror/list?functionId="+functionId;
}
@RequestMapping(value = "exportFileTrafficMirror")
public void exportFileHijack(Model model, HttpServletRequest request, HttpServletResponse response,
@ModelAttribute("cfg") ProxyFileTrafficMirrorCfg entity, String ids, RedirectAttributes redirectAttributes){
try {
// export data info
List<String> titleList = new ArrayList<String>();
Map<String, Class<?>> classMap = new HashMap<String, Class<?>>();
Map<String, List> dataMap = new HashMap<String, List>();
Map<String, String> noExportMap = new HashMap<String, String>();
List<ProxyFileTrafficMirrorCfg> ipLists = new ArrayList<ProxyFileTrafficMirrorCfg>();
// 导出选中记录
if (!StringUtil.isEmpty(ids)) {
ipLists = proxyFileTrafficMirrorService.findByList(ids);
} else {
entity.setTableName(IpPortCfg.getTablename());
Page<ProxyFileTrafficMirrorCfg> pageInfo = new Page<ProxyFileTrafficMirrorCfg>(request, response, "a");
pageInfo.setPageNo(1);
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
Page<ProxyFileTrafficMirrorCfg> page = proxyFileTrafficMirrorService.findPage(pageInfo, entity);
ipLists = page.getList();
}
titleList.add(entity.getMenuNameCode());
classMap.put(entity.getMenuNameCode(), ProxyFileTrafficMirrorCfg.class);
String cfgIndexInfoNoExport = ",config_describe,whether_area_block,block_type,do_log,client_port,ir_type,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
// 时间过滤
if (entity.getSearch_create_time_start() == null && entity.getSearch_create_time_end() == null) {
cfgIndexInfoNoExport = ",config_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_edit_time_start() == null && entity.getSearch_edit_time_end() == null) {
cfgIndexInfoNoExport = ",edit_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_audit_time_start() == null && entity.getSearch_audit_time_end() == null) {
cfgIndexInfoNoExport = ",audit_time" + cfgIndexInfoNoExport;
}
if (!StringUtil.isEmpty(entity.gethColumns())) {
cfgIndexInfoNoExport = "," + entity.gethColumns() + "," + cfgIndexInfoNoExport;
}
noExportMap.put(entity.getMenuNameCode(), cfgIndexInfoNoExport);
dataMap.put(entity.getMenuNameCode(), ipLists);
String timeRange = initTimeMap(entity);
noExportMap.put("timeRange", timeRange);
if ("csv".equals(entity.getExType())) {
this._exportCsv(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
}
} catch (Exception e) {
logger.error("proxyFileTrafficMirror export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
LogUtils.saveLog(request, null, e, null);
}
}
}

View File

@@ -25,7 +25,6 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.nis.domain.FunctionRegionDict; import com.nis.domain.FunctionRegionDict;
import com.nis.domain.FunctionServiceDict; import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page; import com.nis.domain.Page;
import com.nis.domain.callback.ProxyFileResponsePageCfg;
import com.nis.domain.callback.ProxyFileStrategyCfg; import com.nis.domain.callback.ProxyFileStrategyCfg;
import com.nis.domain.configuration.BaseStringCfg; import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CfgIndexInfo; import com.nis.domain.configuration.CfgIndexInfo;
@@ -64,8 +63,8 @@ public class HttpRedirectPolicyController extends BaseController {
model.addAttribute("page", page); model.addAttribute("page", page);
initPageCondition(model, cfg); initPageCondition(model, cfg);
// 获取所有的响应文件内容,阻断,或重定向时可以选择 // 获取所有的响应文件内容,阻断,或重定向时可以选择
List<ProxyFileResponsePageCfg> allProxyFileStrategys = proxyFileResponsePageService List<ProxyFileStrategyCfg> allProxyFileStrategys = proxyFileStrategyService
.getProxyFileResponsePageCfgList(new ProxyFileResponsePageCfg()); .getProxyFileStrategyCfgList(new ProxyFileStrategyCfg());
model.addAttribute("allProxyFileStrategys", allProxyFileStrategys); model.addAttribute("allProxyFileStrategys", allProxyFileStrategys);
return "/cfg/proxy/control/httpRedirectList"; return "/cfg/proxy/control/httpRedirectList";
} }
@@ -175,8 +174,8 @@ public class HttpRedirectPolicyController extends BaseController {
initFormCondition(model, entity); initFormCondition(model, entity);
} }
// 获取所有的响应文件内容,阻断,或重定向时可以选择 // 获取所有的响应文件内容,阻断,或重定向时可以选择
List<ProxyFileResponsePageCfg> allProxyFileStrategys = proxyFileResponsePageService List<ProxyFileStrategyCfg> allProxyFileStrategys = proxyFileStrategyService
.getProxyFileResponsePageCfgList(new ProxyFileResponsePageCfg()); .getProxyFileStrategyCfgList(new ProxyFileStrategyCfg());
model.addAttribute("_cfg", entity); model.addAttribute("_cfg", entity);
model.addAttribute("allProxyFileStrategys", allProxyFileStrategys); model.addAttribute("allProxyFileStrategys", allProxyFileStrategys);
return "/cfg/proxy/control/httpRedirectForm"; return "/cfg/proxy/control/httpRedirectForm";
@@ -331,18 +330,8 @@ public class HttpRedirectPolicyController extends BaseController {
Page<CfgIndexInfo> page = httpRedirectCfgService.getHttpRedirectList(pageInfo, entity); Page<CfgIndexInfo> page = httpRedirectCfgService.getHttpRedirectList(pageInfo, entity);
ipLists = page.getList(); ipLists = page.getList();
} }
Integer fucntionId = Integer.parseInt(request.getParameter("functionId"));
if(fucntionId==207){
for(CfgIndexInfo cfg:ipLists){
String userRegion3 = cfg.getUserRegion3();
if(!"".equals(userRegion3) && userRegion3 !=null){
ProxyFileResponsePageCfg temp = new ProxyFileResponsePageCfg();
temp.setCompileId(Integer.parseInt(cfg.getUserRegion3()));
List<ProxyFileResponsePageCfg> list = proxyFileResponsePageService.getProxyFileResponsePageCfgList(temp);
cfg.setUserRegion2(list.get(0).getFileDesc());
}
}
}
//日志总量 //日志总量
List<Map<String,Object>> logTotals=new ArrayList<Map<String,Object>>(); List<Map<String,Object>> logTotals=new ArrayList<Map<String,Object>>();
StringBuilder compileIds=new StringBuilder(",");//配置ids StringBuilder compileIds=new StringBuilder(",");//配置ids
@@ -376,12 +365,12 @@ public class HttpRedirectPolicyController extends BaseController {
if (entity.getFunctionId() == 207 || entity.getFunctionId() == 208) { if (entity.getFunctionId() == 207 || entity.getFunctionId() == 208) {
if (StringUtil.isEmpty(str.getUserRegion2())) { if (StringUtil.isEmpty(str.getUserRegion2())) {
if (!StringUtil.isEmpty(str.getUserRegion3())) { if (!StringUtil.isEmpty(str.getUserRegion3())) {
ProxyFileResponsePageCfg file = new ProxyFileResponsePageCfg(); ProxyFileStrategyCfg file = new ProxyFileStrategyCfg();
file.setCompileId(Integer.valueOf(str.getUserRegion3())); file.setCompileId(Integer.valueOf(str.getUserRegion3()));
List<ProxyFileResponsePageCfg> allProxyFileResponsePageCfg = proxyFileResponsePageService List<ProxyFileStrategyCfg> allProxyFileStrategys = proxyFileStrategyService
.getProxyFileResponsePageCfgList(file); .getProxyFileStrategyCfgList(file);
if (allProxyFileResponsePageCfg != null && allProxyFileResponsePageCfg.size() > 0) { if (allProxyFileStrategys != null && allProxyFileStrategys.size() > 0) {
str.setUserRegion2(allProxyFileResponsePageCfg.get(0).getCfgDesc()); str.setUserRegion2(allProxyFileStrategys.get(0).getCfgDesc());
} }
} }
} }
@@ -405,15 +394,13 @@ public class HttpRedirectPolicyController extends BaseController {
String cfgIndexInfoNoExport = ",policy_name,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,"; String cfgIndexInfoNoExport = ",policy_name,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
if (entity.getFunctionId() == 207) { if (entity.getFunctionId() == 207) {
cfgIndexInfoNoExport = ",log_total,policy_name,group_name,userregion3,userregion4,userregion5,&userregion1:response_code-userregion2:response_content-"; cfgIndexInfoNoExport = ",policy_name,group_name,userregion3,userregion4,userregion5,&userregion1:response_code-userregion2:response_content-";
} else if (entity.getFunctionId() == 208) { } else if (entity.getFunctionId() == 208) {
cfgIndexInfoNoExport = ",policy_name,group_name,userregion3,userregion4,userregion5,&userregion1:redirect_response_code-userregion2:redirect_url-"; cfgIndexInfoNoExport = ",policy_name,group_name,userregion3,userregion4,userregion5,&userregion1:redirect_response_code-userregion2:redirect_url-";
} else if (entity.getFunctionId() == 209) { } else if (entity.getFunctionId() == 209) {
cfgIndexInfoNoExport = ",policy_name,group_name,userregion4,userregion5,&userregion1:replace_zone-userregion2:replaced_content-userregion3:replace_content-"; cfgIndexInfoNoExport = ",policy_name,group_name,userregion4,userregion5,&userregion1:replace_zone-userregion2:replaced_content-userregion3:replace_content-";
} else if (entity.getFunctionId() == 211) { } else if (entity.getFunctionId() == 211) {
cfgIndexInfoNoExport = ",do_log,log_total,policy_name,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,"; cfgIndexInfoNoExport = ",do_log,log_total,policy_name,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
}else if (entity.getFunctionId() == 210) {
cfgIndexInfoNoExport = ",log_total,policy_name,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
} }
String httpUrlCfgNoExport = ",do_log,action,config_describe,valid_identifier,is_audit,creator,creator" String httpUrlCfgNoExport = ",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time" + ",config_time,editor,edit_time,auditor,audit_time"
@@ -501,7 +488,12 @@ public class HttpRedirectPolicyController extends BaseController {
dataMap.put(entity.getMenuNameCode(), ipLists); dataMap.put(entity.getMenuNameCode(), ipLists);
dataMap.put("NTC_HTTP_URL", httpUrlList); dataMap.put("NTC_HTTP_URL", httpUrlList);
dataMap.put("NTC_HTTP_REQ_HDR", httpReqHdrList); dataMap.put("NTC_HTTP_REQ_HDR", httpReqHdrList);
if (entity.getFunctionId() != 211) { if (entity.getFunctionId() != 208 && entity.getFunctionId() != 211) {
titleList.add("NTC_HTTP_RES_BODY");
classMap.put("NTC_HTTP_RES_BODY", HttpBodyCfg.class);
noExportMap.put("NTC_HTTP_RES_BODY", httpResBodyCfgNoExport);
dataMap.put("NTC_HTTP_RES_BODY", httpResBodyList);
} else if (entity.getFunctionId() != 211) {
titleList.add("NTC_HTTP_RES_HDR"); titleList.add("NTC_HTTP_RES_HDR");
titleList.add("NTC_HTTP_REQ_BODY"); titleList.add("NTC_HTTP_REQ_BODY");
classMap.put("NTC_HTTP_RES_HDR", HttpResHeadCfg.class); classMap.put("NTC_HTTP_RES_HDR", HttpResHeadCfg.class);
@@ -510,12 +502,6 @@ public class HttpRedirectPolicyController extends BaseController {
noExportMap.put("NTC_HTTP_REQ_BODY", httpReqBodyCfgNoExport); noExportMap.put("NTC_HTTP_REQ_BODY", httpReqBodyCfgNoExport);
dataMap.put("NTC_HTTP_RES_HDR", httpResHdrList); dataMap.put("NTC_HTTP_RES_HDR", httpResHdrList);
dataMap.put("NTC_HTTP_REQ_BODY", httpReqBodyList); dataMap.put("NTC_HTTP_REQ_BODY", httpReqBodyList);
if (entity.getFunctionId() != 208) {
titleList.add("NTC_HTTP_RES_BODY");
classMap.put("NTC_HTTP_RES_BODY", HttpBodyCfg.class);
noExportMap.put("NTC_HTTP_RES_BODY", httpResBodyCfgNoExport);
dataMap.put("NTC_HTTP_RES_BODY", httpResBodyList);
}
} }
titleList.add("NTC_UNIVERSAL_IP"); titleList.add("NTC_UNIVERSAL_IP");
titleList.add("NTC_SUBSCRIBE_ID"); titleList.add("NTC_SUBSCRIBE_ID");

View File

@@ -18,19 +18,15 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.nis.domain.Page; import com.nis.domain.Page;
import com.nis.domain.basics.PolicyGroupInfo; import com.nis.domain.basics.PolicyGroupInfo;
import com.nis.domain.callback.ProxyFileTrafficMirrorCfg;
import com.nis.domain.configuration.BaseStringCfg; import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CfgIndexInfo; import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.HttpUrlCfg; import com.nis.domain.configuration.HttpUrlCfg;
import com.nis.domain.configuration.InterceptPktBin; import com.nis.domain.configuration.InterceptPktBin;
import com.nis.domain.configuration.IpPortCfg; import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.PxyInterceptCfg;
import com.nis.domain.configuration.PxyObjKeyring; import com.nis.domain.configuration.PxyObjKeyring;
import com.nis.domain.configuration.PxyObjSpoofingIpPool; import com.nis.domain.configuration.PxyObjSpoofingIpPool;
import com.nis.exceptions.MaatConvertException; import com.nis.exceptions.MaatConvertException;
@@ -40,7 +36,6 @@ import com.nis.util.LogUtils;
import com.nis.util.StringUtil; import com.nis.util.StringUtil;
import com.nis.web.controller.configuration.CommonController; import com.nis.web.controller.configuration.CommonController;
import com.nis.web.security.UserUtils; import com.nis.web.security.UserUtils;
import com.nis.web.service.BaseService;
/** /**
* IP相关配置控制类 * IP相关配置控制类
@@ -62,17 +57,13 @@ public class InterceptController extends CommonController {
// 获取证书信息 // 获取证书信息
List<PxyObjKeyring> certificateList = new ArrayList<PxyObjKeyring>(); List<PxyObjKeyring> certificateList = new ArrayList<PxyObjKeyring>();
List<ProxyFileTrafficMirrorCfg> mirrorProfiles = new ArrayList<ProxyFileTrafficMirrorCfg>(); if (cfg.getFunctionId().equals(200)) {
if (cfg.getFunctionId().equals(200)) {//改为ajax查询 certificateList = pxyObjKeyringService.findPxyObjKeyrings(null, 1, 1, "ip");
//certificateList = pxyObjKeyringService.findPxyObjKeyrings(null, 1, 1, "ip");
//mirrorProfiles=proxyFileTrafficMirrorService.findMirrorList(null,1,1);
} }
if (cfg.getFunctionId().equals(201)) { if (cfg.getFunctionId().equals(201)) {
certificateList = pxyObjKeyringService.findPxyObjKeyrings(null, 1, 1, "domain"); certificateList = pxyObjKeyringService.findPxyObjKeyrings(null, 1, 1, "domain");
} }
model.addAttribute("certificateList", certificateList); model.addAttribute("certificateList", certificateList);
model.addAttribute("mirrorProfiles", mirrorProfiles);
/*if(cfg.getFunctionId().equals(214)){ /*if(cfg.getFunctionId().equals(214)){
// IP地址仿冒策略使用策略组 // IP地址仿冒策略使用策略组
//List<PolicyGroupInfo> policyGroups = policyGroupInfoService.findPolicyGroupInfosByType(6); //List<PolicyGroupInfo> policyGroups = policyGroupInfoService.findPolicyGroupInfosByType(6);
@@ -98,16 +89,13 @@ public class InterceptController extends CommonController {
} }
// 获取证书信息 // 获取证书信息
List<PxyObjKeyring> certificateList = new ArrayList<PxyObjKeyring>(); List<PxyObjKeyring> certificateList = new ArrayList<PxyObjKeyring>();
List<ProxyFileTrafficMirrorCfg> mirrorProfiles = new ArrayList<ProxyFileTrafficMirrorCfg>();
// if (entity.getFunctionId().equals(200)) { // if (entity.getFunctionId().equals(200)) {
certificateList = pxyObjKeyringService.findPxyObjKeyrings(null, 1, 1, null); certificateList = pxyObjKeyringService.findPxyObjKeyrings(null, 1, 1, null);
mirrorProfiles=proxyFileTrafficMirrorService.findMirrorList(null,1,1);
// } // }
// if (entity.getFunctionId().equals(201)) { // if (entity.getFunctionId().equals(201)) {
// certificateList = pxyObjKeyringService.findPxyObjKeyrings(null, 1, 1, "domain"); // certificateList = pxyObjKeyringService.findPxyObjKeyrings(null, 1, 1, "domain");
// } // }
model.addAttribute("certificateList", certificateList); model.addAttribute("certificateList", certificateList);
model.addAttribute("mirrorProfiles", mirrorProfiles);
model.addAttribute("_cfg", entity); model.addAttribute("_cfg", entity);
// IP地址仿冒策略使用策略组 // IP地址仿冒策略使用策略组
@@ -122,129 +110,6 @@ public class InterceptController extends CommonController {
public String saveInterceptIpCfg(RedirectAttributes redirectAttributes, Model model, HttpServletRequest request, public String saveInterceptIpCfg(RedirectAttributes redirectAttributes, Model model, HttpServletRequest request,
HttpServletResponse response, String ids, CfgIndexInfo entity) { HttpServletResponse response, String ids, CfgIndexInfo entity) {
try { try {
if(!entity.getAction().equals(2)||!entity.getServiceId().equals(512)) {
entity.setUserRegion(null);
}else {
if(entity.getUserRegion()==null) {
entity.setUserRegion(new HashMap<String,Object>());
}
//keyring
String keyring = request.getParameter("keyring");
if(StringUtils.isNotBlank(keyring)) {
entity.getUserRegion().put("keyring", Long.parseLong(keyring));
}else {
entity.getUserRegion().put("keyring", 1);
}
Map<String,Object> map = new HashMap();
//exclusions
String ev_cert = request.getParameter("ev_cert");
String cert_transparency = request.getParameter("cert_transparency");
String client_cert_req = request.getParameter("client_cert_req");
String pinning = request.getParameter("pinning");
String protocol_errors = request.getParameter("protocol_errors");
if(StringUtils.isNotBlank(ev_cert)){
map.put("ev_cert", Integer.parseInt(ev_cert.trim()));
}else {
map.put("ev_cert", 0);
}
if(StringUtils.isNotBlank(cert_transparency)){
map.put("cert_transparency",Integer.parseInt(cert_transparency.trim()));
}else {
map.put("cert_transparency", 0);
}
if(StringUtils.isNotBlank(pinning)){
map.put("pinning", Integer.parseInt(pinning.trim()));
}else {
map.put("pinning", 0);
}
if(StringUtils.isNotBlank(protocol_errors)){
map.put("protocol_errors", Integer.parseInt(protocol_errors.trim()));
}else {
map.put("protocol_errors", 0);
}
if(StringUtils.isNotBlank(client_cert_req)){
map.put("client_cert_req", Integer.parseInt(client_cert_req.trim()));
}else {
map.put("client_cert_req", 0);
}
entity.getUserRegion().put("exclusions", map);
//cert_verify
Map<String,Object> map1=new HashMap<>();
map=new HashMap<>();
String cn=request.getParameter("cn");
String issuer=request.getParameter("issuer");
String self_signed=request.getParameter("self-signed");
String expiration=request.getParameter("expiration");
if(StringUtils.isNotBlank(cn)){
map.put("cn",Integer.parseInt(cn.trim()));
}else {
map.put("cn",0);
}
if(StringUtils.isNotBlank(issuer)){
map.put("issuer",Integer.parseInt(issuer.trim()));
}else {
map.put("issuer",0);
}
if(StringUtils.isNotBlank(self_signed)){
map.put("self-signed",Integer.parseInt(self_signed.trim()));
}else {
map.put("self-signed",0);
}
if(StringUtils.isNotBlank(expiration)){
map.put("expiration",Integer.parseInt(expiration.trim()));
}else {
map.put("expiration",0);
}
map1.put("approach", map);
String fail_method=request.getParameter("fail_method");
if(StringUtils.isNotBlank(fail_method)){
map1.put("fail_method",fail_method.trim());
}
entity.getUserRegion().put("cert_verify", map1);
//ssl_ver
map=new HashMap<>();
String mirror_client=request.getParameter("mirror_client");
String allow_http2 = request.getParameter("allow_http2");
String min=request.getParameter("min");
String max=request.getParameter("max");
if(StringUtils.isNotBlank(mirror_client)){
map.put("mirror_client", Integer.parseInt(mirror_client.trim()));
}else {
mirror_client="0";
map.put("mirror_client", 0);
}
if(StringUtils.isNotBlank(allow_http2)){
map.put("allow_http2", Integer.parseInt(allow_http2.trim()));
}else {
allow_http2="0";
map.put("allow_http2", 0);
}
if("0".equals(mirror_client)) {
if(StringUtils.isNotBlank(min)){
map.put("min", min.trim());
}
if(StringUtils.isNotBlank(max)){
map.put("max", max.trim());
}
}
entity.getUserRegion().put("ssl_ver", map);
//decrypt_mirror
map=new HashMap<>();
String enable=request.getParameter("enable");
String mirror_profile=request.getParameter("mirror_profile");
if(StringUtils.isNotBlank(enable)){
map.put("enable", Integer.parseInt(enable.trim()));
}else {
enable="0";
map.put("enable", 0);
}
if("1".equals(enable)) {
if(StringUtils.isNotBlank(mirror_profile)){
map.put("mirror_profile", Integer.parseInt(mirror_profile));
}
}
entity.getUserRegion().put("decrypt_mirror", map);
}
interceptCfgService.saveInterceptCfg(entity); interceptCfgService.saveInterceptCfg(entity);
//配置仅保存 //配置仅保存
if(StringUtil.isEmpty(entity.getIsValid()) || entity.getIsValid()!=1) { if(StringUtil.isEmpty(entity.getIsValid()) || entity.getIsValid()!=1) {
@@ -304,33 +169,6 @@ public class InterceptController extends CommonController {
model.addAttribute("tabList", tabList); model.addAttribute("tabList", tabList);
return "/cfg/intercept/interceptSubList"; return "/cfg/intercept/interceptSubList";
} }
//替换keyring,mirror_profiles
@RequestMapping(value = { "/ajaxGetValues" })
@ResponseBody
public Map<String,Object> ajaxGetValues(Model model, @RequestParam(required=false,value="keyrings")String keyrings, @RequestParam(required=false,value="mirrorProfiles")String mirrorProfiles) {
Map<String,Object> datas=new HashMap<>();
List<PxyObjKeyring> certificateList = new ArrayList<PxyObjKeyring>();
List<ProxyFileTrafficMirrorCfg> mirrorProfileList = new ArrayList<ProxyFileTrafficMirrorCfg>();
// if (entity.getFunctionId().equals(200)) {
Map<String,Object> _datas=new HashMap<>();
if(StringUtils.isNotBlank(keyrings)) {
certificateList = pxyObjKeyringService.findAllPxyObjKeyrings(keyrings, 1, 1, null);
for(PxyObjKeyring certificate:certificateList) {
_datas.put(certificate.getCompileId().toString(), certificate.getCfgDesc());
}
datas.put("keyrings", _datas);
}
if(StringUtils.isNotBlank(mirrorProfiles)) {
mirrorProfileList=proxyFileTrafficMirrorService.findMirrorList(mirrorProfiles,1,1);
_datas=new HashMap<>();
for(ProxyFileTrafficMirrorCfg mirrorProfile:mirrorProfileList) {
_datas.put(mirrorProfile.getCompileId().toString(), mirrorProfile.getCfgDesc());
}
datas.put("mirrorProfiles", _datas);
}
return datas;
}
@RequestMapping(value = { "auditInterceptIpCfg", "auditInterceptDomainCfg", "auditInterceptIpPayloadCfg" }) @RequestMapping(value = { "auditInterceptIpCfg", "auditInterceptDomainCfg", "auditInterceptIpPayloadCfg" })
public String auditInterceptIpCfg(Model model, @ModelAttribute("cfg") CfgIndexInfo cfg, Integer isValid, public String auditInterceptIpCfg(Model model, @ModelAttribute("cfg") CfgIndexInfo cfg, Integer isValid,
@@ -446,7 +284,6 @@ public class InterceptController extends CommonController {
Map<String, String> replaceExportMap = new HashMap<String, String>(); Map<String, String> replaceExportMap = new HashMap<String, String>();
Properties prop = getMsgProp(); Properties prop = getMsgProp();
List<CfgIndexInfo> ipLists = new ArrayList<CfgIndexInfo>(); List<CfgIndexInfo> ipLists = new ArrayList<CfgIndexInfo>();
List<PxyInterceptCfg> pxyInterceptCfgs=new ArrayList<>();
// 导出选中记录 // 导出选中记录
if (!StringUtil.isEmpty(ids)) { if (!StringUtil.isEmpty(ids)) {
ipLists = ipCfgService.getByIdsList(ids); ipLists = ipCfgService.getByIdsList(ids);
@@ -489,132 +326,59 @@ public class InterceptController extends CommonController {
} }
// 获取证书信息 // 获取证书信息
List<PxyObjKeyring> certificateList = new ArrayList<PxyObjKeyring>(); List<PxyObjKeyring> certificateList = new ArrayList<PxyObjKeyring>();
//获取镜像相关信息
List<ProxyFileTrafficMirrorCfg> mirrorProfileList=new ArrayList<>();
if (entity.getFunctionId().equals(200)) { if (entity.getFunctionId().equals(200)) {
certificateList = pxyObjKeyringService.findPxyObjKeyrings(null, 1, 1, "ip"); certificateList = pxyObjKeyringService.findPxyObjKeyrings(null, 1, 1, "ip");
mirrorProfileList=proxyFileTrafficMirrorService.findMirrorList(null, 1, 1);
} }
if (entity.getFunctionId().equals(201)) { if (entity.getFunctionId().equals(201)) {
certificateList = pxyObjKeyringService.findPxyObjKeyrings(null, 1, 1, "domain"); certificateList = pxyObjKeyringService.findPxyObjKeyrings(null, 1, 1, "domain");
} }
for (CfgIndexInfo str : ipLists) { for (CfgIndexInfo str : ipLists) {
PxyInterceptCfg pxyInterceptCfg=new PxyInterceptCfg();
BeanUtils.copyProperties(str, pxyInterceptCfg);
if (!StringUtil.isEmpty(str.getUserRegion5())) { if (!StringUtil.isEmpty(str.getUserRegion5())) {
String cs = DictUtils.getDictLabel("INTERCEPT_DOMAIN_INTENSITY", str.getUserRegion5()); String cs = DictUtils.getDictLabel("INTERCEPT_DOMAIN_INTENSITY", str.getUserRegion5());
str.setUserRegion5(prop.getProperty(cs)); str.setUserRegion5(prop.getProperty(cs));
} }
str.setUserRegion(new HashMap<String,Object>());
if (certificateList != null) { if (certificateList != null) {
if (entity.getFunctionId().equals(200) ) { if (entity.getFunctionId() == 200 || entity.getFunctionId() == 201) {
if (!StringUtil.isEmpty(str.getUserRegion1())&&str.getUserRegion1().startsWith("{")) { if (!StringUtil.isEmpty(str.getUserRegion1())) {
boolean flag = false;
Map<String,Object> userregion=BaseService.gsonFromJson(str.getUserRegion1(), Map.class); for (PxyObjKeyring pxyObjKeyring : certificateList) {
if(userregion.containsKey("keyring")) { if (str.getUserRegion1().equals(String.valueOf(pxyObjKeyring.getCompileId()))) {
for (PxyObjKeyring pxyObjKeyring : certificateList) { str.setUserRegion1(pxyObjKeyring.getCfgDesc());
if (String.valueOf(pxyObjKeyring.getCompileId()).equals(userregion.get("keyring").toString())) { flag = true;
pxyInterceptCfg.setKeyring(pxyObjKeyring.getCfgDesc()); break;
break;
}
} }
} }
if(((Map<String,Object>)userregion.get("exclusions")).containsKey("ev_cert")){ if (!flag) {
pxyInterceptCfg.setEvCert(((Map<String,Object>)userregion.get("exclusions")).get("ev_cert").toString()); str.setUserRegion1(null);
}
if(((Map<String,Object>)userregion.get("exclusions")).containsKey("cert_transparency")){
pxyInterceptCfg.setCertTransparency(((Map<String,Object>)userregion.get("exclusions")).get("cert_transparency").toString());
}
if(((Map<String,Object>)userregion.get("exclusions")).containsKey("ev_cert")) {
pxyInterceptCfg.setClientCertReq(((Map<String,Object>)userregion.get("exclusions")).get("client_cert_req").toString());
}
if(((Map<String,Object>)userregion.get("exclusions")).containsKey("ev_cert")) {
pxyInterceptCfg.setPinning(((Map<String,Object>)userregion.get("exclusions")).get("pinning").toString());
}
if(((Map<String,Object>)userregion.get("exclusions")).containsKey("ev_cert")) {
pxyInterceptCfg.setProtocolErrors(String.valueOf(((Map<String,Object>)userregion.get("exclusions")).get("protocol_errors")));
}
if(((Map<String,Object>)((Map<String,Object>)userregion.get("cert_verify")).get("approach")).containsKey("cn")) {
pxyInterceptCfg.setCn(((Map<String,Object>)((Map<String,Object>)userregion.get("cert_verify")).get("approach")).get("cn").toString());
}
if(((Map<String,Object>)((Map<String,Object>)userregion.get("cert_verify")).get("approach")).containsKey("issuer")) {
pxyInterceptCfg.setIssuer(((Map<String,Object>)((Map<String,Object>)userregion.get("cert_verify")).get("approach")).get("issuer").toString());
}
if(((Map<String,Object>)((Map<String,Object>)userregion.get("cert_verify")).get("approach")).containsKey("self-signed")) {
pxyInterceptCfg.setSelfSigned(((Map<String,Object>)((Map<String,Object>)userregion.get("cert_verify")).get("approach")).get("self-signed").toString());
}
if(((Map<String,Object>)((Map<String,Object>)userregion.get("cert_verify")).get("approach")).containsKey("expiration")) {
pxyInterceptCfg.setExpiration(((Map<String,Object>)((Map<String,Object>)userregion.get("cert_verify")).get("approach")).get("expiration").toString());
}
if(((Map<String,Object>)userregion.get("cert_verify")).containsKey("fail_method")) {
pxyInterceptCfg.setFailMethod(((Map<String,Object>)userregion.get("cert_verify")).get("fail_method").toString());
}
if(((Map<String,Object>)userregion.get("ssl_ver")).containsKey("min")) {
pxyInterceptCfg.setMin(((Map<String,Object>)userregion.get("ssl_ver")).get("min").toString());
}
if(((Map<String,Object>)userregion.get("ssl_ver")).containsKey("max")) {
pxyInterceptCfg.setMax(((Map<String,Object>)userregion.get("ssl_ver")).get("max").toString());
}
if(((Map<String,Object>)userregion.get("ssl_ver")).containsKey("mirror_client")) {
pxyInterceptCfg.setMirrorClient(((Map<String,Object>)userregion.get("ssl_ver")).get("mirror_client").toString());
}
if(((Map<String,Object>)userregion.get("ssl_ver")).containsKey("allow_http2")) {
pxyInterceptCfg.setAllowHttp2(((Map<String,Object>)userregion.get("ssl_ver")).get("allow_http2").toString());
}
if(((Map<String,Object>)userregion.get("decrypt_mirror")).containsKey("enable")) {
pxyInterceptCfg.setEnable(((Map<String,Object>)userregion.get("decrypt_mirror")).get("enable").toString());
}
if(((Map<String,Object>)userregion.get("decrypt_mirror")).containsKey("mirror_profile")) {
}
//pxyInterceptCfg.setMirrorProfile(((Map<String,Object>)userregion.get("decrypt_mirror")).get("mirror_profile").toString());
if(((Map<String,Object>)userregion.get("decrypt_mirror")).containsKey("mirror_profile")) {
for (ProxyFileTrafficMirrorCfg mirrorProfile : mirrorProfileList) {
if (String.valueOf(mirrorProfile.getCompileId()).equals(((Map<String,Object>)userregion.get("decrypt_mirror")).get("mirror_profile").toString())) {
pxyInterceptCfg.setMirrorProfile(mirrorProfile.getCfgDesc());
break;
}
}
} }
} }
} }
} }
pxyInterceptCfgs.add(pxyInterceptCfg);
} }
titleList.add(entity.getMenuNameCode()); titleList.add(entity.getMenuNameCode());
if(entity.getFunctionId().equals(200)) { classMap.put(entity.getMenuNameCode(), CfgIndexInfo.class);
classMap.put(entity.getMenuNameCode(), PxyInterceptCfg.class);
}else {
classMap.put(entity.getMenuNameCode(), CfgIndexInfo.class);
}
String cfgIndexInfoNoExport = ""; String cfgIndexInfoNoExport = "";
String ipPortInfoNoExport = ",do_log,action,config_describe,valid_identifier,is_audit,creator,creator" String ipPortInfoNoExport = ",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time" + ",config_time,editor,edit_time,auditor,audit_time"
+ ",letter,whether_area_block,classification,attribute,label,block_type," + ",letter,whether_area_block,classification,attribute,label"
+ ",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,group_name,"; + ",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,group_name,";
String interceptNoExport = ",do_log,action,config_describe,valid_identifier,is_audit,creator,creator" String interceptNoExport = ",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time" + ",config_time,editor,edit_time,auditor,audit_time"
+ ",letter,whether_area_block,classification,attribute,label,block_type," + ",letter,whether_area_block,classification,attribute,label"
+ ",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,group_name,"; + ",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,group_name,";
String httpUrlCfgNoExport = ",do_log,action,config_describe,valid_identifier,is_audit,creator,creator" String httpUrlCfgNoExport = ",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time" + ",config_time,editor,edit_time,auditor,audit_time"
+ ",letter,whether_area_block,classification,attribute,label" + ",letter,whether_area_block,classification,attribute,label"
+ ",userregion1,userregion2,userregion3,userregion4,userregion5,block_type,"; + ",userregion1,userregion2,userregion3,userregion4,userregion5,";
List<IpPortCfg> ipList = new ArrayList<IpPortCfg>(); List<IpPortCfg> ipList = new ArrayList<IpPortCfg>();
List<BaseStringCfg> httpUrlList = new ArrayList<BaseStringCfg>(); List<BaseStringCfg> httpUrlList = new ArrayList<BaseStringCfg>();
List<BaseStringCfg> pktBinList = new ArrayList<BaseStringCfg>(); List<BaseStringCfg> pktBinList = new ArrayList<BaseStringCfg>();
int index=0;
for (CfgIndexInfo cfg : ipLists) { for (CfgIndexInfo cfg : ipLists) {
for (Map<String,Object> logTotal : logTotals) { for (Map<String,Object> logTotal : logTotals) {
if(cfg.getCompileId().equals(Integer.parseInt((String) logTotal.get("compileId")))){ if(cfg.getCompileId().equals(Integer.parseInt((String) logTotal.get("compileId")))){
cfg.setTotalLogs((Long)logTotal.get("sum")); cfg.setTotalLogs((Long)logTotal.get("sum"));
if (entity.getFunctionId().equals(200)){
pxyInterceptCfgs.get(index).setTotalLogs((Long)logTotal.get("sum"));
}
break; break;
} }
} }
@@ -624,40 +388,20 @@ public class InterceptController extends CommonController {
pktBinList.addAll(maps.get("PXY_INTERCEPT_PKT_BIN")); pktBinList.addAll(maps.get("PXY_INTERCEPT_PKT_BIN"));
if (entity.getFunctionId() == 200){ if (entity.getFunctionId() == 200){
Properties msgProp = getMsgProp(); Properties msgProp = getMsgProp();
if(cfg.getAction().equals(2)) { if(cfg.getAction().equals(1)) {
pxyInterceptCfgs.get(index).setUserRegion5(msgProp.getProperty("intercept")); cfg.setUserRegion5(msgProp.getProperty("intercept"));
}else if(cfg.getAction().equals(48)) { }else if(cfg.getAction().equals(48)) {
pxyInterceptCfgs.get(index).setUserRegion5(msgProp.getProperty("action_spoofing")); cfg.setUserRegion5(msgProp.getProperty("action_spoofing"));
}else if(cfg.getAction().equals(128)) { }else if(cfg.getAction().equals(128)) {
pxyInterceptCfgs.get(index).setUserRegion5(msgProp.getProperty("bypass")); cfg.setUserRegion5(msgProp.getProperty("bypass"));
}else { }else {
pxyInterceptCfgs.get(index).setUserRegion5(msgProp.getProperty(DictUtils.getDictLabels("SERVICE_ACTION", cfg.getAction().toString(), cfg.getAction().toString()))); cfg.setUserRegion5(msgProp.getProperty(DictUtils.getDictLabels("SERVICE_ACTION", cfg.getAction().toString(), cfg.getAction().toString())));
} }
} }
if (214==entity.getFunctionId()) {
if (!StringUtil.isBlank(cfg.getUserRegion1())) {
cfg.setUserRegion1(DictUtils.getDictLabels("SPOOFING_IP_TYPE", cfg.getUserRegion1(),cfg.getUserRegion1()));
}
}
index++;
} }
//为何多循环一次???
/*if (214==entity.getFunctionId()) {
for (CfgIndexInfo cfg : ipLists) {
if (!StringUtil.isBlank(cfg.getUserRegion1())) {
cfg.setUserRegion1(DictUtils.getDictLabels("SPOOFING_IP_TYPE", cfg.getUserRegion1(),cfg.getUserRegion1()));
}
}
}*/
pktBinList = BaseStringCfg.replaceBaseKeyList(pktBinList); pktBinList = BaseStringCfg.replaceBaseKeyList(pktBinList);
httpUrlList = BaseStringCfg.baseHexList(httpUrlList); httpUrlList = BaseStringCfg.baseHexList(httpUrlList);
if(entity.getFunctionId().equals(200)) { dataMap.put(entity.getMenuNameCode(), ipLists);
dataMap.put(entity.getMenuNameCode(), pxyInterceptCfgs);
}else {
dataMap.put(entity.getMenuNameCode(), ipLists);
}
if (entity.getFunctionId() == 212) { // IP Payload if (entity.getFunctionId() == 212) { // IP Payload
cfgIndexInfoNoExport = ",policy_name,group_name,userregion4,userregion5,&userregion1:replace_zone-userregion2:replaced_content-userregion3:replace_content-"; cfgIndexInfoNoExport = ",policy_name,group_name,userregion4,userregion5,&userregion1:replace_zone-userregion2:replaced_content-userregion3:replace_content-";
titleList.add("PXY_INTERCEPT_IP"); titleList.add("PXY_INTERCEPT_IP");
@@ -669,15 +413,11 @@ public class InterceptController extends CommonController {
dataMap.put("PXY_INTERCEPT_IP", ipList); dataMap.put("PXY_INTERCEPT_IP", ipList);
dataMap.put("PXY_INTERCEPT_PKT_BIN", pktBinList); dataMap.put("PXY_INTERCEPT_PKT_BIN", pktBinList);
} else if (entity.getFunctionId() == 200) {// IP拦截 } else if (entity.getFunctionId() == 200) {// IP拦截
cfgIndexInfoNoExport = ",log_total,userRegion1,userRegion5,do_log,policy_name,group_name,userregion3,userregion4,block_type,&userregion2:ratelimit-userregion5:block_type"; cfgIndexInfoNoExport = ",policy_name,group_name,userregion3,userregion4,block_type,&userregion1:intercept_file_strategy-userregion2:ratelimit-userregion5:block_type";
titleList.add("PXY_INTERCEPT_IP"); titleList.add("PXY_INTERCEPT_IP");
classMap.put("PXY_INTERCEPT_IP", IpPortCfg.class); classMap.put("PXY_INTERCEPT_IP", IpPortCfg.class);
noExportMap.put("PXY_INTERCEPT_IP", ipPortInfoNoExport); noExportMap.put("PXY_INTERCEPT_IP", ipPortInfoNoExport);
dataMap.put("PXY_INTERCEPT_IP", ipList); dataMap.put("PXY_INTERCEPT_IP", ipList);
titleList.add("PXY_INTERCEPT_DOMAIN");
classMap.put("PXY_INTERCEPT_DOMAIN", HttpUrlCfg.class);
noExportMap.put("PXY_INTERCEPT_DOMAIN", httpUrlCfgNoExport);
dataMap.put("PXY_INTERCEPT_DOMAIN", httpUrlList);
} else if (entity.getFunctionId() == 201) {// 域名拦截 } else if (entity.getFunctionId() == 201) {// 域名拦截
cfgIndexInfoNoExport = ",policy_name,group_name,userregion3,userregion4,&userregion2:ratelimit-userregion1:intercept_file_strategy-userregion5:intercept_intensity-"; cfgIndexInfoNoExport = ",policy_name,group_name,userregion3,userregion4,&userregion2:ratelimit-userregion1:intercept_file_strategy-userregion5:intercept_intensity-";
titleList.add("NTC_HTTP_URL"); titleList.add("NTC_HTTP_URL");

View File

@@ -1,565 +0,0 @@
package com.nis.web.controller.configuration.proxy;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.alibaba.fastjson.JSON;
import com.nis.domain.FunctionRegionDict;
import com.nis.domain.Page;
import com.nis.domain.callback.ProxyFileHijackCfg;
import com.nis.domain.callback.ProxyFileInsertScriptCfg;
import com.nis.domain.callback.ProxyFileResponsePageCfg;
import com.nis.domain.callback.ProxyFileStrategyCfg;
import com.nis.domain.configuration.BaseCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.domain.configuration.HttpBodyCfg;
import com.nis.domain.configuration.HttpReqHeadCfg;
import com.nis.domain.configuration.HttpResHeadCfg;
import com.nis.domain.configuration.HttpUrlCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.ManipulatCfgExport;
import com.nis.domain.configuration.NtcSubscribeIdCfg;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.LogUtils;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
import jersey.repackaged.com.google.common.collect.Lists;
/**
* 操控策略业务
*/
@Controller
@RequestMapping("${adminPath}/proxy/control/manipulatPolicy")
public class ManipulatPolicyController extends BaseController {
@RequestMapping("list")
public String list(Model model, @ModelAttribute("cfg") CfgIndexInfo cfg, HttpServletRequest request, HttpServletResponse response) {
Page<CfgIndexInfo> searchPage = new Page<CfgIndexInfo>(request, response, "a");
Page<CfgIndexInfo> page = manipulatPolicyService.getPolicyList(searchPage, cfg);
model.addAttribute("page", page);
initPageCondition(model, cfg);
// 获取所有的响应文件内容Block可以选择
/*List<ProxyFileStrategyCfg> allProxyFileStrategys = proxyFileStrategyService.getProxyFileStrategyCfgList(new ProxyFileStrategyCfg());
model.addAttribute("allProxyFileStrategys", allProxyFileStrategys);*/
manipulatPolicyService.setFileRegion(model);
return "/cfg/proxy/control/manipulatPolicyList";
}
@RequestMapping("form")
public String form(Model model, @ModelAttribute("cfg") CfgIndexInfo entity, HttpServletRequest request, HttpServletResponse response, String ids) {
if (StringUtils.isNotBlank(ids)) {
entity = manipulatPolicyService.getPolicyCfg(Long.parseLong(ids), null);
HttpUrlCfg urlCfg = new HttpUrlCfg();
urlCfg.setCfgType(Constants.HTTP_REDIRECT_URL_REGION);
entity.setHttpUrl(urlCfg);
HttpReqHeadCfg reqHdrCfg = new HttpReqHeadCfg();
reqHdrCfg.setCfgType(Constants.HTTP_REDIRECT_REQ_HEAD_REGION);
entity.setHttpReqHdr(reqHdrCfg);
HttpResHeadCfg resHdrCfg = new HttpResHeadCfg();
resHdrCfg.setCfgType(Constants.HTTP_REDIRECT_RES_HEAD_REGION);
entity.setHttpResHdr(resHdrCfg);
HttpBodyCfg reqBodyCfg = new HttpBodyCfg();
reqBodyCfg.setCfgType(Constants.HTTP_REDIRECT_REQ_BODY_REGION);
entity.setHttpReqBody(reqBodyCfg);
HttpBodyCfg resBodyCfg = new HttpBodyCfg();
resBodyCfg.setCfgType(Constants.HTTP_REDIRECT_RES_BODY_REGION);
entity.setHttpResBody(resBodyCfg);
IpPortCfg ipPortCfg = new IpPortCfg();
ipPortCfg.setCfgType(Constants.HTTP_REDIRECT_IP_REGION);
entity.setIpPort(ipPortCfg);
NtcSubscribeIdCfg subscribeIdCfg = new NtcSubscribeIdCfg();
subscribeIdCfg.setCfgType(Constants.PXY_CRTL_SUBSCRIBE_ID_REGION);
entity.setNtcSubscribeIdCfg(subscribeIdCfg);
if (entity.getHttpUrlList().size() == 0) {
entity.getHttpUrlList().add(urlCfg);
}
if (entity.getHttpReqHdrList().size() == 0) {
entity.getHttpReqHdrList().add(reqHdrCfg);
}
if (entity.getHttpResHdrList().size() == 0) {
entity.getHttpResHdrList().add(resHdrCfg);
}
if (entity.getHttpReqBodyList().size() == 0) {
entity.getHttpReqBodyList().add(reqBodyCfg);
}
if (entity.getHttpResBodyList().size() == 0) {
entity.getHttpResBodyList().add(resBodyCfg);
}
if (entity.getIpPortList().size() == 0) {
entity.getIpPortList().add(ipPortCfg);
}
if (entity.getNtcSubscribeIdCfgList().size() == 0) {
entity.getNtcSubscribeIdCfgList().add(subscribeIdCfg);
}
initUpdateFormCondition(model, entity);
manipulatPolicyService.setFileRegion(model);
} else {
// 设置http各类配置的配置域类型
HttpUrlCfg urlCfg = new HttpUrlCfg();
urlCfg.setCfgType(Constants.HTTP_REDIRECT_URL_REGION);
entity.setHttpUrl(urlCfg);
HttpReqHeadCfg reqHdrCfg = new HttpReqHeadCfg();
reqHdrCfg.setCfgType(Constants.HTTP_REDIRECT_REQ_HEAD_REGION);
entity.setHttpReqHdr(reqHdrCfg);
HttpResHeadCfg resHdrCfg = new HttpResHeadCfg();
resHdrCfg.setCfgType(Constants.HTTP_REDIRECT_RES_HEAD_REGION);
entity.setHttpResHdr(resHdrCfg);
HttpBodyCfg reqBodyCfg = new HttpBodyCfg();
reqBodyCfg.setCfgType(Constants.HTTP_REDIRECT_REQ_BODY_REGION);
entity.setHttpReqBody(reqBodyCfg);
HttpBodyCfg resBodyCfg = new HttpBodyCfg();
resBodyCfg.setCfgType(Constants.HTTP_REDIRECT_RES_BODY_REGION);
entity.setHttpResBody(resBodyCfg);
IpPortCfg ipPortCfg = new IpPortCfg();
ipPortCfg.setCfgType(Constants.HTTP_IP_REGION);
entity.setIpPort(ipPortCfg);
// subscribeId
NtcSubscribeIdCfg subscribeIdCfg = new NtcSubscribeIdCfg();
subscribeIdCfg.setCfgType(Constants.PXY_CRTL_SUBSCRIBE_ID_REGION);
entity.setNtcSubscribeIdCfg(subscribeIdCfg);
List<HttpUrlCfg> urlList = new ArrayList<HttpUrlCfg>();
urlList.add(urlCfg);
entity.setHttpUrlList(urlList);
List<HttpReqHeadCfg> reqHdrList = new ArrayList<HttpReqHeadCfg>();
reqHdrList.add(reqHdrCfg);
entity.setHttpReqHdrList(reqHdrList);
List<HttpResHeadCfg> resHdrList = new ArrayList<HttpResHeadCfg>();
resHdrList.add(resHdrCfg);
entity.setHttpResHdrList(resHdrList);
List<HttpBodyCfg> reqBodyList = new ArrayList<HttpBodyCfg>();
reqBodyList.add(reqBodyCfg);
entity.setHttpReqBodyList(reqBodyList);
List<HttpBodyCfg> resBodyList = new ArrayList<HttpBodyCfg>();
resBodyList.add(resBodyCfg);
entity.setHttpResBodyList(resBodyList);
List<IpPortCfg> ipPortList = new ArrayList<IpPortCfg>();
ipPortList.add(ipPortCfg);
entity.setIpPortList(ipPortList);
List<NtcSubscribeIdCfg> subscribeCfgList = Lists.newArrayList();
subscribeCfgList.add(subscribeIdCfg);
entity.setNtcSubscribeIdCfgList(subscribeCfgList);
initFormCondition(model, entity);
}
// 获取所有的响应文件内容Block可以选择
/*List<ProxyFileStrategyCfg> allProxyFileStrategys = proxyFileStrategyService.getProxyFileStrategyCfgList(new ProxyFileStrategyCfg());
model.addAttribute("allProxyFileStrategys", allProxyFileStrategys);*/
model.addAttribute("_cfg", entity);
return "/cfg/proxy/control/manipulatPolicyForm";
}
@RequestMapping("saveOrUpdate")
public String saveOrUpdate(Model model, @ModelAttribute("cfg") CfgIndexInfo cfg, RedirectAttributes redirectAttributes,
HttpServletRequest request, HttpServletResponse response) {
try {
manipulatPolicyService.savePolicyCfg(cfg);
if(StringUtil.isEmpty(cfg.getIsValid()) || cfg.getIsValid()!=1) { // 配置仅保存
addMessage(redirectAttributes, "success", "save_success");
}else { // 配置直接生效
addMessage(redirectAttributes, "success", "audit_success");
}
} catch (Exception e) {
logger.error("save_failed", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} else {
addMessage(redirectAttributes, "error", "save_failed");
LogUtils.saveLog(request, null, e, null);
}
}
return "redirect:" + adminPath + "/proxy/control/manipulatPolicy/list?functionId=" + cfg.getFunctionId();
}
@RequestMapping("ajaxPolicySubList")
public String ajaxPolicySubList(Model model, Long cfgId, Integer index, Integer compileId) {
CfgIndexInfo cfg = manipulatPolicyService.getPolicyCfg(cfgId, compileId);
model.addAttribute("_cfg", cfg);
model.addAttribute("index", index);
return "/cfg/proxy/control/httpRedirectSubList";
}
@RequestMapping("delete")
public String delete(Integer isAudit, Integer isValid, String ids, Integer functionId, RedirectAttributes redirectAttributes,
HttpServletRequest request, HttpServletResponse response, @ModelAttribute("cfg")CfgIndexInfo cfg) {
try {
if (!StringUtil.isEmpty(ids)) {
manipulatPolicyService.updatePolicyCfgValid(isValid, ids, functionId);
addMessage(redirectAttributes, "success", "delete_success");
}else {
// 批量删除
Page<CfgIndexInfo> searchPage = new Page<CfgIndexInfo>(request, response, "a");
deleteAll(searchPage, functionId, cfg);
}
} catch (Exception e) {
logger.error("配置删除失败:", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} else {
addMessage(redirectAttributes, "error", "delete_failed");
LogUtils.saveLog(request, null, e, null);
}
}
return "redirect:" + adminPath + "/proxy/control/manipulatPolicy/list?functionId=" + functionId;
}
@RequestMapping("audit")
public String audit(Model model, @ModelAttribute("cfg") CfgIndexInfo cfg, Integer isValid, Integer isAudit, String ids,
Integer functionId, RedirectAttributes redirectAttributes, HttpServletResponse response,HttpServletRequest request) {
if (!StringUtil.isEmpty(ids)) {
CfgIndexInfo entity = new CfgIndexInfo();
String[] idArray = ids.split(",");
for (String id : idArray) {
entity = manipulatPolicyService.getPolicyCfg(Long.parseLong(id), null);
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setAuditorId(UserUtils.getUser().getId());
entity.setAuditTime(new Date());
entity.setFunctionId(functionId);
try {
manipulatPolicyService.auditPolicyCfg(entity, isAudit,Constants.INSERT_ACTION);
addMessage(redirectAttributes, "success", "audit_success");
} catch (Exception e) {
e.printStackTrace();
logger.info("http重定向配置下发失败" + e.getMessage());
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} else {
addMessage(redirectAttributes, "error", "audit_failed");
LogUtils.saveLog(request, null, e, null);
}
}
}
} else {// 条件下所有配置审核
Page<CfgIndexInfo> searchPage = new Page<CfgIndexInfo>(request, response, "a");
Page<CfgIndexInfo> auditPage = new Page<CfgIndexInfo>(request, response, "a");
BeanUtils.copyProperties(searchPage, auditPage);
try {
auditAll(auditPage, isValid, cfg);
addMessage(redirectAttributes, "success", "audit_success");
} catch (Exception e) {
logger.error("配置下发失败:", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} else {
addMessage(redirectAttributes, "error", "audit_failed");
LogUtils.saveLog(request, null, e, null);
}
}
return list(model, cfg, request, response);
}
return "redirect:" + adminPath + "/proxy/control/manipulatPolicy/list?functionId=" + functionId;
}
// 配置导出
@RequestMapping(value = "exportPolicy")
public void exportPolicy(Model model,@ModelAttribute("cfg") CfgIndexInfo entity, String ids, RedirectAttributes redirectAttributes,
HttpServletRequest request, HttpServletResponse response) {
try {
// export data info
List<String> titleList = new ArrayList<String>();
Map<String, Class<?>> classMap = new HashMap<String, Class<?>>();
Map<String, List> dataMap = new HashMap<String, List>();
Map<String, String> noExportMap = new HashMap<String, String>();
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(entity.getFunctionId());
List<CfgIndexInfo> ipLists = new ArrayList<CfgIndexInfo>();
// 导出选中记录
if (!StringUtil.isEmpty(ids)) {
ipLists = ipCfgService.getByIdsList(ids);
} else {
Page<CfgIndexInfo> pageInfo = new Page<CfgIndexInfo>(request, response, "a");
pageInfo.setPageNo(1);
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
Page<CfgIndexInfo> page = manipulatPolicyService.getPolicyList(pageInfo, entity);
ipLists = page.getList();
}
//日志总量
List<Map<String,Object>> logTotals=new ArrayList<Map<String,Object>>();
StringBuilder compileIds=new StringBuilder(",");//配置ids
Set<Integer> set=new HashSet<Integer>();//服务ids
Map<String, String> blockDict = DictUtils.getDictMap("RESPONSE_CODE"); // Block
Map<String, String> redirectDict = DictUtils.getDictMap("REDIRECT_RESPONSE_CODE"); // Redirect
Map<String, String> replaceDict = DictUtils.getDictMap("CONTROL_REPLACE_ZONE"); // Replace
// 用于检索引用的文件配置信息
ProxyFileResponsePageCfg searchResponseFile = new ProxyFileResponsePageCfg();
ProxyFileHijackCfg searchHijackFile = new ProxyFileHijackCfg();
ProxyFileInsertScriptCfg searchInsertFile = new ProxyFileInsertScriptCfg();
Properties prop = getMsgProp();
List<ManipulatCfgExport> baseLists = new ArrayList<ManipulatCfgExport>();
for (CfgIndexInfo source : ipLists) {
ManipulatCfgExport str = new ManipulatCfgExport();
BeanUtils.copyProperties(source, str);
str.setActionExport("action_manipulate");
if(str.getUserRegion5().equals("85")) {
str.setMethodExport("action_hijack");
}else if(str.getUserRegion5().equals("90")) {
str.setMethodExport("action_insert");
}else {
str.setMethodExport(str.getUserRegion5());
}
if(str.getIsAudit()!=0){
set.add(str.getServiceId());
compileIds.append(str.getCompileId()+",");
}else{
Map<String,Object> logTotal=new HashMap<String,Object>();
logTotal.put("compileId", str.getCompileId()+"");
logTotal.put("sum",0L);
logTotals.add(logTotal);
}
if (!str.getUserRegion5().equals("85") && !str.getUserRegion5().equals("90")) {
String value = "";
/*if(str.getUserRegion5().equals("16")) {// Block
value = blockDict.get(str.getUserRegion1());
str.setResponseCode(prop.getProperty(value));
str.setUserRegion1(str.getUserRegion2());
str.setUserRegion2(null);
}else*/
if(str.getUserRegion5().equals("48")) {// Redirect
value = redirectDict.get(str.getUserRegion1());
str.setResponseCode(prop.getProperty(value));
str.setUserRegion1(null);
}else if(str.getUserRegion5().equals("80")) {// Replace
value = replaceDict.get(str.getUserRegion1());
str.setUserRegion5(str.getUserRegion3());
str.setUserRegion3(prop.getProperty(value));
str.setUserRegion4(str.getUserRegion2());
str.setUserRegion1(null);
str.setUserRegion2(null);
}
/*if (str.getUserRegion5().equals("16") || str.getUserRegion5().equals("48")) {
if (!StringUtil.isEmpty(str.getUserRegion3())) { // 是否存在文件策略
searchResponseFile.setCompileId(Integer.valueOf(str.getUserRegion3()));
List<ProxyFileResponsePageCfg> allProxyFileStrategys = proxyFileResponsePageService.getProxyFileResponsePageCfgList(searchResponseFile);
if (allProxyFileStrategys != null && allProxyFileStrategys.size() > 0) {
str.setUserRegion1(allProxyFileStrategys.get(0).getFileDesc());
}
str.setUserRegion3(null);
}
}*/
}
if(str.getUserRegion5().equals("48") || str.getUserRegion5().equals("85") ||
str.getUserRegion5().equals("90")) {
if(str.getUserRegion5().equals("85")) {
searchHijackFile.setCompileId(Integer.parseInt(source.getUserRegion4()));
Page<ProxyFileHijackCfg> page = proxyFileHijackService.findPage(new Page<ProxyFileHijackCfg>(request, response, "a"), searchHijackFile);
List<ProxyFileHijackCfg> list = page.getList();
if(list != null && list.size() > 0) {
str.setProfileInfo(list.get(0).getCfgDesc());
}
//str.setUserRegion1(null);
str.setUserRegion4(null);
}else if(str.getUserRegion5().equals("90")) {
searchInsertFile.setCompileId(Integer.parseInt(source.getUserRegion4()));
Page<ProxyFileInsertScriptCfg> page = proxyFileInsertScriptService.findPage(new Page<ProxyFileInsertScriptCfg>(request, response, "a"), searchInsertFile);
List<ProxyFileInsertScriptCfg> list = page.getList();
if(list != null && list.size() > 0) {
str.setProfileInfo(list.get(0).getCfgDesc());
}
str.setUserRegion4(null);
}
str.setUserRegion5(null);
}
baseLists.add(str);
}
//获取日志总量
StringBuilder serviceIds=new StringBuilder(",");
if(set.size()>0) {
for (Integer id : set) {
serviceIds.append(id+",");
}
String serviceIdsStr=serviceIds.toString().substring(1, serviceIds.length()-1);
String compileIdsStr=compileIds.toString().substring(1, compileIds.length()-1);
if(!StringUtils.isBlank(serviceIdsStr)&&!StringUtils.isBlank(compileIdsStr)){
List<Map<String,Object>> logs = getLogTotal( null,serviceIdsStr,compileIdsStr);
logTotals.addAll(logs);
}
}
String cfgIndexInfoNoExport = ",log_total,policy_name,group_name,userregion1,&method_export:method-responseCode:response_code-userregion2:redirect_url-userregion3:replace_zone-userregion4:replaced_content-userregion5:replace_content-";
String httpUrlCfgNoExport = ",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time"
+ ",letter,whether_area_block,classification,attribute,label"
+ ",userregion1,userregion2,userregion3,userregion4,userregion5,";
String httpReqHeadCfgNoExport = ",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time"
+ ",letter,whether_area_block,classification,attribute,label"
+ ",userregion1,userregion2,userregion3,userregion4,userregion5,";
String httpResHeadCfgNoExport = ",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time"
+ ",letter,whether_area_block,classification,attribute,label"
+ ",userregion1,userregion2,userregion3,userregion4,userregion5,";
String httpReqBodyCfgNoExport = ",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time"
+ ",letter,whether_area_block,classification,attribute,label"
+ ",userregion1,userregion2,userregion3,userregion4,userregion5,";
String httpResBodyCfgNoExport = ",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time"
+ ",letter,whether_area_block,classification,attribute,label"
+ ",userregion1,userregion2,userregion3,userregion4,userregion5,";
String ipPortCfgNoExport = ",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time"
+ ",letter,whether_area_block,classification,attribute,label"
+ ",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,group_name,";
String ntcSubscribeIdCfgNoExport = ",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time"
+ ",letter,whether_area_block,classification,attribute,label"
+ ",userregion1,userregion2,userregion3,userregion4,userregion5,";
// 时间过滤
if (entity.getSearch_create_time_start() == null && entity.getSearch_create_time_end() == null) {
cfgIndexInfoNoExport = ",config_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_edit_time_start() == null && entity.getSearch_edit_time_end() == null) {
cfgIndexInfoNoExport = ",edit_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_audit_time_start() == null && entity.getSearch_audit_time_end() == null) {
cfgIndexInfoNoExport = ",audit_time" + cfgIndexInfoNoExport;
}
if (!StringUtil.isEmpty(entity.gethColumns())) {
cfgIndexInfoNoExport = "," + entity.gethColumns() + "," + cfgIndexInfoNoExport;
}
List<BaseStringCfg> httpUrlList = new ArrayList<>();
List<ComplexkeywordCfg> httpReqHdrList = new ArrayList<>();
List<ComplexkeywordCfg> httpResHdrList = new ArrayList<>();
List<BaseStringCfg> httpReqBodyList = new ArrayList<>();
List<BaseStringCfg> httpResBodyList = new ArrayList<>();
List<IpPortCfg> ipPortList = new ArrayList<>();
List<BaseStringCfg> subscribeIdList = new ArrayList<>();
for (ManipulatCfgExport cfg : baseLists) {
Map<String, List> maps = manipulatPolicyService.exportHttpCfg(cfg);
httpUrlList.addAll(maps.get("NTC_HTTP_URL"));
httpReqHdrList.addAll(maps.get("NTC_HTTP_REQ_HDR"));
httpResHdrList.addAll(maps.get("NTC_HTTP_RES_HDR"));
httpReqBodyList.addAll(maps.get("NTC_HTTP_REQ_BODY"));
httpResBodyList.addAll(maps.get("NTC_HTTP_RES_BODY"));
ipPortList.addAll(maps.get("NTC_UNIVERSAL_IP"));
subscribeIdList.addAll(maps.get("NTC_SUBSCRIBE_ID"));
for (Map<String,Object> logTotal : logTotals) {
if(cfg.getCompileId().equals(Integer.parseInt((String) logTotal.get("compileId")))){
cfg.setTotalLogs((Long)logTotal.get("sum"));
break;
}
}
}
httpUrlList = BaseStringCfg.replaceBaseKeyList(httpUrlList);
httpReqHdrList = ComplexkeywordCfg.replaceComplexKeyList(httpReqHdrList);
httpResHdrList = ComplexkeywordCfg.replaceComplexKeyList(httpResHdrList);
httpReqBodyList = BaseStringCfg.replaceBaseKeyList(httpReqBodyList);
httpResBodyList = BaseStringCfg.replaceBaseKeyList(httpResBodyList);
subscribeIdList = BaseStringCfg.baseHexList(subscribeIdList);
titleList.add(entity.getMenuNameCode());
titleList.add("NTC_HTTP_URL");
titleList.add("NTC_HTTP_REQ_HDR");
classMap.put(entity.getMenuNameCode(), ManipulatCfgExport.class);
classMap.put("NTC_HTTP_URL", HttpUrlCfg.class);
classMap.put("NTC_HTTP_REQ_HDR", HttpReqHeadCfg.class);
noExportMap.put(entity.getMenuNameCode(), cfgIndexInfoNoExport);
noExportMap.put("NTC_HTTP_URL", httpUrlCfgNoExport);
noExportMap.put("NTC_HTTP_REQ_HDR", httpReqHeadCfgNoExport);
dataMap.put(entity.getMenuNameCode(), baseLists);
dataMap.put("NTC_HTTP_URL", httpUrlList);
dataMap.put("NTC_HTTP_REQ_HDR", httpReqHdrList);
titleList.add("NTC_HTTP_RES_HDR");
titleList.add("NTC_HTTP_REQ_BODY");
classMap.put("NTC_HTTP_RES_HDR", HttpResHeadCfg.class);
classMap.put("NTC_HTTP_REQ_BODY", HttpBodyCfg.class);
noExportMap.put("NTC_HTTP_RES_HDR", httpResHeadCfgNoExport);
noExportMap.put("NTC_HTTP_REQ_BODY", httpReqBodyCfgNoExport);
dataMap.put("NTC_HTTP_RES_HDR", httpResHdrList);
dataMap.put("NTC_HTTP_REQ_BODY", httpReqBodyList);
titleList.add("NTC_UNIVERSAL_IP");
titleList.add("NTC_SUBSCRIBE_ID");
classMap.put("NTC_UNIVERSAL_IP", IpPortCfg.class);
classMap.put("NTC_SUBSCRIBE_ID", NtcSubscribeIdCfg.class);
noExportMap.put("NTC_UNIVERSAL_IP", ipPortCfgNoExport);
noExportMap.put("NTC_SUBSCRIBE_ID", ntcSubscribeIdCfgNoExport);
dataMap.put("NTC_UNIVERSAL_IP", ipPortList);
dataMap.put("NTC_SUBSCRIBE_ID", subscribeIdList);
String timeRange = initTimeMap(entity);
noExportMap.put("timeRange", timeRange);
if ("csv".equals(entity.getExType())) {
this._exportCsv(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
}
} catch (Exception e) {
logger.error("http export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
LogUtils.saveLog(request, null, e, null);
}
}
@ResponseBody
@RequestMapping("ajaxGetProfileInfo")
public List<BaseCfg> ajaxGetProfileInfo(Integer source, HttpServletRequest request, HttpServletResponse response){
return manipulatPolicyService.getProfileInfo(source);
}
}

View File

@@ -13,7 +13,6 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
@@ -27,15 +26,13 @@ import javax.net.ssl.TrustManagerFactory;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.mvc.support.RedirectAttributes;
@@ -63,7 +60,6 @@ import com.nis.util.JsonMapper;
import com.nis.util.LogUtils; import com.nis.util.LogUtils;
import com.nis.util.StringUtil; import com.nis.util.StringUtil;
import com.nis.web.controller.BaseController; import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
/** /**
* 拦截策略 * 拦截策略
@@ -214,7 +210,7 @@ public class PxyObjKeyringController extends BaseController {
String filename = publicKeyFileI.getOriginalFilename(); String filename = publicKeyFileI.getOriginalFilename();
String prefix = FileUtils.getPrefix(filename, false); String prefix = FileUtils.getPrefix(filename, false);
String suffix = FileUtils.getSuffix(filename, false); String suffix = FileUtils.getSuffix(filename, false);
file = File.createTempFile("file_" + prefix, FileUtils.getSuffix(filename, true)); file = File.createTempFile("file_" + prefix, suffix);
publicKeyFileI.transferTo(file);// 复制文件 publicKeyFileI.transferTo(file);// 复制文件
String md5 = FileUtils.getFileMD5(file); String md5 = FileUtils.getFileMD5(file);
Map<String, Object> srcMap = Maps.newHashMap(); Map<String, Object> srcMap = Maps.newHashMap();
@@ -238,7 +234,7 @@ public class PxyObjKeyringController extends BaseController {
String filename = privateKeyFileI.getOriginalFilename(); String filename = privateKeyFileI.getOriginalFilename();
String prefix = FileUtils.getPrefix(filename, false); String prefix = FileUtils.getPrefix(filename, false);
String suffix = FileUtils.getSuffix(filename, false); String suffix = FileUtils.getSuffix(filename, false);
file = File.createTempFile("file_" + prefix, FileUtils.getSuffix(filename, true)); file = File.createTempFile("file_" + prefix, suffix);
privateKeyFileI.transferTo(file);// 复制文件 privateKeyFileI.transferTo(file);// 复制文件
String md5 = FileUtils.getFileMD5(file); String md5 = FileUtils.getFileMD5(file);
Map<String, Object> srcMap = Maps.newHashMap(); Map<String, Object> srcMap = Maps.newHashMap();
@@ -296,13 +292,6 @@ public class PxyObjKeyringController extends BaseController {
* @throws Exception * @throws Exception
*/ */
public boolean validCertFileContent(MultipartFile file,MultipartFile privateFile, String validateType) throws Exception { public boolean validCertFileContent(MultipartFile file,MultipartFile privateFile, String validateType) throws Exception {
boolean delTempFile=true;
//内置可信证书列表不允许删除
if("-incacert".equals(validateType)) {
delTempFile=false;
validateType="-incert";
}
String os = System.getProperty("os.name").toLowerCase(); String os = System.getProperty("os.name").toLowerCase();
if (!os.contains("windows") && file != null) { if (!os.contains("windows") && file != null) {
// 证书文件临时保存路径 // 证书文件临时保存路径
@@ -330,7 +319,7 @@ public class PxyObjKeyringController extends BaseController {
// 验证文件 // 验证文件
logger.info(x509Shell + " " + validateType + " " + filePath+ " " + privateFilePath); logger.info(x509Shell + " " + validateType + " " + filePath+ " " + privateFilePath);
Map<String, Object> resultMap = this.execShell(x509Shell, validateType, filePath, privateFilePath); Map<String, Object> resultMap = this.execShell(x509Shell, validateType, filePath, privateFilePath);
if (resultMap == null || StringUtil.isEmpty(resultMap.get("out"))) { if (resultMap == null || StringUtil.isEmpty(resultMap.get("out"))) {
// 临时文件删除 // 临时文件删除
logger.info("delete file" + filePath); logger.info("delete file" + filePath);
@@ -353,15 +342,9 @@ public class PxyObjKeyringController extends BaseController {
return false; return false;
} }
// 临时文件删除 // 临时文件删除
if(!delTempFile) { logger.info("delete file" + filePath);
this.certInfoMap.put("certFilePath", filePath); FileUtils.deleteFile(filePath);
logger.info("证书列表文件目录"+certInfoMap.get("certFilePath"));
}else {
logger.info("delete file" + filePath);
FileUtils.deleteFile(filePath);
}
} }
return true; return true;
} }
@@ -372,23 +355,6 @@ public class PxyObjKeyringController extends BaseController {
// 查询时left join policyGroup // 查询时left join policyGroup
Page<PxyObjKeyring> page = pxyObjKeyringService.findPage(new Page<PxyObjKeyring>(request, response, "r"), Page<PxyObjKeyring> page = pxyObjKeyringService.findPage(new Page<PxyObjKeyring>(request, response, "r"),
entity); entity);
//查询是否存在内置配置
PxyObjKeyring searchEntity0=new PxyObjKeyring();
searchEntity0.setCompileId(0);
PxyObjKeyring searchEntity1=new PxyObjKeyring();
searchEntity1.setCompileId(1);
Page<PxyObjKeyring> searchPage=new Page<PxyObjKeyring>();
Page<PxyObjKeyring> builtInPage0 = pxyObjKeyringService.findPage(searchPage,
searchEntity0);
Page<PxyObjKeyring> builtInPage1 = pxyObjKeyringService.findPage(searchPage,
searchEntity1);
if((builtInPage0 != null && !StringUtil.isEmpty(builtInPage0.getList())) || (builtInPage1 != null && !StringUtil.isEmpty(builtInPage1.getList()))) {
model.addAttribute("hasBuiltIn", true);
}else {
model.addAttribute("hasBuiltIn", false);
}
model.addAttribute("page", page); model.addAttribute("page", page);
initPageCondition(model, entity); initPageCondition(model, entity);
return "/cfg/intercept/strateagy/list"; return "/cfg/intercept/strateagy/list";
@@ -569,12 +535,9 @@ public class PxyObjKeyringController extends BaseController {
Page<PxyObjTrustedCaCert> page = pxyObjKeyringService.findTrustedCertPage(pageInfo, entity); Page<PxyObjTrustedCaCert> page = pxyObjKeyringService.findTrustedCertPage(pageInfo, entity);
ipLists = page.getList(); ipLists = page.getList();
} }
Properties prop = getMsgProp();
for (PxyObjTrustedCaCert cert : ipLists) { for (PxyObjTrustedCaCert cert : ipLists) {
if (!StringUtil.isEmpty(cert.getCompileId())) { if (!StringUtil.isEmpty(cert.getCompileId())) {
cert.setCrlFile(ConfigDictUtils.getTrustedCrlByCerId(cert.getCompileId())); cert.setCrlFile(ConfigDictUtils.getTrustedCrlByCerId(cert.getCompileId()));
cert.setBuiltInExp(prop.getProperty(cert.getBuiltIn()==0?"no":"yes"));
} }
} }
titleList.add(entity.getMenuNameCode()); titleList.add(entity.getMenuNameCode());
@@ -622,20 +585,6 @@ public class PxyObjKeyringController extends BaseController {
@ModelAttribute("cfg") PxyObjTrustedCaCert entity, RedirectAttributes redirectAttributes) { @ModelAttribute("cfg") PxyObjTrustedCaCert entity, RedirectAttributes redirectAttributes) {
Page<PxyObjTrustedCaCert> page = pxyObjKeyringService Page<PxyObjTrustedCaCert> page = pxyObjKeyringService
.findTrustedCertPage(new Page<PxyObjTrustedCaCert>(request, response, "r"), entity); .findTrustedCertPage(new Page<PxyObjTrustedCaCert>(request, response, "r"), entity);
//判断是否存在内置证书,不存在则按钮开放。
PxyObjTrustedCaCert searchBuiltIn=new PxyObjTrustedCaCert();
searchBuiltIn.setBuiltIn(1);
searchBuiltIn.setIsValid(1);
searchBuiltIn.setIsAudit(1);
Page<PxyObjTrustedCaCert> searchPage =new Page<PxyObjTrustedCaCert>();
Page<PxyObjTrustedCaCert> builtInReslt = pxyObjKeyringService
.findTrustedCertPage(searchPage, searchBuiltIn);
if(builtInReslt != null && !StringUtil.isEmpty(builtInReslt.getList())) {
model.addAttribute("hasBuiltIn", true);
}else {
model.addAttribute("hasBuiltIn", false);
}
model.addAttribute("page", page); model.addAttribute("page", page);
initPageCondition(model, entity); initPageCondition(model, entity);
return "/cfg/intercept/strateagy/trustedCertList"; return "/cfg/intercept/strateagy/trustedCertList";
@@ -717,7 +666,7 @@ public class PxyObjKeyringController extends BaseController {
String filename = certFileI.getOriginalFilename(); String filename = certFileI.getOriginalFilename();
String prefix = FileUtils.getPrefix(filename, false); String prefix = FileUtils.getPrefix(filename, false);
String suffix = FileUtils.getSuffix(filename, false); String suffix = FileUtils.getSuffix(filename, false);
file = File.createTempFile("file_" + prefix, FileUtils.getSuffix(filename, true)); file = File.createTempFile("file_" + prefix, suffix);
certFileI.transferTo(file);// 复制文件 certFileI.transferTo(file);// 复制文件
String md5 = FileUtils.getFileMD5(file); String md5 = FileUtils.getFileMD5(file);
Map<String, Object> srcMap = Maps.newHashMap(); Map<String, Object> srcMap = Maps.newHashMap();
@@ -797,7 +746,7 @@ public class PxyObjKeyringController extends BaseController {
LogUtils.saveLog(request, null, e, null); LogUtils.saveLog(request, null, e, null);
} }
} }
try { try {
if (validFlag) { if (validFlag) {
validFlag = true; validFlag = true;
@@ -813,7 +762,7 @@ public class PxyObjKeyringController extends BaseController {
} else { } else {
cfg.setIssuer(issuer); cfg.setIssuer(issuer);
} }
} }
} else { } else {
logger.error("crl的issuser为空"); logger.error("crl的issuser为空");
@@ -838,7 +787,7 @@ public class PxyObjKeyringController extends BaseController {
String filename = crlFileI.getOriginalFilename(); String filename = crlFileI.getOriginalFilename();
String prefix = FileUtils.getPrefix(filename, false); String prefix = FileUtils.getPrefix(filename, false);
String suffix = FileUtils.getSuffix(filename, false); String suffix = FileUtils.getSuffix(filename, false);
file = File.createTempFile("file_" + prefix, FileUtils.getSuffix(filename, true)); file = File.createTempFile("file_" + prefix, suffix);
crlFileI.transferTo(file);// 复制文件 crlFileI.transferTo(file);// 复制文件
String md5 = FileUtils.getFileMD5(file); String md5 = FileUtils.getFileMD5(file);
Map<String, Object> srcMap = Maps.newHashMap(); Map<String, Object> srcMap = Maps.newHashMap();
@@ -858,10 +807,10 @@ public class PxyObjKeyringController extends BaseController {
} }
} }
pxyObjKeyringService.trustedCrlsaveOrUpdate(cfg); pxyObjKeyringService.trustedCrlsaveOrUpdate(cfg);
addMessage(redirectAttributes, "success", "save_success"); addMessage(redirectAttributes, "success", "save_success");
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("crl上传失败", e); logger.error("crl上传失败", e);
if (e instanceof MaatConvertException) { if (e instanceof MaatConvertException) {
@@ -875,414 +824,8 @@ public class PxyObjKeyringController extends BaseController {
LogUtils.saveLog(request, null, e, null); LogUtils.saveLog(request, null, e, null);
} }
} }
return "redirect:" + adminPath + "/proxy/intercept/strateagy/trustedCertList?functionId=" + cfg.getFunctionId();
}
/**
* 内置可信证书导入
* @param model
* @param request
* @param response
* @param cfg
* @param crlFileI
* @param redirectAttributes
* @return
*/
@RequestMapping(value = { "/addBuiltInCert" })
public String trustedCertBuiltIn(Model model, HttpServletRequest request, HttpServletResponse response,
@ModelAttribute("cfg") PxyObjTrustedCaCert cfg, MultipartFile crlFileI,
RedirectAttributes redirectAttributes) {
logger.info("证书列表开始校验");
boolean validFlag = true;
try {
if(crlFileI != null) {
//校验证书格式
boolean certFileflag = validCertFileContent(crlFileI,null, "-incacert");
logger.info("证书列表校验结果"+certFileflag);
if (!certFileflag) {
addMessage(redirectAttributes, "error", "save_failed");
logger.error(crlFileI.getOriginalFilename() + " file non crl file format ");
throw new MultiPartNewException(this.getMsgProp().getProperty("cert_file_error"));
}
}
} catch (Exception e) {
validFlag = false;
logger.error("证书文件校验失败", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} else if (e instanceof MultiPartNewException) {
addMessage(redirectAttributes, "error", e.getMessage());
LogUtils.saveLog(request, null, e, null);
} else {
addMessage(redirectAttributes, "error", "save_failed");
LogUtils.saveLog(request, null, e, null);
}
}
logger.info("证书列表开始解析");
//2、调用脚本生成pem文件
//./cacert.sh tls-ca-bundle.pem /home/ddm/cacert
String certFilePath="";
String resultDirPath="";
try {
if(validFlag && !certInfoMap.isEmpty() && !StringUtil.isEmpty(certInfoMap.get("certFilePath"))) {
certFilePath=certInfoMap.get("certFilePath").toString();
logger.info("证书列表解析文件"+certFilePath);
String cacert = Thread.currentThread().getContextClassLoader()
.getResource(File.separator + "shell" + File.separator + Constants.CA_CERT_FILE).getPath();
this.execShell("", "chmod", "+x", cacert);
logger.info(Constants.CA_CERT_FILE+"脚本分配可执行权限:" + "chmod" + " " + "+x" + " " + cacert);
FileUtils.createDirectory(Constants.CA_CERT_DIR);
resultDirPath = Constants.CA_CERT_DIR;
logger.info("证书列表解析结果目录"+resultDirPath);
this.execShell(cacert, certFilePath,resultDirPath);
logger.info("内置证书文件生成:"+cacert + " " + certFilePath+" "+resultDirPath);
}
//删除临时文件
if(!StringUtil.isEmpty(certFilePath)) {
logger.info("delete file" + certFilePath);
FileUtils.deleteFile(certFilePath);
}
} catch (Exception e) {
validFlag = false;
logger.error("可信证书列表解析失败", e);
addMessage(redirectAttributes, "error", "save_failed");
LogUtils.saveLog(request, null, e, null);
}
logger.info("所有证书开始校验");
//校验内置证书并获取issuer信息
File fileDir=null;
Map<String,String> issuerMap=new HashMap<>();
if(validFlag && !StringUtil.isEmpty(resultDirPath)) {
logger.info("证书列表文件解析结果目录:"+resultDirPath);
fileDir=new File(resultDirPath);
try {
if(validFlag) {
for (File file : fileDir.listFiles()) {
FileInputStream fileInputStream = new FileInputStream(file);
MultipartFile multipartFile = new MockMultipartFile(file.getName(),fileInputStream);
//校验证书格式
boolean validResult = validCertFileContent(multipartFile,null, "-incacert");
logger.info("证书校验结果"+validResult);
if (validResult && !certInfoMap.isEmpty() && !StringUtil.isEmpty(certInfoMap.get("ca issuer"))) {
String issuer=certInfoMap.get("ca issuer").toString();
issuerMap.put(file.getName(), issuer);
}else{
addMessage(redirectAttributes, "error", "save_failed");
logger.error(crlFileI.getOriginalFilename() + " file non crl file format ");
throw new MultiPartNewException(this.getMsgProp().getProperty("cert_file_error"));
}
}
}
} catch (Exception e) {
validFlag = false;
logger.error("证书文件校验失败", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} else if (e instanceof MultiPartNewException) {
addMessage(redirectAttributes, "error", e.getMessage());
LogUtils.saveLog(request, null, e, null);
} else {
addMessage(redirectAttributes, "error", "save_failed");
LogUtils.saveLog(request, null, e, null);
}
}
}
logger.info("所有证书开始上传minio");
List<PxyObjTrustedCaCert> caCertList=new ArrayList<PxyObjTrustedCaCert>();
if(validFlag && fileDir != null && !StringUtil.isEmpty(fileDir.listFiles())) {
int index=1;
for (File file : fileDir.listFiles()) {
File newFile = null;
String filename ="";
try {
FileInputStream fileInputStream = new FileInputStream(file);
MultipartFile multipartFile = new MockMultipartFile(file.getName(),fileInputStream);
PxyObjTrustedCaCert cacertBuitIn=new PxyObjTrustedCaCert();
cfg.setBuiltIn(1);
BeanUtils.copyProperties(cfg, cacertBuitIn);
filename = file.getName();
String prefix = FileUtils.getPrefix(filename, false);
String suffix = FileUtils.getSuffix(filename, false);
newFile = File.createTempFile("file_" + prefix, FileUtils.getSuffix(filename, true));
multipartFile.transferTo(newFile);// 复制文件
String md5 = FileUtils.getFileMD5(file);
Map<String, Object> srcMap = Maps.newHashMap();
srcMap.put("filetype", suffix);
srcMap.put("datatype", "dbSystem");// 源文件存入数据中心
srcMap.put("createTime", new Date());
srcMap.put("key", prefix);
srcMap.put("fileName", filename);
srcMap.put("checksum", md5);
ToMaatResult result = ConfigServiceUtil.postFileCfg(null, file, JsonMapper.toJsonString(srcMap));
logger.info("可信证书内置证书 文件上传响应信息:" + JsonMapper.toJsonString(result));
String crlFileAccessUrl = null;
if (!StringUtil.isEmpty(result)) {
ResponseData data = result.getData();
crlFileAccessUrl = data.getAccessUrl();
cacertBuitIn.setCertFile(crlFileAccessUrl);
}
cacertBuitIn.setIssuer(issuerMap.get(file.getName()));
cacertBuitIn.setCfgDesc("built-in_cert"+index);
caCertList.add(cacertBuitIn);
} catch (Exception e) {
validFlag = false;
logger.error("内置可信证书"+filename+"上传minio失败", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
}else {
addMessage(redirectAttributes, "error", "save_failed");
LogUtils.saveLog(request, null, e, null);
}
}
index++;
}
}
logger.info("所有证书信息开始入库并下发");
//入库并下发
if(validFlag){
try {
if(!StringUtil.isEmpty(caCertList)){
pxyObjKeyringService.caCertSaveAndAudit(caCertList);
}
}catch (Exception e) {
validFlag = false;
logger.error("内置可信证书下发失败", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
}else {
addMessage(redirectAttributes, "error", "save_failed");
LogUtils.saveLog(request, null, e, null);
}
}
}
return "redirect:" + adminPath + "/proxy/intercept/strateagy/trustedCertList?functionId=" + cfg.getFunctionId();
}
/**
* 内置Keyring 导入功能
* @param model
* @param request
* @param response
* @param cfg
* @param certFileI
* @param redirectAttributes
* @return
*/
@RequestMapping(value = { "/addKeyRingBuiltInCert" })
public String addKeyRingBuiltInCert(Model model, HttpServletRequest request, HttpServletResponse response,
@ModelAttribute("cfg") PxyObjKeyring cfg, @RequestParam("certFileI")MultipartFile[] certFileI,
RedirectAttributes redirectAttributes) {
logger.info("keyring内置证书开始校验");
boolean validFlag = true;
//每个证书文件的内容
Map<String, Map> fileCertMap=new HashMap<>();
try {
if(certFileI != null && certFileI.length > 0) {
for (MultipartFile multipartFile : certFileI) {
//校验证书格式
boolean certFileflag = validCertFileContent(multipartFile,null, "-incert");
logger.info("证书列表校验结果"+certFileflag);
if (!certFileflag) {
addMessage(redirectAttributes, "error", "save_failed");
logger.error(multipartFile.getOriginalFilename() + " file non crl file format ");
throw new MultiPartNewException(this.getMsgProp().getProperty("cert_file_error"));
}else {
if(!certInfoMap.isEmpty()) {
String issuer = StringUtil.isEmpty(certInfoMap.get("ca issuer")) ? ""
: certInfoMap.get("ca issuer").toString();// 颁发者
String fingerprint = StringUtil.isEmpty(certInfoMap.get("ca fingerprint")) ? ""
: certInfoMap.get("ca fingerprint").toString();// 指纹
if(!StringUtil.isEmpty(issuer) && !StringUtil.isEmpty(fingerprint)) {
if(Constants.KEYRING_BUILT_IN_ISSER.contains("||"+issuer+"||")
&& Constants.KEYRING_BUILT_IN_FINGERPRINT.contains("||"+fingerprint+"||")) {
fileCertMap.put(multipartFile.getOriginalFilename(), certInfoMap);
}else {
validFlag=false;
break;
}
}else {
validFlag=false;
break;
}
}else {
validFlag=false;
break;
}
}
}
}else {
addMessage(redirectAttributes, "error", "save_failed");
logger.error(" keyring is null ");
throw new Exception();
}
} catch (Exception e) {
validFlag = false;
logger.error("证书文件校验失败", e);
if (e instanceof MaatConvertException) {
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} else if (e instanceof MultiPartNewException) {
addMessage(redirectAttributes, "error", e.getMessage());
LogUtils.saveLog(request, null, e, null);
} else {
addMessage(redirectAttributes, "error", "save_failed");
LogUtils.saveLog(request, null, e, null);
}
}
List<PxyObjKeyring> keyringList=new ArrayList<PxyObjKeyring>();
//是keyring内置证书且验证通过进行证书文件上传
try {
if(validFlag) {
File file=null;
for (MultipartFile certFile :certFileI) {
PxyObjKeyring keyring=new PxyObjKeyring();
BeanUtils.copyProperties(cfg, keyring);
/**************************证书信息获取*************************************/
String issuer = StringUtil.isEmpty(fileCertMap.get(certFile.getOriginalFilename()).get("ca issuer")) ? ""
: fileCertMap.get(certFile.getOriginalFilename()).get("ca issuer").toString();// 颁发者
String subject = StringUtil.isEmpty(fileCertMap.get(certFile.getOriginalFilename()).get("ca subjectname")) ? ""
: fileCertMap.get(certFile.getOriginalFilename()).get("ca subjectname").toString();// 颁发给
String notBeforeStr = "";
if (!StringUtil.isEmpty(fileCertMap.get(certFile.getOriginalFilename()).get("ca notbefore"))) {
Date notBeforeTime = new Date(fileCertMap.get(certFile.getOriginalFilename()).get("ca notbefore").toString());// 开始时间
notBeforeStr = sdf.format(notBeforeTime);
}
String notAfterStr = "";
if (!StringUtil.isEmpty(fileCertMap.get(certFile.getOriginalFilename()).get("ca notafter"))) {
Date notAfterTime = new Date(fileCertMap.get(certFile.getOriginalFilename()).get("ca notafter").toString());// 结束时间
notAfterStr = sdf.format(notAfterTime);
}
String cn = "";// CN
// CN精确信息获取
if (!StringUtil.isEmpty(subject)) {
for (String cnStr : subject.split(",")) {
cnStr = StringUtil.isEmpty(cnStr) ? "" : cnStr.trim();
if (cnStr.split("=").length > 1) {
cn = cnStr.split("=")[1];
cn = StringUtil.isEmpty(cn) ? "" : cn.trim();
}
}
}
String altName = StringUtil.isEmpty(fileCertMap.get(certFile.getOriginalFilename()).get("ca altname")) ? ""
: fileCertMap.get(certFile.getOriginalFilename()).get("ca altname").toString();// SAN
keyring.setIssuer(issuer); return "redirect:" + adminPath + "/proxy/intercept/strateagy/trustedCertList?functionId=" + cfg.getFunctionId();
keyring.setSubject(subject);
keyring.setCn(cn);
keyring.setAltName(altName);
keyring.setNotBeforeTime(notBeforeStr);
keyring.setNotAfterTime(notAfterStr);
keyring.setKeyringType("root");
keyring.setExpireAfter(30);
keyring.setCrl("");
keyring.setPublicKeyAlgo("");
/**************************公私钥文件上传*************************************/
if (certFile != null) {
String filename = certFile.getOriginalFilename();
String prefix = FileUtils.getPrefix(filename, false);
keyring.setKeyringName(prefix);
keyring.setCfgDesc(prefix);
String suffix = FileUtils.getSuffix(filename, false);
file = File.createTempFile("file_" + prefix, FileUtils.getSuffix(filename, true));
certFile.transferTo(file);// 复制文件
String md5 = FileUtils.getFileMD5(file);
Map<String, Object> srcMap = Maps.newHashMap();
srcMap.put("filetype", suffix);
srcMap.put("datatype", "dbSystem");// 源文件存入数据中心
srcMap.put("createTime", new Date());
srcMap.put("key", prefix);
srcMap.put("fileName", filename);
srcMap.put("checksum", md5);
ToMaatResult result = ConfigServiceUtil.postFileCfg(null, file, JsonMapper.toJsonString(srcMap));
logger.info("proxy 证书文件策略公钥 文件上传响应信息:" + JsonMapper.toJsonString(result));
String publicKeyFileAccessUrl = null;
if (!StringUtil.isEmpty(result)) {
ResponseData data = result.getData();
publicKeyFileAccessUrl = data.getAccessUrl();
keyring.setPublicKeyFile(publicKeyFileAccessUrl);
}
}
if (certFile != null) {
String filename = certFile.getOriginalFilename();
String prefix = FileUtils.getPrefix(filename, false);
String suffix = FileUtils.getSuffix(filename, false);
file = File.createTempFile("file_" + prefix, FileUtils.getSuffix(filename, true));
certFile.transferTo(file);// 复制文件
String md5 = FileUtils.getFileMD5(file);
Map<String, Object> srcMap = Maps.newHashMap();
srcMap.put("filetype", suffix);
srcMap.put("datatype", "dbSystem");// 源文件存入数据中心
srcMap.put("createTime", new Date());
srcMap.put("key", prefix);
srcMap.put("fileName", filename);
srcMap.put("checksum", md5);
ToMaatResult result = ConfigServiceUtil.postFileCfg(null, file, JsonMapper.toJsonString(srcMap));
logger.info("proxy 证书文件策略私钥 上传响应信息:" + JsonMapper.toJsonString(result));
String privateKeyFileAccessUrl = null;
if (!StringUtil.isEmpty(result)) {
ResponseData data = result.getData();
privateKeyFileAccessUrl = data.getAccessUrl();
keyring.setPrivateKeyFile(privateKeyFileAccessUrl);
;
}
}
logger.info(keyring.getPublicKeyFile());
logger.info(keyring.getPrivateKeyFile());
keyringList.add(keyring);
}
}
} catch (MultiPartNewException e) {
logger.error("证书文件上传失败:",e);
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} catch (MaatConvertException e) {
logger.error("策略配置下发失败:",e);
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} catch (Exception e) {
logger.error("策略配置保存失败:",e);
addMessage(redirectAttributes, "error", "save_failed");
LogUtils.saveLog(request, null, e, null);
}
try {
if(!StringUtil.isEmpty(keyringList)) {
pxyObjKeyringService.saveAndAuditKeyring(keyringList);
//配置仅保存
if(StringUtil.isEmpty(cfg.getIsValid()) || cfg.getIsValid()!=1) {
addMessage(redirectAttributes, "success", "save_success");
}else {
//配置直接生效
addMessage(redirectAttributes, "success", "audit_success");
}
}
} catch (MaatConvertException e) {
logger.error("策略配置下发失败:",e);
addMessage(redirectAttributes, "error", "request_service_failed");
LogUtils.saveLog(request, null, e, null);
} catch (Exception e) {
logger.error("策略配置保存失败:",e);
addMessage(redirectAttributes, "error", "save_failed");
LogUtils.saveLog(request, null, e, null);
}
return "redirect:" + adminPath + "/proxy/intercept/strateagy/list?functionId=" + cfg.getFunctionId();
} }
/** /**
@@ -1469,4 +1012,31 @@ public class PxyObjKeyringController extends BaseController {
} }
return "redirect:" + adminPath + "/proxy/intercept/strateagy/trustedCertList?functionId=" + functionId; return "redirect:" + adminPath + "/proxy/intercept/strateagy/trustedCertList?functionId=" + functionId;
} }
/**
* 验证Keyring是否有被使用
*
* @param entity
* @param request
* @param response
* @return
*/
@ResponseBody
@RequestMapping(value = { "/ajaxKeyinfIsUsed" })
public boolean ajaxKeyinfIsUsed(String[] compileIds, HttpServletRequest request, HttpServletResponse response) {
for(String compileId:compileIds){
CfgIndexInfo cfg = new CfgIndexInfo();
cfg.setIsAudit(1);
cfg.setIsValid(1);
cfg.setFunctionId(200);//代理拦截策略
cfg.setServiceId(512);
cfg.setUserRegion1(compileId);
List<CfgIndexInfo> list = httpRedirectCfgService.getCfgIndexInfos(cfg);
if (list.size() > 0) {
return false;
}
}
return true;
}
} }

View File

@@ -1,99 +0,0 @@
package com.nis.web.controller.configuration.proxy;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.web.controller.BaseController;
import com.nis.web.service.BaseService;
import com.nis.web.service.configuration.StatusOfUsedService;
@Controller
@RequestMapping("${adminPath}/proxy/statusOfUsed")
public class StatusOfUsedController extends BaseController{
@Autowired
protected StatusOfUsedService statusOfUsedService;
@ResponseBody
@RequestMapping(value = { "/ajaxRequest" })
public boolean statusOfUsed(String[] compileIds, HttpServletRequest request, HttpServletResponse response) {
Integer isValid = Integer.parseInt(request.getParameter("isValid"));
Integer ServiceId = Integer.parseInt(request.getParameter("serviceId"));
Integer functionId = 0;
String key = "";
//拦截证书策略
if(ServiceId==520){
functionId = 200;
ServiceId = 512;
key = "keyring";
}//流量转发目的地址
if(ServiceId==645){
functionId = 200;
ServiceId = 512;
key = "mirror_profile";
}
//劫持文件、注入脚本文件
else if(ServiceId==643 || ServiceId==644){
functionId = 215;
ServiceId = 656;
}//访问阻断页面
else if(ServiceId==646){
functionId = 207;
ServiceId = 576;
}
if(ServiceId == 576 || ServiceId==656){
for(String compileId:compileIds){
CfgIndexInfo cfg = new CfgIndexInfo();
if(ServiceId==656){
cfg.setUserRegion4(compileId);
}else if(ServiceId==576){
cfg.setUserRegion3(compileId);
}
cfg.setIsValid(isValid);
cfg.setFunctionId(functionId);
cfg.setServiceId(ServiceId);
List<CfgIndexInfo> list = statusOfUsedService.getStatusOfUsed(cfg);
if (list.size() > 0) {
return false;
}
}
return true;
}else if(ServiceId==512){
CfgIndexInfo cfg = new CfgIndexInfo();
cfg.setIsValid(isValid);
cfg.setFunctionId(functionId);
cfg.setServiceId(ServiceId);
List<CfgIndexInfo> list = statusOfUsedService.getStatusOfUsed(cfg);
Map<String,Map<String,Object>> tempMap = new HashMap<>();
for(CfgIndexInfo temp:list){
tempMap = BaseService.gsonFromJson(temp.getUserRegion1(), Map.class);
String value = "";
if("keyring".equals(key)){
value = String.valueOf(tempMap.get(key));
}else if("mirror_profile".equals(key)){
value = String.valueOf(tempMap.get("decrypt_mirror").get("mirror_profile"));
}
for(String s: compileIds){
if(s.equals(value))
return false;
}
}
return true;
}
return true;
}
}

View File

@@ -1,385 +0,0 @@
package com.nis.web.controller.log.pxy;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page;
import com.nis.domain.PageLog;
import com.nis.domain.SysDataDictionaryItem;
import com.nis.domain.SysUser;
import com.nis.domain.configuration.AppIpCfg;
import com.nis.domain.log.BaseLogEntity;
import com.nis.domain.log.PxyHttpLog;
import com.nis.domain.log.PxyHttpManipulationLog;
import com.nis.domain.maat.LogRecvData;
import com.nis.domain.specific.SpecificServiceCfg;
import com.nis.util.CodeDicUtils;
import com.nis.util.Constants;
import com.nis.util.DateUtils;
import com.nis.util.DictUtils;
import com.nis.util.LogUtils;
import com.nis.util.StringUtil;
import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.dao.dashboard.codedic.CodeResult;
import com.nis.web.security.UserUtils;
@Controller
@RequestMapping("${adminPath}/log/pxy")
public class PxyHttpBlockLogController extends BaseController{
@RequestMapping(value = "/httpBlockList")
public String list(@ModelAttribute("log") PxyHttpManipulationLog log, Model model, HttpServletRequest request,
HttpServletResponse response,Integer searchAction) {
try {
List<CodeResult> protocolCodeList = CodeDicUtils.getCodeList("protocolCode");
List<CodeResult> appCodeList = CodeDicUtils.getCodeList("appCode");
PageLog<PxyHttpManipulationLog> page = new PageLog<PxyHttpManipulationLog>(request, response);
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageSize", page.getPageSize());
params.put("pageNo", page.getPageNo());
if(searchAction !=null){
log.setAction(searchAction);
}
if (StringUtils.isNotBlank(log.getDomain())) {
String domain = StringEscapeUtils.unescapeHtml(log.getDomain());
params.put("searchDomain", domain);
}
if (StringUtils.isNotBlank(log.getUrl())) {
String httpurl = StringEscapeUtils.unescapeHtml(log.getUrl());
params.put("searchUrl", httpurl);
}
if (StringUtils.isNotBlank(log.getsIp())) {
log.setClientIp(log.getsIp());
}
if (StringUtils.isNotBlank(log.getdIp())) {
log.setServerIp(log.getdIp());
}
if(log.getCfgId()!=null && log.getPolicyId() ==null){
log.setPolicyId(log.getCfgId());
}
if (StringUtils.isNotBlank(log.getAppId())) {
params.put("searchAppId", log.getAppId());
}
if (StringUtils.isNotBlank(log.getProtocolId())) {
params.put("searchProtocolId", log.getProtocolId());
}
initLogSearchValues(log, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
model.addAttribute("appList", appCodeList);
model.addAttribute("protocolList", protocolCodeList);
String url = Constants.LOG_BASE_URL + Constants.POLICY_EVENT;
String recv = HttpClientUtil.getMsg(url, params, request);
Gson gson = new GsonBuilder().create();
LogRecvData<PxyHttpManipulationLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<PxyHttpManipulationLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<PxyHttpManipulationLog> data = fromJson.getData();
page.setCount(data.getCount());
page.setLast(data.getLast());
page.setList(data.getList());
List<PxyHttpManipulationLog> list = page.getList();
for (PxyHttpManipulationLog l : list) {
l.setFunctionId(log.getFunctionId());
// setLogAction(l, serviceList);
l.setStartTime(timeStamp2Date(l.getStartTime(),null));
l.setEndTime(timeStamp2Date(l.getEndTime(),null));
l.setRecvTime(timeStamp2Date(l.getRecvTime(),null));
for (CodeResult code : appCodeList) {
Integer value3 = Integer.valueOf(code.getCode());
if(StringUtils.isNotBlank(l.getAppId()) && l.getAppId().equals(code.getCode())){
l.setAppName(code.getItem());
break;
}
}
for (CodeResult code : protocolCodeList) {
Integer value3 = Integer.valueOf(code.getCode());
if(StringUtils.isNotBlank(l.getProtocolId()) && l.getProtocolId().equals(code.getCode())){
l.setProtocolName(code.getItem());
break;
}
}
}
}
model.addAttribute("page", page);
} catch (Exception e) {
logger.error("查询失败", e);
addMessageLog(model, e.getMessage());
LogUtils.saveLog(request, null, e, null);
}
return "/log/pxy/pxyHttpBlockList";
}
// 导出
@RequestMapping(value = "exportPxyHttpBlock")
public void exportPxy(@ModelAttribute("log") PxyHttpManipulationLog log, Model model, String hColumns, String type,
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
try {
List<String> titleList = new ArrayList<String>();
Map<String, Class<?>> classMap = new HashMap<String, Class<?>>();
Map<String, List> dataMap = new HashMap<String, List>();
Map<String, String> noExportMap = new HashMap<String, String>();
// ---------------------------
List<CodeResult> protocolCodeList = CodeDicUtils.getCodeList("protocolCode");
List<CodeResult> appCodeList = CodeDicUtils.getCodeList("appCode");
PageLog<PxyHttpManipulationLog> page = new PageLog<PxyHttpManipulationLog>(request, response);
page.setPageNo(1);
page.setPageSize(Constants.MAX_LOG_EXPORT_SIZE);
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageSize", page.getPageSize());
params.put("pageNo", page.getPageNo());
if (StringUtils.isNotBlank(log.getsIp())) {
log.setClientIp(log.getsIp());
}
if (StringUtils.isNotBlank(log.getdIp())) {
log.setServerIp(log.getdIp());
}
initLogSearchValues(log, params);
if (StringUtils.isNotBlank(log.getUrl())) {
String httpurl = StringEscapeUtils.unescapeHtml(log.getUrl());
params.put("searchUrl", httpurl);
}
if (StringUtils.isNotBlank(log.getDomain())) {
String domain = StringEscapeUtils.unescapeHtml(log.getDomain());
params.put("searchDomain", domain);
}
if (StringUtils.isNotBlank(log.getAppId())) {
params.put("searchAppId", log.getAppId());
}
if (StringUtils.isNotBlank(log.getProtocolId())) {
params.put("searchProtocolId", log.getProtocolId());
}
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.POLICY_EVENT;
String recv = HttpClientUtil.getMsg(url, params, request);
List<PxyHttpManipulationLog> list = new ArrayList<PxyHttpManipulationLog>();
if (StringUtils.isNotBlank(recv)) {
Gson gson = new GsonBuilder().create();
LogRecvData<PxyHttpManipulationLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<PxyHttpManipulationLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<PxyHttpManipulationLog> data = fromJson.getData();
list = data.getList();
}
}
for (PxyHttpManipulationLog l : list) {
l.setFunctionId(log.getFunctionId());
l.setStartTime(timeStamp2Date(l.getStartTime(),null));
l.setEndTime(timeStamp2Date(l.getEndTime(),null));
l.setRecvTime(timeStamp2Date(l.getRecvTime(),null));
for (CodeResult code : appCodeList) {
Integer value3 = Integer.valueOf(code.getCode());
if(StringUtils.isNotBlank(l.getAppId()) && l.getAppId().equals(code.getCode())){
l.setAppName(code.getItem());
break;
}
}
for (CodeResult code : protocolCodeList) {
Integer value3 = Integer.valueOf(code.getCode());
if(StringUtils.isNotBlank(l.getProtocolId()) && l.getProtocolId().equals(code.getCode())){
l.setProtocolName(code.getItem());
break;
}
}
}
titleList.add("http_manipulation");
classMap.put("http_manipulation", PxyHttpManipulationLog.class);
SysUser user = UserUtils.getUser();
if (!user.isAdmin()) {
hColumns += ",scene_file,";
} else {
hColumns += ",";
}
String cfgIndexInfoNoExport = ",req_header,resp_header,inner_smac,inner_dmac,nest_addr_list,scene_file,"
+ ",found_time,"
+ hColumns;
noExportMap.put("http_manipulation", cfgIndexInfoNoExport);
dataMap.put("http_manipulation", list);
String timeRange= initLogMaps(log,"http_manipulation");
noExportMap.put("timeRange", timeRange);
if ("csv".equals(type)) {
this._exportCsv(model, request, response, redirectAttributes, "http_manipulation", titleList, classMap,
dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, "http_manipulation", titleList, classMap, dataMap,
noExportMap);
}
} catch (Exception e) {
logger.error("Http Manipulation export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
LogUtils.saveLog(request, null, e, null);
}
}
public void initLogSearchValues(PxyHttpManipulationLog entry, Map<String, Object> params) {
if (StringUtils.isNotBlank(entry.getSearchFoundStartTime())
&& StringUtils.isNotBlank(entry.getSearchFoundEndTime())) {
params.put("searchStartRecvTime", date2TimeStamp(entry.getSearchFoundStartTime(),"yyyy-MM-dd HH:mm:ss"));
params.put("searchEndRecvTime", date2TimeStamp(entry.getSearchFoundEndTime(),"yyyy-MM-dd HH:mm:ss"));
} else {
// 判断是否是从配置界面过来的日志查询
if (StringUtils.isNotBlank(entry.getIsLogTotalSearch())) {
Calendar time = Calendar.getInstance();
String searchEndTime = DateUtils.formatDateTime(time.getTime());
time.add(Calendar.MINUTE, -(Constants.LOG_TIME_RANGE/1000/60));
String searchStartTime = DateUtils.formatDateTime(time.getTime());
params.put("searchStartRecvTime", date2TimeStamp(searchStartTime,"yyyy-MM-dd HH:mm:ss"));
params.put("searchEndRecvTime", date2TimeStamp(searchEndTime,"yyyy-MM-dd HH:mm:ss"));
entry.setSearchFoundStartTime(searchStartTime);
entry.setSearchFoundEndTime(searchEndTime);
} else {
// 设置默认查询当前时间及前五分钟
String endTime = DateUtils.getDateTime();
Date dateStart = new Date(new Date().getTime() - Constants.LOG_TIME_INTERVAL);
String startTime = DateUtils.formatDateTime(dateStart);
params.put("searchStartRecvTime", String.valueOf(dateStart.getTime()/1000));
params.put("searchEndRecvTime", date2TimeStamp(endTime,"yyyy-MM-dd HH:mm:ss"));
entry.setSearchFoundStartTime(startTime);
entry.setSearchFoundEndTime(endTime);
}
logger.info("searchStartRecvTime" + params.get("searchStartRecvTime"));
logger.info("searchEndRecvTime" + params.get("searchEndRecvTime"));
}
if (StringUtils.isNotBlank(entry.getTransProto())) {
params.put("searchTransProto", entry.getTransProto());
}
/* if (entry.getService() != null) {
params.put("searchService", entry.getService());
} else if (entry.getAction() != null) {
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());
}
}
}*/
if (StringUtils.isNotBlank(entry.getServerIp())) {
params.put("searchServerIp", entry.getServerIp());
}
if (StringUtils.isNotBlank(entry.getClientIp())) {
params.put("searchClientIp", entry.getClientIp());
}
if (StringUtils.isNotBlank(entry.getCapIp())) {
params.put("searchCapIp", entry.getCapIp());
}
if (entry.getDirection() != null) {
params.put("searchDirection", entry.getDirection());
}
if (entry.getEntranceId() != null) {
params.put("searchEntranceId", entry.getEntranceId());
}
if (entry.getPolicyId() != null) {
params.put("searchPolicyId", entry.getPolicyId());
}
if (entry.getAction() != null) {
params.put("searchAction", entry.getAction());
}
if (entry.getAddrType() != null) {
params.put("searchAddrType", entry.getAddrType());
}
if (StringUtils.isNotBlank(entry.getIsp())) {
params.put("searchIsp", entry.getIsp());
}
if (StringUtils.isNotBlank(entry.getServerLocation())) {
params.put("searchServerLocation", entry.getServerLocation());
}
if (StringUtils.isNotBlank(entry.getClientLocation())) {
params.put("searchClientLocation", entry.getClientLocation());
}
if (StringUtils.isNotBlank(entry.getHost())) {
params.put("searchHost", entry.getHost());
}
if (StringUtils.isNotBlank(entry.getSni())) {
params.put("searchSni", entry.getSni());
}
if (StringUtils.isNotBlank(entry.getSan())) {
params.put("searchSan", entry.getSan());
}
if (StringUtils.isNotBlank(entry.getCn())) {
params.put("searchCn", entry.getCn());
}
if (StringUtils.isNotBlank(entry.getOrderBy())) {
params.put("orderBy", entry.getOrderBy());
}
if (StringUtils.isNotBlank(entry.getFields())) {
params.put("fields", entry.getFields());
}
}
public String initLogMaps(PxyHttpManipulationLog log,String title){
Properties msgProp = getMsgProp();
String logTime=msgProp.getProperty(title,title);;
if(log.getSearchFoundStartTime()!=null){
logTime+=" "+msgProp.getProperty("begin_date")+""+log.getSearchFoundStartTime();
}
if(log.getSearchFoundEndTime()!=null){
logTime+=" "+msgProp.getProperty("end_date")+""+log.getSearchFoundEndTime();
}
return logTime;
}
/**
* 日期格式字符串转换成时间戳
* @param date 字符串日期
* @param format 如yyyy-MM-dd HH:mm:ss
* @return
*/
public static String date2TimeStamp(String date_str,String format){
try {
SimpleDateFormat sdf = new SimpleDateFormat(format);
return String.valueOf(sdf.parse(date_str).getTime()/1000);
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
/**
* 时间戳转换成日期格式字符串
* @param seconds 精确到秒的字符串
* @param formatStr
* @return
*/
public static String timeStamp2Date(String seconds,String format) {
if(seconds == null || seconds.isEmpty() || seconds.equals("null")){
return "";
}
if(format == null || format.isEmpty()) format = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(new Date(Long.valueOf(seconds+"000")));
}
}

View File

@@ -1,393 +0,0 @@
package com.nis.web.controller.log.pxy;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page;
import com.nis.domain.PageLog;
import com.nis.domain.SysDataDictionaryItem;
import com.nis.domain.SysUser;
import com.nis.domain.configuration.AppIpCfg;
import com.nis.domain.log.BaseLogEntity;
import com.nis.domain.log.PxyHttpLog;
import com.nis.domain.log.PxyHttpManipulationLog;
import com.nis.domain.maat.LogRecvData;
import com.nis.domain.specific.SpecificServiceCfg;
import com.nis.util.CodeDicUtils;
import com.nis.util.Constants;
import com.nis.util.DateUtils;
import com.nis.util.DictUtils;
import com.nis.util.LogUtils;
import com.nis.util.StringUtil;
import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.dao.dashboard.codedic.CodeResult;
import com.nis.web.security.UserUtils;
@Controller
@RequestMapping("${adminPath}/log/pxy")
public class PxyHttpManipulLogController extends BaseController{
@RequestMapping(value = {"/httpManipulList", "/httpBlockLists", "/httpMonitLists"})
public String list(@ModelAttribute("log") PxyHttpManipulationLog log, Model model, HttpServletRequest request,
HttpServletResponse response,Integer searchAction) {
try {
// List<CodeResult> protocolCodeList = CodeDicUtils.getCodeList("protocolCode");
// List<CodeResult> appCodeList = CodeDicUtils.getCodeList("appCode");
PageLog<PxyHttpManipulationLog> page = new PageLog<PxyHttpManipulationLog>(request, response);
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageSize", page.getPageSize());
params.put("pageNo", page.getPageNo());
if(searchAction !=null){
log.setAction(searchAction);
}
if (StringUtils.isNotBlank(log.getDomain())) {
String domain = StringEscapeUtils.unescapeHtml(log.getDomain());
params.put("searchDomain", domain);
}
if (StringUtils.isNotBlank(log.getUrl())) {
String httpurl = StringEscapeUtils.unescapeHtml(log.getUrl());
params.put("searchUrl", httpurl);
}
if (StringUtils.isNotBlank(log.getsIp())) {
log.setClientIp(log.getsIp());
}
if (StringUtils.isNotBlank(log.getdIp())) {
log.setServerIp(log.getdIp());
}
if(log.getCfgId()!=null && log.getPolicyId() ==null){
log.setPolicyId(log.getCfgId());
}
// if (StringUtils.isNotBlank(log.getAppId())) {
// params.put("searchAppId", log.getAppId());
// }
// if (StringUtils.isNotBlank(log.getProtocolId())) {
// params.put("searchProtocolId", log.getProtocolId());
// }
initLogSearchValues(log, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
// model.addAttribute("appList", appCodeList);
// model.addAttribute("protocolList", protocolCodeList);
String url = Constants.LOG_BASE_URL + Constants.POLICY_EVENT;
String recv = HttpClientUtil.getMsg(url, params, request);
Gson gson = new GsonBuilder().create();
LogRecvData<PxyHttpManipulationLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<PxyHttpManipulationLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<PxyHttpManipulationLog> data = fromJson.getData();
page.setCount(data.getCount());
page.setLast(data.getLast());
page.setList(data.getList());
List<PxyHttpManipulationLog> list = page.getList();
for (PxyHttpManipulationLog l : list) {
l.setFunctionId(log.getFunctionId());
// setLogAction(l, serviceList);
l.setStartTime(timeStamp2Date(l.getStartTime(),null));
l.setEndTime(timeStamp2Date(l.getEndTime(),null));
l.setRecvTime(timeStamp2Date(l.getRecvTime(),null));
/*for (CodeResult code : appCodeList) {
Integer value3 = Integer.valueOf(code.getCode());
if(StringUtils.isNotBlank(l.getAppId()) && l.getAppId().equals(code.getCode())){
l.setAppName(code.getItem());
break;
}
}
for (CodeResult code : protocolCodeList) {
Integer value3 = Integer.valueOf(code.getCode());
if(StringUtils.isNotBlank(l.getProtocolId()) && l.getProtocolId().equals(code.getCode())){
l.setProtocolName(code.getItem());
break;
}
}*/
}
}
model.addAttribute("page", page);
} catch (Exception e) {
logger.error("查询失败", e);
addMessageLog(model, e.getMessage());
LogUtils.saveLog(request, null, e, null);
}
return "/log/pxy/pxyHttpManipulationList";
}
// 导出
@RequestMapping(value = "exportPxyHttpManipul")
public void exportPxy(@ModelAttribute("log") PxyHttpManipulationLog log, Model model, String hColumns, String type,
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
try {
List<String> titleList = new ArrayList<String>();
Map<String, Class<?>> classMap = new HashMap<String, Class<?>>();
Map<String, List> dataMap = new HashMap<String, List>();
Map<String, String> noExportMap = new HashMap<String, String>();
// ---------------------------
// List<CodeResult> protocolCodeList = CodeDicUtils.getCodeList("protocolCode");
// List<CodeResult> appCodeList = CodeDicUtils.getCodeList("appCode");
PageLog<PxyHttpManipulationLog> page = new PageLog<PxyHttpManipulationLog>(request, response);
page.setPageNo(1);
page.setPageSize(Constants.MAX_LOG_EXPORT_SIZE);
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageSize", page.getPageSize());
params.put("pageNo", page.getPageNo());
if (StringUtils.isNotBlank(log.getsIp())) {
log.setClientIp(log.getsIp());
}
if (StringUtils.isNotBlank(log.getdIp())) {
log.setServerIp(log.getdIp());
}
initLogSearchValues(log, params);
if (StringUtils.isNotBlank(log.getUrl())) {
String httpurl = StringEscapeUtils.unescapeHtml(log.getUrl());
params.put("searchUrl", httpurl);
}
if (StringUtils.isNotBlank(log.getDomain())) {
String domain = StringEscapeUtils.unescapeHtml(log.getDomain());
params.put("searchDomain", domain);
}
// if (StringUtils.isNotBlank(log.getAppId())) {
// params.put("searchAppId", log.getAppId());
// }
// if (StringUtils.isNotBlank(log.getProtocolId())) {
// params.put("searchProtocolId", log.getProtocolId());
// }
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.POLICY_EVENT;
String recv = HttpClientUtil.getMsg(url, params, request);
List<PxyHttpManipulationLog> list = new ArrayList<PxyHttpManipulationLog>();
if (StringUtils.isNotBlank(recv)) {
Gson gson = new GsonBuilder().create();
LogRecvData<PxyHttpManipulationLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<PxyHttpManipulationLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<PxyHttpManipulationLog> data = fromJson.getData();
list = data.getList();
}
}
for (PxyHttpManipulationLog l : list) {
l.setFunctionId(log.getFunctionId());
l.setStartTime(timeStamp2Date(l.getStartTime(),null));
l.setEndTime(timeStamp2Date(l.getEndTime(),null));
l.setRecvTime(timeStamp2Date(l.getRecvTime(),null));
// for (CodeResult code : appCodeList) {
// Integer value3 = Integer.valueOf(code.getCode());
// if(StringUtils.isNotBlank(l.getAppId()) && l.getAppId().equals(code.getCode())){
// l.setAppName(code.getItem());
// break;
// }
// }
// for (CodeResult code : protocolCodeList) {
// Integer value3 = Integer.valueOf(code.getCode());
// if(StringUtils.isNotBlank(l.getProtocolId()) && l.getProtocolId().equals(code.getCode())){
// l.setProtocolName(code.getItem());
// break;
// }
// }
}
String title="";
if(log.getAction().equals(1)){//监测
title="http_monit";
}else if(log.getAction().equals(16)){//阻断
title="http_block";
}else if(log.getAction().equals(48)){//操控
title="http_manipulation";
}
titleList.add(title);
classMap.put(title, PxyHttpManipulationLog.class);
SysUser user = UserUtils.getUser();
if (!user.isAdmin()) {
hColumns += ",scene_file,";
} else {
hColumns += ",";
}
String cfgIndexInfoNoExport = ",req_header,resp_header,inner_smac,inner_dmac,nest_addr_list,scene_file,"
+ ",found_time,"
+ hColumns;
noExportMap.put(title, cfgIndexInfoNoExport);
dataMap.put(title, list);
String timeRange= initLogMaps(log,title);
noExportMap.put("timeRange", timeRange);
if ("csv".equals(type)) {
this._exportCsv(model, request, response, redirectAttributes, title, titleList, classMap,
dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, title, titleList, classMap, dataMap,
noExportMap);
}
} catch (Exception e) {
logger.error("Http Manipulation export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
LogUtils.saveLog(request, null, e, null);
}
}
public void initLogSearchValues(PxyHttpManipulationLog entry, Map<String, Object> params) {
if (StringUtils.isNotBlank(entry.getSearchFoundStartTime())
&& StringUtils.isNotBlank(entry.getSearchFoundEndTime())) {
params.put("searchStartRecvTime", date2TimeStamp(entry.getSearchFoundStartTime(),"yyyy-MM-dd HH:mm:ss"));
params.put("searchEndRecvTime", date2TimeStamp(entry.getSearchFoundEndTime(),"yyyy-MM-dd HH:mm:ss"));
} else {
// 判断是否是从配置界面过来的日志查询
if (StringUtils.isNotBlank(entry.getIsLogTotalSearch())) {
Calendar time = Calendar.getInstance();
String searchEndTime = DateUtils.formatDateTime(time.getTime());
time.add(Calendar.MINUTE, -(Constants.LOG_TIME_RANGE/1000/60));
String searchStartTime = DateUtils.formatDateTime(time.getTime());
params.put("searchStartRecvTime", date2TimeStamp(searchStartTime,"yyyy-MM-dd HH:mm:ss"));
params.put("searchEndRecvTime", date2TimeStamp(searchEndTime,"yyyy-MM-dd HH:mm:ss"));
entry.setSearchFoundStartTime(searchStartTime);
entry.setSearchFoundEndTime(searchEndTime);
} else {
// 设置默认查询当前时间及前五分钟
String endTime = DateUtils.getDateTime();
Date dateStart = new Date(new Date().getTime() - Constants.LOG_TIME_INTERVAL);
String startTime = DateUtils.formatDateTime(dateStart);
params.put("searchStartRecvTime", String.valueOf(dateStart.getTime()/1000));
params.put("searchEndRecvTime", date2TimeStamp(endTime,"yyyy-MM-dd HH:mm:ss"));
entry.setSearchFoundStartTime(startTime);
entry.setSearchFoundEndTime(endTime);
}
logger.info("searchStartRecvTime" + params.get("searchStartRecvTime"));
logger.info("searchEndRecvTime" + params.get("searchEndRecvTime"));
}
if (StringUtils.isNotBlank(entry.getTransProto())) {
params.put("searchTransProto", entry.getTransProto());
}
/* if (entry.getService() != null) {
params.put("searchService", entry.getService());
} else if (entry.getAction() != null) {
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());
}
}
}*/
if (StringUtils.isNotBlank(entry.getServerIp())) {
params.put("searchServerIp", entry.getServerIp());
}
if (StringUtils.isNotBlank(entry.getClientIp())) {
params.put("searchClientIp", entry.getClientIp());
}
if (StringUtils.isNotBlank(entry.getCapIp())) {
params.put("searchCapIp", entry.getCapIp());
}
if (entry.getDirection() != null) {
params.put("searchDirection", entry.getDirection());
}
if (entry.getEntranceId() != null) {
params.put("searchEntranceId", entry.getEntranceId());
}
if (entry.getPolicyId() != null) {
params.put("searchPolicyId", entry.getPolicyId());
}
if (entry.getAction() != null) {
params.put("searchAction", entry.getAction());
}
if (entry.getAddrType() != null) {
params.put("searchAddrType", entry.getAddrType());
}
if (StringUtils.isNotBlank(entry.getIsp())) {
params.put("searchIsp", entry.getIsp());
}
if (StringUtils.isNotBlank(entry.getServerLocation())) {
params.put("searchServerLocation", entry.getServerLocation());
}
if (StringUtils.isNotBlank(entry.getClientLocation())) {
params.put("searchClientLocation", entry.getClientLocation());
}
if (StringUtils.isNotBlank(entry.getHost())) {
params.put("searchHost", entry.getHost());
}
if (StringUtils.isNotBlank(entry.getSni())) {
params.put("searchSni", entry.getSni());
}
if (StringUtils.isNotBlank(entry.getSan())) {
params.put("searchSan", entry.getSan());
}
if (StringUtils.isNotBlank(entry.getCn())) {
params.put("searchCn", entry.getCn());
}
if (StringUtils.isNotBlank(entry.getOrderBy())) {
params.put("orderBy", entry.getOrderBy());
}
if (StringUtils.isNotBlank(entry.getFields())) {
params.put("fields", entry.getFields());
}
}
public String initLogMaps(PxyHttpManipulationLog log,String title){
Properties msgProp = getMsgProp();
String logTime=msgProp.getProperty(title,title);;
if(log.getSearchFoundStartTime()!=null){
logTime+=" "+msgProp.getProperty("begin_date")+""+log.getSearchFoundStartTime();
}
if(log.getSearchFoundEndTime()!=null){
logTime+=" "+msgProp.getProperty("end_date")+""+log.getSearchFoundEndTime();
}
return logTime;
}
/**
* 日期格式字符串转换成时间戳
* @param date 字符串日期
* @param format 如yyyy-MM-dd HH:mm:ss
* @return
*/
public static String date2TimeStamp(String date_str,String format){
try {
SimpleDateFormat sdf = new SimpleDateFormat(format);
return String.valueOf(sdf.parse(date_str).getTime()/1000);
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
/**
* 时间戳转换成日期格式字符串
* @param seconds 精确到秒的字符串
* @param formatStr
* @return
*/
public static String timeStamp2Date(String seconds,String format) {
if(seconds == null || seconds.isEmpty() || seconds.equals("null")){
return "";
}
if(format == null || format.isEmpty()) format = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(new Date(Long.valueOf(seconds+"000")));
}
}

Some files were not shown because too many files have changed in this diff Show More