in taverna-commandline-common/src/main/java/org/apache/taverna/commandline/CommandLineMasterPasswordProvider.java [102:152]
private String getCredentialManagerPasswordFromStdin()
throws CommandLineMasterPasswordException {
String password = null;
Console console = System.console();
if (console == null) { // password is being piped in, not entered in the terminal by user
BufferedReader buffReader = null;
try {
buffReader = new BufferedReader(new InputStreamReader(System.in));
password = buffReader.readLine();
} catch (IOException ex) {
// For some reason the error of the exception thrown
// does not get printed from the Launcher so print it here as
// well as it gives more clue as to what is going wrong.
logger.error(
"An error occured while trying to read Credential Manager's password that was piped in: "
+ ex.getMessage(), ex);
throw new CommandLineMasterPasswordException(
"An error occured while trying to read Credential Manager's password that was piped in: "
+ ex.getMessage(), ex);
} finally {
try {
buffReader.close();
} catch (Exception ioe1) {
// Ignore
}
}
} else { // read the password from the terminal as entered by the user
try {
// Block until user enters password
char passwordArray[] = console.readPassword("Password for Credential Manager: ");
if (passwordArray != null) { // user did not abort input
password = new String(passwordArray);
} // else password will be null
} catch (Exception ex) {
// For some reason the error of the exception thrown
// does not get printed from the Launcher so print it here as
// well as it gives more clue as to what is going wrong.
logger.error(
"An error occured while trying to read Credential Manager's password from the terminal: "
+ ex.getMessage(), ex);
throw new CommandLineMasterPasswordException(
"An error occured while trying to read Credential Manager's password from the terminal: "
+ ex.getMessage(), ex);
}
}
return password;
}