diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 952ad7398a9269ff84e9571faba8e3411ae72c05..b7b133472c46a8b00b57230e9f21735667086b99 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -10,7 +10,7 @@ Nor is code the only way to contribute to the project. We strongly value documen
To submit a change for inclusion, please do the following:
#### If the change is non-trivial please include some unit tests that cover the new functionality.
-#### If you are introducing a completely new feature or API it is a good idea to start a [RIP](https://github.com/apache/rocketmq/wiki/RocketMQ-Improvement-Proposal) and get consensus on the basic design first.
+#### If you are introducing a completely new feature or API it is a good idea to start a wiki and get consensus on the basic design first.
#### It is our job to follow up on patches in a timely fashion. Nag us if we aren't doing our job (sometimes we drop things).
## Becoming a Committer
@@ -19,8 +19,9 @@ We are always interested in adding new contributors. What we look for are series
Nowadays,we have several important contribution points:
#### Wiki & JavaDoc
+#### RocketMQ Console
#### RocketMQ SDK(C++\.Net\Php\Python\Go\Node.js)
-#### RocketMQ Connectors
+#### RocketMQ MySQL(Oracle\PostgreSQL\Redis\MongoDB\HBase\MSSQL) Replicator
##### Prerequisite
If you want to contribute the above listing points, you must abide our some prerequisites:
diff --git a/README.md b/README.md
index 1c17c7e242f044a513e7f399e175a13cf5a73721..98d97a00ffd2badb69c1f7130144c2e942fc08e2 100644
--- a/README.md
+++ b/README.md
@@ -51,23 +51,3 @@ We always welcome new contributions, whether for trivial cleanups, [big new feat
[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) Copyright (C) Apache Software Foundation
-----------
-## Export Control Notice
-This distribution includes cryptographic software. The country in which you currently reside may have
-restrictions on the import, possession, use, and/or re-export to another country, of encryption software.
-BEFORE using any encryption software, please check your country's laws, regulations and policies concerning
-the import, possession, or use, and re-export of encryption software, to see if this is permitted. See
- for more information.
-
-The U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has classified this
-software as Export Commodity Control Number (ECCN) 5D002.C.1, which includes information security software
-using or performing cryptographic functions with asymmetric algorithms. The form and manner of this Apache
-Software Foundation distribution makes it eligible for export under the License Exception ENC Technology
-Software Unrestricted (TSU) exception (see the BIS Export Administration Regulations, Section 740.13) for
-both object code and source code.
-
-The following provides more details on the included cryptographic software:
-
-This software uses Apache Commons Crypto (https://commons.apache.org/proper/commons-crypto/) to
-support authentication, and encryption and decryption of data sent across the network between
-services.
diff --git a/acl/pom.xml b/acl/pom.xml
index ec5ab0493fb588101213d8105a632f5db49bd0e6..923acfe6227a7c566917a801b1c74b99198e04fd 100644
--- a/acl/pom.xml
+++ b/acl/pom.xml
@@ -13,7 +13,7 @@
org.apache.rocketmq
rocketmq-all
- 4.6.0-SNAPSHOT
+ 4.5.2-SNAPSHOT
rocketmq-acl
rocketmq-acl ${project.version}
@@ -67,10 +67,6 @@
logback-core
test
-
- commons-validator
- commons-validator
-
diff --git a/acl/src/main/java/org/apache/rocketmq/acl/common/AclUtils.java b/acl/src/main/java/org/apache/rocketmq/acl/common/AclUtils.java
index 8973320237c684c68864c29ff0c4a90d75bfdd3e..20e1cfa26b90916aecfec39e2669179c85854e20 100644
--- a/acl/src/main/java/org/apache/rocketmq/acl/common/AclUtils.java
+++ b/acl/src/main/java/org/apache/rocketmq/acl/common/AclUtils.java
@@ -23,7 +23,6 @@ import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
-import java.util.ArrayList;
import java.util.Map;
import java.util.SortedMap;
import org.apache.commons.lang3.StringUtils;
@@ -70,75 +69,24 @@ public class AclUtils {
return signature;
}
- public static void IPv6AddressCheck(String netaddress) {
- if (isAsterisk(netaddress) || isMinus(netaddress)) {
- int asterisk = netaddress.indexOf("*");
- int minus = netaddress.indexOf("-");
-// '*' must be the end of netaddress if it exists
- if (asterisk > -1 && asterisk != netaddress.length() - 1) {
- throw new AclException(String.format("Netaddress examine scope Exception netaddress is %s", netaddress));
- }
-
-// format like "2::ac5:78:1-200:*" or "2::ac5:78:1-200" is legal
- if (minus > -1) {
- if (asterisk == -1) {
- if (minus <= netaddress.lastIndexOf(":")) {
- throw new AclException(String.format("Netaddress examine scope Exception netaddress is %s", netaddress));
- }
- } else {
- if (minus <= netaddress.lastIndexOf(":", netaddress.lastIndexOf(":") - 1)) {
- throw new AclException(String.format("Netaddress examine scope Exception netaddress is %s", netaddress));
- }
- }
- }
- }
- }
-
- public static String v6ipProcess(String netaddress, String[] strArray, int index) {
- int part;
- String subAddress;
- boolean isAsterisk = isAsterisk(netaddress);
- boolean isMinus = isMinus(netaddress);
- if (isAsterisk && isMinus) {
- part = 6;
- int lastColon = netaddress.lastIndexOf(':');
- int secondLastColon = netaddress.substring(0, lastColon).lastIndexOf(':');
- subAddress = netaddress.substring(0, secondLastColon);
- } else if (!isAsterisk && !isMinus) {
- part = 8;
- subAddress = netaddress;
- } else {
- part = 7;
- subAddress = netaddress.substring(0, netaddress.lastIndexOf(':'));
- }
- return expandIP(subAddress, part);
- }
-
public static void verify(String netaddress, int index) {
if (!AclUtils.isScope(netaddress, index)) {
throw new AclException(String.format("Netaddress examine scope Exception netaddress is %s", netaddress));
}
}
- public static String[] getAddreeStrArray(String netaddress, String partialAddress) {
- String[] parAddStrArray = StringUtils.split(partialAddress.substring(1, partialAddress.length() - 1), ",");
+ public static String[] getAddreeStrArray(String netaddress, String four) {
+ String[] fourStrArray = StringUtils.split(four.substring(1, four.length() - 1), ",");
String address = netaddress.substring(0, netaddress.indexOf("{"));
- String[] addreeStrArray = new String[parAddStrArray.length];
- for (int i = 0; i < parAddStrArray.length; i++) {
- addreeStrArray[i] = address + parAddStrArray[i];
+ String[] addreeStrArray = new String[fourStrArray.length];
+ for (int i = 0; i < fourStrArray.length; i++) {
+ addreeStrArray[i] = address + fourStrArray[i];
}
return addreeStrArray;
}
- public static boolean isScope(String netaddress, int index) {
-// IPv6 Address
- if (isColon(netaddress)) {
- netaddress = expandIP(netaddress, 8);
- String[] strArray = StringUtils.split(netaddress, ":");
- return isIPv6Scope(strArray, index);
- }
-
- String[] strArray = StringUtils.split(netaddress, ".");
+ public static boolean isScope(String num, int index) {
+ String[] strArray = StringUtils.split(num, ".");
if (strArray.length != 4) {
return false;
}
@@ -159,10 +107,6 @@ public class AclUtils {
}
- public static boolean isColon(String netaddress) {
- return netaddress.indexOf(':') > -1;
- }
-
public static boolean isScope(String num) {
return isScope(Integer.valueOf(num.trim()));
}
@@ -175,7 +119,7 @@ public class AclUtils {
return asterisk.indexOf('*') > -1;
}
- public static boolean isComma(String colon) {
+ public static boolean isColon(String colon) {
return colon.indexOf(',') > -1;
}
@@ -184,88 +128,6 @@ public class AclUtils {
}
- public static boolean isIPv6Scope(String[] num, int index) {
- for (int i = 0; i < index; i++) {
- int value;
- try {
- value = Integer.parseInt(num[i], 16);
- } catch (NumberFormatException e) {
- return false;
- }
- if (!isIPv6Scope(value)) {
- return false;
- }
- }
- return true;
- }
-
- public static boolean isIPv6Scope(int num) {
- int min = Integer.parseInt("0", 16);
- int max = Integer.parseInt("ffff", 16);
- return num >= min && num <= max;
- }
-
- public static String expandIP(String netaddress, int part) {
- boolean compress = false;
- int compressIndex = -1;
- String[] strArray = StringUtils.split(netaddress, ":");
- ArrayList indexes = new ArrayList<>();
- for (int i = 0; i < netaddress.length(); i++) {
- if (netaddress.charAt(i) == ':') {
- if (indexes.size() > 0 && i - indexes.get(indexes.size() - 1) == 1) {
- compressIndex = i;
- compress = true;
- }
- indexes.add(i);
- }
- }
-
- for (int i = 0; i < strArray.length; i++) {
- if (strArray[i].length() < 4) {
- strArray[i] = "0000".substring(0, 4 - strArray[i].length()) + strArray[i];
- }
- }
-
- StringBuilder sb = new StringBuilder();
- if (compress) {
- int pos = indexes.indexOf(compressIndex);
- int index = 0;
- if (!netaddress.startsWith(":")) {
- for (int i = 0; i < pos; i++) {
- sb.append(strArray[index]).append(":");
- index += 1;
- }
- }
- int zeroNum = part - strArray.length;
- if (netaddress.endsWith(":")) {
- for (int i = 0; i < zeroNum; i++) {
- sb.append("0000");
- if (i != zeroNum - 1) {
- sb.append(":");
- }
- }
- } else {
- for (int i = 0; i < zeroNum; i++) {
- sb.append("0000").append(":");
- }
- for (int i = index; i < strArray.length; i++) {
- sb.append(strArray[i]);
- if (i != strArray.length - 1) {
- sb.append(":");
- }
- }
- }
- } else {
- for (int i = 0; i < strArray.length; i++) {
- sb.append(strArray[i]);
- if (i != strArray.length - 1) {
- sb.append(":");
- }
- }
- }
- return sb.toString().toUpperCase();
- }
-
public static T getYamlDataObject(String path, Class clazz) {
Yaml yaml = new Yaml();
FileInputStream fis = null;
@@ -286,7 +148,7 @@ public class AclUtils {
}
}
- public static boolean writeDataObject(String path, Map dataMap) {
+ public static boolean writeDataObject(String path, Map dataMap) {
Yaml yaml = new Yaml();
PrintWriter pw = null;
try {
@@ -310,15 +172,15 @@ public class AclUtils {
yamlDataObject = AclUtils.getYamlDataObject(fileName,
JSONObject.class);
} catch (Exception e) {
- log.error("Convert yaml file to data object error, ", e);
+ log.error("Convert yaml file to data object error, ",e);
return null;
}
if (yamlDataObject == null || yamlDataObject.isEmpty()) {
- log.warn("Cannot find conf file :{}, acl isn't be enabled.", fileName);
+ log.warn("Cannot find conf file :{}, acl isn't be enabled." ,fileName);
return null;
}
-
+
String accessKey = yamlDataObject.getString(AclConstants.CONFIG_ACCESS_KEY);
String secretKey = yamlDataObject.getString(AclConstants.CONFIG_SECRET_KEY);
@@ -327,7 +189,7 @@ public class AclUtils {
return null;
}
- return new AclClientRPCHook(new SessionCredentials(accessKey, secretKey));
+ return new AclClientRPCHook(new SessionCredentials(accessKey,secretKey));
}
}
diff --git a/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainAccessValidator.java b/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainAccessValidator.java
index 0d7ddb3053b5b3a408eec2d5893cbd112b4214ae..c8ce23908484c1f56c9576c6ee97c7b907227539 100644
--- a/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainAccessValidator.java
+++ b/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainAccessValidator.java
@@ -50,7 +50,7 @@ public class PlainAccessValidator implements AccessValidator {
public AccessResource parse(RemotingCommand request, String remoteAddr) {
PlainAccessResource accessResource = new PlainAccessResource();
if (remoteAddr != null && remoteAddr.contains(":")) {
- accessResource.setWhiteRemoteAddress(remoteAddr.substring(0, remoteAddr.lastIndexOf(':')));
+ accessResource.setWhiteRemoteAddress(remoteAddr.split(":")[0]);
} else {
accessResource.setWhiteRemoteAddress(remoteAddr);
}
diff --git a/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java b/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java
index 6931eb7c426aa3511769f5e9fa8a4abc6c260bb3..cc2dcee77f9b71d5a516b2eb68a10b2744d6364e 100644
--- a/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java
+++ b/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java
@@ -19,7 +19,6 @@ package org.apache.rocketmq.acl.plain;
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.validator.routines.InetAddressValidator;
import org.apache.rocketmq.acl.common.AclException;
import org.apache.rocketmq.acl.common.AclUtils;
import org.apache.rocketmq.common.constant.LoggerName;
@@ -42,26 +41,17 @@ public class RemoteAddressStrategyFactory {
if (StringUtils.isBlank(remoteAddr)) {
return BLANK_NET_ADDRESS_STRATEGY;
}
- if ("*".equals(remoteAddr) || "*.*.*.*".equals(remoteAddr) || "*:*:*:*:*:*:*:*".equals(remoteAddr)) {
+ if ("*".equals(remoteAddr) || "*.*.*.*".equals(remoteAddr)) {
return NULL_NET_ADDRESS_STRATEGY;
}
if (remoteAddr.endsWith("}")) {
- if (AclUtils.isColon(remoteAddr)) {
- String[] strArray = StringUtils.split(remoteAddr, ":");
- String last = strArray[strArray.length - 1];
- if (!last.startsWith("{")) {
- throw new AclException(String.format("MultipleRemoteAddressStrategy netaddress examine scope Exception netaddress", remoteAddr));
- }
- return new MultipleRemoteAddressStrategy(AclUtils.getAddreeStrArray(remoteAddr, last));
- } else {
- String[] strArray = StringUtils.split(remoteAddr, ".");
- String four = strArray[3];
- if (!four.startsWith("{")) {
- throw new AclException(String.format("MultipleRemoteAddressStrategy netaddress examine scope Exception netaddress", remoteAddr));
- }
- return new MultipleRemoteAddressStrategy(AclUtils.getAddreeStrArray(remoteAddr, four));
+ String[] strArray = StringUtils.split(remoteAddr, ".");
+ String four = strArray[3];
+ if (!four.startsWith("{")) {
+ throw new AclException(String.format("MultipleRemoteAddressStrategy netaddress examine scope Exception netaddress", remoteAddr));
}
- } else if (AclUtils.isComma(remoteAddr)) {
+ return new MultipleRemoteAddressStrategy(AclUtils.getAddreeStrArray(remoteAddr, four));
+ } else if (AclUtils.isColon(remoteAddr)) {
return new MultipleRemoteAddressStrategy(StringUtils.split(remoteAddr, ","));
} else if (AclUtils.isAsterisk(remoteAddr) || AclUtils.isMinus(remoteAddr)) {
return new RangeRemoteAddressStrategy(remoteAddr);
@@ -91,26 +81,15 @@ public class RemoteAddressStrategyFactory {
private final Set multipleSet = new HashSet<>();
public MultipleRemoteAddressStrategy(String[] strArray) {
- InetAddressValidator validator = InetAddressValidator.getInstance();
for (String netaddress : strArray) {
- if (validator.isValidInet4Address(netaddress)) {
- multipleSet.add(netaddress);
- } else if (validator.isValidInet6Address(netaddress)) {
- multipleSet.add(AclUtils.expandIP(netaddress, 8));
- } else {
- throw new AclException(String.format("Netaddress examine Exception netaddress is %s", netaddress));
- }
+ AclUtils.verify(netaddress, 4);
+ multipleSet.add(netaddress);
}
}
@Override
public boolean match(PlainAccessResource plainAccessResource) {
- InetAddressValidator validator = InetAddressValidator.getInstance();
- String whiteRemoteAddress = plainAccessResource.getWhiteRemoteAddress();
- if (validator.isValidInet6Address(whiteRemoteAddress)) {
- whiteRemoteAddress = AclUtils.expandIP(whiteRemoteAddress, 8);
- }
- return multipleSet.contains(whiteRemoteAddress);
+ return multipleSet.contains(plainAccessResource.getWhiteRemoteAddress());
}
}
@@ -121,16 +100,12 @@ public class RemoteAddressStrategyFactory {
public OneRemoteAddressStrategy(String netaddress) {
this.netaddress = netaddress;
- InetAddressValidator validator = InetAddressValidator.getInstance();
- if (!(validator.isValidInet4Address(netaddress) || validator.isValidInet6Address(netaddress))) {
- throw new AclException(String.format("Netaddress examine Exception netaddress is %s", netaddress));
- }
+ AclUtils.verify(netaddress, 4);
}
@Override
public boolean match(PlainAccessResource plainAccessResource) {
- String writeRemoteAddress = AclUtils.expandIP(plainAccessResource.getWhiteRemoteAddress(), 8).toUpperCase();
- return AclUtils.expandIP(netaddress, 8).toUpperCase().equals(writeRemoteAddress);
+ return netaddress.equals(plainAccessResource.getWhiteRemoteAddress());
}
}
@@ -146,29 +121,14 @@ public class RemoteAddressStrategyFactory {
private int index;
public RangeRemoteAddressStrategy(String remoteAddr) {
-// IPv6 Address
- if (AclUtils.isColon(remoteAddr)) {
- AclUtils.IPv6AddressCheck(remoteAddr);
- String[] strArray = StringUtils.split(remoteAddr, ":");
- for (int i = 1; i < strArray.length; i++) {
- if (ipv6Analysis(strArray, i)) {
- AclUtils.verify(remoteAddr, index - 1);
- String preAddress = AclUtils.v6ipProcess(remoteAddr, strArray, index);
- this.index = StringUtils.split(preAddress, ":").length;
- this.head = preAddress;
- break;
- }
- }
- } else {
- String[] strArray = StringUtils.split(remoteAddr, ".");
- if (analysis(strArray, 1) || analysis(strArray, 2) || analysis(strArray, 3)) {
- AclUtils.verify(remoteAddr, index - 1);
- StringBuffer sb = new StringBuffer();
- for (int j = 0; j < index; j++) {
- sb.append(strArray[j].trim()).append(".");
- }
- this.head = sb.toString();
+ String[] strArray = StringUtils.split(remoteAddr, ".");
+ if (analysis(strArray, 1) || analysis(strArray, 2) || analysis(strArray, 3)) {
+ AclUtils.verify(remoteAddr, index - 1);
+ StringBuffer sb = new StringBuffer().append(strArray[0].trim()).append(".").append(strArray[1].trim()).append(".");
+ if (index == 3) {
+ sb.append(strArray[2].trim()).append(".");
}
+ this.head = sb.toString();
}
}
@@ -192,27 +152,6 @@ public class RemoteAddressStrategyFactory {
return this.end > 0 ? true : false;
}
- private boolean ipv6Analysis(String[] strArray, int index) {
- String value = strArray[index].trim();
- this.index = index;
- if ("*".equals(value)) {
- int min = Integer.parseInt("0", 16);
- int max = Integer.parseInt("ffff", 16);
- setValue(min, max);
- } else if (AclUtils.isMinus(value)) {
- if (value.indexOf("-") == 0) {
- throw new AclException(String.format("RangeRemoteAddressStrategy netaddress examine scope Exception value %s ", value));
- }
- String[] valueArray = StringUtils.split(value, "-");
- this.start = Integer.parseInt(valueArray[0], 16);
- this.end = Integer.parseInt(valueArray[1], 16);
- if (!(AclUtils.isIPv6Scope(end) && AclUtils.isIPv6Scope(start) && start <= end)) {
- throw new AclException(String.format("RangeRemoteAddressStrategy netaddress examine scope Exception start is %s , end is %s", start, end));
- }
- }
- return this.end > 0 ? true : false;
- }
-
private void setValue(int start, int end) {
this.start = start;
this.end = end;
@@ -221,33 +160,21 @@ public class RemoteAddressStrategyFactory {
@Override
public boolean match(PlainAccessResource plainAccessResource) {
String netAddress = plainAccessResource.getWhiteRemoteAddress();
- InetAddressValidator validator = InetAddressValidator.getInstance();
- if (validator.isValidInet4Address(netAddress)) {
- if (netAddress.startsWith(this.head)) {
- String value;
- if (index == 3) {
- value = netAddress.substring(this.head.length());
- } else if (index == 2) {
- value = netAddress.substring(this.head.length(), netAddress.lastIndexOf('.'));
- } else {
- value = netAddress.substring(this.head.length(), netAddress.lastIndexOf('.', netAddress.lastIndexOf('.') - 1));
- }
- Integer address = Integer.valueOf(value);
- if (address >= this.start && address <= this.end) {
- return true;
- }
+ if (netAddress.startsWith(this.head)) {
+ String value;
+ if (index == 3) {
+ value = netAddress.substring(this.head.length());
+ } else {
+ value = netAddress.substring(this.head.length(), netAddress.lastIndexOf('.'));
}
- } else if (validator.isValidInet6Address(netAddress)) {
- netAddress = AclUtils.expandIP(netAddress, 8).toUpperCase();
- if (netAddress.startsWith(this.head)) {
- String value = netAddress.substring(5 * index, 5 * index + 4);
- Integer address = Integer.parseInt(value, 16);
- if (address >= this.start && address <= this.end) {
- return true;
- }
+ Integer address = Integer.valueOf(value);
+ if (address >= this.start && address <= this.end) {
+ return true;
}
}
return false;
}
+
}
+
}
diff --git a/acl/src/test/java/org/apache/rocketmq/acl/common/AclUtilsTest.java b/acl/src/test/java/org/apache/rocketmq/acl/common/AclUtilsTest.java
index 5705b745a0e7472ca7a215468ae20775a53babfb..5b2627de85dc66f13f1868b7b0c5e014aba3117f 100644
--- a/acl/src/test/java/org/apache/rocketmq/acl/common/AclUtilsTest.java
+++ b/acl/src/test/java/org/apache/rocketmq/acl/common/AclUtilsTest.java
@@ -46,35 +46,20 @@ public class AclUtilsTest {
addressList.add("1.1.1.3");
addressList.add("1.1.1.4");
Assert.assertEquals(newAddressList, addressList);
-
-// IPv6 test
- String ipv6Address = "1:ac41:9987::bb22:666:{1,2,3,4}";
- String[] ipv6AddressArray = AclUtils.getAddreeStrArray(ipv6Address, "{1,2,3,4}");
- List newIPv6AddressList = new ArrayList<>();
- for (String a : ipv6AddressArray) {
- newIPv6AddressList.add(a);
- }
-
- List ipv6AddressList = new ArrayList<>();
- ipv6AddressList.add("1:ac41:9987::bb22:666:1");
- ipv6AddressList.add("1:ac41:9987::bb22:666:2");
- ipv6AddressList.add("1:ac41:9987::bb22:666:3");
- ipv6AddressList.add("1:ac41:9987::bb22:666:4");
- Assert.assertEquals(newIPv6AddressList, ipv6AddressList);
}
@Test
public void isScopeStringArray() {
- String address = "12";
+ String adderss = "12";
for (int i = 0; i < 6; i++) {
- boolean isScope = AclUtils.isScope(address, 4);
+ boolean isScope = AclUtils.isScope(adderss, 4);
if (i == 3) {
Assert.assertTrue(isScope);
} else {
Assert.assertFalse(isScope);
}
- address = address + ".12";
+ adderss = adderss + ".12";
}
}
@@ -92,25 +77,6 @@ public class AclUtilsTest {
isScope = AclUtils.isScope(adderss, 3);
Assert.assertFalse(isScope);
-// IPv6 test
- adderss = StringUtils.split("1050:0000:0000:0000:0005:0600:300c:326b", ":");
- isScope = AclUtils.isIPv6Scope(adderss, 8);
- Assert.assertTrue(isScope);
- isScope = AclUtils.isIPv6Scope(adderss, 4);
- Assert.assertTrue(isScope);
-
- adderss = StringUtils.split("1050:9876:0000:0000:0005:akkg:300c:326b", ":");
- isScope = AclUtils.isIPv6Scope(adderss, 8);
- Assert.assertFalse(isScope);
- isScope = AclUtils.isIPv6Scope(adderss, 4);
- Assert.assertTrue(isScope);
-
- adderss = StringUtils.split(AclUtils.expandIP("1050::0005:akkg:300c:326b", 8), ":");
- isScope = AclUtils.isIPv6Scope(adderss, 8);
- Assert.assertFalse(isScope);
- isScope = AclUtils.isIPv6Scope(adderss, 4);
- Assert.assertTrue(isScope);
-
}
@Test
@@ -136,18 +102,6 @@ public class AclUtilsTest {
isScope = AclUtils.isScope(256);
Assert.assertFalse(isScope);
- // IPv6 test
- int min = Integer.parseInt("0", 16);
- int max = Integer.parseInt("ffff", 16);
- for (int i = min; i < max + 1; i++) {
- isScope = AclUtils.isIPv6Scope(i);
- Assert.assertTrue(isScope);
- }
- isScope = AclUtils.isIPv6Scope(-1);
- Assert.assertFalse(isScope);
- isScope = AclUtils.isIPv6Scope(max + 1);
- Assert.assertFalse(isScope);
-
}
@Test
@@ -161,10 +115,10 @@ public class AclUtilsTest {
@Test
public void isColonTest() {
- boolean isColon = AclUtils.isComma(",");
+ boolean isColon = AclUtils.isColon(",");
Assert.assertTrue(isColon);
- isColon = AclUtils.isComma("-");
+ isColon = AclUtils.isColon("-");
Assert.assertFalse(isColon);
}
@@ -177,36 +131,6 @@ public class AclUtilsTest {
Assert.assertFalse(isMinus);
}
- @Test
- public void v6ipProcessTest() {
- String remoteAddr = "5::7:6:1-200:*";
- String[] strArray = StringUtils.split(remoteAddr, ":");
- Assert.assertEquals(AclUtils.v6ipProcess(remoteAddr, strArray, 3), "0005:0000:0000:0000:0007:0006");
-
- remoteAddr = "5::7:6:1-200";
- strArray = StringUtils.split(remoteAddr, ":");
- Assert.assertEquals(AclUtils.v6ipProcess(remoteAddr, strArray, 3), "0005:0000:0000:0000:0000:0007:0006");
-
- remoteAddr = "5::7:6:*";
- strArray = StringUtils.split(remoteAddr, ":");
- Assert.assertEquals(AclUtils.v6ipProcess(remoteAddr, strArray, 3), "0005:0000:0000:0000:0000:0007:0006");
-
- remoteAddr = "5:7:6:*";
- strArray = StringUtils.split(remoteAddr, ":");
- Assert.assertEquals(AclUtils.v6ipProcess(remoteAddr, strArray, 3), "0005:0007:0006");
- }
-
- @Test
- public void expandIPTest() {
- Assert.assertEquals(AclUtils.expandIP("::1", 8), "0000:0000:0000:0000:0000:0000:0000:0001");
- Assert.assertEquals(AclUtils.expandIP("3::", 8), "0003:0000:0000:0000:0000:0000:0000:0000");
- Assert.assertEquals(AclUtils.expandIP("2::2", 8), "0002:0000:0000:0000:0000:0000:0000:0002");
- Assert.assertEquals(AclUtils.expandIP("4::aac4:92", 8), "0004:0000:0000:0000:0000:0000:AAC4:0092");
- Assert.assertEquals(AclUtils.expandIP("ab23:56:901a::cc6:765:bb:9011", 8), "AB23:0056:901A:0000:0CC6:0765:00BB:9011");
- Assert.assertEquals(AclUtils.expandIP("ab23:56:901a:1:cc6:765:bb:9011", 8), "AB23:0056:901A:0001:0CC6:0765:00BB:9011");
- Assert.assertEquals(AclUtils.expandIP("5::7:6", 6), "0005:0000:0000:0000:0007:0006");
- }
-
@SuppressWarnings("unchecked")
@Test
public void getYamlDataObjectTest() {
@@ -216,7 +140,7 @@ public class AclUtilsTest {
}
@Test
- public void writeDataObject2YamlFileTest() throws IOException {
+ public void writeDataObject2YamlFileTest() throws IOException{
String targetFileName = "src/test/resources/conf/plain_write_acl.yml";
File transport = new File(targetFileName);
@@ -229,7 +153,7 @@ public class AclUtilsTest {
List globalWhiteRemoteAddrs = new ArrayList();
globalWhiteRemoteAddrs.add("10.10.103.*");
globalWhiteRemoteAddrs.add("192.168.0.*");
- aclYamlMap.put("globalWhiteRemoteAddrs", globalWhiteRemoteAddrs);
+ aclYamlMap.put("globalWhiteRemoteAddrs",globalWhiteRemoteAddrs);
// For accounts element in acl yaml config file
List