@Test public void getAclRPCHookTest() { RPCHook errorContRPCHook = AclUtils.getAclRPCHook("src/test/resources/conf/plain_acl_format_error.yml"); Assert.assertNull(errorContRPCHook); RPCHook noFileRPCHook = AclUtils.getAclRPCHook("src/test/resources/plain_acl_format_error1.yml"); Assert.assertNull(noFileRPCHook); RPCHook emptyContRPCHook = AclUtils.getAclRPCHook("src/test/resources/conf/plain_acl_null.yml"); Assert.assertNull(emptyContRPCHook); RPCHook incompleteContRPCHook = AclUtils.getAclRPCHook("src/test/resources/conf/plain_acl_incomplete.yml"); Assert.assertNull(incompleteContRPCHook); }
public static RPCHook getAclRPCHook(String fileName) { JSONObject yamlDataObject = null; try { yamlDataObject = AclUtils.getYamlDataObject(fileName, JSONObject.class); } catch (Exception 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); return null; } String accessKey = yamlDataObject.getString(AclConstants.CONFIG_ACCESS_KEY); String secretKey = yamlDataObject.getString(AclConstants.CONFIG_SECRET_KEY); if (StringUtils.isBlank(accessKey) || StringUtils.isBlank(secretKey)) { log.warn("AccessKey or secretKey is blank, the acl is not enabled."); return null; } return new AclClientRPCHook(new SessionCredentials(accessKey, secretKey)); }
AclUtils { public static RPCHook getAclRPCHook(String fileName) { JSONObject yamlDataObject = null; try { yamlDataObject = AclUtils.getYamlDataObject(fileName, JSONObject.class); } catch (Exception 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); return null; } String accessKey = yamlDataObject.getString(AclConstants.CONFIG_ACCESS_KEY); String secretKey = yamlDataObject.getString(AclConstants.CONFIG_SECRET_KEY); if (StringUtils.isBlank(accessKey) || StringUtils.isBlank(secretKey)) { log.warn("AccessKey or secretKey is blank, the acl is not enabled."); return null; } return new AclClientRPCHook(new SessionCredentials(accessKey, secretKey)); } }
AclUtils { public static RPCHook getAclRPCHook(String fileName) { JSONObject yamlDataObject = null; try { yamlDataObject = AclUtils.getYamlDataObject(fileName, JSONObject.class); } catch (Exception 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); return null; } String accessKey = yamlDataObject.getString(AclConstants.CONFIG_ACCESS_KEY); String secretKey = yamlDataObject.getString(AclConstants.CONFIG_SECRET_KEY); if (StringUtils.isBlank(accessKey) || StringUtils.isBlank(secretKey)) { log.warn("AccessKey or secretKey is blank, the acl is not enabled."); return null; } return new AclClientRPCHook(new SessionCredentials(accessKey, secretKey)); }  }
AclUtils { public static RPCHook getAclRPCHook(String fileName) { JSONObject yamlDataObject = null; try { yamlDataObject = AclUtils.getYamlDataObject(fileName, JSONObject.class); } catch (Exception 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); return null; } String accessKey = yamlDataObject.getString(AclConstants.CONFIG_ACCESS_KEY); String secretKey = yamlDataObject.getString(AclConstants.CONFIG_SECRET_KEY); if (StringUtils.isBlank(accessKey) || StringUtils.isBlank(secretKey)) { log.warn("AccessKey or secretKey is blank, the acl is not enabled."); return null; } return new AclClientRPCHook(new SessionCredentials(accessKey, secretKey)); }  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 RPCHook getAclRPCHook(String fileName) { JSONObject yamlDataObject = null; try { yamlDataObject = AclUtils.getYamlDataObject(fileName, JSONObject.class); } catch (Exception 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); return null; } String accessKey = yamlDataObject.getString(AclConstants.CONFIG_ACCESS_KEY); String secretKey = yamlDataObject.getString(AclConstants.CONFIG_SECRET_KEY); if (StringUtils.isBlank(accessKey) || StringUtils.isBlank(secretKey)) { log.warn("AccessKey or secretKey is blank, the acl is not enabled."); return null; } return new AclClientRPCHook(new SessionCredentials(accessKey, secretKey)); }  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);  }