(1)IP配置审核提交
(2)域名白名单审核修改
This commit is contained in:
@@ -2,6 +2,7 @@ package com.nis.web.service.configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -54,9 +55,6 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void addIpCfg(BaseIpCfg cfg){
|
||||
//区域IPsetAreaEffectiveIds设置
|
||||
List<AreaIpCfg> areaCfg=cfg.getAreaCfg();
|
||||
List<AreaBean> areaIsps=cfg.getAreaIsp();
|
||||
//调用服务接口获取compileId
|
||||
Integer compileId = 0;
|
||||
try {
|
||||
@@ -71,40 +69,17 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
}
|
||||
if(compileId!=0){
|
||||
cfg.setCompileId(compileId);
|
||||
if(Constants.IS_AREA_EFFECTIVE_NO==cfg.getIsAreaEffective()){
|
||||
cfg.setAreaEffectiveIds("0");
|
||||
cfg.setAreaType(null);
|
||||
}else if(Constants.IS_AREA_EFFECTIVE_YES==cfg.getIsAreaEffective()){
|
||||
if(Constants.AREA_EFFECTIVE_TYPE_AREA_ISP==cfg.getAreaType()&&areaIsps!=null&&areaIsps.size()>0){
|
||||
StringBuffer areaEffectiveIds=new StringBuffer();
|
||||
for(int i=0;i<areaIsps.size();i++){
|
||||
if(StringUtils.isNotBlank(areaIsps.get(i).getArea())&&StringUtils.isNotBlank(areaIsps.get(i).getIsp())){
|
||||
areaEffectiveIds.append(areaIsps.get(i).getArea()+":"+areaIsps.get(i).getIsp());
|
||||
}else if(StringUtils.isNotBlank(areaIsps.get(i).getArea())){
|
||||
areaEffectiveIds.append(areaIsps.get(i).getArea());
|
||||
}else if(StringUtils.isNotBlank(areaIsps.get(i).getIsp())){
|
||||
areaEffectiveIds.append(areaIsps.get(i).getIsp());
|
||||
}
|
||||
if(i!=areaIsps.size()-1){
|
||||
areaEffectiveIds.append(",");
|
||||
}
|
||||
}
|
||||
cfg.setAreaEffectiveIds(areaEffectiveIds.toString());
|
||||
}else if(Constants.AREA_EFFECTIVE_TYPE_AREA_IP==cfg.getAreaType()&&areaCfg!=null&&areaCfg.size()>0){
|
||||
cfg.setAreaEffectiveIds("0");
|
||||
}
|
||||
if(areaCfg!=null&&areaCfg.size()>0){
|
||||
for(AreaIpCfg c:cfg.getAreaCfg()){
|
||||
c.initDefaultValue();
|
||||
BeanUtils.copyProperties(cfg, c,new String[]{"cfgId","ipType","direction",
|
||||
"protocol","protocolId","areaEffectiveIds","cfgRegionCode",
|
||||
"cfgType","ipPattern","srcIpAddress","portPattern","srcPort","destIpAddress","destPort"});
|
||||
c.setTableName(AreaIpCfg.getTablename());
|
||||
}
|
||||
this.saveIpBatch(cfg.getAreaCfg());
|
||||
setAreaEffectiveIds(cfg);
|
||||
if(cfg.getAreaCfg()!=null&&cfg.getAreaCfg().size()>0){
|
||||
for(AreaIpCfg c:cfg.getAreaCfg()){
|
||||
c.initDefaultValue();
|
||||
BeanUtils.copyProperties(cfg, c,new String[]{"cfgId","ipType","direction",
|
||||
"protocol","protocolId","areaEffectiveIds","cfgRegionCode",
|
||||
"cfgType","ipPattern","srcIpAddress","portPattern","srcPort","destIpAddress","destPort"});
|
||||
c.setTableName(AreaIpCfg.getTablename());
|
||||
}
|
||||
this.saveIpBatch(cfg.getAreaCfg());
|
||||
}
|
||||
|
||||
ipCfgDao.insert(cfg);
|
||||
}else{
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
@@ -153,77 +128,166 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
area.setFunctionId(cfg.getFunctionId());
|
||||
areaIpCfgDao.deleteAreaIpCfg(area);
|
||||
//区域IPsetAreaEffectiveIds设置
|
||||
List<AreaIpCfg> areaCfg=cfg.getAreaCfg();
|
||||
List<AreaBean> areaIsps=cfg.getAreaIsp();
|
||||
if(Constants.IS_AREA_EFFECTIVE_NO==cfg.getIsAreaEffective()){
|
||||
cfg.setAreaEffectiveIds("0");
|
||||
cfg.setAreaType(null);
|
||||
}else if(Constants.IS_AREA_EFFECTIVE_YES==cfg.getIsAreaEffective()){
|
||||
if(Constants.AREA_EFFECTIVE_TYPE_AREA_ISP==cfg.getAreaType()&&areaIsps!=null&&areaIsps.size()>0){
|
||||
StringBuffer areaEffectiveIds=new StringBuffer();
|
||||
for(int i=0;i<areaIsps.size();i++){
|
||||
if(StringUtils.isNotBlank(areaIsps.get(i).getArea())&&StringUtils.isNotBlank(areaIsps.get(i).getIsp())){
|
||||
areaEffectiveIds.append(areaIsps.get(i).getArea()+":"+areaIsps.get(i).getIsp());
|
||||
}else if(StringUtils.isNotBlank(areaIsps.get(i).getArea())){
|
||||
areaEffectiveIds.append(areaIsps.get(i).getArea());
|
||||
}else if(StringUtils.isNotBlank(areaIsps.get(i).getIsp())){
|
||||
areaEffectiveIds.append(areaIsps.get(i).getIsp());
|
||||
}
|
||||
if(i!=areaIsps.size()-1){
|
||||
areaEffectiveIds.append(",");
|
||||
}
|
||||
}
|
||||
cfg.setAreaEffectiveIds(areaEffectiveIds.toString());
|
||||
}else if(Constants.AREA_EFFECTIVE_TYPE_AREA_IP==cfg.getAreaType()&&areaCfg!=null&&areaCfg.size()>0){
|
||||
cfg.setAreaEffectiveIds("0");
|
||||
}
|
||||
if(areaCfg!=null&&areaCfg.size()>0){
|
||||
for(AreaIpCfg c:cfg.getAreaCfg()){
|
||||
c.initDefaultValue();
|
||||
BeanUtils.copyProperties(cfg, c,new String[]{"cfgId","ipType","direction",
|
||||
"protocol","protocolId","areaEffectiveIds","cfgRegionCode",
|
||||
"cfgType","ipPattern","srcIpAddress","portPattern","srcPort","destIpAddress","destPort"});
|
||||
c.setTableName(AreaIpCfg.getTablename());
|
||||
}
|
||||
this.saveIpBatch(cfg.getAreaCfg());
|
||||
setAreaEffectiveIds(cfg);
|
||||
Date date=new Date();
|
||||
if(cfg.getAreaCfg()!=null&&cfg.getAreaCfg().size()>0){
|
||||
for(AreaIpCfg c:cfg.getAreaCfg()){
|
||||
c.initDefaultValue();
|
||||
BeanUtils.copyProperties(cfg, c,new String[]{"cfgId","ipType","direction",
|
||||
"protocol","protocolId","areaEffectiveIds","cfgRegionCode",
|
||||
"cfgType","ipPattern","srcIpAddress","portPattern","srcPort","destIpAddress","destPort"});
|
||||
c.setTableName(AreaIpCfg.getTablename());
|
||||
c.setCreatorId(cfg.getCurrentUser().getId());
|
||||
c.setCreateTime(date);
|
||||
}
|
||||
this.saveIpBatch(cfg.getAreaCfg());
|
||||
}
|
||||
ipCfgDao.update(cfg);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* updateIpCfg(更新IP类配置)
|
||||
* (继承BaseIpCfg这个类方可使用)
|
||||
* @param baseIpCfg
|
||||
* @return
|
||||
*int
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void updateIpCfg(BaseIpCfg baseIpCfg,List<BaseIpCfg> addAreaCfg,List<BaseIpCfg> updateAreaCfg,List<BaseIpCfg> deleteAreaCfgs){
|
||||
// if(addAreaCfg!=null&&addAreaCfg.size()>0){
|
||||
// this.saveIpBatch(addAreaCfg);
|
||||
// }
|
||||
// if(updateAreaCfg!=null&&updateAreaCfg.size()>0){
|
||||
// this.updateIpBatch(updateAreaCfg);
|
||||
// }
|
||||
// if(deleteAreaCfgs!=null&&deleteAreaCfgs.size()>0){
|
||||
// this.deleteIpBatch(deleteAreaCfgs);
|
||||
// }
|
||||
// return ipCfgDao.update(baseIpCfg);
|
||||
}
|
||||
public void audit(BaseIpCfg cfg) throws Exception{
|
||||
//更新IP配置与区域IP的状态
|
||||
List<BaseIpCfg> beans=new ArrayList<>();
|
||||
beans.add(cfg);
|
||||
this.auditBatch(beans, IpCfgDao.class);
|
||||
List<BaseIpCfg> beans1=new ArrayList<>();
|
||||
List<AreaIpCfg> areaIpCfgList=areaIpCfgDao.getByCompileId(cfg.getCompileId());
|
||||
for(AreaIpCfg area:areaIpCfgList){
|
||||
BeanUtils.copyProperties(cfg,area ,new String[]{"cfgRegionCode"
|
||||
,"cfgType"
|
||||
,"cfgId"
|
||||
,"ipType"
|
||||
,"ipPattern"
|
||||
,"srcIpAddress"
|
||||
,"portPattern"
|
||||
,"srcPort"
|
||||
,"destPort"
|
||||
,"protocol"
|
||||
,"direction"
|
||||
,"protocolId"
|
||||
});
|
||||
beans1.add(area);
|
||||
}
|
||||
this.auditIpBatch(beans1);
|
||||
|
||||
List<MaatCfg> configCompileList = new ArrayList<>();
|
||||
List<GroupCfg> groupRelationList = new ArrayList<>();
|
||||
// List<GroupCfg> areaGroupRelationList = new ArrayList<>();
|
||||
List<IpCfg> ipRegionList = new ArrayList<>();
|
||||
List<StringCfg> strRegionList = new ArrayList<>();
|
||||
List<NumBoundaryCfg> numRegionList = new ArrayList<>();
|
||||
List<DigestCfg> digestRegionList = new ArrayList<>();
|
||||
List<IpCfg> areaIpRegionList = new ArrayList<>();
|
||||
ToMaatBean maatBean = new ToMaatBean();
|
||||
MaatCfg maatCfg = new MaatCfg();
|
||||
maatCfg.initDefaultValue();
|
||||
BeanUtils.copyProperties(cfg, maatCfg);
|
||||
String json="";
|
||||
if(cfg.getIsAudit()==1){
|
||||
if(Constants.DROP_ACTION==cfg.getAction()||Constants.LOOP_ACTION==cfg.getAction()){
|
||||
//调用服务接口下发配置数据
|
||||
json=gsonToJson(cfg);
|
||||
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;
|
||||
}
|
||||
}else{
|
||||
Map<String,List> map = cfgConvert(ipRegionList,beans,1,cfg,groupRelationList);
|
||||
ipRegionList=map.get("dstList");
|
||||
groupRelationList=map.get("groupList");
|
||||
Map<String,List> areaMap = cfgConvert(areaIpRegionList,beans1,1,cfg,groupRelationList);
|
||||
groupRelationList=areaMap.get("groupList");
|
||||
areaIpRegionList=areaMap.get("dstList");
|
||||
maatCfg.setAreaEffectiveIds(StringUtils.isBlank(cfg.getAreaEffectiveIds())?"0":cfg.getAreaEffectiveIds());
|
||||
maatCfg.setUserRegion(cfg.getCompileId()+"");
|
||||
maatCfg.setAction(cfg.getAction());
|
||||
maatCfg.setAuditTime(cfg.getAuditTime());
|
||||
maatCfg.setIpRegionList(ipRegionList);
|
||||
maatCfg.setStrRegionList(strRegionList);
|
||||
maatCfg.setNumRegionList(numRegionList);
|
||||
maatCfg.setAreaIpRegionList(areaIpRegionList);
|
||||
maatCfg.setDigestRegionList(digestRegionList);
|
||||
maatCfg.setGroupRelationList(groupRelationList);
|
||||
maatCfg.setGroupNum(groupRelationList.size());
|
||||
maatCfg.setAreaIpRegionList(areaIpRegionList);
|
||||
configCompileList.add(maatCfg);
|
||||
maatBean.setOpAction(Constants.INSERT_ACTION);
|
||||
maatBean.setConfigCompileList(configCompileList);
|
||||
maatBean.setAuditTime(cfg.getAuditTime());
|
||||
maatBean.setCreatorName(cfg.getCurrentUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
//调用服务接口下发配置数据
|
||||
json=gsonToJson(maatBean);
|
||||
logger.info("IP管控下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||||
if(result!=null){
|
||||
logger.info("IP管控配置下发响应信息:"+result.getMsg());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("IP管控配置下发失败",e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}else if(cfg.getIsAudit()==3){
|
||||
if(Constants.DROP_ACTION==cfg.getAction()||Constants.LOOP_ACTION==cfg.getAction()){
|
||||
Map<String,Object> map=new HashMap<String, Object>();
|
||||
map.put("updateStatCfgList", cfg);
|
||||
//调用服务接口取消配置
|
||||
json=gsonToJson(map);
|
||||
logger.info("IP管控配置参数:"+json);
|
||||
//调用服务接口取消配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.put(json, 2);
|
||||
logger.info("IP管控取消配置响应信息:"+result.getMsg());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("IP管控取消配置失败");
|
||||
throw e;
|
||||
}
|
||||
}else{
|
||||
maatCfg.setCompileId(cfg.getCompileId());
|
||||
maatCfg.setServiceId(cfg.getServiceId());
|
||||
maatCfg.setIsValid(0);//无效
|
||||
configCompileList.add(maatCfg);
|
||||
maatBean.setConfigCompileList(configCompileList);
|
||||
maatBean.setAuditTime(cfg.getAuditTime());
|
||||
maatBean.setCreatorName(cfg.getCurrentUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
//调用服务接口取消配置
|
||||
json=gsonToJson(maatBean);
|
||||
logger.info("IP管控配置参数:"+json);
|
||||
//调用服务接口取消配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.put(json, 1);
|
||||
logger.info("IP管控取消配置响应信息:"+result.getMsg());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("IP管控取消配置失败");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void auditWhiteIp(BaseIpCfg cfg) throws Exception{
|
||||
List<BaseIpCfg> beans=new ArrayList<>();
|
||||
beans.add(cfg);
|
||||
this.auditBatch(beans, IpCfgDao.class);
|
||||
List<MaatCfg> configCompileList = new ArrayList();
|
||||
List<GroupCfg> groupRelationList = new ArrayList();
|
||||
List<IpCfg> ipRegionList = new ArrayList();
|
||||
List<StringCfg> strRegionList = new ArrayList();
|
||||
List<NumBoundaryCfg> numRegionList = new ArrayList();
|
||||
List<DigestCfg> digestRegionList = new ArrayList();
|
||||
List<IpCfg> areaIpRegionList = new ArrayList();
|
||||
List<MaatCfg> configCompileList = new ArrayList<>();
|
||||
List<GroupCfg> groupRelationList = new ArrayList<>();
|
||||
List<IpCfg> ipRegionList = new ArrayList<>();
|
||||
List<StringCfg> strRegionList = new ArrayList<>();
|
||||
List<NumBoundaryCfg> numRegionList = new ArrayList<>();
|
||||
List<DigestCfg> digestRegionList = new ArrayList<>();
|
||||
List<IpCfg> areaIpRegionList = new ArrayList<>();
|
||||
ToMaatBean maatBean = new ToMaatBean();
|
||||
MaatCfg maatCfg = new MaatCfg();
|
||||
maatCfg.initDefaultValue();
|
||||
@@ -287,48 +351,6 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
}
|
||||
}
|
||||
}
|
||||
public void auditWhiteIp(String ids,IpPortCfg cfg) throws Exception{
|
||||
|
||||
List<BaseIpCfg> beans=this.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());
|
||||
}
|
||||
this.auditBatch(beans, IpCfgDao.class);
|
||||
if(cfg.getIsAudit()==1){
|
||||
//待调整
|
||||
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(beans);
|
||||
logger.info("IP白名单下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||||
logger.info("IP白名单配置下发响应信息:"+result.getMsg());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("IP白名单配置下发失败");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
}else if(cfg.getIsAudit()==3){
|
||||
//调用服务接口取消配置
|
||||
String json=gsonToJson(beans);
|
||||
logger.info("IP白名单配置参数:"+json);
|
||||
//调用服务接口取消配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.put(json, 2);
|
||||
logger.info("IP白名单取消配置响应信息:"+result.getMsg());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("IP白名单取消配置失败");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* auditIpCfg(审核IP类配置)
|
||||
|
||||
Reference in New Issue
Block a user