Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,24 @@ private void initAdminUser() throws Exception {
}

private String inputPassword() {
String prompt = "Please input the admin password:";
String inputPrompt = "Please input the admin password:";
String notEmptyPrompt = "The admin password can't be empty";
Console console = System.console();
if (console != null) {
char[] chars = console.readPassword(prompt);
return new String(chars);
} else {
System.out.print(prompt);
@SuppressWarnings("resource") // just wrapper of System.in
Scanner scanner = new Scanner(System.in);
return scanner.nextLine();
while (true) {
String password = "";
if (console != null) {
char[] chars = console.readPassword(inputPrompt);
password = new String(chars);
} else {
System.out.print(inputPrompt);
@SuppressWarnings("resource") // just wrapper of System.in
Scanner scanner = new Scanner(System.in);
password = scanner.nextLine();
}
if (!password.isEmpty()) {
return password;
}
System.out.println(notEmptyPrompt);
}
}

Expand Down