Merge "Signapk.java: hide the password"
This commit is contained in:
@@ -35,6 +35,7 @@ import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
|
|||||||
import org.bouncycastle.operator.jcajce.JcaDigestCalculatorProviderBuilder;
|
import org.bouncycastle.operator.jcajce.JcaDigestCalculatorProviderBuilder;
|
||||||
import org.bouncycastle.util.encoders.Base64;
|
import org.bouncycastle.util.encoders.Base64;
|
||||||
|
|
||||||
|
import java.io.Console;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@@ -166,18 +167,17 @@ class SignApk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the password from stdin and returns it as a string.
|
* 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) {
|
||||||
// TODO: use Console.readPassword() when it's available.
|
Console console;
|
||||||
System.out.print("Enter password for " + keyFile + " (password will not be hidden): ");
|
char[] pwd;
|
||||||
System.out.flush();
|
if((console = System.console()) != null &&
|
||||||
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
|
(pwd = console.readPassword("[%s]", "Enter password for " + keyFile)) != null){
|
||||||
try {
|
return String.valueOf(pwd);
|
||||||
return stdin.readLine();
|
} else {
|
||||||
} catch (IOException ex) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user