DebugKeyProviderpublic class DebugKeyProvider extends Object A provider of a dummy key to sign Android application for debugging purpose.
This provider uses a custom keystore to create and store a key with a known password. |
Fields Summary |
---|
private static final String | PASSWORD_STRING | private static final char[] | PASSWORD_CHAR | private static final String | DEBUG_ALIAS | private static final String | CERTIFICATE_DESC | private KeyStore$PrivateKeyEntry | mEntry |
Constructors Summary |
---|
public DebugKeyProvider(String osKeyStorePath, String storeType, IKeyGenOutput output)Creates a provider using a keystore at the given location.
The keystore, and a new random android debug key are created if they do not yet exist.
Password for the store/key is android , and the key alias is
AndroidDebugKey .
if (osKeyStorePath == null) {
osKeyStorePath = getDefaultKeyStoreOsPath();
}
if (loadKeyEntry(osKeyStorePath, storeType) == false) {
// create the store with the key
createNewStore(osKeyStorePath, storeType, output);
}
|
Methods Summary |
---|
private void | createNewStore(java.lang.String osKeyStorePath, java.lang.String storeType, com.android.jarutils.DebugKeyProvider$IKeyGenOutput output)Creates a new store
if (KeystoreHelper.createNewStore(osKeyStorePath, storeType, PASSWORD_STRING, DEBUG_ALIAS,
PASSWORD_STRING, CERTIFICATE_DESC, 1 /* validity*/, output)) {
loadKeyEntry(osKeyStorePath, storeType);
}
| public java.security.cert.Certificate | getCertificate()Returns the debug {@link Certificate} to use to sign applications for debug purpose.
if (mEntry != null) {
return mEntry.getCertificate();
}
return null;
| public java.security.PrivateKey | getDebugKey()Returns the debug {@link PrivateKey} to use to sign applications for debug purpose.
if (mEntry != null) {
return mEntry.getPrivateKey();
}
return null;
| public static java.lang.String | getDefaultKeyStoreOsPath()Returns the OS path to the default debug keystore.
String folder = AndroidLocation.getFolder();
if (folder == null) {
throw new KeytoolException("Failed to get HOME directory!\n");
}
String osKeyStorePath = folder + "debug.keystore";
return osKeyStorePath;
| private boolean | loadKeyEntry(java.lang.String osKeyStorePath, java.lang.String storeType)Loads the debug key from the keystore.
try {
KeyStore keyStore = KeyStore.getInstance(
storeType != null ? storeType : KeyStore.getDefaultType());
FileInputStream fis = new FileInputStream(osKeyStorePath);
keyStore.load(fis, PASSWORD_CHAR);
fis.close();
mEntry = (KeyStore.PrivateKeyEntry)keyStore.getEntry(
DEBUG_ALIAS, new KeyStore.PasswordProtection(PASSWORD_CHAR));
} catch (FileNotFoundException e) {
return false;
}
return true;
|
|