2018-07-24 18:45:27 +08:00
|
|
|
|
package com.nis.web.controller.configuration;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
import java.util.Date;
|
2018-10-17 10:36:38 +08:00
|
|
|
|
import java.util.HashMap;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
import java.util.List;
|
2018-10-17 10:36:38 +08:00
|
|
|
|
import java.util.Map;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
|
|
|
|
|
|
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.configuration.AppPolicyCfg;
|
2018-10-24 18:36:31 +08:00
|
|
|
|
import com.nis.domain.configuration.BaseStringCfg;
|
2018-10-17 10:36:38 +08:00
|
|
|
|
import com.nis.domain.configuration.CfgIndexInfo;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
import com.nis.domain.configuration.IpPortCfg;
|
2018-08-22 15:20:14 +08:00
|
|
|
|
import com.nis.domain.configuration.NtcSubscribeIdCfg;
|
2018-10-17 10:36:38 +08:00
|
|
|
|
import com.nis.domain.specific.ConfigGroupInfo;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
import com.nis.domain.specific.SpecificServiceCfg;
|
2018-08-22 15:20:14 +08:00
|
|
|
|
import com.nis.exceptions.CallExternalProceduresException;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
import com.nis.exceptions.MaatConvertException;
|
|
|
|
|
|
import com.nis.util.Constants;
|
2018-10-17 10:36:38 +08:00
|
|
|
|
import com.nis.util.StringUtil;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
import com.nis.web.controller.BaseController;
|
|
|
|
|
|
import com.nis.web.security.UserUtils;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 基础协议控制类
|
|
|
|
|
|
* @author wx
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Controller
|
|
|
|
|
|
@RequestMapping("${adminPath}/basicprotocol")
|
|
|
|
|
|
public class BasicProtocolController 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<AppPolicyCfg> searchPage=new Page<AppPolicyCfg>(request,response,"r");
|
|
|
|
|
|
Page<AppPolicyCfg> page = appCfgService.findAppPolicyList(searchPage, cfg);
|
2018-10-25 12:51:29 +08:00
|
|
|
|
// for(AppPolicyCfg entity:page.getList()){
|
|
|
|
|
|
// SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
|
|
|
|
|
|
// if(app!=null) {
|
|
|
|
|
|
// entity.setAppName(app.getSpecServiceName());
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// }
|
2018-07-24 18:45:27 +08:00
|
|
|
|
model.addAttribute("page", page);
|
|
|
|
|
|
initPageCondition(model,cfg);
|
|
|
|
|
|
return "/cfg/basicprotocol/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<String[]> 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();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-08-22 15:20:14 +08:00
|
|
|
|
if(cfg.getNtcSubscribeIdCfgList()!=null){
|
|
|
|
|
|
String cfgType = null;
|
|
|
|
|
|
for(NtcSubscribeIdCfg ntc:cfg.getNtcSubscribeIdCfgList()){
|
|
|
|
|
|
if(!ntc.getCfgType().equals(cfgType)){
|
|
|
|
|
|
tabList.add(new String[]{"2",ntc.getCfgType()});
|
|
|
|
|
|
cfgType = ntc.getCfgType();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
model.addAttribute("_cfg", cfg);
|
2018-07-24 18:45:27 +08:00
|
|
|
|
model.addAttribute("index", index);
|
|
|
|
|
|
model.addAttribute("tabList", tabList);
|
2018-08-30 19:09:39 +08:00
|
|
|
|
return "/cfg/basicprotocol/basicProtocolSubList";
|
2018-07-24 18:45:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 策略配置表单
|
|
|
|
|
|
* @param model
|
|
|
|
|
|
* @param ids
|
|
|
|
|
|
* @param entity
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"form"})
|
|
|
|
|
|
@RequiresPermissions(value={"basicprotocol: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/basicprotocol/form";
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 策略配置新增修改
|
|
|
|
|
|
* @param model
|
|
|
|
|
|
* @param request
|
|
|
|
|
|
* @param response
|
|
|
|
|
|
* @param entity
|
|
|
|
|
|
* @param redirectAttributes
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"save"})
|
|
|
|
|
|
@RequiresPermissions(value={"basicprotocol: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);
|
2018-08-22 15:20:14 +08:00
|
|
|
|
addMessage(redirectAttributes,"save_success");
|
2018-07-24 18:45:27 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
2018-08-22 15:20:14 +08:00
|
|
|
|
logger.error("基础协议信息保存失败",e);
|
|
|
|
|
|
if(e instanceof MaatConvertException||e instanceof CallExternalProceduresException) {
|
|
|
|
|
|
// addMessage(redirectAttributes,e.getMessage());
|
2018-08-22 22:42:12 +08:00
|
|
|
|
addMessage(redirectAttributes,"request_service_failed");
|
2018-08-22 15:20:14 +08:00
|
|
|
|
}else {
|
|
|
|
|
|
addMessage(redirectAttributes,"save_failed");
|
|
|
|
|
|
}
|
2018-07-24 18:45:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return "redirect:" + adminPath +"/basicprotocol/list?functionId="+entity.getFunctionId();
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 策略配置审核
|
|
|
|
|
|
* @param isAudit
|
|
|
|
|
|
* @param isValid
|
|
|
|
|
|
* @param ids
|
|
|
|
|
|
* @param functionId
|
|
|
|
|
|
* @param redirectAttributes
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"audit"})
|
|
|
|
|
|
@RequiresPermissions(value={"basicprotocol: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_BASIC_PROTOCOL);
|
|
|
|
|
|
try {
|
|
|
|
|
|
appCfgService.auditAppPolicyCfg(entity,isAudit);
|
2018-11-02 16:08:08 +08:00
|
|
|
|
addMessage(redirectAttributes,"success","audit_success");
|
2018-08-22 15:20:14 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
if(e instanceof MaatConvertException) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger.info("app策略配置下发失败:"+e.getMessage());;
|
2018-11-02 16:08:08 +08:00
|
|
|
|
addMessage(redirectAttributes,"error","request_service_failed");
|
2018-08-22 15:20:14 +08:00
|
|
|
|
}else {
|
|
|
|
|
|
e.printStackTrace();
|
2018-08-22 15:46:27 +08:00
|
|
|
|
logger.error("app策略配置下发失败",e);
|
2018-11-02 16:08:08 +08:00
|
|
|
|
addMessage(redirectAttributes,"error","audit_failed");
|
2018-08-22 15:20:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-24 18:45:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return "redirect:" + adminPath +"/basicprotocol/list?functionId="+functionId;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 策略配置删除
|
|
|
|
|
|
* @param isValid
|
|
|
|
|
|
* @param ids
|
|
|
|
|
|
* @param functionId
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"updateValid"})
|
|
|
|
|
|
@RequiresPermissions(value={"basicprotocol:config"})
|
2018-08-22 15:20:14 +08:00
|
|
|
|
public String updateAppPolicyCfgValid(Integer isValid,String ids,Integer functionId,RedirectAttributes redirectAttributes) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
appCfgService.updateAppPolicyCfgValid(isValid,ids,functionId);
|
|
|
|
|
|
addMessage(redirectAttributes,"delete_success");
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.error("基础协议信息保存失败",e);
|
|
|
|
|
|
if(e instanceof MaatConvertException||e instanceof CallExternalProceduresException) {
|
|
|
|
|
|
e.printStackTrace();
|
2018-08-22 22:42:12 +08:00
|
|
|
|
addMessage(redirectAttributes,"request_service_failed");
|
2018-08-22 15:20:14 +08:00
|
|
|
|
}else {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
addMessage(redirectAttributes,"delete_failed");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-24 18:45:27 +08:00
|
|
|
|
return "redirect:" + adminPath +"/basicprotocol/list?functionId="+functionId;
|
|
|
|
|
|
}
|
2018-10-17 10:36:38 +08:00
|
|
|
|
|
|
|
|
|
|
//ip配置导出
|
|
|
|
|
|
@RequestMapping(value = "exportIpAddr")
|
|
|
|
|
|
public void exportIp(Model model,HttpServletRequest request,HttpServletResponse response,
|
|
|
|
|
|
@ModelAttribute("cfg")AppPolicyCfg 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>();
|
|
|
|
|
|
/*//导出选中记录
|
|
|
|
|
|
* if(!StringUtil.isEmpty(ids)){
|
|
|
|
|
|
for(String id:ids.split(",")){
|
|
|
|
|
|
Long.parseLong(id);
|
|
|
|
|
|
}
|
|
|
|
|
|
//List<CfgIndexInfo> list=ipCfgService.getListByCfgIdWithName(IpPortCfg.getTablename(), entity.getFunctionId(), ids);
|
|
|
|
|
|
}else{*/
|
|
|
|
|
|
//条件导出数据大于最大导出数,只导出最大导出条数
|
|
|
|
|
|
entity.setTableName(IpPortCfg.getTablename());
|
|
|
|
|
|
Page<AppPolicyCfg> pageInfo=new Page<AppPolicyCfg>(request, response,"a");
|
|
|
|
|
|
if(pageInfo.getCount()>Constants.MAX_EXPORT_SIZE){
|
|
|
|
|
|
pageInfo.setPageNo(1);
|
|
|
|
|
|
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
pageInfo.setPageNo(1);
|
|
|
|
|
|
pageInfo.setPageSize(-1);
|
|
|
|
|
|
}
|
|
|
|
|
|
Page<AppPolicyCfg> page = appCfgService.findAppPolicyList(pageInfo, entity);
|
|
|
|
|
|
for(AppPolicyCfg policy:page.getList()){
|
|
|
|
|
|
SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(policy.getSpecServiceId());
|
|
|
|
|
|
if(app!=null) {
|
|
|
|
|
|
policy.setAppName(app.getSpecServiceName());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
titleList.add(entity.getMenuNameCode());
|
|
|
|
|
|
titleList.add("NTC_IP");
|
|
|
|
|
|
titleList.add("NTC_SUBSCRIBE_ID");
|
|
|
|
|
|
classMap.put(entity.getMenuNameCode(), AppPolicyCfg.class);
|
|
|
|
|
|
classMap.put("NTC_IP", IpPortCfg.class);
|
|
|
|
|
|
classMap.put("NTC_SUBSCRIBE_ID", NtcSubscribeIdCfg.class);
|
|
|
|
|
|
String cfgIndexInfoNoExport=",encrypted_tunnel_behavior,behaviour_type,social_app,behaviour_type,expression_type,match_method,whether_hexbinary,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
|
|
|
|
|
|
String ipPortInfoNoExport=",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 subscribeInfoNoExport=",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,";
|
|
|
|
|
|
noExportMap.put(entity.getMenuNameCode(),cfgIndexInfoNoExport);
|
|
|
|
|
|
noExportMap.put("NTC_IP", ipPortInfoNoExport);
|
|
|
|
|
|
noExportMap.put("NTC_SUBSCRIBE_ID", subscribeInfoNoExport);
|
|
|
|
|
|
List<IpPortCfg> ipList=new ArrayList<IpPortCfg>();
|
2018-10-24 18:36:31 +08:00
|
|
|
|
List<BaseStringCfg> subscribeInfoList=new ArrayList<BaseStringCfg>();
|
2018-10-17 10:36:38 +08:00
|
|
|
|
for (AppPolicyCfg cfg : page.getList()) {
|
|
|
|
|
|
AppPolicyCfg cfgIndexInfo=appCfgService.exportIpInfo(cfg);
|
|
|
|
|
|
ipList.addAll(cfgIndexInfo.getIpPortList());
|
|
|
|
|
|
subscribeInfoList.addAll(cfgIndexInfo.getNtcSubscribeIdCfgList());
|
|
|
|
|
|
}
|
2018-10-24 18:36:31 +08:00
|
|
|
|
subscribeInfoList=BaseStringCfg.baseHexList(subscribeInfoList);
|
2018-10-17 10:36:38 +08:00
|
|
|
|
dataMap.put(entity.getMenuNameCode(), page.getList());
|
|
|
|
|
|
dataMap.put("NTC_IP", ipList);
|
|
|
|
|
|
dataMap.put("NTC_SUBSCRIBE_ID", subscribeInfoList);
|
|
|
|
|
|
|
|
|
|
|
|
/*}*/
|
|
|
|
|
|
this._export(model, request, response, redirectAttributes,entity.getMenuNameCode(),titleList,classMap,dataMap,noExportMap);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.error("ip addr export failed",e);
|
|
|
|
|
|
addMessage(redirectAttributes, "export_failed");
|
|
|
|
|
|
}
|
|
|
|
|
|
//return "redirect:" + adminPath +"/ntc/iplist/list?functionId="+entity.getFunctionId();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-24 18:45:27 +08:00
|
|
|
|
}
|