Merge "Convert to new KeyStore format"
This commit is contained in:
@@ -25,6 +25,7 @@ import android.content.res.Resources;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.security.Credentials;
|
||||||
import android.security.KeyChain.KeyChainConnection;
|
import android.security.KeyChain.KeyChainConnection;
|
||||||
import android.security.KeyChain;
|
import android.security.KeyChain;
|
||||||
import android.security.KeyStore;
|
import android.security.KeyStore;
|
||||||
@@ -187,13 +188,38 @@ public final class CredentialStorage extends Activity {
|
|||||||
if (mInstallBundle != null && !mInstallBundle.isEmpty()) {
|
if (mInstallBundle != null && !mInstallBundle.isEmpty()) {
|
||||||
Bundle bundle = mInstallBundle;
|
Bundle bundle = mInstallBundle;
|
||||||
mInstallBundle = null;
|
mInstallBundle = null;
|
||||||
for (String key : bundle.keySet()) {
|
|
||||||
byte[] value = bundle.getByteArray(key);
|
if (bundle.containsKey(Credentials.EXTRA_USER_PRIVATE_KEY_NAME)) {
|
||||||
if (value != null && !mKeyStore.put(key, value)) {
|
String key = bundle.getString(Credentials.EXTRA_USER_PRIVATE_KEY_NAME);
|
||||||
|
byte[] value = bundle.getByteArray(Credentials.EXTRA_USER_PRIVATE_KEY_DATA);
|
||||||
|
|
||||||
|
if (!mKeyStore.importKey(key, value)) {
|
||||||
Log.e(TAG, "Failed to install " + key);
|
Log.e(TAG, "Failed to install " + key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bundle.containsKey(Credentials.EXTRA_USER_CERTIFICATE_NAME)) {
|
||||||
|
String certName = bundle.getString(Credentials.EXTRA_USER_CERTIFICATE_NAME);
|
||||||
|
byte[] certData = bundle.getByteArray(Credentials.EXTRA_USER_CERTIFICATE_DATA);
|
||||||
|
|
||||||
|
if (!mKeyStore.put(certName, certData)) {
|
||||||
|
Log.e(TAG, "Failed to install " + certName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bundle.containsKey(Credentials.EXTRA_CA_CERTIFICATES_NAME)) {
|
||||||
|
String caListName = bundle.getString(Credentials.EXTRA_CA_CERTIFICATES_NAME);
|
||||||
|
byte[] caListData = bundle.getByteArray(Credentials.EXTRA_CA_CERTIFICATES_DATA);
|
||||||
|
|
||||||
|
if (!mKeyStore.put(caListName, caListData)) {
|
||||||
|
Log.e(TAG, "Failed to install " + caListName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
setResult(RESULT_OK);
|
setResult(RESULT_OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user