IP导入改为数字验证
This commit is contained in:
@@ -724,14 +724,12 @@ public class BaseController {
|
|||||||
StringBuffer errInfo=new StringBuffer();
|
StringBuffer errInfo=new StringBuffer();
|
||||||
// ip_type check start
|
// ip_type check start
|
||||||
Integer ipType=value.getIpType();
|
Integer ipType=value.getIpType();
|
||||||
String ipTypeString=null;
|
|
||||||
if(ipType==null){
|
if(ipType==null){
|
||||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ip_type"))+";");
|
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ip_type"))+";");
|
||||||
}else{
|
}else{
|
||||||
boolean has=false;
|
boolean has=false;
|
||||||
for(SysDataDictionaryItem ipTypeItem:ipTypeList){
|
for(SysDataDictionaryItem ipTypeItem:ipTypeList){
|
||||||
if(ipType==Integer.parseInt(ipTypeItem.getItemCode())){
|
if(ipType==Integer.parseInt(ipTypeItem.getItemCode())){
|
||||||
ipTypeString=ipTypeItem.getItemValue();
|
|
||||||
has=true;
|
has=true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -743,14 +741,12 @@ public class BaseController {
|
|||||||
// ip_type check end
|
// ip_type check end
|
||||||
// ip_pattern check start
|
// ip_pattern check start
|
||||||
Integer ipPattern=value.getIpPattern();
|
Integer ipPattern=value.getIpPattern();
|
||||||
String ipPatternString=null;
|
|
||||||
if(ipPattern==null){
|
if(ipPattern==null){
|
||||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ip_pattern"))+";");
|
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ip_pattern"))+";");
|
||||||
}else{
|
}else{
|
||||||
boolean has=false;
|
boolean has=false;
|
||||||
for(SysDataDictionaryItem ipPatternItem:ipPatternList){
|
for(SysDataDictionaryItem ipPatternItem:ipPatternList){
|
||||||
if(ipPattern==Integer.parseInt(ipPatternItem.getItemCode())){
|
if(ipPattern==Integer.parseInt(ipPatternItem.getItemCode())){
|
||||||
ipPatternString=ipPatternItem.getItemValue();
|
|
||||||
has=true;
|
has=true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -764,9 +760,9 @@ public class BaseController {
|
|||||||
String srcIp=value.getSrcIpAddress();
|
String srcIp=value.getSrcIpAddress();
|
||||||
String _msg="";
|
String _msg="";
|
||||||
if("ipmulitiplex".equals(specialItem)) {
|
if("ipmulitiplex".equals(specialItem)) {
|
||||||
_msg=checkIP(prop,prop.getProperty("IP"),srcIp,ipTypeString,ipPatternString);
|
_msg=checkIP(prop,prop.getProperty("IP"),srcIp,ipType,ipPattern);
|
||||||
}else {
|
}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)){
|
if(StringUtils.isNotBlank(_msg)){
|
||||||
errInfo.append(_msg);
|
errInfo.append(_msg);
|
||||||
@@ -776,40 +772,40 @@ public class BaseController {
|
|||||||
String destIp=value.getDestIpAddress();
|
String destIp=value.getDestIpAddress();
|
||||||
if("ipmulitiplex".equals(specialItem)) {//set 默认值
|
if("ipmulitiplex".equals(specialItem)) {//set 默认值
|
||||||
if(ipPattern!=null&&ipType!=null) {
|
if(ipPattern!=null&&ipType!=null) {
|
||||||
if("ip_subnet".equals(ipPatternString)) {
|
if(1==ipPattern.intValue()) {
|
||||||
if("ipv4".equals(ipTypeString)) {
|
if(4==ipType.intValue()) {
|
||||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
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);
|
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);
|
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);
|
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);
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||||
}
|
}
|
||||||
}else if("ip_range".equals(ipPatternString)) {
|
}else if(2==ipPattern.intValue()) {
|
||||||
if("ipv4".equals(ipTypeString)) {
|
if(4==ipType.intValue()) {
|
||||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
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);
|
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);
|
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);
|
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);
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||||
}
|
}
|
||||||
}else if("ip".equals(ipPatternString)) {
|
}else if(3==ipPattern.intValue()) {
|
||||||
if("ipv4".equals(ipTypeString)) {
|
if(4==ipType.intValue()) {
|
||||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||||
}else if("ipv6".equals(ipTypeString)) {
|
}else if(6==ipType.intValue()) {
|
||||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
||||||
}else if("4over6".equals(ipTypeString)) {
|
}else if(46==ipType.intValue()) {
|
||||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
||||||
}else if("6over4".equals(ipTypeString)) {
|
}else if(64==ipType.intValue()) {
|
||||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||||
}else if("all".equals(ipTypeString)) {
|
}else if(10==ipType.intValue()) {
|
||||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -819,13 +815,13 @@ public class BaseController {
|
|||||||
String info=String.format(prop.getProperty("are_the_same"),prop.getProperty("client_ip"),prop.getProperty("server_ip"));
|
String info=String.format(prop.getProperty("are_the_same"),prop.getProperty("client_ip"),prop.getProperty("server_ip"));
|
||||||
errInfo.append(info+";");
|
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)){
|
if(StringUtils.isNotBlank(_msg)){
|
||||||
errInfo.append(_msg);
|
errInfo.append(_msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!"ipmulitiplex".equals(specialItem)&&("4over6".equals(ipTypeString)||"6over4".equals(ipTypeString)||"all".equals(ipTypeString))) {
|
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, ipTypeString, ipPatternString);
|
_msg=checkIp(prop, prop.getProperty("client_ip"), srcIp, prop.getProperty("server_ip"), destIp, ipType, ipPattern);
|
||||||
if(StringUtils.isNotBlank(_msg)){
|
if(StringUtils.isNotBlank(_msg)){
|
||||||
errInfo.append(_msg);
|
errInfo.append(_msg);
|
||||||
}
|
}
|
||||||
@@ -833,14 +829,12 @@ public class BaseController {
|
|||||||
//server_ip check end
|
//server_ip check end
|
||||||
//port_pattern check start
|
//port_pattern check start
|
||||||
Integer portPattern=value.getPortPattern();
|
Integer portPattern=value.getPortPattern();
|
||||||
String portPatternString=null;
|
|
||||||
if(portPattern==null){
|
if(portPattern==null){
|
||||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("port_pattern"))+";");
|
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("port_pattern"))+";");
|
||||||
}else{
|
}else{
|
||||||
boolean has=false;
|
boolean has=false;
|
||||||
for(SysDataDictionaryItem portPatternItem:portPatternList){
|
for(SysDataDictionaryItem portPatternItem:portPatternList){
|
||||||
if(portPattern==Integer.parseInt(portPatternItem.getItemCode())){
|
if(portPattern==Integer.parseInt(portPatternItem.getItemCode())){
|
||||||
portPatternString=portPatternItem.getItemValue();
|
|
||||||
has=true;
|
has=true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -853,9 +847,9 @@ public class BaseController {
|
|||||||
//src_port check start
|
//src_port check start
|
||||||
String srcPort=value.getSrcPort();
|
String srcPort=value.getSrcPort();
|
||||||
if("ipmulitiplex".equals(specialItem)) {
|
if("ipmulitiplex".equals(specialItem)) {
|
||||||
_msg=checkPort(prop,prop.getProperty("port"), srcPort, portPatternString);
|
_msg=checkPort(prop,prop.getProperty("port"), srcPort, portPattern);
|
||||||
}else {
|
}else {
|
||||||
_msg=checkPort(prop,prop.getProperty("client_port"), srcPort, portPatternString);
|
_msg=checkPort(prop,prop.getProperty("client_port"), srcPort, portPattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StringUtils.isNotBlank(_msg)){
|
if(StringUtils.isNotBlank(_msg)){
|
||||||
@@ -866,14 +860,14 @@ public class BaseController {
|
|||||||
String destPort=value.getDestPort();
|
String destPort=value.getDestPort();
|
||||||
if("ipmulitiplex".equals(specialItem)) {//set 默认值
|
if("ipmulitiplex".equals(specialItem)) {//set 默认值
|
||||||
if(portPattern!=null) {
|
if(portPattern!=null) {
|
||||||
if("port_mask".equals(portPatternString)) {
|
if(2==portPattern.intValue()) {
|
||||||
value.setDestPort(Constants.PORT_MASK_DEFAULT);
|
value.setDestPort(Constants.PORT_MASK_DEFAULT);
|
||||||
}else if("port".equals(portPatternString)) {
|
}else if(1==portPattern.intValue()) {
|
||||||
value.setDestPort(Constants.PORT_DEFAULT);
|
value.setDestPort(Constants.PORT_DEFAULT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
_msg=checkPort(prop,prop.getProperty("server_port"), destPort, portPatternString);
|
_msg=checkPort(prop,prop.getProperty("server_port"), destPort, portPattern);
|
||||||
}
|
}
|
||||||
if(StringUtils.isNotBlank(_msg)){
|
if(StringUtils.isNotBlank(_msg)){
|
||||||
errInfo.append(_msg);
|
errInfo.append(_msg);
|
||||||
@@ -1144,10 +1138,72 @@ public class BaseController {
|
|||||||
}
|
}
|
||||||
return msg.toString();
|
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();
|
StringBuffer msg=new StringBuffer();
|
||||||
if("4over6".equals(ipType)){
|
if(StringUtils.isBlank(ip)){
|
||||||
if("ip_subnet".equals(ipPattern)){
|
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 patternV4=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
|
||||||
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
||||||
Matcher matcherV4=patternV4.matcher(srcIp);
|
Matcher matcherV4=patternV4.matcher(srcIp);
|
||||||
@@ -1158,7 +1214,7 @@ public class BaseController {
|
|||||||
if(!matcherV6.matches()){//完全匹配
|
if(!matcherV6.matches()){//完全匹配
|
||||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
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 patternV4=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
|
||||||
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
|
||||||
Matcher matcherV4=patternV4.matcher(srcIp);
|
Matcher matcherV4=patternV4.matcher(srcIp);
|
||||||
@@ -1169,7 +1225,7 @@ public class BaseController {
|
|||||||
if(!matcherV6.matches()){//完全匹配
|
if(!matcherV6.matches()){//完全匹配
|
||||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
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 patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
|
||||||
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP);
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP);
|
||||||
Matcher matcherV4=patternV4.matcher(srcIp);
|
Matcher matcherV4=patternV4.matcher(srcIp);
|
||||||
@@ -1181,8 +1237,8 @@ public class BaseController {
|
|||||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if("6over4".equals(ipType)) {
|
}else if(64==ipType.intValue()) {
|
||||||
if("ip_subnet".equals(ipPattern)){
|
if(1==ipPattern.intValue()){
|
||||||
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
|
||||||
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
||||||
Matcher matcherV4=patternV4.matcher(destIp);
|
Matcher matcherV4=patternV4.matcher(destIp);
|
||||||
@@ -1193,7 +1249,7 @@ public class BaseController {
|
|||||||
if(!matcherV6.matches()){//完全匹配
|
if(!matcherV6.matches()){//完全匹配
|
||||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
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 patternV4=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
|
||||||
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
|
||||||
Matcher matcherV4=patternV4.matcher(destIp);
|
Matcher matcherV4=patternV4.matcher(destIp);
|
||||||
@@ -1204,7 +1260,7 @@ public class BaseController {
|
|||||||
if(!matcherV6.matches()){//完全匹配
|
if(!matcherV6.matches()){//完全匹配
|
||||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName )+";");
|
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 patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
|
||||||
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP);
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP);
|
||||||
Matcher matcherV4=patternV4.matcher(destIp);
|
Matcher matcherV4=patternV4.matcher(destIp);
|
||||||
@@ -1216,8 +1272,8 @@ public class BaseController {
|
|||||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if("all".equals(ipType)) {
|
}else if(10==ipType.intValue()) {
|
||||||
if("ip_subnet".equals(ipPattern)){
|
if(1==ipPattern.intValue()){
|
||||||
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
|
||||||
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
||||||
Matcher matcherSrcIpV4=patternV4.matcher(srcIp);
|
Matcher matcherSrcIpV4=patternV4.matcher(srcIp);
|
||||||
@@ -1230,7 +1286,7 @@ public class BaseController {
|
|||||||
if(!matcherDestIpV4.matches()&&!matcherDestIpV6.matches()){//完全匹配
|
if(!matcherDestIpV4.matches()&&!matcherDestIpV6.matches()){//完全匹配
|
||||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
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 patternV4=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
|
||||||
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
|
||||||
Matcher matcherSrcIpV4=patternV4.matcher(srcIp);
|
Matcher matcherSrcIpV4=patternV4.matcher(srcIp);
|
||||||
@@ -1243,7 +1299,7 @@ public class BaseController {
|
|||||||
if(!matcherDestIpV4.matches()&&!matcherDestIpV6.matches()){//完全匹配
|
if(!matcherDestIpV4.matches()&&!matcherDestIpV6.matches()){//完全匹配
|
||||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
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 patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
|
||||||
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP);
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP);
|
||||||
Matcher matcherSrcIpV4=patternV4.matcher(srcIp);
|
Matcher matcherSrcIpV4=patternV4.matcher(srcIp);
|
||||||
@@ -1260,12 +1316,12 @@ public class BaseController {
|
|||||||
}
|
}
|
||||||
return msg.toString();
|
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();
|
StringBuffer msg=new StringBuffer();
|
||||||
if(StringUtils.isBlank(port)){
|
if(StringUtils.isBlank(port)){
|
||||||
msg.append(String.format(prop.getProperty("can_not_null"), portName)+";");
|
msg.append(String.format(prop.getProperty("can_not_null"), portName)+";");
|
||||||
}else{
|
}else{
|
||||||
if("port".equals(portPattern)){
|
if(1==portPattern.intValue()){
|
||||||
try{
|
try{
|
||||||
Integer portInt=Integer.parseInt(port);
|
Integer portInt=Integer.parseInt(port);
|
||||||
if(portInt<0||portInt>65535){
|
if(portInt<0||portInt>65535){
|
||||||
@@ -1275,7 +1331,7 @@ public class BaseController {
|
|||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
msg.append(String.format(prop.getProperty("not_number"), portName)+";");
|
msg.append(String.format(prop.getProperty("not_number"), portName)+";");
|
||||||
}
|
}
|
||||||
}else if("port_mask".equals(portPattern)){
|
}else if(2==portPattern.intValue()){
|
||||||
if(port.indexOf("/")==-1){
|
if(port.indexOf("/")==-1){
|
||||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), portName)+";");
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), portName)+";");
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
Reference in New Issue
Block a user