am 4f6f0f92
: Merge "If a console doesn\'t exist, read password from stdin."
* commit '4f6f0f924eba9f80493861a9e7ff7f40f9924aa2': If a console doesn't exist, read password from stdin.
This commit is contained in:
@@ -167,18 +167,29 @@ class SignApk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the password from console and returns it as a string.
|
* If a console doesn't exist, reads the password from stdin
|
||||||
|
* If a console exists, reads the password from console and returns it as a string.
|
||||||
*
|
*
|
||||||
* @param keyFile The file containing the private key. Used to prompt the user.
|
* @param keyFile The file containing the private key. Used to prompt the user.
|
||||||
*/
|
*/
|
||||||
private static String readPassword(File keyFile) {
|
private static String readPassword(File keyFile) {
|
||||||
Console console;
|
Console console;
|
||||||
char[] pwd;
|
char[] pwd;
|
||||||
if((console = System.console()) != null &&
|
if ((console = System.console()) == null) {
|
||||||
(pwd = console.readPassword("[%s]", "Enter password for " + keyFile)) != null){
|
System.out.print("Enter password for " + keyFile + " (password will not be hidden): ");
|
||||||
return String.valueOf(pwd);
|
System.out.flush();
|
||||||
|
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
|
||||||
|
try {
|
||||||
|
return stdin.readLine();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return null;
|
if ((pwd = console.readPassword("[%s]", "Enter password for " + keyFile)) != null) {
|
||||||
|
return String.valueOf(pwd);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user