Merge branch 'develop' of http://192.168.10.125/k18_web/NFS.git into develop
This commit is contained in:
@@ -40,21 +40,23 @@ public class AppPolicyCfg extends BaseCfg<AppPolicyCfg> {
|
||||
private Integer appCode;//specific_service_cfg表一级节点的spec_service_code
|
||||
private Integer behavCode;//specific_service_cfg表二级节点的spec_service_code
|
||||
private Integer specServiceId;
|
||||
@ExcelField(title="basic_protocol",sort=3)
|
||||
@ExcelField(title="basic_protocol",sort=5)
|
||||
private String appName;
|
||||
@ExcelField(title="behaviour_type",sort=4)
|
||||
@ExcelField(title="behaviour_type",sort=6)
|
||||
private String behavName;
|
||||
private String cfgKeywords;
|
||||
private String userRegion1;
|
||||
@ExcelField(title="ratelimit",dictType="APP_RATE_LIMIT",sort=3)
|
||||
private String userRegion2;
|
||||
private String userRegion3;
|
||||
@ExcelField(title="block_by_app_server_ip",dictType="SYS_YES_NO",sort=4)
|
||||
private String userRegion4;
|
||||
private String userRegion5;
|
||||
private String configType;
|
||||
|
||||
@ExcelField(title="encrypted_tunnel_behavior",sort=3)
|
||||
@ExcelField(title="encrypted_tunnel_behavior",sort=5)
|
||||
private String behaviorName;
|
||||
@ExcelField(title="social_app",sort=3)
|
||||
@ExcelField(title="social_app",sort=5)
|
||||
private String socialName;
|
||||
|
||||
|
||||
|
||||
@@ -624,6 +624,142 @@ public class ConfigServiceUtil {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置全量更新指令下发
|
||||
* @param params
|
||||
* @return
|
||||
* @throws MaatConvertException
|
||||
*/
|
||||
public static ToMaatResult configSyncCmd(String params) throws MaatConvertException{
|
||||
Response response=null;
|
||||
ToMaatResult bean = null;
|
||||
try {
|
||||
String result = null;
|
||||
String url = DictUtils.getDictLabel("config_sync_url", "sync_cmd");
|
||||
//创建连接
|
||||
WebTarget wt = ClientUtil.getWebTarger(url);
|
||||
logger.info("sync_cmd url:"+url);
|
||||
//获取响应结果
|
||||
Builder header = wt.request(MediaType.APPLICATION_JSON)
|
||||
.header("Content-Type", MediaType.APPLICATION_JSON);
|
||||
try {
|
||||
response= header.post(Entity.entity(params, MediaType.APPLICATION_JSON));
|
||||
if(response != null) {
|
||||
result=response.readEntity(String.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response != null && response.getStatus() == 200){
|
||||
logger.info("get result success");
|
||||
JsonConfig config=new JsonConfig();
|
||||
JSONObject resObject = JSONObject.fromObject(result,config);
|
||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||
}else{
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}finally {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
/**
|
||||
* 配置全量更新获取当前状态
|
||||
* @param params
|
||||
* @return
|
||||
* @throws MaatConvertException
|
||||
*/
|
||||
public static ToMaatResult configSyncStatus() throws MaatConvertException{
|
||||
Response response=null;
|
||||
ToMaatResult bean = null;
|
||||
try {
|
||||
String result = null;
|
||||
String url = DictUtils.getDictLabel("config_sync_url", "get_sync_status");
|
||||
//创建连接
|
||||
WebTarget wt = ClientUtil.getWebTarger(url);
|
||||
logger.info("get_sync_status url:"+url);
|
||||
//获取响应结果
|
||||
Builder header = wt.request(MediaType.APPLICATION_JSON)
|
||||
.header("Content-Type", MediaType.APPLICATION_JSON);
|
||||
try {
|
||||
response= header.get();
|
||||
if(response != null) {
|
||||
result=response.readEntity(String.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response != null && response.getStatus() == 200){
|
||||
logger.info("get result success");
|
||||
JsonConfig config=new JsonConfig();
|
||||
JSONObject resObject = JSONObject.fromObject(result,config);
|
||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||
}else{
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}finally {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
/**
|
||||
* 配置全量更新
|
||||
* @param params
|
||||
* @return
|
||||
* @throws MaatConvertException
|
||||
*/
|
||||
public static ToMaatResult configSync(String params,Integer cfgType,Integer serviceId,String tableName,String completeTag) throws MaatConvertException{
|
||||
Response response=null;
|
||||
ToMaatResult bean = null;
|
||||
try {
|
||||
String result = null;
|
||||
String url = DictUtils.getDictLabel("config_sync_url", "sync_send");
|
||||
//创建连接
|
||||
WebTarget wt = ClientUtil.getWebTarger(url);
|
||||
logger.info("sync_send url:"+url);
|
||||
//获取响应结果
|
||||
Builder header = wt.request(MediaType.APPLICATION_JSON)
|
||||
.header("Content-Type", MediaType.APPLICATION_JSON)
|
||||
.header("Config-Type", cfgType)
|
||||
.header("Service-Id", serviceId)
|
||||
.header("Config-Table", tableName)
|
||||
.header("Last-Completed-Tag", completeTag);
|
||||
try {
|
||||
response= header.post(Entity.entity(params, MediaType.APPLICATION_JSON));
|
||||
if(response != null) {
|
||||
result=response.readEntity(String.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response != null && response.getStatus() == 200){
|
||||
logger.info("get result success");
|
||||
JsonConfig config=new JsonConfig();
|
||||
config.setExcludes(new String[]{"configCompileList"});
|
||||
JSONObject resObject = JSONObject.fromObject(result,config);
|
||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||
}else{
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}finally {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
|
||||
return bean;
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
// getId(1,1);
|
||||
|
||||
@@ -677,6 +677,8 @@ public final class Constants {
|
||||
public static String INTERCEPT_IP_RATELIMIT_DROPRATE_USER_REGION_KEY=Configurations.getStringProperty("Droprate", "Droprate");
|
||||
public static String INTERCEPT_IP_RATELIMIT_BANDWITH_USER_REGION_KEY=Configurations.getStringProperty("Bandwidth", "Bandwidth");
|
||||
public static String INTERCEPT_DOMAN_INTENSITY_USER_REGION_KEY=Configurations.getStringProperty("intercept_domain_intensity", "DOMAIN_INTENSITY");
|
||||
//APP VIGNORE
|
||||
public static String APP_VIGNORE_USER_REGION_KEY=Configurations.getStringProperty("app_vignore_user_region_key", "VIGNORE");
|
||||
|
||||
//大屏统计分析查询接口URL
|
||||
public static final String DASHBOARD_URL = Configurations.getStringProperty("dashboardUrl","dashboardUrl");
|
||||
|
||||
137
src/main/java/com/nis/util/ServiceConfigTemplateUtil.java
Normal file
137
src/main/java/com/nis/util/ServiceConfigTemplateUtil.java
Normal file
@@ -0,0 +1,137 @@
|
||||
package com.nis.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections.map.CaseInsensitiveMap;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dom4j.Attribute;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.Node;
|
||||
import org.dom4j.io.SAXReader;
|
||||
|
||||
public class ServiceConfigTemplateUtil {
|
||||
|
||||
private Logger logger = Logger.getLogger(getClass());
|
||||
|
||||
private Node root;
|
||||
/**
|
||||
* 配置文件内容
|
||||
* @return
|
||||
*/
|
||||
public ServiceConfigTemplateUtil(){
|
||||
SAXReader reader = new SAXReader();
|
||||
org.dom4j.Document document = null;
|
||||
String configPath = "/service/service_config.xml";
|
||||
try {
|
||||
document = reader.read(ServiceConfigTemplateUtil.class.getResourceAsStream(configPath));
|
||||
root = document.getRootElement();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取业务节点列表
|
||||
* @return
|
||||
*/
|
||||
public List<Node> getServiceNodeList(){
|
||||
List<Node> nodes = root.selectNodes("service");
|
||||
return nodes;
|
||||
}
|
||||
/**
|
||||
* 获取业务列表
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getServiceList(){
|
||||
List<Map<String,Object>> list =new ArrayList();
|
||||
List<Element> elements = root.selectNodes("service");
|
||||
for(Element element:elements){
|
||||
Map<String,Object> map = new HashMap();
|
||||
for(int i=0;i<element.attributes().size();i++){
|
||||
String attributeName = element.attribute(i).getName();
|
||||
map.put(attributeName, element.attributeValue(attributeName));
|
||||
}
|
||||
map.put("cfgList", getServiceCfgList(element));
|
||||
map.put("userRegionList",getUserRegionList(element));
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取业务配置列表
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getServiceCfgList(Element serviceNode){
|
||||
List<Map<String,Object>> list = new ArrayList();
|
||||
List<Element> elements = serviceNode.selectNodes("serviceCfg");
|
||||
for(Element element:elements){
|
||||
Map<String,Object> map = new HashMap();
|
||||
for(int i=0;i<element.attributes().size();i++){
|
||||
map.put(element.attribute(i).getName(), element.attributeValue(element.attribute(i).getName()));
|
||||
}
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* 获取用户自定义域列表
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getUserRegionList(Element serviceNode){
|
||||
List<Map<String,Object>> list = new ArrayList();
|
||||
List<Element> elements = serviceNode.selectNodes("userRegion");
|
||||
for(Element element:elements){
|
||||
Map<String,Object> map = new HashMap();
|
||||
for(int i=0;i<element.attributes().size();i++){
|
||||
map.put(element.attribute(i).getName(), element.attributeValue(element.attribute(i).getName()));
|
||||
}
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* 根据标签获取配置属性列表
|
||||
* @param tag,如多层标签,格式为/tag/subTag/...
|
||||
* @param attribute
|
||||
* @return
|
||||
*/
|
||||
public List getXmlParamListByTag(String tag,String attribute){
|
||||
List list =new ArrayList();
|
||||
List<Element> elements = root.selectNodes(tag);
|
||||
for(Element element:elements){
|
||||
list.add(element.attributeValue(attribute));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
ServiceConfigTemplateUtil serviceTemplate = new ServiceConfigTemplateUtil();
|
||||
List<Map<String,Object>> list = serviceTemplate.getServiceList();
|
||||
for(Map<String,Object> map :list){
|
||||
System.out.println("业务配置:"+map.get("id")+","+map.get("functionId")+","+map.get("serviceType")+","+map.get("tableName"));
|
||||
List<Map<String,Object>> cfgList = (List<Map<String, Object>>) map.get("cfgList");
|
||||
List<Map<String,Object>> userRegionList = (List<Map<String, Object>>) map.get("userRegionList");
|
||||
if(cfgList!=null){
|
||||
for(Map<String,Object> m:cfgList){
|
||||
System.out.println("cfgList:"+m.get("cfgType")+","+m.get("tableName")+","+m.get("groupReuse")+","+m.get("groupId"));
|
||||
}
|
||||
}
|
||||
if(userRegionList!=null){
|
||||
for(Map<String,Object> n:userRegionList){
|
||||
System.out.println("userRegionList:"+n.get("regionKey")+","+n.get("regionColumn")+","+n.get("handleType"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,6 +115,7 @@ import com.nis.web.service.configuration.AvContentCfgService;
|
||||
import com.nis.web.service.configuration.BgpCfgService;
|
||||
import com.nis.web.service.configuration.CachePolicyService;
|
||||
import com.nis.web.service.configuration.ComplexStringCfgService;
|
||||
import com.nis.web.service.configuration.ConfigSynchronizationService;
|
||||
import com.nis.web.service.configuration.ControlPolicyService;
|
||||
import com.nis.web.service.configuration.DdosCfgService;
|
||||
import com.nis.web.service.configuration.DnsIpCfgService;
|
||||
@@ -251,6 +252,8 @@ public class BaseController {
|
||||
//protected ConfigGroupInfoService configGroupInfoService;
|
||||
@Autowired
|
||||
protected CachePolicyService cachePolicyService;
|
||||
@Autowired
|
||||
protected ConfigSynchronizationService configSynchronizationService;
|
||||
/**
|
||||
* 管理基础路径
|
||||
*/
|
||||
|
||||
@@ -255,7 +255,7 @@ public class BasicProtocolController extends BaseController {
|
||||
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 cfgIndexInfoNoExport=",ratelimit,block_by_app_server_ip,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"
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.nis.web.controller.configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.nis.domain.FunctionServiceDict;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.web.controller.BaseController;
|
||||
|
||||
/**
|
||||
* 配置全量同步
|
||||
* @author zhangwei
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/config/synchronization")
|
||||
public class ConfigSynchronizationController extends BaseController {
|
||||
|
||||
/**
|
||||
* 下发同步命令
|
||||
*/
|
||||
@RequestMapping(value = {"cmd"})
|
||||
public String cmd(Model model,String cmd){
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发同步配置
|
||||
*/
|
||||
@RequestMapping(value = {"send"})
|
||||
public void send(Model model,HttpServletRequest request,HttpServletResponse response){
|
||||
try {
|
||||
configSynchronizationService.send(request,response,null);
|
||||
} catch (NoSuchFieldException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (SecurityException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IllegalArgumentException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 同步状态获取
|
||||
*/
|
||||
@RequestMapping(value = {"getStatus"})
|
||||
public String getStatus(Model model){
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -293,7 +293,7 @@ public class EncryptedTunnelBehaviorController extends BaseController {
|
||||
classMap.put(entity.getMenuNameCode(), AppPolicyCfg.class);
|
||||
classMap.put("NTC_IP", IpPortCfg.class);
|
||||
classMap.put("NTC_SUBSCRIBE_ID", NtcSubscribeIdCfg.class);
|
||||
String cfgIndexInfoNoExport=",social_app,basic_protocol,expression_type,match_method,whether_hexbinary,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
|
||||
String cfgIndexInfoNoExport=",ratelimit,block_by_app_server_ip,social_app,basic_protocol,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"
|
||||
|
||||
@@ -2066,13 +2066,13 @@
|
||||
USER_REGION2 =#{userRegion2,jdbcType=VARCHAR},
|
||||
<!-- </if>
|
||||
<if test="userRegion3 != null and userRegion3 != ''"> -->
|
||||
USER_REGION1 =#{userRegion3,jdbcType=VARCHAR},
|
||||
USER_REGION3 =#{userRegion3,jdbcType=VARCHAR},
|
||||
<!-- </if>
|
||||
<if test="userRegion4 != null and userRegion4 != ''"> -->
|
||||
USER_REGION1 =#{userRegion4,jdbcType=VARCHAR},
|
||||
USER_REGION4 =#{userRegion4,jdbcType=VARCHAR},
|
||||
<!-- </if>
|
||||
<if test="userRegion5 != null and userRegion5 != ''"> -->
|
||||
USER_REGION1 =#{userRegion5,jdbcType=VARCHAR},
|
||||
USER_REGION5 =#{userRegion5,jdbcType=VARCHAR},
|
||||
<!-- </if> -->
|
||||
DO_LOG=#{doLog,jdbcType=INTEGER},
|
||||
<if test="exprType != null">
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.nis.web.dao.configuration;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.apache.ibatis.annotations.ResultType;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.nis.domain.configuration.AppByteCfg;
|
||||
import com.nis.domain.configuration.AppComplexKeywordCfg;
|
||||
import com.nis.domain.configuration.AppDomainCfg;
|
||||
import com.nis.domain.configuration.AppHeaderCfg;
|
||||
import com.nis.domain.configuration.AppHttpCfg;
|
||||
import com.nis.domain.configuration.AppIdCfg;
|
||||
import com.nis.domain.configuration.AppIdCfg.AppFeaturesIndex;
|
||||
import com.nis.domain.configuration.AppInnerRuleCfg;
|
||||
import com.nis.domain.configuration.AppIpCfg;
|
||||
import com.nis.domain.configuration.AppPolicyCfg;
|
||||
import com.nis.domain.configuration.AppSslCertCfg;
|
||||
import com.nis.domain.configuration.AppStringCfg;
|
||||
import com.nis.domain.configuration.AppTcpCfg;
|
||||
import com.nis.domain.configuration.AppTopicDomainCfg;
|
||||
import com.nis.domain.configuration.AvFileSampleCfg;
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.configuration.ComplexkeywordCfg;
|
||||
import com.nis.domain.configuration.DdosIpCfg;
|
||||
import com.nis.domain.configuration.DnsIpCfg;
|
||||
import com.nis.domain.configuration.DnsResStrategy;
|
||||
import com.nis.domain.configuration.FileDigestCfg;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.configuration.PxyObjKeyring;
|
||||
import com.nis.domain.configuration.PxyObjTrustedCaCert;
|
||||
import com.nis.domain.configuration.PxyObjTrustedCaCrl;
|
||||
import com.nis.domain.configuration.WebsiteDomainTopic;
|
||||
import com.nis.web.dao.CrudDao;
|
||||
import com.nis.web.dao.MyBatisDao;
|
||||
|
||||
|
||||
/**
|
||||
* 配置全量同步相关配置数据处理类
|
||||
* @author zhangwei
|
||||
*
|
||||
*/
|
||||
@MyBatisDao
|
||||
public interface ConfigSynchronizationDao {
|
||||
//app策略配置增删改查
|
||||
// public List<AppPolicyCfg> findAppPolicyList(AppPolicyCfg entity) ;
|
||||
// public List<IpPortCfg> getAppPolicyIpList(AppPolicyCfg entity);
|
||||
// //app协议IP配置增删改查
|
||||
// public List<AppIpCfg> findAppIpList(AppIpCfg entity) ;
|
||||
// //app http特征增删改查
|
||||
// public List<AppHttpCfg> findAppHttpList(AppHttpCfg entity) ;
|
||||
// //app 域名配置增删改查
|
||||
// public List<AppDomainCfg> findAppDomainList(AppDomainCfg entity) ;
|
||||
// //app 主题网站配置增删改查
|
||||
// public List<AppTopicDomainCfg> findAppTopicDomainList(AppTopicDomainCfg entity) ;
|
||||
// //app 字节特征增删改查
|
||||
// public List<AppByteCfg> findAppByteList(AppByteCfg entity) ;
|
||||
// //app ssl证书特征配置CRUD
|
||||
// public List<AppSslCertCfg> findAppSslList(AppSslCertCfg entity);
|
||||
// //app header特征配置CRUD
|
||||
// public List<AppHeaderCfg> findAppHeaderList(AppHeaderCfg entity);
|
||||
// //域名关联表操作
|
||||
// public List<WebsiteDomainTopic> getDomainDict(WebsiteDomainTopic websiteDomainTopic);
|
||||
|
||||
public List<CfgIndexInfo> getCfgIndexList(BaseCfg entity);
|
||||
public List<IpPortCfg> getIpPortList(@Param("tableName")String tableName,@Param("compileIds")List compileIds);
|
||||
public List<BaseStringCfg> getStrList(@Param("tableName")String tableName,@Param("compileIds")List compileIds);
|
||||
public List<ComplexkeywordCfg> getComplexStrList(@Param("tableName")String tableName,@Param("compileIds")List compileIds);
|
||||
public List<FileDigestCfg> getFileDigestList(@Param("tableName")String tableName,@Param("compileIds")List compileIds);
|
||||
|
||||
public List<DdosIpCfg> getDdosIpCfgList(BaseCfg entity);
|
||||
|
||||
public List<AvFileSampleCfg> getAvFileCfgList(BaseCfg entity);
|
||||
public List<PxyObjKeyring> getPxyObjKeyringCfgList(BaseCfg entity);
|
||||
public List<PxyObjTrustedCaCert> getPxyObjTrustedCertCfgList(BaseCfg entity);
|
||||
public List<PxyObjTrustedCaCrl> getPxyObjTrustedCrlCfgList(BaseCfg entity);
|
||||
public List<DnsResStrategy> getDnsStrategyList(BaseCfg entity);
|
||||
public List<DnsIpCfg> getDnsIpCfgList(BaseCfg entity);
|
||||
public List<IpPortCfg> getIpPortListByService(BaseCfg entity);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -225,8 +225,8 @@
|
||||
)values (
|
||||
#{cfgDesc,jdbcType=VARCHAR},
|
||||
#{action,jdbcType=INTEGER},
|
||||
0,
|
||||
0,
|
||||
#{isValid,jdbcType=INTEGER},
|
||||
#{isAudit,jdbcType=INTEGER},
|
||||
#{creatorId,jdbcType=INTEGER},
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
#{editorId,jdbcType=INTEGER},
|
||||
|
||||
@@ -224,8 +224,8 @@
|
||||
)values (
|
||||
#{cfgDesc,jdbcType=VARCHAR},
|
||||
#{action,jdbcType=INTEGER},
|
||||
0,
|
||||
0,
|
||||
#{isValid,jdbcType=INTEGER},
|
||||
#{isAudit,jdbcType=INTEGER},
|
||||
#{creatorId,jdbcType=INTEGER},
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
#{editorId,jdbcType=INTEGER},
|
||||
|
||||
@@ -768,8 +768,8 @@
|
||||
)values (
|
||||
#{cfgDesc,jdbcType=VARCHAR},
|
||||
#{action,jdbcType=INTEGER},
|
||||
0,
|
||||
0,
|
||||
#{isValid,jdbcType=INTEGER},
|
||||
#{isAudit,jdbcType=INTEGER},
|
||||
#{creatorId,jdbcType=INTEGER},
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
#{editorId,jdbcType=INTEGER},
|
||||
@@ -830,8 +830,8 @@
|
||||
)values (
|
||||
#{cfgDesc,jdbcType=VARCHAR},
|
||||
#{action,jdbcType=INTEGER},
|
||||
0,
|
||||
0,
|
||||
#{isValid,jdbcType=INTEGER},
|
||||
#{isAudit,jdbcType=INTEGER},
|
||||
#{creatorId,jdbcType=INTEGER},
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
#{editorId,jdbcType=INTEGER},
|
||||
|
||||
@@ -964,6 +964,23 @@ public class AppCfgService extends BaseService {
|
||||
if (entity.getBehavCode() != null) {
|
||||
userRegion += Constants.USER_REGION_SPLIT + Constants.BEHAV_ID_REGION + "=" + entity.getBehavCode();
|
||||
}
|
||||
|
||||
// 限速业务需要设置
|
||||
if (Constants.RATELIMIT_ACTION.equals(entity.getAction())) {
|
||||
entity.setUserRegion1(StringUtil.isEmpty(entity.getUserRegion1()) ? "0":entity.getUserRegion1());
|
||||
//限速 需要发Droprate=0.001 ,暂不支持Bandwidth=200kbps
|
||||
if(entity.getUserRegion1().equals("0")){//丢包率
|
||||
entity.setUserRegion2(StringUtil.isEmpty(entity.getUserRegion2()) ? "":entity.getUserRegion2());
|
||||
userRegion+=Constants.USER_REGION_SPLIT +Constants.INTERCEPT_IP_RATELIMIT_DROPRATE_USER_REGION_KEY+"="+entity.getUserRegion2();
|
||||
}else if(entity.getUserRegion1().equals("1")){//带宽
|
||||
entity.setUserRegion3(StringUtil.isEmpty(entity.getUserRegion3()) ? "":entity.getUserRegion3());
|
||||
userRegion+=Constants.USER_REGION_SPLIT +Constants.INTERCEPT_IP_RATELIMIT_BANDWITH_USER_REGION_KEY+"="+entity.getUserRegion3();
|
||||
}
|
||||
}
|
||||
//VIGNORE=1
|
||||
if(StringUtil.isEmpty(entity.getUserRegion4())){
|
||||
userRegion+=Constants.USER_REGION_SPLIT +Constants.APP_VIGNORE_USER_REGION_KEY+"=1";
|
||||
}
|
||||
} else if (Constants.SPECIFIC_SERVICE_CFG_TYPE_BASIC_PROTOCOL.equalsIgnoreCase(configType)) {
|
||||
userRegion = Constants.PROTO_ID_REGION + "=" + entity.getAppCode();
|
||||
} else if (Constants.SPECIFIC_SERVICE_CFG_TYPE_ENCRYPTED_TUNNEL_BEHAVIOR.equalsIgnoreCase(configType)) {
|
||||
@@ -973,14 +990,6 @@ public class AppCfgService extends BaseService {
|
||||
}
|
||||
|
||||
}
|
||||
// 限速业务需要设置
|
||||
String actionCode = DictUtils.getDictCode("SERVICE_ACTION", "action_ratelimit");
|
||||
if (!actionCode.equals("默认")) {
|
||||
if (entity.getAction().equals(Integer.parseInt(actionCode))) {
|
||||
userRegion += Constants.USER_REGION_SPLIT + Constants.RATE_LIMIT_REGION + "="
|
||||
+ entity.getRatelimit();
|
||||
}
|
||||
}
|
||||
maatCfg.setUserRegion(userRegion);
|
||||
configCompileList.add(maatCfg);
|
||||
maatBean.setConfigCompileList(configCompileList);
|
||||
|
||||
@@ -0,0 +1,557 @@
|
||||
package com.nis.web.service.configuration;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.dom4j.Node;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import antlr.StringUtils;
|
||||
|
||||
import com.nis.domain.FunctionServiceDict;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.configuration.AppPolicyCfg;
|
||||
import com.nis.domain.configuration.AvFileSampleCfg;
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.configuration.ComplexkeywordCfg;
|
||||
import com.nis.domain.configuration.DdosIpCfg;
|
||||
import com.nis.domain.configuration.DnsIpCfg;
|
||||
import com.nis.domain.configuration.DnsResStrategy;
|
||||
import com.nis.domain.configuration.FileDigestCfg;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.configuration.PxyObjKeyring;
|
||||
import com.nis.domain.configuration.PxyObjTrustedCaCert;
|
||||
import com.nis.domain.configuration.PxyObjTrustedCaCrl;
|
||||
import com.nis.domain.maat.MaatCfg;
|
||||
import com.nis.domain.maat.ToMaatBean;
|
||||
import com.nis.domain.maat.ToMaatResult;
|
||||
import com.nis.domain.maat.MaatCfg.DigestCfg;
|
||||
import com.nis.domain.maat.MaatCfg.GroupCfg;
|
||||
import com.nis.domain.maat.MaatCfg.IpCfg;
|
||||
import com.nis.domain.maat.MaatCfg.NumBoundaryCfg;
|
||||
import com.nis.domain.maat.MaatCfg.StringCfg;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.ServiceConfigTemplateUtil;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.configuration.ConfigSynchronizationDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
import com.nis.web.service.BaseService;
|
||||
|
||||
/**
|
||||
* 配置全量同步事务类
|
||||
* @author zhangwei
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class ConfigSynchronizationService extends BaseService{
|
||||
@Autowired
|
||||
protected ConfigSynchronizationDao configSynchronizationDao;
|
||||
private ToMaatBean maatBean;
|
||||
private MaatCfg maatCfg;
|
||||
private List<MaatCfg> configCompileList;
|
||||
private List<GroupCfg> groupRelationList;
|
||||
private List<IpCfg> ipRegionList;
|
||||
private List<StringCfg> strRegionList;
|
||||
private List<NumBoundaryCfg> numRegionList;
|
||||
private List<DigestCfg> digestRegionList;
|
||||
private List<IpCfg> areaIpRegionList;
|
||||
|
||||
/**
|
||||
* 配置全量更新下发
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
* @throws SecurityException
|
||||
* @throws NoSuchFieldException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public void send(HttpServletRequest request,HttpServletResponse response,BaseCfg cfg) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, ClassNotFoundException {
|
||||
long start = System.currentTimeMillis();
|
||||
ServiceConfigTemplateUtil serviceTemplate = new ServiceConfigTemplateUtil();
|
||||
if(cfg==null){
|
||||
List<Map<String,Object>> serviceList = serviceTemplate.getServiceList();
|
||||
for(Map<String,Object> service:serviceList){
|
||||
String tableName = service.get("tableName").toString();
|
||||
String serviceType = service.get("serviceType").toString();
|
||||
String className = service.get("className").toString();
|
||||
String serviceId = service.get("id").toString();
|
||||
BaseCfg entity = new BaseCfg();
|
||||
entity.setServiceId(Integer.valueOf(serviceId));
|
||||
entity.setIsAudit(1);
|
||||
entity.setIsValid(1);
|
||||
if("1".equals(serviceType)){//maat类配置
|
||||
List<Map<String,Object>> cfgList = (List<Map<String, Object>>) service.get("cfgList");
|
||||
List<Map<String,Object>> userRegionList = (List<Map<String, Object>>) service.get("userRegionList");
|
||||
if("cfg_index_info".equals(tableName)){
|
||||
Page<CfgIndexInfo> page=new Page<CfgIndexInfo>(request,response,Constants.MAAT_JSON_SEND_SIZE,"a");
|
||||
handleNtcMaatData(cfgList,userRegionList,page,entity,request,response,false);
|
||||
}else if("ddos_ip_cfg".equals(tableName)){
|
||||
Page<DdosIpCfg> page=new Page<DdosIpCfg>(request,response,Constants.MAAT_JSON_SEND_SIZE,"a");
|
||||
handleDdosMaatData(cfgList,userRegionList,page,entity,request,response,false);
|
||||
}
|
||||
}else if("2".equals(serviceType)){//回调类配置
|
||||
entity.setTableName(tableName);
|
||||
entity.setServiceId(Integer.valueOf(serviceId));
|
||||
Page<BaseCfg> page=new Page<BaseCfg>(request,response,Constants.MAAT_JSON_SEND_SIZE,"a");
|
||||
handleCallbackData(className,page,entity,request,response,false);
|
||||
}
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
logger.info("本次配置全量同步,开始时间:"+start
|
||||
+",结束时间:"+end
|
||||
+",共计花费"+((end-start)/1000+"秒"));
|
||||
}else{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* 处理ntc业务maat类配置
|
||||
* @param serviceId
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws SecurityException
|
||||
* @throws NoSuchFieldException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public void handleNtcMaatData(List<Map<String,Object>>cfgList,List<Map<String,Object>>userRegionList,
|
||||
Page<CfgIndexInfo> page,BaseCfg entity,HttpServletRequest request,HttpServletResponse response,
|
||||
boolean isUpdateCfg) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException{
|
||||
|
||||
boolean hasData = true;
|
||||
while(hasData){
|
||||
List<IpPortCfg> ipList = new ArrayList();
|
||||
List<BaseStringCfg> strList = new ArrayList();
|
||||
List<ComplexkeywordCfg> complexStrList = new ArrayList();
|
||||
List<com.nis.domain.configuration.NumBoundaryCfg> numList = new ArrayList();
|
||||
List<FileDigestCfg> fileList = new ArrayList();
|
||||
maatBean = new ToMaatBean();
|
||||
configCompileList = new ArrayList();
|
||||
entity.setPage(page);
|
||||
List<CfgIndexInfo> list = configSynchronizationDao.getCfgIndexList(entity);
|
||||
if(!StringUtil.isEmpty(list)){
|
||||
List<Integer> compileIds = new ArrayList();
|
||||
for(CfgIndexInfo cfg:list){
|
||||
compileIds.add(cfg.getCompileId());
|
||||
}
|
||||
if(cfgList!=null){
|
||||
for(Map<String,Object> m:cfgList){
|
||||
String tableName = m.get("tableName").toString();
|
||||
if("1".equals(m.get("cfgType"))){
|
||||
if(tableName.equals("asn_ip_cfg")){
|
||||
|
||||
}else{
|
||||
ipList.addAll(configSynchronizationDao.getIpPortList(tableName, compileIds));
|
||||
}
|
||||
}else if("2".equals(m.get("cfgType"))){
|
||||
strList.addAll(configSynchronizationDao.getStrList(tableName,compileIds));
|
||||
}else if("3".equals(m.get("cfgType"))){
|
||||
complexStrList.addAll(configSynchronizationDao.getComplexStrList(tableName,compileIds));
|
||||
}else if("4".equals(m.get("cfgType"))){
|
||||
|
||||
}else if("5".equals(m.get("cfgType"))){
|
||||
fileList.addAll(configSynchronizationDao.getFileDigestList(tableName, compileIds));
|
||||
}
|
||||
}
|
||||
}
|
||||
for(CfgIndexInfo cfg:list){
|
||||
maatCfg = new MaatCfg();
|
||||
maatCfg.initDefaultValue();
|
||||
groupRelationList = new ArrayList();
|
||||
ipRegionList = new ArrayList();
|
||||
strRegionList = new ArrayList();
|
||||
numRegionList = new ArrayList();
|
||||
digestRegionList = new ArrayList();
|
||||
areaIpRegionList = new ArrayList();
|
||||
List<IpPortCfg> list1 = new ArrayList();
|
||||
List<BaseStringCfg> list2 = new ArrayList();
|
||||
List<ComplexkeywordCfg> list3 = new ArrayList();
|
||||
List<com.nis.domain.configuration.NumBoundaryCfg> list4 = new ArrayList();
|
||||
List<FileDigestCfg> list5 = new ArrayList();
|
||||
String userRegion = "";
|
||||
//处理自定义域
|
||||
if(userRegionList!=null){
|
||||
for(Map<String,Object> n:userRegionList){
|
||||
Object userRegionPosition = n.get("userRegionPosition");
|
||||
if(userRegionPosition!=null && (userRegionPosition.toString().equals("1")||userRegionPosition.toString().equals("0"))){
|
||||
//通过反射机制获取自定义域字段值
|
||||
String regionColumn = n.get("regionColumn").toString();
|
||||
Class aClass = null;
|
||||
if(userRegionPosition.toString().equals(("0"))){
|
||||
aClass = BaseCfg.class;
|
||||
}else{
|
||||
aClass = CfgIndexInfo.class;
|
||||
}
|
||||
|
||||
Object value = "";
|
||||
if(entity.getServiceId().equals(517)||entity.getServiceId().equals(560)){//代理替换策略
|
||||
String[] regionArray = regionColumn.split(",");
|
||||
for(int r=0;r<regionArray.length;r++){
|
||||
Field field = aClass.getDeclaredField(regionArray[r]);
|
||||
field.setAccessible(true);
|
||||
value += "/"+replaceContentEscape(field.get(cfg)==null?"":field.get(cfg).toString());//自定义域以/分割时的处理
|
||||
}
|
||||
userRegion += n.get("regionKey")+"="+value+Constants.USER_REGION_SPLIT;
|
||||
}else{
|
||||
Field field = aClass.getDeclaredField(regionColumn);
|
||||
field.setAccessible(true);
|
||||
value = field.get(cfg);
|
||||
if(!StringUtil.isEmpty(value)){
|
||||
if(StringUtil.isEmpty(n.get("regionKey"))){
|
||||
userRegion = value.toString();
|
||||
}else{
|
||||
userRegion += n.get("regionKey")+"="+value+Constants.USER_REGION_SPLIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// System.out.println("userRegionList:"+n.get("regionKey")+","+n.get("regionColumn")+","+n.get("handleType"));
|
||||
}
|
||||
if(userRegion.endsWith(Constants.USER_REGION_SPLIT)){
|
||||
userRegion = userRegion.substring(0, userRegion.length()-1);
|
||||
}
|
||||
}
|
||||
for(IpPortCfg ip:ipList){
|
||||
if(ip.getCompileId().equals(cfg.getCompileId())){
|
||||
list1.add(ip);
|
||||
}
|
||||
}
|
||||
for(BaseStringCfg str:strList){
|
||||
if(str.getCompileId().equals(cfg.getCompileId())){
|
||||
list2.add(str);
|
||||
if(entity.getServiceId().equals(513)||entity.getServiceId().equals(515)){
|
||||
if(userRegion.equals("")){
|
||||
userRegion += Constants.USERREGION_DOMAIN_STR+"="+str.getCfgKeywords();
|
||||
}else{
|
||||
userRegion += Constants.USER_REGION_SPLIT+Constants.USERREGION_DOMAIN_STR+"="+str.getCfgKeywords();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(ComplexkeywordCfg str:complexStrList){
|
||||
if(str.getCompileId().equals(cfg.getCompileId())){
|
||||
list3.add(str);
|
||||
if(entity.getServiceId().equals(129) && str.getDistrict()!=null){//http监测
|
||||
String dictValue = DictUtils.getDictCode(Constants.HTTP_HEADER_DICT_MODULE, str.getDistrict());
|
||||
if(StringUtil.isEmpty(dictValue) || dictValue.equals("默认")){
|
||||
if(userRegion.equals("")){
|
||||
userRegion += Constants.HTTP_HEADER_USER_REGION_KEY+"="+str.getDistrict();
|
||||
}else{
|
||||
userRegion += Constants.USER_REGION_SPLIT+Constants.HTTP_HEADER_USER_REGION_KEY+"="+str.getDistrict();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(com.nis.domain.configuration.NumBoundaryCfg num:numList){
|
||||
if(num.getCompileId().equals(cfg.getCompileId())){
|
||||
list4.add(num);
|
||||
}
|
||||
}
|
||||
for(FileDigestCfg file:fileList){
|
||||
if(file.getCompileId().equals(cfg.getCompileId())){
|
||||
list5.add(file);
|
||||
}
|
||||
}
|
||||
if(list1.size()>0){
|
||||
ipList.removeAll(list1);
|
||||
Map<String,List> map = cfgConvert(ipRegionList,list1,1,cfg,groupRelationList);
|
||||
groupRelationList=map.get("groupList");
|
||||
ipRegionList=map.get("dstList");
|
||||
if(map.get("numRegionList")!=null){
|
||||
numRegionList.addAll(map.get("numRegionList"));
|
||||
}
|
||||
}
|
||||
if(list2.size()>0){
|
||||
strList.removeAll(list2);
|
||||
Map<String,List> map = cfgConvert(strRegionList,list2,2,cfg,groupRelationList);
|
||||
groupRelationList=map.get("groupList");
|
||||
strRegionList=map.get("dstList");
|
||||
}
|
||||
if(list3.size()>0){
|
||||
complexStrList.removeAll(list3);
|
||||
Map<String,List> map = cfgConvert(strRegionList,list3,3,cfg,groupRelationList);
|
||||
groupRelationList=map.get("groupList");
|
||||
strRegionList=map.get("dstList");
|
||||
}
|
||||
if(list4.size()>0){
|
||||
numList.removeAll(list4);
|
||||
Map<String,List> map = cfgConvert(numRegionList,list4,4,cfg,groupRelationList);
|
||||
groupRelationList=map.get("groupList");
|
||||
numRegionList=map.get("dstList");
|
||||
}
|
||||
if(list5.size()>0){
|
||||
fileList.removeAll(list5);
|
||||
Map<String,List> map = cfgConvert(digestRegionList,list5,5,cfg,groupRelationList);
|
||||
groupRelationList=map.get("groupList");
|
||||
digestRegionList=map.get("dstList");
|
||||
}
|
||||
|
||||
BeanUtils.copyProperties(cfg, maatCfg);
|
||||
maatCfg.setAction(cfg.getAction());
|
||||
maatCfg.setAuditTime(cfg.getAuditTime());
|
||||
maatCfg.setIpRegionList(ipRegionList);
|
||||
maatCfg.setStrRegionList(strRegionList);
|
||||
maatCfg.setNumRegionList(numRegionList);
|
||||
maatCfg.setDigestRegionList(digestRegionList);
|
||||
maatCfg.setGroupRelationList(groupRelationList);
|
||||
maatCfg.setGroupNum(groupRelationList.size());
|
||||
maatCfg.setAreaIpRegionList(areaIpRegionList);
|
||||
maatCfg.setIsValid(cfg.getIsValid());
|
||||
if(!StringUtil.isEmpty(userRegion)){
|
||||
maatCfg.setUserRegion(userRegion);
|
||||
}
|
||||
configCompileList.add(maatCfg);
|
||||
}
|
||||
page.setList(list);
|
||||
if(page.isLastPage()){
|
||||
hasData = false;
|
||||
}else{
|
||||
page.setPageNo(page.getNext());
|
||||
}
|
||||
if(!StringUtil.isEmpty(configCompileList.size())){
|
||||
maatBean.setConfigCompileList(configCompileList);
|
||||
maatBean.setAuditTime(new Date());
|
||||
maatBean.setCreatorName(UserUtils.getUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.INSERT_ACTION);
|
||||
String json=gsonToJson(maatBean);
|
||||
// System.out.println(json);
|
||||
|
||||
//调用服务接口配置全量更新
|
||||
ToMaatResult result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,(hasData?null:"FINISHED"));
|
||||
}
|
||||
}else{
|
||||
hasData = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理ddos配置
|
||||
* @param serviceId
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws SecurityException
|
||||
* @throws NoSuchFieldException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public void handleDdosMaatData(List<Map<String,Object>>cfgList,List<Map<String,Object>>userRegionList,
|
||||
Page<DdosIpCfg> page,BaseCfg entity,HttpServletRequest request,HttpServletResponse response,
|
||||
boolean isUpdateCfg) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException{
|
||||
|
||||
boolean hasData = true;
|
||||
while(hasData){
|
||||
List<IpPortCfg> ipList = new ArrayList();
|
||||
maatBean = new ToMaatBean();
|
||||
configCompileList = new ArrayList();
|
||||
entity.setPage(page);
|
||||
List<DdosIpCfg> list = configSynchronizationDao.getDdosIpCfgList(entity);
|
||||
if(!StringUtil.isEmpty(list)){
|
||||
for(DdosIpCfg cfg:list){
|
||||
maatCfg = new MaatCfg();
|
||||
maatCfg.initDefaultValue();
|
||||
groupRelationList = new ArrayList();
|
||||
ipRegionList = new ArrayList();
|
||||
strRegionList = new ArrayList();
|
||||
numRegionList = new ArrayList();
|
||||
digestRegionList = new ArrayList();
|
||||
areaIpRegionList = new ArrayList();
|
||||
List<DdosIpCfg> list1 = new ArrayList();
|
||||
String userRegion = "";
|
||||
//处理自定义域
|
||||
if(userRegionList!=null){
|
||||
for(Map<String,Object> n:userRegionList){
|
||||
Object userRegionPosition = n.get("userRegionPosition");
|
||||
if(userRegionPosition!=null && (userRegionPosition.toString().equals("1")||userRegionPosition.toString().equals("0"))){
|
||||
//通过反射机制获取自定义域字段值
|
||||
String regionColumn = n.get("regionColumn").toString();
|
||||
Class aClass = null;
|
||||
if(userRegionPosition.toString().equals(("0"))){
|
||||
aClass = BaseCfg.class;
|
||||
}else{
|
||||
aClass = DdosIpCfg.class;
|
||||
}
|
||||
Object value = "";
|
||||
Field field = aClass.getDeclaredField(regionColumn);
|
||||
field.setAccessible(true);
|
||||
value = field.get(cfg);
|
||||
if(!StringUtil.isEmpty(value)){
|
||||
if(StringUtil.isEmpty(n.get("regionKey"))){
|
||||
userRegion = value.toString();
|
||||
}else{
|
||||
userRegion += n.get("regionKey")+"="+value+Constants.USER_REGION_SPLIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(userRegion.endsWith(Constants.USER_REGION_SPLIT)){
|
||||
userRegion = userRegion.substring(0, userRegion.length()-1);
|
||||
}
|
||||
}
|
||||
list1.add(cfg);
|
||||
if(list1.size()>0){
|
||||
ipList.removeAll(list1);
|
||||
Map<String,List> map = cfgConvert(ipRegionList,list1,1,cfg,groupRelationList);
|
||||
groupRelationList=map.get("groupList");
|
||||
ipRegionList=map.get("dstList");
|
||||
if(map.get("numRegionList")!=null){
|
||||
numRegionList.addAll(map.get("numRegionList"));
|
||||
}
|
||||
}
|
||||
BeanUtils.copyProperties(cfg, maatCfg);
|
||||
maatCfg.setAction(cfg.getAction());
|
||||
maatCfg.setAuditTime(cfg.getAuditTime());
|
||||
maatCfg.setIpRegionList(ipRegionList);
|
||||
maatCfg.setStrRegionList(strRegionList);
|
||||
maatCfg.setNumRegionList(numRegionList);
|
||||
maatCfg.setDigestRegionList(digestRegionList);
|
||||
maatCfg.setGroupRelationList(groupRelationList);
|
||||
maatCfg.setGroupNum(groupRelationList.size());
|
||||
maatCfg.setAreaIpRegionList(areaIpRegionList);
|
||||
maatCfg.setIsValid(cfg.getIsValid());
|
||||
if(!StringUtil.isEmpty(userRegion)){
|
||||
maatCfg.setUserRegion(userRegion);
|
||||
}
|
||||
configCompileList.add(maatCfg);
|
||||
}
|
||||
page.setList(list);
|
||||
if(page.isLastPage()){
|
||||
hasData = false;
|
||||
}else{
|
||||
page.setPageNo(page.getNext());
|
||||
}
|
||||
if(!StringUtil.isEmpty(configCompileList.size())){
|
||||
maatBean.setConfigCompileList(configCompileList);
|
||||
maatBean.setAuditTime(new Date());
|
||||
maatBean.setCreatorName(UserUtils.getUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.INSERT_ACTION);
|
||||
String json=gsonToJson(maatBean);
|
||||
// System.out.println(json);
|
||||
|
||||
//调用服务接口配置全量更新
|
||||
ToMaatResult result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,(hasData?null:"FINISHED"));
|
||||
}
|
||||
}else{
|
||||
hasData = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 处理app业务maat类配置
|
||||
* @param serviceId
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
public void handleAppMaatData(List<Map<String,Object>>cfgList,List<Map<String,Object>>userRegionList,
|
||||
Page<BaseCfg> page,Object entity,HttpServletRequest request,HttpServletResponse response){
|
||||
/*if(entity instanceof AppPolicyCfg){
|
||||
AppPolicyCfg newEntity = entity;
|
||||
entity.setPage(page);
|
||||
}
|
||||
|
||||
boolean hasData = true;
|
||||
while(hasData){
|
||||
List<CfgIndexInfo> list = configSynchronizationDao.getCfgIndexList(entity);
|
||||
page.setList(list);
|
||||
if(page.isLastPage()){
|
||||
hasData = false;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理回调类业务配置
|
||||
* @param serviceId
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public void handleCallbackData(String className,
|
||||
Page<BaseCfg> page,BaseCfg entity,HttpServletRequest request,HttpServletResponse response,
|
||||
boolean isUpdateCfg) throws ClassNotFoundException{
|
||||
|
||||
boolean hasData = true;
|
||||
while(hasData){
|
||||
maatBean = new ToMaatBean();
|
||||
configCompileList = new ArrayList();
|
||||
entity.setPage(page);
|
||||
List list = new ArrayList();
|
||||
List newList = new ArrayList();
|
||||
if(className.equals("AvFileSampleCfg")){
|
||||
list = configSynchronizationDao.getAvFileCfgList(entity);
|
||||
}else if(className.equals("PxyObjKeyring")){
|
||||
list = configSynchronizationDao.getPxyObjKeyringCfgList(entity);
|
||||
for(int i=0;i<list.size();i++){
|
||||
PxyObjKeyring cfg = (PxyObjKeyring) list.get(i);
|
||||
newList.add(convertCallBackProxyObjKeyring(cfg));
|
||||
}
|
||||
}else if(className.equals("PxyObjTrustedCaCert")){
|
||||
list = configSynchronizationDao.getPxyObjTrustedCertCfgList(entity);
|
||||
for(int i=0;i<list.size();i++){
|
||||
PxyObjTrustedCaCert cfg = (PxyObjTrustedCaCert) list.get(i);
|
||||
newList.add(convertCallBackProxyObjTrustedCa(cfg,null));
|
||||
}
|
||||
}else if(className.equals("PxyObjTrustedCaCrl")){
|
||||
list = configSynchronizationDao.getPxyObjTrustedCrlCfgList(entity);
|
||||
for(int i=0;i<list.size();i++){
|
||||
PxyObjTrustedCaCrl cfg = (PxyObjTrustedCaCrl) list.get(i);
|
||||
newList.add(convertCallBackProxyObjTrustedCa(null,cfg));
|
||||
}
|
||||
}else if(className.equals("DnsResStrategy")){
|
||||
list = configSynchronizationDao.getDnsStrategyList(entity);
|
||||
for(int i=0;i<list.size();i++){
|
||||
DnsResStrategy cfg = (DnsResStrategy) list.get(i);
|
||||
newList.add(convertCallBackDnsResStrategy(cfg));
|
||||
}
|
||||
}else if(className.equals("DnsIpCfg")){
|
||||
list = configSynchronizationDao.getDnsIpCfgList(entity);
|
||||
for(int i=0;i<list.size();i++){
|
||||
DnsIpCfg cfg = (DnsIpCfg) list.get(i);
|
||||
newList.add(convertCallBackIp(cfg,cfg.getGroupId()));
|
||||
}
|
||||
}else if(className.equals("IpPortCfg")){
|
||||
list = configSynchronizationDao.getIpPortListByService(entity);
|
||||
for(int i=0;i<list.size();i++){
|
||||
IpPortCfg cfg = (IpPortCfg) list.get(i);
|
||||
newList.add(convertCallBackIp(cfg,cfg.getGroupId()));
|
||||
}
|
||||
}
|
||||
page.setList(list);
|
||||
if(page.isLastPage()){
|
||||
hasData = false;
|
||||
}else{
|
||||
page.setPageNo(page.getNext());
|
||||
}
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(newList);
|
||||
logger.info("回调类配置同步:"+json);
|
||||
//调用服务接口同步回调类配置
|
||||
ToMaatResult result = ConfigServiceUtil.configSync(json,2,entity.getServiceId(),entity.getTableName(),(hasData?null:"FINISHED"));
|
||||
// logger.info("回调类配置同步:"+result.getMsg());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user