提交 5503cff5 编写于 作者: H hujie

tools acl

上级 ceaa64bb
......@@ -16,6 +16,9 @@
*/
package org.apache.rocketmq.tools.command;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
......@@ -26,7 +29,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Properties;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.PosixParser;
......@@ -81,10 +83,6 @@ import org.apache.rocketmq.tools.command.topic.UpdateTopicPermSubCommand;
import org.apache.rocketmq.tools.command.topic.UpdateTopicSubCommand;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
public class MQAdminStartup {
protected static List<SubCommand> subCommandList = new ArrayList<SubCommand>();
......@@ -220,7 +218,7 @@ public class MQAdminStartup {
private static void printHelp() {
System.out.printf("The most commonly used mqadmin commands are:%n");
System.out.println("ROCKETMQ_HOME Add tools.properties to the %ROCKETMQ_HOME%/conf/ directory or add -account xxxx -password xxxx Join when executing a command");
System.out.printf("ROCKETMQ_HOME Add tools.properties to the %ROCKETMQ_HOME%/conf/ directory or add -account xxxx -password xxxx Join when executing a command");
for (SubCommand cmd : subCommandList) {
System.out.printf(" %-20s %s%n", cmd.commandName(), cmd.commandDesc());
}
......@@ -254,19 +252,19 @@ public class MQAdminStartup {
}
public static RPCHook getAclRPCHook(CommandLine commandLine) {
String account=null ,password = null;
if(commandLine.hasOption("account")) {
String account = null, password = null;
if (commandLine.hasOption("account")) {
account = commandLine.getOptionValue("account");
password = commandLine.getOptionValue("password");
}else {
String fileHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY,System.getenv(MixAll.ROCKETMQ_HOME_ENV));
File file = new File(fileHome+"/conf/tools.properties");
if(!file.exists()) {
System.out.println("no find tools.properties , , Execution may fail without account andd password");
System.out.println("ROCKETMQ_HOME Add tools.properties to the %ROCKETMQ_HOME%/conf/ directory or add -account xxxx -password xxxx Join when executing a command");
} else {
String fileHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV));
File file = new File(fileHome + "/conf/tools.properties");
if (!file.exists()) {
System.out.printf("no find tools.properties , , Execution may fail without account andd password");
System.out.printf("ROCKETMQ_HOME Add tools.properties to the %ROCKETMQ_HOME%/conf/ directory or add -account xxxx -password xxxx Join when executing a command");
return null;
}
InputStream in=null;
InputStream in = null;
try {
in = new BufferedInputStream(new FileInputStream(file));
Properties properties = new Properties();
......@@ -277,8 +275,8 @@ public class MQAdminStartup {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
if(in != null) {
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
......@@ -287,7 +285,7 @@ public class MQAdminStartup {
}
}
}
if(StringUtils.isNotBlank(account) && StringUtils.isNotBlank(password) ) {
if (StringUtils.isNotBlank(account) && StringUtils.isNotBlank(password)) {
final String newAccount = account;
final String newPassword = password;
return new RPCHook() {
......@@ -304,11 +302,12 @@ public class MQAdminStartup {
}
@Override
public void doAfterResponse(String remoteAddr, RemotingCommand request, RemotingCommand response) {}
public void doAfterResponse(String remoteAddr, RemotingCommand request, RemotingCommand response) {
}
};
}
System.out.println("account andd password data incorrectness , Execution may fail without account andd password");
System.out.println("ROCKETMQ_HOME Add tools.properties to the %ROCKETMQ_HOME%/conf/ directory or add -account xxxx -password xxxx Join when executing a command");
System.out.printf("account andd password data incorrectness , Execution may fail without account andd password");
System.out.printf("ROCKETMQ_HOME Add tools.properties to the %ROCKETMQ_HOME%/conf/ directory or add -account xxxx -password xxxx Join when executing a command");
return null;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册