mirror of
https://github.com/apache/rocketmq.git
synced 2026-09-24 16:04:00 +08:00
Treat multiple file paths into one
This commit is contained in:
@@ -120,14 +120,14 @@ public class PlainPermissionManager {
|
||||
Map<String, DataVersion> dataVersionMap = new HashMap<>();
|
||||
|
||||
assureAclConfigFilesExist();
|
||||
|
||||
|
||||
fileList = getAllAclFiles(defaultAclDir);
|
||||
if (new File(defaultAclFile).exists() && !fileList.contains(defaultAclFile)) {
|
||||
fileList.add(defaultAclFile);
|
||||
}
|
||||
|
||||
for (int i = 0; i < fileList.size(); i++) {
|
||||
final String currentFile = fileList.get(i);
|
||||
final String currentFile = MixAll.dealFilePath(fileList.get(i));
|
||||
JSONObject plainAclConfData = AclUtils.getYamlDataObject(currentFile,
|
||||
JSONObject.class);
|
||||
if (plainAclConfData == null || plainAclConfData.isEmpty()) {
|
||||
@@ -206,6 +206,7 @@ public class PlainPermissionManager {
|
||||
}
|
||||
|
||||
public void load(String aclFilePath) {
|
||||
aclFilePath = MixAll.dealFilePath(aclFilePath);
|
||||
Map<String, PlainAccessResource> plainAccessResourceMap = new HashMap<>();
|
||||
List<RemoteAddressStrategy> globalWhiteRemoteAddressStrategy = new ArrayList<>();
|
||||
|
||||
@@ -351,7 +352,7 @@ public class PlainPermissionManager {
|
||||
aclPlainAccessResourceMap.put(aclFileName, accountMap);
|
||||
return AclUtils.writeDataObject(aclFileName, updateAclConfigFileVersion(aclFileName, aclAccessConfigMap));
|
||||
} else {
|
||||
String fileName = defaultAclFile;
|
||||
String fileName = MixAll.dealFilePath(defaultAclFile);
|
||||
//Create acl access config elements on the default acl file
|
||||
if (aclPlainAccessResourceMap.get(defaultAclFile) == null || aclPlainAccessResourceMap.get(defaultAclFile).size() == 0) {
|
||||
try {
|
||||
|
||||
@@ -87,6 +87,8 @@ public class MixAll {
|
||||
public static final String REPLY_MESSAGE_FLAG = "reply";
|
||||
public static final String LMQ_PREFIX = "%LMQ%";
|
||||
public static final String MULTI_DISPATCH_QUEUE_SPLITTER = ",";
|
||||
public static final String MULTI_SEPARATE = "//";
|
||||
public static final String SEPARATE_DOT = "/.";
|
||||
private static final InternalLogger log = InternalLoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
|
||||
|
||||
public static String getWSAddr() {
|
||||
@@ -451,4 +453,18 @@ public class MixAll {
|
||||
public static boolean isLmq(String lmqMetaData) {
|
||||
return lmqMetaData != null && lmqMetaData.startsWith(LMQ_PREFIX);
|
||||
}
|
||||
|
||||
public static String dealFilePath(String aclFilePath) {
|
||||
StringBuilder sub = new StringBuilder(aclFilePath);
|
||||
while (sub.indexOf(MULTI_SEPARATE) != -1) {
|
||||
int index = sub.indexOf(MULTI_SEPARATE);
|
||||
sub.delete(index, index + 1);
|
||||
}
|
||||
while (sub.indexOf(SEPARATE_DOT) != -1 ) {
|
||||
int index = sub.indexOf(SEPARATE_DOT);
|
||||
sub.delete(index, index + SEPARATE_DOT.length());
|
||||
}
|
||||
return sub.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user