diff --git a/src/main/java/com/nis/domain/specific/SpecificServiceCfg.java b/src/main/java/com/nis/domain/specific/SpecificServiceCfg.java index 40b187746..57c095820 100644 --- a/src/main/java/com/nis/domain/specific/SpecificServiceCfg.java +++ b/src/main/java/com/nis/domain/specific/SpecificServiceCfg.java @@ -25,11 +25,18 @@ public class SpecificServiceCfg extends BaseEntity{ private SpecificServiceCfg parent; //parent_id 父节点id int N 0表示一级节点 private Integer isLeaf; //is_leaf 是否是叶子节点 int N 0否,1是,只有一级填0 private Integer groupId; //group_id maat端配置分组id int N 缺省0,表示未与maat分组同步 - private Integer cfgType;//配置类型,1,app;2,加密隧道协议 - + private Integer cfgType;//配置类型,1,app;2,加密隧道;3,基础协议 + private Integer parentType;//父配置类型 private Date beginDate; // 开始日期 private Date endDate; // 结束日期 private String showSequence; //显示序号 + + public Integer getParentType() { + return parentType; + } + public void setParentType(Integer parentType) { + this.parentType = parentType; + } public Integer getCfgType() { return cfgType; } diff --git a/src/main/java/com/nis/web/controller/configuration/EncryptedTunnelBehaviorController.java b/src/main/java/com/nis/web/controller/configuration/EncryptedTunnelBehaviorController.java new file mode 100644 index 000000000..806641e01 --- /dev/null +++ b/src/main/java/com/nis/web/controller/configuration/EncryptedTunnelBehaviorController.java @@ -0,0 +1,194 @@ +package com.nis.web.controller.configuration; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.nis.domain.Page; +import com.nis.domain.SysDataDictionaryItem; +import com.nis.domain.configuration.AppPolicyCfg; +import com.nis.domain.configuration.IpPortCfg; +import com.nis.domain.specific.SpecificServiceCfg; +import com.nis.exceptions.MaatConvertException; +import com.nis.util.Constants; +import com.nis.util.DictUtils; +import com.nis.web.controller.BaseController; +import com.nis.web.security.UserUtils; + +/** + * 加密隧道行为控制类 + * @author wx + * + */ +@Controller +@RequestMapping("${adminPath}/encryptedtunnelbehav") +public class EncryptedTunnelBehaviorController extends BaseController { + /** + * app策略列表 + * @param model + * @param cfg + * @param request + * @param response + * @return + */ + @RequestMapping(value = {"list"}) + public String policyCfgList(Model model,@ModelAttribute("cfg")AppPolicyCfg cfg,HttpServletRequest request,HttpServletResponse response) { + Page searchPage=new Page(request,response,"r"); + Page page = appCfgService.findAppPolicyList(searchPage, cfg); + for(AppPolicyCfg entity:page.getList()){ + SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId()); + entity.setAppName(app.getSpecServiceName()); + } + //查找社交应用的所有有效二级特定服务 + SpecificServiceCfg second=new SpecificServiceCfg(); + for(SysDataDictionaryItem dict:DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) { + if(Constants.SPECIFIC_SERVICE_CFG_TYPE_ENCRYPTED_TUNNEL_BEHAVIOR.equals(dict.getItemValue())) { + second.setCfgType(Integer.parseInt(dict.getItemCode())); + break; + } + } + second.setIsValid(Constants.VALID_YES); + second.setIsLeaf(1); + List secondList=specificServiceCfgService.findAllSpecificServiceCfg(second, null); + //遍历,找到匹配项后将行为设置进去 + for(SpecificServiceCfg secondCfg:secondList) { + if(secondCfg.getSpecServiceCode()==null) continue; + for(AppPolicyCfg entity:page.getList()){ + if(entity.getBehavCode()==null) continue; + if(secondCfg.getSpecServiceCode().intValue()==entity.getBehavCode().intValue()) { + entity.setBehavName(secondCfg.getSpecServiceName()); + break; + } + } + } + model.addAttribute("page", page); + initPageCondition(model,cfg); + return "/cfg/encryptedtunnelbehav/list"; + } + /** + * 查询APP策略IP子配置 + * @param model + * @param cfgId + * @param index + * @return + */ + @RequestMapping(value = {"ajaxIpList"}) + public String ajaxSslSubList(Model model,Long cfgId,Integer index) { + AppPolicyCfg cfg = appCfgService.getAppPolicyCfg(cfgId); + List tabList = new ArrayList(); + if(cfg.getIpPortList()!=null){ + String cfgType = null; + for(IpPortCfg ip:cfg.getIpPortList()){ + if(!ip.getCfgType().equals(cfgType)){ + tabList.add(new String[]{"1",ip.getCfgType()}); + cfgType = ip.getCfgType(); + } + } + } + model.addAttribute("_cfg", cfg); + model.addAttribute("index", index); + model.addAttribute("tabList", tabList); + return "/cfg/encryptedtunnelbehav/ipList"; + } + /** + * 策略配置表单 + * @param model + * @param ids + * @param entity + * @return + */ + @RequestMapping(value = {"form"}) + @RequiresPermissions(value={"encryptedtunnelbehav:config"}) + public String policyCfgForm(Model model,String ids,AppPolicyCfg entity) { + if(StringUtils.isNotBlank(ids)){ + entity = appCfgService.getAppPolicyCfg(Long.parseLong(ids)); + initUpdateFormCondition(model,entity); + }else{ + initFormCondition(model,entity); + } + model.addAttribute("_cfg", entity); + return "/cfg/encryptedtunnelbehav/form"; + } + /** + * 策略配置新增修改 + * @param model + * @param request + * @param response + * @param entity + * @param redirectAttributes + * @return + */ + @RequestMapping(value = {"save"}) + @RequiresPermissions(value={"encryptedtunnelbehav:config"}) + public String saveAppPolicyCfg(Model model,HttpServletRequest request,HttpServletResponse response, + AppPolicyCfg entity,RedirectAttributes redirectAttributes) { + try { + SpecificServiceCfg specificService = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId()); + if(specificService!=null){ + entity.setAppCode(specificService.getSpecServiceCode()); + } + appCfgService.saveOrUpdateAppPolicyCfg(entity); + } catch (Exception e) { + e.printStackTrace(); + addMessage(redirectAttributes, e.getMessage()); + } + + return "redirect:" + adminPath +"/encryptedtunnelbehav/list?functionId="+entity.getFunctionId(); + } + /** + * 策略配置审核 + * @param isAudit + * @param isValid + * @param ids + * @param functionId + * @param redirectAttributes + * @return + */ + @RequestMapping(value = {"audit"}) + @RequiresPermissions(value={"encryptedtunnelbehav:confirm"}) + public String auditAppPolicyCfg(Integer isAudit,Integer isValid,String ids,Integer functionId, RedirectAttributes redirectAttributes) { + AppPolicyCfg entity = new AppPolicyCfg(); + String[] idArray = ids.split(","); + for(String id :idArray){ + entity = appCfgService.getAppPolicyCfg(Long.parseLong(id)); + entity.setIsAudit(isAudit); + entity.setIsValid(isValid); + entity.setAuditorId(UserUtils.getUser().getId()); + entity.setAuditTime(new Date()); + entity.setFunctionId(functionId); + entity.setConfigType(Constants.SPECIFIC_SERVICE_CFG_TYPE_ENCRYPTED_TUNNEL_BEHAVIOR); + try { + appCfgService.auditAppPolicyCfg(entity,isAudit); + } catch (MaatConvertException e) { + e.printStackTrace(); + logger.info("app策略配置下发失败:"+e.getMessage()); + addMessage(redirectAttributes, e.getMessage()); + } + } + return "redirect:" + adminPath +"/encryptedtunnelbehav/list?functionId="+functionId; + } + /** + * 策略配置删除 + * @param isValid + * @param ids + * @param functionId + * @return + */ + @RequestMapping(value = {"updateValid"}) + @RequiresPermissions(value={"encryptedtunnelbehav:config"}) + public String updateAppPolicyCfgValid(Integer isValid,String ids,Integer functionId) { + appCfgService.updateAppPolicyCfgValid(isValid,ids,functionId); + return "redirect:" + adminPath +"/encryptedtunnelbehav/list?functionId="+functionId; + } +} 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 d0c9b1c45..56fa943dc 100644 --- a/src/main/java/com/nis/web/controller/specific/SpecificServiceCfgController.java +++ b/src/main/java/com/nis/web/controller/specific/SpecificServiceCfgController.java @@ -129,6 +129,10 @@ public class SpecificServiceCfgController extends BaseController { SpecificServiceCfg parent = new SpecificServiceCfg(); parent.setSpecServiceId(0); specificServiceCfg.setParent(parent); + specificServiceCfg.setParentType(0); + } + if(specificServiceCfg!=null&&specificServiceCfg.getParent().getSpecServiceId()!=null){//获取父配置的id + specificServiceCfg.setParentType(specificServiceCfgService.getParentType(specificServiceCfg.getParent().getSpecServiceId())); } model.addAttribute("specificServiceCfg", specificServiceCfg); if (doAction != null && doAction.equals("0")) { @@ -195,6 +199,7 @@ public class SpecificServiceCfgController extends BaseController { Map map2 = Maps.newHashMap(); map2.put("id", 0); map2.put("pId", 0); + map2.put("type",0); map2.put("name","root_node"); //map2.put("placeholder","0"); mapList.add(map2); @@ -203,13 +208,15 @@ public class SpecificServiceCfgController extends BaseController { SpecificServiceCfg specificServiceCfg = list.get(i); if(StringUtils.isBlank(extId)||(extId!=null&&!extId.equals(specificServiceCfg.getSpecServiceId().toString()))){ if(specificServiceCfg.getIsValid().equals(0)|| - (!isLeafShow && specificServiceCfg.getIsLeaf().equals(1))||specificServiceCfg.getCfgType().intValue()!=cfgType){ + (!isLeafShow && specificServiceCfg.getIsLeaf().equals(1))|| + (cfgType.intValue()!=0&&specificServiceCfg.getCfgType().intValue()!=cfgType)){ continue; } Map map = Maps.newHashMap(); map.put("id", specificServiceCfg.getSpecServiceId()); map.put("pId", specificServiceCfg.getParent().getSpecServiceId()); map.put("name",specificServiceCfg.getSpecServiceName()); + map.put("type",specificServiceCfg.getCfgType()); mapList.add(map); } } @@ -230,6 +237,7 @@ public class SpecificServiceCfgController extends BaseController { map.put("code", specificServiceCfg.getSpecServiceCode()); map.put("pId", specificServiceCfg.getParent().getSpecServiceId()); map.put("name",specificServiceCfg.getSpecServiceName()); + map.put("type",specificServiceCfg.getCfgType()); mapList.add(map); } } diff --git a/src/main/java/com/nis/web/dao/configuration/AppCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/AppCfgDao.xml index 6b1f5d881..2395f4f71 100644 --- a/src/main/java/com/nis/web/dao/configuration/AppCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/AppCfgDao.xml @@ -1708,7 +1708,7 @@ - delete from ip_port_cfg where compile_id=#{compileId} and protocol_id=21 and function_id=#{functionId} + delete from ip_port_cfg where compile_id=#{compileId} and function_id=#{functionId} + 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 79f7d39d4..7e5c3626d 100644 --- a/src/main/java/com/nis/web/service/specific/SpecificServiceCfgService.java +++ b/src/main/java/com/nis/web/service/specific/SpecificServiceCfgService.java @@ -140,6 +140,8 @@ public class SpecificServiceCfgService extends BaseService{ return specificServiceCfgDao.getChildrenById(specServiceId); } - + public Integer getParentType(Integer specServiceId) { + return specificServiceCfgDao.getParentType(specServiceId); + } } diff --git a/src/main/resources/messages/message_en.properties b/src/main/resources/messages/message_en.properties index ee9bbfc0c..7391f7335 100644 --- a/src/main/resources/messages/message_en.properties +++ b/src/main/resources/messages/message_en.properties @@ -792,7 +792,7 @@ app_byte_config=APP Byte Feature social_app=Applicaiton app_policy_config=APP Policy app_features_config=APP Feature -cfg_type=Cfg Type +cfg_type=Configuration Type encrypted_tunnel_behavior=Encrypted Tunnel Behavior behaviour_type=Behaviour Type basic_protocol=Basic Protocol diff --git a/src/main/resources/messages/message_ru.properties b/src/main/resources/messages/message_ru.properties index 8bd41de51..82cf99d8c 100644 --- a/src/main/resources/messages/message_ru.properties +++ b/src/main/resources/messages/message_ru.properties @@ -714,7 +714,7 @@ app_byte_config=APP Byte Feature social_app=Applicaiton app_policy_config=APP Policy app_features_config=APP Feature -cfg_type=Cfg Type +cfg_type=Configuration Type encrypted_tunnel_behavior=Encrypted Tunnel Behavior behaviour_type=Behaviour Type basic_protocol=Basic Protocol diff --git a/src/main/webapp/WEB-INF/include/left_menu.jsp b/src/main/webapp/WEB-INF/include/left_menu.jsp index ef545e7de..0a960debe 100644 --- a/src/main/webapp/WEB-INF/include/left_menu.jsp +++ b/src/main/webapp/WEB-INF/include/left_menu.jsp @@ -17,7 +17,7 @@ - href="javascript:;" onclick="page_turn('${secondMenu.id }','${secondMenu.functionId }','1','','${ctx}/${secondMenu.href }',this)" target="mainFrame" > + href="javascript:;" onclick="page_turn('${secondMenu.id }','${secondMenu.functionId }','1','','${ctx}${secondMenu.href }',this)" target="mainFrame" > href="javascript:;" class="nav-link nav-toggle"> @@ -42,7 +42,7 @@ - href="javascript:;" onclick="page_turn('${thirdMenu.id }','${thirdMenu.functionId }','2','','${ctx}/${thirdMenu.href }',this)" target="mainFrame" > + href="javascript:;" onclick="page_turn('${thirdMenu.id }','${thirdMenu.functionId }','2','','${ctx}${thirdMenu.href }',this)" target="mainFrame" > @@ -61,7 +61,7 @@