Manno15 commented on a change in pull request #2228:
URL: https://github.com/apache/accumulo/pull/2228#discussion_r686242352
##########
File path:
server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java
##########
@@ -748,24 +735,27 @@ private String getRootUserName(SiteConfiguration
siteConfig, Opts opts) throws I
if (opts.cliPassword != null) {
return opts.cliPassword.getBytes(UTF_8);
}
- String rootpass;
- String confirmpass;
+ char[] rootpass;
+ char[] confirmpass;
+ String strrootpass;
+ String strconfirmpass;
do {
- rootpass = getLineReader().readLine(
- "Enter initial password for " + rootUser +
getInitialPasswordWarning(siteConfig), '*');
+ rootpass = System.console().readPassword(
+ "Enter initial password for " + rootUser +
getInitialPasswordWarning(siteConfig));
if (rootpass == null) {
System.exit(0);
}
- confirmpass =
- getLineReader().readLine("Confirm initial password for " + rootUser
+ ": ", '*');
+ confirmpass = System.console().readPassword("Confirm initial password
for " + rootUser + ":");
if (confirmpass == null) {
System.exit(0);
}
- if (!rootpass.equals(confirmpass)) {
+ strrootpass = new String(rootpass);
+ strconfirmpass = new String(confirmpass);
+ if (!strrootpass.equals(strconfirmpass)) {
log.error("Passwords do not match");
}
} while (!rootpass.equals(confirmpass));
- return rootpass.getBytes(UTF_8);
+ return strrootpass.getBytes(Charset.forName("UTF-8"));
Review comment:
```suggestion
return strrootpass.getBytes(UTF_8);
```
##########
File path:
server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java
##########
@@ -144,17 +141,8 @@
private static final String DEFAULT_ROOT_USER = "root";
private static final String TABLE_TABLETS_TABLET_DIR = "table_info";
- private static LineReader reader = null;
- private static Terminal terminal = null;
private static ZooReaderWriter zoo = null;
-
- private static LineReader getLineReader() throws IOException {
- if (terminal == null)
- terminal = TerminalBuilder.builder().jansi(false).build();
- if (reader == null)
- reader = LineReaderBuilder.builder().terminal(terminal).build();
- return reader;
- }
+ private static Console reader = null;
Review comment:
```suggestion
```
##########
File path:
server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java
##########
@@ -748,24 +735,27 @@ private String getRootUserName(SiteConfiguration
siteConfig, Opts opts) throws I
if (opts.cliPassword != null) {
return opts.cliPassword.getBytes(UTF_8);
}
- String rootpass;
- String confirmpass;
+ char[] rootpass;
+ char[] confirmpass;
+ String strrootpass;
+ String strconfirmpass;
do {
- rootpass = getLineReader().readLine(
- "Enter initial password for " + rootUser +
getInitialPasswordWarning(siteConfig), '*');
+ rootpass = System.console().readPassword(
+ "Enter initial password for " + rootUser +
getInitialPasswordWarning(siteConfig));
if (rootpass == null) {
System.exit(0);
}
- confirmpass =
- getLineReader().readLine("Confirm initial password for " + rootUser
+ ": ", '*');
+ confirmpass = System.console().readPassword("Confirm initial password
for " + rootUser + ":");
if (confirmpass == null) {
System.exit(0);
}
- if (!rootpass.equals(confirmpass)) {
+ strrootpass = new String(rootpass);
+ strconfirmpass = new String(confirmpass);
+ if (!strrootpass.equals(strconfirmpass)) {
log.error("Passwords do not match");
}
} while (!rootpass.equals(confirmpass));
Review comment:
This should probably be the comparison of the string version otherwise,
you would need Arrays.,equals
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]