(1)白名单审核调整在controller层遍历
(2)jquert validate插件调整 (3)IP白名单show more调整调用样式
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.nis.web.controller.configuration.ntc;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -19,8 +20,13 @@ import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
import com.nis.domain.configuration.HttpUrlCfg;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.maat.ToMaatResult;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.dao.configuration.IpCfgDao;
|
||||
import com.nis.web.dao.configuration.StringCfgDao;
|
||||
|
||||
/**
|
||||
* 白名单
|
||||
@@ -165,7 +171,19 @@ public class WhiteListController extends BaseController{
|
||||
// @RequiresPermissions("whitelist:aduit")
|
||||
public String auditIp(String ids,IpPortCfg cfg,RedirectAttributes redirectAttributes) {
|
||||
try{
|
||||
ipCfgService.auditWhiteIp(ids, cfg);
|
||||
for(String id:ids.split(",")){
|
||||
Long.parseLong(id);
|
||||
}
|
||||
List<BaseIpCfg> beans=ipCfgService.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());
|
||||
ipCfgService.auditWhiteIp(bean);
|
||||
}
|
||||
addMessage(redirectAttributes,"audit_success");
|
||||
}catch(Exception e){
|
||||
logger.error("审核失败", e);
|
||||
@@ -177,7 +195,16 @@ public class WhiteListController extends BaseController{
|
||||
// @RequiresPermissions("whitelist:aduit")
|
||||
public String auditDomain(String ids,HttpUrlCfg cfg,RedirectAttributes redirectAttributes) {
|
||||
try{
|
||||
stringCfgService.auditWhiteDomain(ids, cfg);
|
||||
List<BaseStringCfg> beans=stringCfgService.getListByCfgId(HttpUrlCfg.getTablename(),ids);
|
||||
Date date=new Date();
|
||||
for(BaseStringCfg bean:beans){
|
||||
bean.setTableName(IpPortCfg.getTablename());
|
||||
bean.setAuditorId(bean.getCurrentUser().getId());
|
||||
bean.setAuditTime(date);
|
||||
bean.setIsAudit(cfg.getIsAudit());
|
||||
bean.setIsValid(cfg.getIsValid());
|
||||
stringCfgService.auditWhiteDomain(cfg);
|
||||
}
|
||||
addMessage(redirectAttributes,"audit_success");
|
||||
}catch(Exception e){
|
||||
logger.error("审核失败", e);
|
||||
|
||||
@@ -90,10 +90,42 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
}
|
||||
return ipCfgDao.update(baseIpCfg);
|
||||
}
|
||||
public void auditWhiteIp(String ids,IpPortCfg cfg) throws Exception{
|
||||
for(String id:ids.split(",")){
|
||||
Long.parseLong(id);
|
||||
public void auditWhiteIp(BaseIpCfg cfg) throws Exception{
|
||||
List<BaseIpCfg> beans=new ArrayList<>();
|
||||
beans.add(cfg);
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
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){
|
||||
@@ -105,6 +137,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
}
|
||||
this.auditBatch(beans, IpCfgDao.class);
|
||||
if(cfg.getIsAudit()==1){
|
||||
//待调整
|
||||
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(beans);
|
||||
logger.info("IP白名单下发配置参数:"+json);
|
||||
|
||||
@@ -89,6 +89,38 @@ public class StringCfgService extends CrudService<StringCfgDao,BaseStringCfg> {
|
||||
}
|
||||
return stringCfgDao.update(baseStringCfg);
|
||||
}
|
||||
public void auditWhiteDomain(BaseStringCfg cfg) throws Exception{
|
||||
List<BaseStringCfg> beans=new ArrayList<>();
|
||||
beans.add(cfg);
|
||||
this.auditBatch(beans, StringCfgDao.class);
|
||||
if(cfg.getIsAudit()==1){
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(beans);
|
||||
logger.info("文件样例下发配置参数:"+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());
|
||||
}
|
||||
}
|
||||
}
|
||||
public void auditWhiteDomain(String ids,HttpUrlCfg cfg) throws Exception{
|
||||
for(String id:ids.split(",")){
|
||||
Long.parseLong(id);
|
||||
@@ -241,4 +273,18 @@ public class StringCfgService extends CrudService<StringCfgDao,BaseStringCfg> {
|
||||
// TODO Auto-generated method stub
|
||||
return stringCfgDao.getListByCompileId(tableName,ids);
|
||||
}
|
||||
/**
|
||||
* getListByCfgId(这里用一句话描述这个方法的作用)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param tablename
|
||||
* @param ids
|
||||
* @return
|
||||
*List<BaseStringCfg>
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public List<BaseStringCfg> getListByCfgId(String tableName, String ids) {
|
||||
// TODO Auto-generated method stub
|
||||
return stringCfgDao.getListByCfgId(tableName, ids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ $(function(){
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row hidden protocol">
|
||||
<div class="row hidden destPort">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group ">
|
||||
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="server_ip"/></label>
|
||||
|
||||
@@ -180,7 +180,14 @@ jQuery.validator.addMethod("ipCheck",function(value, element) {
|
||||
if(typeInt==4){
|
||||
if(ipPattern){
|
||||
if(ipPattern==1){//ip/掩码格式
|
||||
return this.optional(element)||(/^(\d+)\.(\d+)\.(\d+)\.(\d+)\/(\d+)$/.test(value) && (RegExp.$1 <256 && RegExp.$2<256 && RegExp.$3<256 && RegExp.$4<256 && RegExp.$5<=32));
|
||||
if(this.optional(element)||(/^(\d+)\.(\d+)\.(\d+)\.(\d+)\/(\d+)$/.test(value) && (RegExp.$1 <256 && RegExp.$2<256 && RegExp.$3<256 && RegExp.$4<256 && RegExp.$5<=32))){
|
||||
return true;
|
||||
}else if(RegExp.$5&&RegExp.$5>32){
|
||||
$.validator.messages.ipCheck=$.validator.messages.ipMaskRange;
|
||||
return false;
|
||||
}else{
|
||||
$.validator.messages.ipCheck=$.validator.messages.ipMask;
|
||||
}
|
||||
}else if(ipPattern==2){//ip range
|
||||
//A类 0.0.0.0-127.255.255.255 默认掩码255.0.0.0
|
||||
//B类128.0.0.0-191.255.255.255 默认掩码255.255.0.0
|
||||
@@ -193,14 +200,18 @@ jQuery.validator.addMethod("ipCheck",function(value, element) {
|
||||
||(startPart0>223&&startPart1>223&&startPart0<240&&startPart1<240)
|
||||
||(startPart0>239&&startPart1>239&&startPart0<256&&startPart1<256)){
|
||||
}else{
|
||||
$.validator.messages.ipCheck=$.validator.messages.ipRange;
|
||||
return false;
|
||||
}
|
||||
var startIp=value.split("-")[0];
|
||||
var endIp=value.split("-")[1];
|
||||
if(ipToNumber(startIp)<=ipToNumber(endIp)){//比较IP大小
|
||||
return true;
|
||||
}else{
|
||||
$.validator.messages.ipCheck=$.validator.messages.ipRange1;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
@@ -256,17 +267,26 @@ jQuery.validator.addMethod("ipMask",function(value, element) {
|
||||
}, "请填写正确的IP地址掩码");
|
||||
jQuery.validator.addMethod("portCheck",function(value, element) {
|
||||
if(value.length==0||value.trim().length==0){return true;}
|
||||
obj=value;
|
||||
var typeInt=$(element).parents(".row").siblings().find("select[name$='portPattern']").val();
|
||||
if(!typeInt){
|
||||
typeInt=$(element).parents(".row").find("select[name$='portPattern']").val();
|
||||
}
|
||||
if(typeInt==1){//port 0~65535
|
||||
return this.optional(element)||(/^([0-9]+)$/.test(value) && (RegExp.$1 <=65535 && RegExp.$1 >=0));
|
||||
if(this.optional(element)||(/^([0-9]+)$/.test(value) && (RegExp.$1 <=65535 && RegExp.$1 >=0))){
|
||||
return true;
|
||||
}else{
|
||||
$.validator.messages.portCheck=$.validator.messages.portRange
|
||||
return false;
|
||||
}
|
||||
}else if(typeInt==2){// port -mask 0~65535/0~65535
|
||||
return this.optional(element)||(/^([0-9]+)\/([0-9]+)$/.test(value) && (RegExp.$1 <=65535 && RegExp.$2 <=65535));
|
||||
if(this.optional(element)||(/^([0-9]+)\/([0-9]+)$/.test(value) && (RegExp.$1 <=65535 && RegExp.$2 <=65535))){
|
||||
return true;
|
||||
}else{
|
||||
$.validator.messages.portCheck=$.validator.messages.portMaskRange
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}, "请填写正确的端口");
|
||||
});
|
||||
//ip v4转数字
|
||||
var ipToNumber=function (ip){
|
||||
var num =0;
|
||||
|
||||
@@ -23,8 +23,13 @@
|
||||
min: $.validator.format("Please enter a value greater than or equal to {0}."),
|
||||
noBlankSpace:"can not be space",
|
||||
ipCheck:"Please enter a correct IP address",
|
||||
ipMask:"Please enter a correct IP mask",
|
||||
ipMask:"Please enter a correct IP/mask",
|
||||
ipMaskRange:"IP mask must between 0 and 32",
|
||||
ipRange:"Wrong IP format or start IP and end IP in two subnet",
|
||||
ipRange1:"start IP should smaller than end IP",
|
||||
portCheck:"Please enter a correct port",
|
||||
notStartZero:"Please enter a valid Integer"
|
||||
notStartZero:"Please enter a valid Integer",
|
||||
portRange:"Port must between 0 and 65535",
|
||||
portMaskRange:"Port and mask must between 0 and 65535.The right pattern is \"port/mask\"."
|
||||
});
|
||||
}(jQuery));
|
||||
|
||||
@@ -24,8 +24,13 @@
|
||||
min: $.validator.format("请输入一个最小为 {0} 的值"),
|
||||
noBlankSpace:"不能为空格",
|
||||
ipCheck:"请填写正确的IP地址",
|
||||
ipMask:"请填写正确的IP地址掩码",
|
||||
ipMask:"请填写正确的IP地址/掩码",
|
||||
portCheck:"请填写正确的端口",
|
||||
notStartZero:"请填写正确的数值"
|
||||
notStartZero:"请填写正确的数值",
|
||||
ipMaskRange:"掩码范围0到32",
|
||||
ipRange:"IP范围格式错误或者起始IP与结束IP不在同一网段",
|
||||
ipRange1:"起始IP值应小于结束IP值",
|
||||
portRange:"端口范围0 到 65535",
|
||||
portMaskRange:"端口和掩码均为0-65535,格式为\"端口/掩码\""
|
||||
});
|
||||
}(jQuery));
|
||||
|
||||
Reference in New Issue
Block a user