mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-03-24 17:09:03 +00:00
Correctly handle password promnpt in CLI
This commit is contained in:
parent
3fd86efa73
commit
87f90fec47
@ -90,18 +90,23 @@ public abstract class BaseCommand implements Comparable<BaseCommand> {
|
||||
protected String promptUser(String thePrompt) throws ParseException {
|
||||
System.out.print(ansi().bold().fgBrightDefault());
|
||||
System.out.print(thePrompt);
|
||||
System.out.print(ansi().bold().fgBrightGreen());
|
||||
System.out.print(ansi().boldOff().fgBlack().bgDefault());
|
||||
System.out.flush();
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
|
||||
Console console = System.console();
|
||||
String retVal;
|
||||
try {
|
||||
retVal = reader.readLine();
|
||||
} catch (IOException e) {
|
||||
throw new ParseException("Failed to read input from user: " + e.toString());
|
||||
if (console == null) {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
|
||||
try {
|
||||
retVal = reader.readLine();
|
||||
} catch (IOException e) {
|
||||
throw new ParseException("Failed to read input from user: " + e.toString());
|
||||
}
|
||||
} else {
|
||||
retVal = new String(console.readPassword());
|
||||
}
|
||||
|
||||
System.out.print(ansi().boldOff().fgDefault());
|
||||
System.out.print(ansi().boldOff().fgDefault().bgDefault());
|
||||
|
||||
return retVal;
|
||||
}
|
||||
@ -254,7 +259,8 @@ public abstract class BaseCommand implements Comparable<BaseCommand> {
|
||||
if (theCommandLine.hasOption(theOptionName)) {
|
||||
String optionValue = theCommandLine.getOptionValue(theOptionName);
|
||||
if (PROMPT.equals(optionValue)) {
|
||||
promptUser("Enter Basic Auth Credentials (format is \"username:password\"): ");
|
||||
optionValue = promptUser("Enter Basic Auth Credentials (format is \"username:password\"): ");
|
||||
optionValue = trim(optionValue);
|
||||
}
|
||||
|
||||
byte[] basicAuth = optionValue.getBytes();
|
||||
|
@ -44,6 +44,10 @@
|
||||
The JPA database migrator tool has been enhanced so that it now supports migrations from
|
||||
HAPI FHIR 3.3.0 to HAPI FHIR 3.4.0 / 3.5.0+ as well.
|
||||
</action>
|
||||
<action type="fix">
|
||||
When using the HAPI FHIR CLI, user-prompted passwords were not correctly encoded, meaning that the
|
||||
"--basic-auth PROMPT" action was not usable. This has been corrected.
|
||||
</action>
|
||||
</release>
|
||||
|
||||
<release version="3.5.0" date="2018-09-17">
|
||||
|
Loading…
x
Reference in New Issue
Block a user