mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
disable console echo when reading secure info
This commit is contained in:
parent
9d2e808664
commit
ca81e1bcb4
@ -3,6 +3,7 @@ package io.nosqlbench.driver.jmx;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.Console;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
@ -24,24 +25,10 @@ public class SecureUtils {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else if (source.startsWith("console:")||source.equals("")) {
|
||||
System.out.println("")
|
||||
StringBuilder sb = new StringBuilder();
|
||||
char in=0;
|
||||
while (true) {
|
||||
try {
|
||||
in= (char)System.in.read();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (in!='\n' && in!='\r') {
|
||||
sb.append(in);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
|
||||
System.out.print("Enter " + description+":");
|
||||
|
||||
char[] chars = System.console().readPassword("%s:",description);
|
||||
return new String(chars);
|
||||
} else {
|
||||
logger.warn("Parameter for '" + description + "' was passed directly. This is less secure." +
|
||||
" Consider using 'file:<file>' or 'console:' for this value instead");
|
||||
|
Loading…
Reference in New Issue
Block a user