You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2019/06/13 02:57:23 UTC
[GitHub] [rocketmq] githublaohu commented on a change in pull request #1217:
[ISSUE #1156]new mqadmin API for ACL configuration
githublaohu commented on a change in pull request #1217: [ISSUE #1156]new mqadmin API for ACL configuration
URL: https://github.com/apache/rocketmq/pull/1217#discussion_r293189045
##########
File path: acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionLoader.java
##########
@@ -89,10 +91,182 @@ public void load() {
}
}
+ //for loading dataversion part just
+ JSONArray dataVersion4Yaml = plainAclConfData.getJSONArray(AclConstants.CONFIG_DATA_VERSION);
+ if (dataVersion4Yaml != null && !dataVersion4Yaml.isEmpty()) {
+ List<DataVersion> dataVersion = dataVersion4Yaml.toJavaList(DataVersion.class);
+ DataVersion firstElement = dataVersion.get(0);
+ this.dataVersion.assignNewOne(firstElement);
+ }
+
this.globalWhiteRemoteAddressStrategy = globalWhiteRemoteAddressStrategy;
this.plainAccessResourceMap = plainAccessResourceMap;
}
+ public String getAclConfigDataVersion() {
+ return this.dataVersion.toJson();
+ }
+
+ private Map<String, Object> updateAclConfigFileVersion(Map<String, Object> updateAclConfigMap) {
+
+ dataVersion.nextVersion();
+ List<Map<String, Object>> versionElement = new ArrayList<Map<String, Object>>();
+ Map<String, Object> accountsMap = new LinkedHashMap<String, Object>() {
+ {
+ put(AclConstants.CONFIG_COUNTER, dataVersion.getCounter().longValue());
+ put(AclConstants.CONFIG_TIME_STAMP, dataVersion.getTimestamp());
+ }
+ };
+ versionElement.add(accountsMap);
+ updateAclConfigMap.put(AclConstants.CONFIG_DATA_VERSION, versionElement);
+ return updateAclConfigMap;
+ }
+
+ public boolean updateAccessConfig(PlainAccessConfig plainAccessConfig) {
+
+ if (plainAccessConfig == null) {
+ log.error("parameter value plainAccessConfig is null,please check your parameter");
+ return false;
+ }
+
+ Map<String, Object> aclAccessConfigMap = AclUtils.getYamlDataObject(fileHome + File.separator + fileName,
+ Map.class);
+
+ List<Map<String, Object>> accounts = (List<Map<String, Object>>) aclAccessConfigMap.get(AclConstants.CONFIG_ACCOUNTS);
+ Map<String, Object> updateAccountMap = null;
+ if (accounts != null) {
+ for (Map<String, Object> account : accounts) {
+ if (account.get(AclConstants.CONFIG_ACCESS_KEY).equals(plainAccessConfig.getAccessKey())) {
+ //update acl access config elements
+ accounts.remove(account);
Review comment:
You don't have to delete it, AclUtils.writeDataObject2Yaml and then load it
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services