@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"); }
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); }
AclUtils { 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); } }
AclUtils { 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); }  }
AclUtils { 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); }  static byte[] combineRequestContent(RemotingCommand request, SortedMap<String, String> fieldsMap); static byte[] combineBytes(byte[] b1, byte[] b2); static String calSignature(byte[] data, String secretKey); static void IPv6AddressCheck(String netaddress); static String v6ipProcess(String netaddress, String[] strArray, int index); static void verify(String netaddress, int index); static String[] getAddreeStrArray(String netaddress, String partialAddress); static boolean isScope(String netaddress, int index); static boolean isScope(String[] num, int index); static boolean isColon(String netaddress); static boolean isScope(String num); static boolean isScope(int num); static boolean isAsterisk(String asterisk); static boolean isComma(String colon); static boolean isMinus(String minus); static boolean isIPv6Scope(String[] num, int index); static boolean isIPv6Scope(int num); static String expandIP(String netaddress, int part); static T getYamlDataObject(String path, Class<T> clazz); static boolean writeDataObject(String path, Map<String, Object> dataMap); static RPCHook getAclRPCHook(String fileName); }
AclUtils { 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); }  static byte[] combineRequestContent(RemotingCommand request, SortedMap<String, String> fieldsMap); static byte[] combineBytes(byte[] b1, byte[] b2); static String calSignature(byte[] data, String secretKey); static void IPv6AddressCheck(String netaddress); static String v6ipProcess(String netaddress, String[] strArray, int index); static void verify(String netaddress, int index); static String[] getAddreeStrArray(String netaddress, String partialAddress); static boolean isScope(String netaddress, int index); static boolean isScope(String[] num, int index); static boolean isColon(String netaddress); static boolean isScope(String num); static boolean isScope(int num); static boolean isAsterisk(String asterisk); static boolean isComma(String colon); static boolean isMinus(String minus); static boolean isIPv6Scope(String[] num, int index); static boolean isIPv6Scope(int num); static String expandIP(String netaddress, int part); static T getYamlDataObject(String path, Class<T> clazz); static boolean writeDataObject(String path, Map<String, Object> dataMap); static RPCHook getAclRPCHook(String fileName);  }