diff --git a/src/main/java/com/nis/domain/callback/InlineIp.java b/src/main/java/com/nis/domain/callback/InlineIp.java new file mode 100644 index 000000000..d710df9a6 --- /dev/null +++ b/src/main/java/com/nis/domain/callback/InlineIp.java @@ -0,0 +1,280 @@ +/** + *@Title: InlineIp.java + *@Package com.nis.domain.callback + *@Description TODO + *@author dell + *@date 2018年6月5日 上午9:08:34 + *@version 版本号 + */ +package com.nis.domain.callback; + +import java.util.Date; + +import com.google.gson.annotations.Expose; + +/** + * @ClassName: InlineIp.java + * @Description: TODO + * @author (dell) + * @date 2018年6月5日 上午9:08:34 + * @version V1.0 + */ +public class InlineIp { + @Expose + private Integer cfgId; + @Expose + private Integer action; + @Expose + private Integer service; + @Expose + private Integer addrType; + @Expose + private String srcIp; + @Expose + private String maskSrcIp; + @Expose + private String srcPort; + @Expose + private String maskSrcPort; + @Expose + private String dstIp; + @Expose + private String maskDstIp; + @Expose + private String dstPort; + @Expose + private String maskDstPort; + @Expose + private Integer protocol; + @Expose + private Integer direction; + @Expose + private Integer isValid; + @Expose + private Date opTime; + /** + * action + * @return action + */ + + public Integer getAction() { + return action; + } + /** + * @param action the action to set + */ + public void setAction(Integer action) { + this.action = action; + } + /** + * addrType + * @return addrType + */ + + public Integer getAddrType() { + return addrType; + } + /** + * @param addrType the addrType to set + */ + public void setAddrType(Integer addrType) { + this.addrType = addrType; + } + /** + * srcIp + * @return srcIp + */ + + public String getSrcIp() { + return srcIp; + } + /** + * @param srcIp the srcIp to set + */ + public void setSrcIp(String srcIp) { + this.srcIp = srcIp; + } + /** + * maskSrcIp + * @return maskSrcIp + */ + + public String getMaskSrcIp() { + return maskSrcIp; + } + /** + * @param maskSrcIp the maskSrcIp to set + */ + public void setMaskSrcIp(String maskSrcIp) { + this.maskSrcIp = maskSrcIp; + } + /** + * srcPort + * @return srcPort + */ + + public String getSrcPort() { + return srcPort; + } + /** + * @param srcPort the srcPort to set + */ + public void setSrcPort(String srcPort) { + this.srcPort = srcPort; + } + /** + * maskSrcPort + * @return maskSrcPort + */ + + public String getMaskSrcPort() { + return maskSrcPort; + } + /** + * @param maskSrcPort the maskSrcPort to set + */ + public void setMaskSrcPort(String maskSrcPort) { + this.maskSrcPort = maskSrcPort; + } + /** + * dstIp + * @return dstIp + */ + + public String getDstIp() { + return dstIp; + } + /** + * @param dstIp the dstIp to set + */ + public void setDstIp(String dstIp) { + this.dstIp = dstIp; + } + /** + * maskDstIp + * @return maskDstIp + */ + + public String getMaskDstIp() { + return maskDstIp; + } + /** + * @param maskDstIp the maskDstIp to set + */ + public void setMaskDstIp(String maskDstIp) { + this.maskDstIp = maskDstIp; + } + /** + * dstPort + * @return dstPort + */ + + public String getDstPort() { + return dstPort; + } + /** + * @param dstPort the dstPort to set + */ + public void setDstPort(String dstPort) { + this.dstPort = dstPort; + } + /** + * maskDstPort + * @return maskDstPort + */ + + public String getMaskDstPort() { + return maskDstPort; + } + /** + * @param maskDstPort the maskDstPort to set + */ + public void setMaskDstPort(String maskDstPort) { + this.maskDstPort = maskDstPort; + } + /** + * protocol + * @return protocol + */ + + public Integer getProtocol() { + return protocol; + } + /** + * @param protocol the protocol to set + */ + public void setProtocol(Integer protocol) { + this.protocol = protocol; + } + /** + * direction + * @return direction + */ + + public Integer getDirection() { + return direction; + } + /** + * @param direction the direction to set + */ + public void setDirection(Integer direction) { + this.direction = direction; + } + /** + * isValid + * @return isValid + */ + + public Integer getIsValid() { + return isValid; + } + /** + * @param isValid the isValid to set + */ + public void setIsValid(Integer isValid) { + this.isValid = isValid; + } + /** + * opTime + * @return opTime + */ + + public Date getOpTime() { + return opTime; + } + /** + * @param opTime the opTime to set + */ + public void setOpTime(Date opTime) { + this.opTime = opTime; + } + /** + * cfgId + * @return cfgId + */ + + public Integer getCfgId() { + return cfgId; + } + /** + * @param cfgId the cfgId to set + */ + public void setCfgId(Integer cfgId) { + this.cfgId = cfgId; + } + /** + * service + * @return service + */ + + public Integer getService() { + return service; + } + /** + * @param service the service to set + */ + public void setService(Integer service) { + this.service = service; + } + +} diff --git a/src/main/java/com/nis/web/service/BaseService.java b/src/main/java/com/nis/web/service/BaseService.java index 539ae4fb2..58f43db1e 100644 --- a/src/main/java/com/nis/web/service/BaseService.java +++ b/src/main/java/com/nis/web/service/BaseService.java @@ -23,6 +23,7 @@ import com.googlecode.ipv6.IPv6Address; import com.googlecode.ipv6.IPv6Network; import com.nis.domain.SysRole; import com.nis.domain.SysUser; +import com.nis.domain.callback.InlineIp; import com.nis.domain.configuration.AreaBean; import com.nis.domain.configuration.AreaIpCfg; import com.nis.domain.configuration.BaseCfg; @@ -508,6 +509,28 @@ public abstract class BaseService { } return dstIp; } + //ip转换为callback用ip + public InlineIp convertCallBackIp(BaseIpCfg cfg){ + IpCfg c=ipConvert(new IpCfg(),cfg); + InlineIp ip=new InlineIp(); + ip.setCfgId(cfg.getCompileId()); + ip.setAction(cfg.getAction()); + ip.setService(cfg.getServiceId()); + ip.setAddrType(cfg.getIpType()); + ip.setSrcIp(c.getSrcIp()); + ip.setMaskSrcIp(c.getSrcIpMask()); + ip.setDstIp(c.getDstIp()); + ip.setMaskDstIp(c.getDstIpMask()); + ip.setSrcPort(c.getSrcPort()); + ip.setMaskSrcPort(c.getSrcPortMask()); + ip.setDstPort(c.getDstPort()); + ip.setMaskDstPort(c.getDstPortMask()); + ip.setProtocol(cfg.getProtocol()); + ip.setDirection(cfg.getDirection()); + ip.setIsValid(cfg.getIsValid()); + ip.setOpTime(cfg.getAuditTime()); + return ip; + } //区域IPsetAreaEffectiveIds设置 public void setAreaEffectiveIds(BaseCfg entity){ List areaCfg=entity.getAreaCfg(); diff --git a/src/main/java/com/nis/web/service/configuration/IpCfgService.java b/src/main/java/com/nis/web/service/configuration/IpCfgService.java index c04a964b5..0cb67ec6d 100644 --- a/src/main/java/com/nis/web/service/configuration/IpCfgService.java +++ b/src/main/java/com/nis/web/service/configuration/IpCfgService.java @@ -12,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.nis.domain.FunctionServiceDict; +import com.nis.domain.callback.InlineIp; import com.nis.domain.configuration.AreaBean; import com.nis.domain.configuration.AreaIpCfg; import com.nis.domain.configuration.BaseIpCfg; @@ -27,6 +29,7 @@ import com.nis.domain.maat.MaatCfg.StringCfg; 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.web.dao.configuration.AreaIpCfgDao; import com.nis.web.dao.configuration.IpCfgDao; @@ -168,10 +171,8 @@ public class IpCfgService extends CrudService { beans1.add(area); } this.auditIpBatch(beans1); - List configCompileList = new ArrayList<>(); List groupRelationList = new ArrayList<>(); -// List areaGroupRelationList = new ArrayList<>(); List ipRegionList = new ArrayList<>(); List strRegionList = new ArrayList<>(); List numRegionList = new ArrayList<>(); @@ -184,8 +185,11 @@ public class IpCfgService extends CrudService { String json=""; if(cfg.getIsAudit()==1){ if(Constants.DROP_ACTION==cfg.getAction()||Constants.LOOP_ACTION==cfg.getAction()){ + List ipList=new ArrayList<>(); + InlineIp ip=convertCallBackIp(cfg); + ipList.add(ip); //调用服务接口下发配置数据 - json=gsonToJson(cfg); + json=gsonToJson(ipList); logger.info("IP管控下发配置参数:"+json); //调用服务接口下发配置 try { @@ -201,6 +205,7 @@ public class IpCfgService extends CrudService { Map map = cfgConvert(ipRegionList,beans,1,cfg,groupRelationList); ipRegionList=map.get("dstList"); groupRelationList=map.get("groupList"); + numRegionList=map.get("numRegionList"); Map areaMap = cfgConvert(areaIpRegionList,beans1,1,cfg,groupRelationList); groupRelationList=areaMap.get("groupList"); areaIpRegionList=areaMap.get("dstList"); @@ -238,10 +243,11 @@ public class IpCfgService extends CrudService { } }else if(cfg.getIsAudit()==3){ if(Constants.DROP_ACTION==cfg.getAction()||Constants.LOOP_ACTION==cfg.getAction()){ - Map map=new HashMap(); - map.put("updateStatCfgList", cfg); + List ipList=new ArrayList<>(); + InlineIp ip=convertCallBackIp(cfg); + ipList.add(ip); //调用服务接口取消配置 - json=gsonToJson(map); + json=gsonToJson(ipList); logger.info("IP管控配置参数:"+json); //调用服务接口取消配置 try {