diff --git a/src/main/java/com/nis/domain/configuration/BaseIpCfg.java b/src/main/java/com/nis/domain/configuration/BaseIpCfg.java index 4915c0e6d..c91963265 100644 --- a/src/main/java/com/nis/domain/configuration/BaseIpCfg.java +++ b/src/main/java/com/nis/domain/configuration/BaseIpCfg.java @@ -65,6 +65,25 @@ public class BaseIpCfg extends BaseCfg { @Expose @SerializedName("protocolId") protected Integer protocolId ; + /** + * 限速比例 + */ + protected Integer ratelimit ; + + /** + * ratelimit + * @return ratelimit + */ + + public Integer getRatelimit() { + return ratelimit; + } + /** + * @param ratelimit the ratelimit to set + */ + public void setRatelimit(Integer ratelimit) { + this.ratelimit = ratelimit; + } /** * ipType * @return ipType diff --git a/src/main/java/com/nis/domain/specific/SpecificServiceCfg.java b/src/main/java/com/nis/domain/specific/SpecificServiceCfg.java index a20649561..fcc2e9811 100644 --- a/src/main/java/com/nis/domain/specific/SpecificServiceCfg.java +++ b/src/main/java/com/nis/domain/specific/SpecificServiceCfg.java @@ -17,7 +17,7 @@ public class SpecificServiceCfg extends BaseEntity{ private static final long serialVersionUID = -1133644323636425766L; private Integer specServiceId; //spec_service_id 协议ID int N 主键,初始化 - //private Integer specServiceCode; //协议编码 int N 暂定,以后可扩展 1000:微信 , 1001:QQ + private Integer specServiceCode; //协议编码 int N 暂定,以后可扩展 1000:微信 , 1001:QQ private String specServiceName; //spec_service_name 协议名称 varchar(64) N private String specServiceDesc; //spec_service_desc 协议描述 varchar2(64) N private Integer isValid; //is_valid 有效标志 int N 1-有效 0-无效 @@ -36,6 +36,12 @@ public class SpecificServiceCfg extends BaseEntity{ public void setSpecServiceId(Integer specServiceId) { this.specServiceId = specServiceId; } + public Integer getSpecServiceCode() { + return specServiceCode; + } + public void setSpecServiceCode(Integer specServiceCode) { + this.specServiceCode = specServiceCode; + } public String getSpecServiceName() { return specServiceName; } diff --git a/src/main/java/com/nis/domain/specific/SpecificServiceHostCfg.java b/src/main/java/com/nis/domain/specific/SpecificServiceHostCfg.java index 0ec34e46c..b775736b0 100644 --- a/src/main/java/com/nis/domain/specific/SpecificServiceHostCfg.java +++ b/src/main/java/com/nis/domain/specific/SpecificServiceHostCfg.java @@ -26,26 +26,21 @@ public class SpecificServiceHostCfg extends BaseEntity{ @Expose private Integer ipType; //ip地址类型 ipV4=4 ipV6=6 @Expose - private String srcIp; //src_ip 源IP地址 varchar(64) N 缺省0.0.0.0值表示任意 - @Expose - private String srcIpMask; //src_ip_mask 源地址掩码 varchar(64) N IPV4:255.255.255.255表示无掩码,即精确IP匹配,0.0.0.0值表示任意; - //IPV6:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF表示无掩码,::(两个半角冒号)表示任意。非0掩码值必须是2的指数幂,下同。 - @Expose - private String srcPort; //src_port 源端口 varchar(6) N 0表示任意值 - @Expose - private String srcPortMask; //src_port_mask 源端口掩码 varchar(6) N 65535表示无掩码,即精确端口匹配,0表示任意 - @Expose - private String dstIp; //dst_ip 目的IP地址 varchar(64) N 缺省0.0.0.0值表示任意 - @Expose - private String dstIpMask; //dst_ip_mask 目的地址掩码 varchar(64) N 同源ip地址掩码 - @Expose - private String dstPort; //dst_port 目的端口 varchar(6) N 目的端口,0表示任意值 - @Expose - private String dstPortMask; //dst_port_mask 目的端口掩码 varchar(6) N 同源端口掩码 - @Expose private Integer direction;; //direction 方向 int N 0双向,1单向,默认缺省为双向。 @Expose private Integer protocol; //protocol 协议 int N 6表示tcp,17表示udp,0表示任意 + @Expose + private Integer ipPattern; //ip格式 + @Expose + private String srcIpAddress; //源(客户端)IP地址 + @Expose + private String destIpAddress; //目的(服务器)IP地址 + @Expose + private Integer portPattern; //端口格式 + @Expose + private String srcPort; //源(客户端)端口 + @Expose + private String destPort;//目的(服务器)端口 private Integer isValid; //is_valid 有效标识 int N 0无效,1有效 private Integer isAudit; //is_audit 是否审核 int N 0未审核,1审核通过,2审核未通过,3取消审核通过(即删除) @@ -90,19 +85,13 @@ public class SpecificServiceHostCfg extends BaseEntity{ this.ipType = ipType; } @ExcelField(title="client_ip",align=2,sort=30,fieldType=String.class) - public String getSrcIp() { - return srcIp; + public String getSrcIpAddress() { + return srcIpAddress; } - public void setSrcIp(String srcIp) { - this.srcIp = srcIp; - } - @ExcelField(title="client_address_mask",align=2,sort=40,fieldType=String.class) - public String getSrcIpMask() { - return srcIpMask; - } - public void setSrcIpMask(String srcIpMask) { - this.srcIpMask = srcIpMask; + public void setSrcIpAddress(String srcIpAddress) { + this.srcIpAddress = srcIpAddress; } + @ExcelField(title="client_port",align=2,sort=50,fieldType=String.class) public String getSrcPort() { return srcPort; @@ -110,40 +99,34 @@ public class SpecificServiceHostCfg extends BaseEntity{ public void setSrcPort(String srcPort) { this.srcPort = srcPort; } - @ExcelField(title="client_port_mask",align=2,sort=60,fieldType=String.class) - public String getSrcPortMask() { - return srcPortMask; - } - public void setSrcPortMask(String srcPortMask) { - this.srcPortMask = srcPortMask; - } + @ExcelField(title="server_ip",align=2,sort=70,fieldType=String.class) - public String getDstIp() { - return dstIp; + public String getDestIpAddress() { + return destIpAddress; } - public void setDstIp(String dstIp) { - this.dstIp = dstIp; - } - @ExcelField(title="server_address_mask",align=2,sort=80,fieldType=String.class) - public String getDstIpMask() { - return dstIpMask; - } - public void setDstIpMask(String dstIpMask) { - this.dstIpMask = dstIpMask; + public void setDestIpAddress(String destIpAddress) { + this.destIpAddress = destIpAddress; } @ExcelField(title="server_port",align=2,sort=90,fieldType=String.class) - public String getDstPort() { - return dstPort; + public String getDestPort() { + return destPort; } - public void setDstPort(String dstPort) { - this.dstPort = dstPort; + public void setDestPort(String destPort) { + this.destPort = destPort; } - @ExcelField(title="server_port_mask",align=2,sort=100,fieldType=String.class) - public String getDstPortMask() { - return dstPortMask; + @ExcelField(title="ip_pattern",align=2,sort=21,fieldType=Integer.class) + public Integer getIpPattern() { + return ipPattern; } - public void setDstPortMask(String dstPortMask) { - this.dstPortMask = dstPortMask; + public void setIpPattern(Integer ipPattern) { + this.ipPattern = ipPattern; + } + @ExcelField(title="port_pattern",align=2,sort=40,fieldType=Integer.class) + public Integer getPortPattern() { + return portPattern; + } + public void setPortPattern(Integer portPattern) { + this.portPattern = portPattern; } @ExcelField(title="direction",align=2,sort=110) public Integer getDirection() { @@ -209,9 +192,6 @@ public class SpecificServiceHostCfg extends BaseEntity{ public void setAuditTime(Date auditTime) { this.auditTime = auditTime; } - - - public Date getBeginDate() { return beginDate; } diff --git a/src/main/java/com/nis/web/controller/configuration/proxy/InterceptController.java b/src/main/java/com/nis/web/controller/configuration/proxy/InterceptController.java new file mode 100644 index 000000000..a2175041b --- /dev/null +++ b/src/main/java/com/nis/web/controller/configuration/proxy/InterceptController.java @@ -0,0 +1,131 @@ +package com.nis.web.controller.configuration.proxy; + +import java.util.Date; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.authz.annotation.Logical; +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.servlet.mvc.support.RedirectAttributes; + +import com.nis.domain.Page; +import com.nis.domain.configuration.AreaIpCfg; +import com.nis.domain.configuration.BaseIpCfg; +import com.nis.domain.configuration.BaseStringCfg; +import com.nis.domain.configuration.HttpUrlCfg; +import com.nis.domain.configuration.IpPortCfg; +import com.nis.exceptions.MaatConvertException; +import com.nis.util.Constants; +import com.nis.web.controller.BaseController; + +/** + * IP相关配置控制类 + * @author dell + * + */ +@Controller +@RequestMapping("${adminPath}/proxy/intercept") +public class InterceptController extends BaseController{ + @RequestMapping(value = {"/ip/list"}) + @RequiresPermissions(value={"intercept:ip:config","intercept:ip:audit"},logical=Logical.OR) + public String ipList(Model model,@ModelAttribute("cfg")IpPortCfg cfg,HttpServletRequest request,HttpServletResponse response) { + cfg.setTableName(IpPortCfg.getTablename()); + Page searchPage=new Page(request,response,"r"); + Page page = ipCfgService.findPage(searchPage, cfg); + model.addAttribute("page", page); + initPageCondition(model,cfg); + return "/cfg/proxy/ipList"; + } + @RequestMapping(value = {"/ip/form"}) + @RequiresPermissions(value={"intercept:ip:config"}) + public String ipForm(Model model,String ids,BaseIpCfg entity) { + if(StringUtils.isNotBlank(ids)){ + entity = ipCfgService.getIpCfgById(IpPortCfg.getTablename(),Long.parseLong(ids)); + } + if(entity.getCfgId()!=null){ + List areaCfg=ipCfgService.getListByComileId(AreaIpCfg.getTablename(), String.valueOf(entity.getCompileId())); + model.addAttribute("areaCfgs", areaCfg); + model.addAttribute("_cfg", entity); + initUpdateFormCondition(model,entity); + }else{ + IpPortCfg cfg=new IpPortCfg(); + cfg.initDefaultValueImpl(); + cfg.setFunctionId(entity.getFunctionId()); + cfg.setProtocolId(entity.getProtocolId()); + model.addAttribute("_cfg", cfg); + initFormCondition(model,entity); + } + + return "/cfg/proxy/ipForm"; + } + @RequestMapping(value = {"/ip/saveOrUpdate"}) + public String saveOrUpdateIp(RedirectAttributes model, IpPortCfg cfg) { + Date date=new Date(); + cfg.setTableName(IpPortCfg.getTablename()); + logger.info("saveOrUpdateIp loaded"); + try{ + cfg.setIsValid(Constants.VALID_NO); + cfg.setIsAudit(Constants.AUDIT_NOT_YET); + if(cfg.getCfgId()==null){//新增 + cfg.setCreatorId(cfg.getCurrentUser().getId()); + cfg.setCreateTime(date); + ipCfgService.addIpCfg(cfg); + }else{//修改 + cfg.setEditorId(cfg.getCurrentUser().getId()); + cfg.setEditTime(new Date()); + ipCfgService.updateIpCfg(cfg); + } + addMessage(model,"save_success"); + }catch(Exception e){ + logger.error("保存失败",e); + addMessage(model,"save_failed"); + } + return "redirect:" + adminPath +"/proxy/intercept/ip/list?functionId="+cfg.getFunctionId(); + } + @RequestMapping(value = {"/ip/delete"}) + @RequiresPermissions("iplist:config") + public String deleteIp(String ids,String compileIds,Integer functionId,RedirectAttributes model) { + try{ + ipCfgService.deleteIp(ids,compileIds,functionId.intValue()); + addMessage(model,"delete_success"); + }catch(Exception e){ + logger.error("删除失败", e); + addMessage(model,"delete_failed"); + } + return "redirect:" + adminPath +"/proxy/intercept/ip/list?functionId="+functionId; + } + @RequestMapping(value = {"/ip/audit"}) +// @RequiresPermissions("intercept:ip:audit") + public String auditIp(String ids,IpPortCfg cfg,RedirectAttributes redirectAttributes) { + try{ + for(String id:ids.split(",")){ + Long.parseLong(id); + } + List beans=ipCfgService.getListByCfgId(IpPortCfg.getTablename(),ids); + Date date=new Date(); + for(BaseIpCfg bean:beans){ + bean.setTableName(IpPortCfg.getTablename()); + bean.setAuditorId(bean.getCurrentUser().getId()); + bean.setAuditTime(date); + bean.setIsAudit(cfg.getIsAudit()); + bean.setIsValid(cfg.getIsValid()); + ipCfgService.audit(bean); + } + addMessage(redirectAttributes,"audit_success"); + }catch(MaatConvertException e){ + logger.error("审核失败", e); + addMessage(redirectAttributes, e.getMessage()); + }catch(Exception e){ + logger.error("审核失败", e); + addMessage(redirectAttributes, "audit_failed"); + } + return "redirect:" + adminPath +"/proxy/intercept/ip/list?functionId="+cfg.getFunctionId(); + } +} diff --git a/src/main/java/com/nis/web/controller/specific/SpecificServiceCfgController.java b/src/main/java/com/nis/web/controller/specific/SpecificServiceCfgController.java index b6d5a5742..f09ed7941 100644 --- a/src/main/java/com/nis/web/controller/specific/SpecificServiceCfgController.java +++ b/src/main/java/com/nis/web/controller/specific/SpecificServiceCfgController.java @@ -147,9 +147,9 @@ public class SpecificServiceCfgController extends BaseController { @RequiresPermissions(value= {"specific:service:add","specific:service:edit"},logical=Logical.OR) @RequestMapping(value="saveOrUpdate") public String saveOrUpdate(SpecificServiceCfg specificServiceCfg, Model model, - RedirectAttributes redirectAttributes,Integer oldId) { + RedirectAttributes redirectAttributes) { try { - specificServiceCfgService.saveOrUpdate(specificServiceCfg,oldId); + specificServiceCfgService.saveOrUpdate(specificServiceCfg); addMessage(redirectAttributes, "save_success"); } catch (Exception e) { e.printStackTrace(); @@ -181,14 +181,16 @@ public class SpecificServiceCfgController extends BaseController { /** * 父节点选择树形结构 - * @param extId + * @param extId排除节点id * @param isShowHide + * @param isLeafShow:叶子节点是否显示 * @param response * @return */ @ResponseBody @RequestMapping(value = "treeData") - public List> treeData(@RequestParam(required=false) String extId,@RequestParam(required=false) String isShowHide, HttpServletResponse response){ + public List> treeData(@RequestParam(required=false) String extId,@RequestParam(required=false) String isShowHide, + @RequestParam(required=false)boolean isLeafShow,HttpServletResponse response){ List> mapList = Lists.newArrayList(); Map map2 = Maps.newHashMap(); map2.put("id", 0); @@ -200,7 +202,8 @@ public class SpecificServiceCfgController extends BaseController { for (int i=0; i map = Maps.newHashMap(); diff --git a/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml index a9a7ee632..32a078831 100644 --- a/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml @@ -34,6 +34,7 @@ + @@ -48,7 +49,7 @@ DIRECTION,PROTOCOL,PROTOCOL_ID,ACTION,IS_VALID,IS_AUDIT, CREATOR_ID,CREATE_TIME,EDITOR_ID,EDIT_TIME,AUDITOR_ID,AUDIT_TIME, SERVICE_ID,REQUEST_ID,COMPILE_ID,IS_AREA_EFFECTIVE,CLASSIFY, - ATTRIBUTE,LABLE,AREA_EFFECTIVE_IDS,FUNCTION_ID + ATTRIBUTE,LABLE,AREA_EFFECTIVE_IDS,FUNCTION_ID,RATELIMIT @@ -58,7 +59,7 @@ ${page.alias}.DIRECTION as direction,${page.alias}.PROTOCOL as protocol,${page.alias}.PROTOCOL_ID as protocolId,${page.alias}.ACTION as action,${page.alias}.IS_VALID as isValid,${page.alias}.IS_AUDIT as isAudit, ${page.alias}.CREATOR_ID as creatorId,${page.alias}.CREATE_TIME AS createTime,${page.alias}.EDITOR_ID as editorId,${page.alias}.EDIT_TIME AS editTime,${page.alias}.AUDITOR_ID as auditorId,${page.alias}.AUDIT_TIME AS auditTime, ${page.alias}.SERVICE_ID as serviceId,${page.alias}.REQUEST_ID AS requestId,${page.alias}.COMPILE_ID AS compileId,${page.alias}.IS_AREA_EFFECTIVE as isAreaEffective,${page.alias}.classify, - ${page.alias}.ATTRIBUTE AS attribute,${page.alias}.LABLE AS lable,${page.alias}.AREA_EFFECTIVE_IDS AS areaEffectiveIds,${page.alias}.FUNCTION_ID AS functionId + ${page.alias}.ATTRIBUTE AS attribute,${page.alias}.LABLE AS lable,${page.alias}.AREA_EFFECTIVE_IDS AS areaEffectiveIds,${page.alias}.FUNCTION_ID AS functionId,${page.alias}.RATELIMIT AS ratelimit r.CFG_ID as cfgId, r.CFG_DESC as cfgDesc,r.CFG_REGION_CODE as cfgRegionCode,r.CFG_TYPE as cfgType, r.IP_TYPE as ipType, @@ -66,7 +67,7 @@ r.DIRECTION as direction,r.PROTOCOL as protocol,r.PROTOCOL_ID as protocolId,r.ACTION as action,r.IS_VALID as isValid,r.IS_AUDIT as isAudit, r.CREATOR_ID as creatorId,r.CREATE_TIME AS createTime,r.EDITOR_ID as editorId,r.EDIT_TIME AS editTime,r.AUDITOR_ID as auditorId,r.AUDIT_TIME AS auditTime, r.SERVICE_ID as serviceId,r.REQUEST_ID AS requestId,r.COMPILE_ID AS compileId,r.IS_AREA_EFFECTIVE as isAreaEffective,r.classify, - r.ATTRIBUTE AS attribute,r.LABLE AS lable,r.AREA_EFFECTIVE_IDS AS areaEffectiveIds,r.FUNCTION_ID as functionId + r.ATTRIBUTE AS attribute,r.LABLE AS lable,r.AREA_EFFECTIVE_IDS AS areaEffectiveIds,r.FUNCTION_ID as functionId,r.RATELIMIT AS ratelimit @@ -80,7 +81,7 @@ AUDITOR_ID,AUDIT_TIME,SERVICE_ID, REQUEST_ID,COMPILE_ID,IS_AREA_EFFECTIVE, CLASSIFY,ATTRIBUTE,LABLE, - AREA_EFFECTIVE_IDS,FUNCTION_ID + AREA_EFFECTIVE_IDS,FUNCTION_ID,RATELIMIT #{cfgDesc,jdbcType=VARCHAR},#{cfgRegionCode,jdbcType=INTEGER},#{cfgType,jdbcType=VARCHAR}, @@ -92,7 +93,7 @@ #{auditorId,jdbcType=INTEGER},#{auditTime,jdbcType=TIMESTAMP},#{serviceId,jdbcType=INTEGER}, #{requestId,jdbcType=INTEGER},#{compileId,jdbcType=INTEGER},#{isAreaEffective,jdbcType=INTEGER}, #{classify,jdbcType=VARCHAR},#{attribute,jdbcType=VARCHAR},#{lable,jdbcType=VARCHAR}, - #{areaEffectiveIds,jdbcType=VARCHAR}, #{functionId,jdbcType=INTEGER} + #{areaEffectiveIds,jdbcType=VARCHAR}, #{functionId,jdbcType=INTEGER}, #{ratelimit,jdbcType=INTEGER} SELECT * from specific_service_cfg where is_valid = 1 - AND spec_service_id like '%${specificServiceCfg.specServiceId}%' + AND spec_service_id =#{specificServiceCfg.specServiceId} + + + AND spec_service_id =#{specificServiceCfg.specServiceCode} AND spec_service_name like '%${specificServiceCfg.specServiceName}%' @@ -122,22 +130,22 @@ - insert into specific_service_cfg (spec_service_id,spec_service_name,spec_service_desc,is_valid, op_time, parent_id,is_leaf,group_id) - values(#{specServiceId},#{specServiceName},#{specServiceDesc},#{isValid},#{opTime},#{parent.specServiceId},#{isLeaf},#{groupId}) + insert into specific_service_cfg (spec_service_code,spec_service_name,spec_service_desc,is_valid, op_time, parent_id,is_leaf,group_id) + values(#{specServiceCode},#{specServiceName},#{specServiceDesc},#{isValid},#{opTime},#{parent.specServiceId},#{isLeaf},#{groupId}) UPDATE specific_service_cfg s SET - s.spec_service_id = #{specificServiceCfg.specServiceId}, - s.spec_service_name = #{specificServiceCfg.specServiceName}, - s.spec_service_desc = #{specificServiceCfg.specServiceDesc}, - s.is_valid = #{specificServiceCfg.isValid}, - s.op_time = #{specificServiceCfg.opTime}, - s.parent_id = #{specificServiceCfg.parent.specServiceId}, - s.is_leaf = #{specificServiceCfg.isLeaf}, - s.group_id = #{specificServiceCfg.groupId} - WHERE s.spec_service_id = #{oldId} + s.spec_service_code = #{specServiceCode}, + s.spec_service_name = #{specServiceName}, + s.spec_service_desc = #{specServiceDesc}, + s.is_valid = #{isValid}, + s.op_time = #{opTime}, + s.parent_id = #{parent.specServiceId}, + s.is_leaf = #{isLeaf}, + s.group_id = #{groupId} + WHERE s.spec_service_id = #{specServiceId} diff --git a/src/main/java/com/nis/web/dao/specific/SpecificServiceHostCfgDao.xml b/src/main/java/com/nis/web/dao/specific/SpecificServiceHostCfgDao.xml index 68b591a23..0fd203dc3 100644 --- a/src/main/java/com/nis/web/dao/specific/SpecificServiceHostCfgDao.xml +++ b/src/main/java/com/nis/web/dao/specific/SpecificServiceHostCfgDao.xml @@ -7,16 +7,14 @@ - - - - - - - - - - + + + + + + + + @@ -39,17 +37,8 @@ s.host_id AS hostId, s.spec_service_id AS specServiceId, - s.ip_type AS ipType, - s.src_ip AS srcIp, - s.src_ip_mask AS srcIpMask, - s.src_port AS srcPort, - s.src_port_mask AS srcPortMask, - s.dst_ip AS dstIp, - s.dst_ip_mask AS dstIpMask, - s.dst_port AS dstPort, - s.dst_port_mask AS dstPortMask, - s.direction AS direction, - s.protocol AS protocol, + s.ip_type,s.src_ip_address,s.ip_pattern,s.port_pattern,s.src_port + ,s.protocol,s.direction,s.dest_ip_address,s.dest_port, s.is_valid AS isValid, s.is_audit AS isAudit, s.creator_id AS "creator.id", @@ -81,11 +70,11 @@ select * from specific_service_host_cfg where is_valid = 1 AND ip_type = #{ipType} - - AND src_ip = #{srcIp} + + AND src_ip_address = #{srcIpAddress} - - AND dst_ip = #{dstIp} + + AND dest_ip_address = #{destIpAddress} AND protocol = #{protocol} @@ -131,24 +120,40 @@ from specific_service_host_cfg s where s.spec_service_id = #{specServiceId} - insert into specific_service_host_cfg (spec_service_id,ip_type,src_ip,src_ip_mask,src_port,src_port_mask,dst_ip,dst_ip_mask,dst_port,dst_port_mask,direction,protocol,is_valid,is_audit,creator_id,create_time,editor_id,edit_time,auditor_id,audit_time) - values(#{specServiceId},#{ipType},#{srcIp},#{srcIpMask},#{srcPort},#{srcPortMask},#{dstIp},#{dstIpMask},#{dstPort},#{dstPortMask},#{direction},#{protocol},#{isValid},#{isAudit},#{creator.id},#{createTime},#{editor.id},#{editTime},#{auditor.id},#{auditTime}) + insert into specific_service_host_cfg (spec_service_id,ip_type, + src_ip_address, + ip_pattern, + port_pattern, + src_port, + protocol, + direction, + dest_port, + dest_ip_address, + is_valid,is_audit,creator_id,create_time,editor_id,edit_time,auditor_id,audit_time) + values(#{specServiceId},#{ipType,jdbcType=INTEGER}, + #{srcIpAddress,jdbcType=VARCHAR}, + #{ipPattern,jdbcType=INTEGER}, + #{portPattern,jdbcType=INTEGER}, + #{srcPort,jdbcType=VARCHAR}, + #{protocol,jdbcType=INTEGER}, + #{direction,jdbcType=INTEGER}, + #{destPort,jdbcType=VARCHAR}, + #{destIpAddress,jdbcType=VARCHAR}, + #{isValid},#{isAudit},#{creator.id},#{createTime},#{editor.id},#{editTime},#{auditor.id},#{auditTime}) update specific_service_host_cfg s set s.spec_service_id = #{specServiceId}, - s.ip_type = #{ipType}, - s.src_ip = #{srcIp}, - s.src_ip_mask = #{srcIpMask}, - s.src_port = #{srcPort}, - s.src_port_mask = #{srcPortMask}, - s.dst_ip = #{dstIp}, - s.dst_ip_mask = #{dstIpMask}, - s.dst_port = #{dstPort}, - s.dst_port_mask = #{dstPortMask}, - s.direction = #{direction}, - s.protocol = #{protocol}, + s.IP_TYPE = #{ipType,jdbcType=INTEGER}, + s.IP_PATTERN=#{ipPattern,jdbcType=INTEGER}, + s.SRC_IP_ADDRESS=#{srcIpAddress,jdbcType=VARCHAR}, + s.DEST_IP_ADDRESS=#{destIpAddress,jdbcType=VARCHAR}, + s.PORT_PATTERN=#{portPattern,jdbcType=INTEGER}, + s.SRC_PORT=#{srcPort,jdbcType=VARCHAR}, + s.DEST_PORT=#{destPort,jdbcType=VARCHAR}, + s.direction = #{direction,jdbcType=INTEGER}, + s.protocol = #{protocol,jdbcType=INTEGER}, s.is_valid = #{isValid}, s.is_audit = #{isAudit}, s.creator_id = #{creator.id}, diff --git a/src/main/java/com/nis/web/service/specific/SpecificServiceCfgService.java b/src/main/java/com/nis/web/service/specific/SpecificServiceCfgService.java index 1877e9795..79f7d39d4 100644 --- a/src/main/java/com/nis/web/service/specific/SpecificServiceCfgService.java +++ b/src/main/java/com/nis/web/service/specific/SpecificServiceCfgService.java @@ -4,6 +4,7 @@ import java.util.Date; import java.util.List; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -13,6 +14,7 @@ import com.nis.domain.Page; import com.nis.domain.specific.ConfigGroupInfo; import com.nis.domain.specific.SpecificServiceCfg; import com.nis.main.ConvertTool; +import com.nis.util.ConfigServiceUtil; import com.nis.util.StringUtil; import com.nis.web.dao.specific.SpecificServiceCfgDao; import com.nis.web.service.BaseService; @@ -65,9 +67,10 @@ public class SpecificServiceCfgService extends BaseService{ * @throws Exception */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public void saveOrUpdate(SpecificServiceCfg specificServiceCfg, Integer oldId) throws Exception { + public void saveOrUpdate(SpecificServiceCfg specificServiceCfg) throws Exception { if(specificServiceCfg.getGroupId()==null || specificServiceCfg.getGroupId()==0){ - specificServiceCfg.setGroupId(new ConvertTool().getGroupId()); + Integer groupId = ConfigServiceUtil.getId(2, 1).get(0); + specificServiceCfg.setGroupId(groupId); } //新增协议分组 ConfigGroupInfo group = specificServiceCfgDao.getConfigGroupInfoByGroupId(specificServiceCfg.getGroupId()); @@ -79,26 +82,28 @@ public class SpecificServiceCfgService extends BaseService{ group.setGroupType(1); specificServiceCfgDao.insertConfigGroupInfo(group); } - if(oldId==null){//新增 + if(specificServiceCfg.getSpecServiceId()==null){//新增 + if(specificServiceCfg.getIsLeaf()==null){ + if(specificServiceCfg.getParent().getSpecServiceId().equals(0)){ + specificServiceCfg.setIsLeaf(0); + }else{ + specificServiceCfg.setIsLeaf(1); + } + } + specificServiceCfg.setIsValid(1); specificServiceCfg.setOpTime(new Date()); specificServiceCfgDao.insert(specificServiceCfg); }else{//修改 - specificServiceCfg.setOpTime(new Date()); - //修改id则将其子类的parent_id一并修改 - if(oldId!=specificServiceCfg.getSpecServiceId()){ - //找出所有子类 - List list = specificServiceCfgDao.getChildrenById(oldId); - SpecificServiceCfg se =new SpecificServiceCfg(); - se.setSpecServiceId(specificServiceCfg.getSpecServiceId()); - for(SpecificServiceCfg ss:list){ - if(ss!=null){ - ss.setParent(se); - specificServiceCfgDao.update(ss,ss.getSpecServiceId()); - } + if(specificServiceCfg.getIsLeaf()==null){ + if(specificServiceCfg.getParent().getSpecServiceId().equals(0)){ + specificServiceCfg.setIsLeaf(0); + }else{ + specificServiceCfg.setIsLeaf(1); } } - specificServiceCfgDao.update(specificServiceCfg,oldId); + specificServiceCfg.setOpTime(new Date()); + specificServiceCfgDao.update(specificServiceCfg); } } /** diff --git a/src/main/java/com/nis/web/service/specific/SpecificServiceHostCfgService.java b/src/main/java/com/nis/web/service/specific/SpecificServiceHostCfgService.java index cec1e7702..fb289b477 100644 --- a/src/main/java/com/nis/web/service/specific/SpecificServiceHostCfgService.java +++ b/src/main/java/com/nis/web/service/specific/SpecificServiceHostCfgService.java @@ -59,34 +59,44 @@ public class SpecificServiceHostCfgService extends BaseService{ public void saveOrUpdate(SpecificServiceHostCfg specificServiceHostCfg) { SysUser user = UserUtils.getUser(); String defaultIp = "0.0.0.0"; //缺省0.0.0.0值表示任意 - String defaultIpMask = ""; if(specificServiceHostCfg.getIpType().equals(4)){ - defaultIpMask = "255.255.255.255"; //255.255.255.255表示无掩码 + if(specificServiceHostCfg.getIpPattern()==1){ + defaultIp = "0.0.0.0/32"; //0.0.0.0表示任意 + }else if(specificServiceHostCfg.getIpPattern()==2){ + defaultIp = "0.0.0.0-0.0.0.0"; + }else{ + defaultIp = "0.0.0.0"; + } + } if(specificServiceHostCfg.getIpType().equals(6)){ - defaultIpMask = "FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"; //FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF表示无掩码 + if(specificServiceHostCfg.getIpPattern()==1){ + defaultIp = "::/64"; + }else if(specificServiceHostCfg.getIpPattern()==2){ + defaultIp = "::-::"; + }else{ + defaultIp = "::"; + } + } + String defaultPort = "0"; //0表示任意 + if(specificServiceHostCfg.getPortPattern().equals(1)){ + defaultPort = "0"; + }else{ + defaultPort = "0/0"; } - String defaultPortMask = "65535"; //65535表示无掩码 //ip地址默认 缺省0.0.0.0值表示任意 - if(StringUtil.isBlank(specificServiceHostCfg.getSrcIp())){ - specificServiceHostCfg.setSrcIp(defaultIp); + if(StringUtil.isBlank(specificServiceHostCfg.getSrcIpAddress())){ + specificServiceHostCfg.setSrcIpAddress(defaultIp); } - if(StringUtil.isBlank(specificServiceHostCfg.getDstIp())){ - specificServiceHostCfg.setDstIp(defaultIp); - } - //ip掩码默认 - if(StringUtil.isBlank(specificServiceHostCfg.getSrcIpMask())){ - specificServiceHostCfg.setSrcIpMask(defaultIpMask); - } - if(StringUtil.isBlank(specificServiceHostCfg.getDstIpMask())){ - specificServiceHostCfg.setDstIpMask(defaultIpMask); + if(StringUtil.isBlank(specificServiceHostCfg.getDestIpAddress())){ + specificServiceHostCfg.setDestIpAddress(defaultIp); } //端口掩码默认 - if(StringUtil.isBlank(specificServiceHostCfg.getSrcPortMask())){ - specificServiceHostCfg.setSrcPortMask(defaultPortMask); + if(StringUtil.isBlank(specificServiceHostCfg.getSrcPort())){ + specificServiceHostCfg.setSrcPort(defaultPort); } - if(StringUtil.isBlank(specificServiceHostCfg.getDstPortMask())){ - specificServiceHostCfg.setDstPortMask(defaultPortMask); + if(StringUtil.isBlank(specificServiceHostCfg.getDestPort())){ + specificServiceHostCfg.setDestPort(defaultPort); } //方向缺省 if(specificServiceHostCfg.getDirection()==null){ @@ -181,7 +191,7 @@ public class SpecificServiceHostCfgService extends BaseService{ } //源IP - if(!StringUtil.isEmpty(specificServiceHostCfg.getSrcIp())&&!BasicProvingUtil.isIpOrIpMask(specificServiceHostCfg.getSrcIp(), specificServiceHostCfg.getIpType())){ + /*if(!StringUtil.isEmpty(specificServiceHostCfg.getSrcIp())&&!BasicProvingUtil.isIpOrIpMask(specificServiceHostCfg.getSrcIp(), specificServiceHostCfg.getIpType())){ logger.info(msgProp.getProperty("the_line_of").replace("rowNum", (i+3)+"")+ msgProp.getProperty("val_src_ip")); // throw new RuntimeException(msgProp.getProperty("the_line_of").replace("rowNum", (i+3)+"")+ msgProp.getProperty("val_src_ip")); importErrorInfo=new ImportErrorInfo(i+3+"",msgProp.getProperty("client_ip"),msgProp.getProperty("the_line_of").replace("rowNum", (i+3)+"")+ msgProp.getProperty("val_src_ip")); @@ -293,7 +303,7 @@ public class SpecificServiceHostCfgService extends BaseService{ //方向缺省 if(specificServiceHostCfg.getDirection()==null){ specificServiceHostCfg.setDirection(0); - } + }*/ Date date = new Date(); specificServiceHostCfg.setIsValid(1); specificServiceHostCfg.setCreator(user); diff --git a/src/main/webapp/WEB-INF/views/cfg/iplist/form.jsp b/src/main/webapp/WEB-INF/views/cfg/iplist/form.jsp index c2e4f0196..2998888ba 100644 --- a/src/main/webapp/WEB-INF/views/cfg/iplist/form.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/iplist/form.jsp @@ -32,8 +32,10 @@ $(function(){ } }); - $("#serviceId").val($(".action:checked").attr("serviceId")); - $("#protocolId").val($(".action:checked").attr("protocolId")); + if('${fn:length(serviceList)}'>1){ + $("#serviceId").val($(".action:checked").attr("serviceId")); + $("#protocolId").val($(".action:checked").attr("protocolId")); + } $("#ipCfgFrom").validate({ errorPlacement: function(error,element){ $(element).parents(".form-group").find("div[for='"+element.attr("name")+"']").append(error); @@ -70,9 +72,19 @@ $(function(){ - + + + + + + + + + + + @@ -110,7 +122,11 @@ $(function(){ protocolId="${service.protocolId }" value="${service.action }" class="required action" checked> - + + + + + diff --git a/src/main/webapp/WEB-INF/views/cfg/iplist/list.jsp b/src/main/webapp/WEB-INF/views/cfg/iplist/list.jsp index 9bef658a1..d6e008c54 100644 --- a/src/main/webapp/WEB-INF/views/cfg/iplist/list.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/iplist/list.jsp @@ -14,11 +14,6 @@ data.obj=$(this) GetLogTotal('${ctx}',data); }); - //$("#loadingModal").modal("show"); - //setTimeout(function(){ - // $("#loadingModal").modal("hide"); - //},1000); - //$("#loadingModal").modal({backdrop:'static',keybord:false}); //搜索框提示语初始化 if("${cfg.srcIpAddress}"){ $("#intype").val("${cfg.srcIpAddress}"); diff --git a/src/main/webapp/WEB-INF/views/cfg/proxy/ipForm.jsp b/src/main/webapp/WEB-INF/views/cfg/proxy/ipForm.jsp new file mode 100644 index 000000000..18bd242ae --- /dev/null +++ b/src/main/webapp/WEB-INF/views/cfg/proxy/ipForm.jsp @@ -0,0 +1,171 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + +<spring:message code="ip_intercept"></spring:message> + + + +
+

+ +

+
+
+
+
+
+ + + +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ + + +
+
+
+
+
+
+ + + + + + + <%@include file="/WEB-INF/include/form/ipInfo.jsp" %> + <%@include file="/WEB-INF/include/form/areaInfo.jsp" %> + <%@include file="/WEB-INF/include/form/basicInfo.jsp" %> +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+ + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/cfg/proxy/ipList.jsp b/src/main/webapp/WEB-INF/views/cfg/proxy/ipList.jsp new file mode 100644 index 000000000..a8fd29272 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/cfg/proxy/ipList.jsp @@ -0,0 +1,336 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + +<spring:message code="ip_intercept"></spring:message> + + + + +
+ +

+ + +

+ +
+
+
+
+
+ + + + + + + + +
+
+ + + + + + +
+
+ +
+
+ + + + + + + + + +
+ + + +
+
+
+ + + +
+
+ + + + + +
+ + +
+
+ + href="javascript:;"> + + +
+
+ + + +
+
+
+
+ + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+
+
+ +
+
+
+ + + + + + <%-- --%> + + + + + + + + + + + + + + + + + + + + + + + + <%-- --%> + + + + + + + <%-- --%> + + + + + + + + + + + + + + + <%-- --%> + + + + + + + + + + + + +
ip
${status.index+1 }${cfg.cfgDesc } + ${ipType.itemValue} + ${cfg.srcIpAddress }${cfg.srcPort }${cfg.destIpAddress }${cfg.destPort } + + + + + + + + + + + + + + + + + + + ${cfg.requestName } + + + + ${fl.itemValue}, + + + + + + + ${xz.itemValue}, + + + + + + ${lable.itemValue}, + + + ${cfg.areaEffectiveIds } + + + + + + + + + + +
${cfg.creatorName }${cfg.editorName }${cfg.auditorName }
+
${page}
+
+ +
+
+
+ + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/cfg/whitelist/ipForm.jsp b/src/main/webapp/WEB-INF/views/cfg/whitelist/ipForm.jsp index a7b77d615..afb81986e 100644 --- a/src/main/webapp/WEB-INF/views/cfg/whitelist/ipForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/whitelist/ipForm.jsp @@ -216,7 +216,11 @@ $(function(){ checked> - + + + + + diff --git a/src/main/webapp/WEB-INF/views/specific/specificServiceCfgForm.jsp b/src/main/webapp/WEB-INF/views/specific/specificServiceCfgForm.jsp index 110b623ab..a46f1b704 100644 --- a/src/main/webapp/WEB-INF/views/specific/specificServiceCfgForm.jsp +++ b/src/main/webapp/WEB-INF/views/specific/specificServiceCfgForm.jsp @@ -2,14 +2,12 @@ <%@ include file="/WEB-INF/include/taglib.jsp"%> - -