InterceptCfgService增加
This commit is contained in:
@@ -54,6 +54,7 @@ import com.nis.util.DictUtils;
|
||||
import com.nis.util.JsonMapper;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.excel.ExportExcel;
|
||||
import com.nis.web.dao.configuration.InterceptCfgDao;
|
||||
import com.nis.web.service.ArchiveServcie;
|
||||
import com.nis.web.service.AreaService;
|
||||
import com.nis.web.service.DictService;
|
||||
@@ -78,10 +79,12 @@ import com.nis.web.service.configuration.DnsResStrategyService;
|
||||
import com.nis.web.service.configuration.DomainService;
|
||||
import com.nis.web.service.configuration.FileTransferCfgService;
|
||||
import com.nis.web.service.configuration.HttpRedirectCfgService;
|
||||
import com.nis.web.service.configuration.InterceptCfgService;
|
||||
import com.nis.web.service.configuration.IpCfgService;
|
||||
import com.nis.web.service.configuration.IpMultiplexPoolCfgService;
|
||||
import com.nis.web.service.configuration.MailCfgService;
|
||||
import com.nis.web.service.configuration.NumCfgService;
|
||||
import com.nis.web.service.configuration.ProxyFileStrategyService;
|
||||
import com.nis.web.service.configuration.RequestInfoService;
|
||||
import com.nis.web.service.configuration.WebsiteCfgService;
|
||||
import com.nis.web.service.configuration.XmppCfgService;
|
||||
@@ -182,6 +185,11 @@ public class BaseController {
|
||||
protected IpMultiplexPoolCfgService ipMultiplexPoolCfgService;
|
||||
@Autowired
|
||||
protected ConfigureStatisticsService configureStatisticsService;
|
||||
@Autowired
|
||||
protected InterceptCfgService interceptCfgService;
|
||||
@Autowired
|
||||
protected ProxyFileStrategyService proxyFileStrategyService;//代理文件策略service
|
||||
|
||||
/**
|
||||
* 管理基础路径
|
||||
*/
|
||||
@@ -724,14 +732,12 @@ public class BaseController {
|
||||
StringBuffer errInfo=new StringBuffer();
|
||||
// ip_type check start
|
||||
Integer ipType=value.getIpType();
|
||||
String ipTypeString=null;
|
||||
if(ipType==null){
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ip_type"))+";");
|
||||
}else{
|
||||
boolean has=false;
|
||||
for(SysDataDictionaryItem ipTypeItem:ipTypeList){
|
||||
if(ipType==Integer.parseInt(ipTypeItem.getItemCode())){
|
||||
ipTypeString=ipTypeItem.getItemValue();
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
@@ -743,14 +749,12 @@ public class BaseController {
|
||||
// ip_type check end
|
||||
// ip_pattern check start
|
||||
Integer ipPattern=value.getIpPattern();
|
||||
String ipPatternString=null;
|
||||
if(ipPattern==null){
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ip_pattern"))+";");
|
||||
}else{
|
||||
boolean has=false;
|
||||
for(SysDataDictionaryItem ipPatternItem:ipPatternList){
|
||||
if(ipPattern==Integer.parseInt(ipPatternItem.getItemCode())){
|
||||
ipPatternString=ipPatternItem.getItemValue();
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
@@ -764,9 +768,9 @@ public class BaseController {
|
||||
String srcIp=value.getSrcIpAddress();
|
||||
String _msg="";
|
||||
if("ipmulitiplex".equals(specialItem)) {
|
||||
_msg=checkIP(prop,prop.getProperty("IP"),srcIp,ipTypeString,ipPatternString);
|
||||
_msg=checkIP(prop,prop.getProperty("IP"),srcIp,ipType,ipPattern);
|
||||
}else {
|
||||
_msg=checkIP(prop,prop.getProperty("client_ip"),srcIp,ipTypeString,ipPatternString);
|
||||
_msg=checkIP(prop,prop.getProperty("client_ip"),srcIp,ipType,ipPattern);
|
||||
}
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
@@ -776,40 +780,40 @@ public class BaseController {
|
||||
String destIp=value.getDestIpAddress();
|
||||
if("ipmulitiplex".equals(specialItem)) {//set 默认值
|
||||
if(ipPattern!=null&&ipType!=null) {
|
||||
if("ip_subnet".equals(ipPatternString)) {
|
||||
if("ipv4".equals(ipTypeString)) {
|
||||
if(1==ipPattern.intValue()) {
|
||||
if(4==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if("ipv6".equals(ipTypeString)) {
|
||||
}else if(6==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if("4over6".equals(ipTypeString)) {
|
||||
}else if(46==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if("6over4".equals(ipTypeString)) {
|
||||
}else if(64==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if("all".equals(ipTypeString)) {
|
||||
}else if(10==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||
}
|
||||
}else if("ip_range".equals(ipPatternString)) {
|
||||
if("ipv4".equals(ipTypeString)) {
|
||||
}else if(2==ipPattern.intValue()) {
|
||||
if(4==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if("ipv6".equals(ipTypeString)) {
|
||||
}else if(6==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if("4over6".equals(ipTypeString)) {
|
||||
}else if(46==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if("6over4".equals(ipTypeString)) {
|
||||
}else if(64==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if("all".equals(ipTypeString)) {
|
||||
}else if(10==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||
}
|
||||
}else if("ip".equals(ipPatternString)) {
|
||||
if("ipv4".equals(ipTypeString)) {
|
||||
}else if(3==ipPattern.intValue()) {
|
||||
if(4==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||
}else if("ipv6".equals(ipTypeString)) {
|
||||
}else if(6==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
||||
}else if("4over6".equals(ipTypeString)) {
|
||||
}else if(46==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
||||
}else if("6over4".equals(ipTypeString)) {
|
||||
}else if(64==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||
}else if("all".equals(ipTypeString)) {
|
||||
}else if(10==ipType.intValue()) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||
}
|
||||
}
|
||||
@@ -819,13 +823,13 @@ public class BaseController {
|
||||
String info=String.format(prop.getProperty("are_the_same"),prop.getProperty("client_ip"),prop.getProperty("server_ip"));
|
||||
errInfo.append(info+";");
|
||||
}
|
||||
_msg=checkIP(prop,prop.getProperty("server_ip"),destIp,ipTypeString,ipPatternString);
|
||||
_msg=checkIP(prop,prop.getProperty("server_ip"),destIp,ipType,ipPattern);
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
}
|
||||
if(!"ipmulitiplex".equals(specialItem)&&("4over6".equals(ipTypeString)||"6over4".equals(ipTypeString)||"all".equals(ipTypeString))) {
|
||||
_msg=checkIp(prop, prop.getProperty("client_ip"), srcIp, prop.getProperty("server_ip"), destIp, ipTypeString, ipPatternString);
|
||||
if(!"ipmulitiplex".equals(specialItem)&&(46==ipType.intValue()||64==ipType.intValue()||10==ipType.intValue())) {
|
||||
_msg=checkIp(prop, prop.getProperty("client_ip"), srcIp, prop.getProperty("server_ip"), destIp, ipType, ipPattern);
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
@@ -833,14 +837,12 @@ public class BaseController {
|
||||
//server_ip check end
|
||||
//port_pattern check start
|
||||
Integer portPattern=value.getPortPattern();
|
||||
String portPatternString=null;
|
||||
if(portPattern==null){
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("port_pattern"))+";");
|
||||
}else{
|
||||
boolean has=false;
|
||||
for(SysDataDictionaryItem portPatternItem:portPatternList){
|
||||
if(portPattern==Integer.parseInt(portPatternItem.getItemCode())){
|
||||
portPatternString=portPatternItem.getItemValue();
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
@@ -853,9 +855,9 @@ public class BaseController {
|
||||
//src_port check start
|
||||
String srcPort=value.getSrcPort();
|
||||
if("ipmulitiplex".equals(specialItem)) {
|
||||
_msg=checkPort(prop,prop.getProperty("port"), srcPort, portPatternString);
|
||||
_msg=checkPort(prop,prop.getProperty("port"), srcPort, portPattern);
|
||||
}else {
|
||||
_msg=checkPort(prop,prop.getProperty("client_port"), srcPort, portPatternString);
|
||||
_msg=checkPort(prop,prop.getProperty("client_port"), srcPort, portPattern);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
@@ -866,14 +868,14 @@ public class BaseController {
|
||||
String destPort=value.getDestPort();
|
||||
if("ipmulitiplex".equals(specialItem)) {//set 默认值
|
||||
if(portPattern!=null) {
|
||||
if("port_mask".equals(portPatternString)) {
|
||||
if(2==portPattern.intValue()) {
|
||||
value.setDestPort(Constants.PORT_MASK_DEFAULT);
|
||||
}else if("port".equals(portPatternString)) {
|
||||
}else if(1==portPattern.intValue()) {
|
||||
value.setDestPort(Constants.PORT_DEFAULT);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
_msg=checkPort(prop,prop.getProperty("server_port"), destPort, portPatternString);
|
||||
_msg=checkPort(prop,prop.getProperty("server_port"), destPort, portPattern);
|
||||
}
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
@@ -1144,10 +1146,72 @@ public class BaseController {
|
||||
}
|
||||
return msg.toString();
|
||||
}
|
||||
public static String checkIp(Properties prop,String srcIpName,String srcIp,String destIpName,String destIp,String ipType,String ipPattern) {
|
||||
/**
|
||||
*
|
||||
* checkIP(IP格式验证)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param ipName
|
||||
* @param ip
|
||||
* @param ipType
|
||||
* @param ipPattern
|
||||
* @return
|
||||
*String
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static String checkIP(Properties prop,String ipName,String ip,Integer ipType,Integer ipPattern){
|
||||
StringBuffer msg=new StringBuffer();
|
||||
if("4over6".equals(ipType)){
|
||||
if("ip_subnet".equals(ipPattern)){
|
||||
if(StringUtils.isBlank(ip)){
|
||||
msg.append(String.format(prop.getProperty("can_not_null"), ipName)+";");
|
||||
}else{
|
||||
if(4==ipType.intValue()){
|
||||
if(1==ipPattern.intValue()){
|
||||
Pattern pattern=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
|
||||
Matcher matcher=pattern.matcher(ip);
|
||||
if(!matcher.matches()){//完全匹配
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
|
||||
}
|
||||
}else if(2==ipPattern.intValue()){
|
||||
Pattern pattern=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
|
||||
Matcher matcher=pattern.matcher(ip);
|
||||
if(!matcher.matches()){//完全匹配
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
|
||||
}
|
||||
}else if(3==ipPattern.intValue()){
|
||||
Pattern pattern=Pattern.compile(Constants.IPV4_IP_REGEXP);
|
||||
Matcher matcher=pattern.matcher(ip);
|
||||
if(!matcher.matches()){//完全匹配
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
|
||||
}
|
||||
}
|
||||
}else if(6==ipType.intValue()){
|
||||
if(1==ipPattern.intValue()){
|
||||
Pattern pattern=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
||||
Matcher matcher=pattern.matcher(ip);
|
||||
if(!matcher.matches()){//完全匹配
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
|
||||
}
|
||||
}else if(2==ipPattern.intValue()){
|
||||
Pattern pattern=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
|
||||
Matcher matcher=pattern.matcher(ip);
|
||||
if(!matcher.matches()){//完全匹配
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
|
||||
}
|
||||
}else if(3==ipPattern.intValue()){
|
||||
Pattern pattern=Pattern.compile(Constants.IPV6_IP_REGEXP);
|
||||
Matcher matcher=pattern.matcher(ip);
|
||||
if(!matcher.matches()){//完全匹配
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName)+";");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return msg.toString();
|
||||
}
|
||||
public static String checkIp(Properties prop,String srcIpName,String srcIp,String destIpName,String destIp,Integer ipType,Integer ipPattern) {
|
||||
StringBuffer msg=new StringBuffer();
|
||||
if(46==ipType.intValue()){
|
||||
if(1==ipPattern.intValue()){
|
||||
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
|
||||
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
||||
Matcher matcherV4=patternV4.matcher(srcIp);
|
||||
@@ -1158,7 +1222,7 @@ public class BaseController {
|
||||
if(!matcherV6.matches()){//完全匹配
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
||||
}
|
||||
}else if("ip_range".equals(ipPattern)){
|
||||
}else if(2==ipPattern.intValue()){
|
||||
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
|
||||
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
|
||||
Matcher matcherV4=patternV4.matcher(srcIp);
|
||||
@@ -1169,7 +1233,7 @@ public class BaseController {
|
||||
if(!matcherV6.matches()){//完全匹配
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
||||
}
|
||||
}else if("ip".equals(ipPattern)){
|
||||
}else if(3==ipPattern.intValue()){
|
||||
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
|
||||
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP);
|
||||
Matcher matcherV4=patternV4.matcher(srcIp);
|
||||
@@ -1181,8 +1245,8 @@ public class BaseController {
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
||||
}
|
||||
}
|
||||
}else if("6over4".equals(ipType)) {
|
||||
if("ip_subnet".equals(ipPattern)){
|
||||
}else if(64==ipType.intValue()) {
|
||||
if(1==ipPattern.intValue()){
|
||||
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
|
||||
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
||||
Matcher matcherV4=patternV4.matcher(destIp);
|
||||
@@ -1193,7 +1257,7 @@ public class BaseController {
|
||||
if(!matcherV6.matches()){//完全匹配
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
||||
}
|
||||
}else if("ip_range".equals(ipPattern)){
|
||||
}else if(2==ipPattern.intValue()){
|
||||
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
|
||||
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
|
||||
Matcher matcherV4=patternV4.matcher(destIp);
|
||||
@@ -1204,7 +1268,7 @@ public class BaseController {
|
||||
if(!matcherV6.matches()){//完全匹配
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName )+";");
|
||||
}
|
||||
}else if("ip".equals(ipPattern)){
|
||||
}else if(3==ipPattern.intValue()){
|
||||
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
|
||||
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP);
|
||||
Matcher matcherV4=patternV4.matcher(destIp);
|
||||
@@ -1216,8 +1280,8 @@ public class BaseController {
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
||||
}
|
||||
}
|
||||
}else if("all".equals(ipType)) {
|
||||
if("ip_subnet".equals(ipPattern)){
|
||||
}else if(10==ipType.intValue()) {
|
||||
if(1==ipPattern.intValue()){
|
||||
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
|
||||
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
||||
Matcher matcherSrcIpV4=patternV4.matcher(srcIp);
|
||||
@@ -1230,7 +1294,7 @@ public class BaseController {
|
||||
if(!matcherDestIpV4.matches()&&!matcherDestIpV6.matches()){//完全匹配
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
||||
}
|
||||
}else if("ip_range".equals(ipPattern)){
|
||||
}else if(2==ipPattern.intValue()){
|
||||
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
|
||||
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
|
||||
Matcher matcherSrcIpV4=patternV4.matcher(srcIp);
|
||||
@@ -1243,7 +1307,7 @@ public class BaseController {
|
||||
if(!matcherDestIpV4.matches()&&!matcherDestIpV6.matches()){//完全匹配
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
||||
}
|
||||
}else if("ip".equals(ipPattern)){
|
||||
}else if(3==ipPattern.intValue()){
|
||||
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
|
||||
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP);
|
||||
Matcher matcherSrcIpV4=patternV4.matcher(srcIp);
|
||||
@@ -1260,12 +1324,12 @@ public class BaseController {
|
||||
}
|
||||
return msg.toString();
|
||||
}
|
||||
public static String checkPort(Properties prop,String portName,String port,String portPattern){
|
||||
public static String checkPort(Properties prop,String portName,String port,Integer portPattern){
|
||||
StringBuffer msg=new StringBuffer();
|
||||
if(StringUtils.isBlank(port)){
|
||||
msg.append(String.format(prop.getProperty("can_not_null"), portName)+";");
|
||||
}else{
|
||||
if("port".equals(portPattern)){
|
||||
if(1==portPattern.intValue()){
|
||||
try{
|
||||
Integer portInt=Integer.parseInt(port);
|
||||
if(portInt<0||portInt>65535){
|
||||
@@ -1275,7 +1339,7 @@ public class BaseController {
|
||||
// TODO: handle exception
|
||||
msg.append(String.format(prop.getProperty("not_number"), portName)+";");
|
||||
}
|
||||
}else if("port_mask".equals(portPattern)){
|
||||
}else if(2==portPattern.intValue()){
|
||||
if(port.indexOf("/")==-1){
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), portName)+";");
|
||||
}else{
|
||||
|
||||
Reference in New Issue
Block a user