summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Carlstrom <bdc@google.com>2011-06-29 10:42:38 -0700
committerBrian Carlstrom <bdc@google.com>2011-06-29 16:51:05 -0700
commit00736f76392c742e9c72c51f158ad7020f22524c (patch)
treed2903fc10ea2a7509a0074c2d6df12d28aae5b90 /src
parentfcd5fb26acec88e98c3bedb41d4510888f7890cd (diff)
downloadandroid_packages_apps_CertInstaller-00736f76392c742e9c72c51f158ad7020f22524c.tar.gz
android_packages_apps_CertInstaller-00736f76392c742e9c72c51f158ad7020f22524c.tar.bz2
android_packages_apps_CertInstaller-00736f76392c742e9c72c51f158ad7020f22524c.zip
Tracking move to KeyChain credential installation API
Bug: 3497064 Change-Id: I4d49354f4687f95d8239ea98d79bd61d06c4ce82
Diffstat (limited to 'src')
-rw-r--r--src/com/android/certinstaller/CertFile.java5
-rw-r--r--src/com/android/certinstaller/CertFileList.java15
-rw-r--r--src/com/android/certinstaller/CertInstaller.java8
-rw-r--r--src/com/android/certinstaller/CredentialHelper.java19
4 files changed, 29 insertions, 18 deletions
diff --git a/src/com/android/certinstaller/CertFile.java b/src/com/android/certinstaller/CertFile.java
index c2701f9..7d89591 100644
--- a/src/com/android/certinstaller/CertFile.java
+++ b/src/com/android/certinstaller/CertFile.java
@@ -21,6 +21,7 @@ import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceActivity;
import android.security.Credentials;
+import android.security.KeyChain;
import android.util.Log;
import android.widget.Toast;
@@ -171,10 +172,10 @@ public class CertFile extends PreferenceActivity implements FileFilter {
intent.putExtra(CredentialHelper.CERT_NAME_KEY, fileName);
if (fileName.endsWith(Credentials.EXTENSION_PFX)
|| fileName.endsWith(Credentials.EXTENSION_P12)) {
- intent.putExtra(Credentials.PKCS12, value);
+ intent.putExtra(KeyChain.EXTRA_PKCS12, value);
} else if (fileName.endsWith(Credentials.EXTENSION_CER)
|| fileName.endsWith(Credentials.EXTENSION_CRT)) {
- intent.putExtra(Credentials.CERTIFICATE, value);
+ intent.putExtra(KeyChain.EXTRA_CERTIFICATE, value);
} else {
throw new AssertionError(fileName);
}
diff --git a/src/com/android/certinstaller/CertFileList.java b/src/com/android/certinstaller/CertFileList.java
index 1ff1529..9c43ec1 100644
--- a/src/com/android/certinstaller/CertFileList.java
+++ b/src/com/android/certinstaller/CertFileList.java
@@ -71,7 +71,9 @@ public class CertFileList extends CertFile
@Override
protected void onError(int errorId) {
- if (errorId == CERT_FILE_MISSING_ERROR) createFileList();
+ if (errorId == CERT_FILE_MISSING_ERROR) {
+ createFileList();
+ }
}
private void setAllFilesEnabled(boolean enabled) {
@@ -97,7 +99,8 @@ public class CertFileList extends CertFile
if (isFinishing()) {
Log.d(TAG, "finishing, exit createFileList()");
return;
- } else if (!isSdCardPresent()) {
+ }
+ if (!isSdCardPresent()) {
Toast.makeText(this, R.string.sdcard_not_present,
Toast.LENGTH_SHORT).show();
finish();
@@ -130,12 +133,16 @@ public class CertFileList extends CertFile
}
private void startSdCardMonitor() {
- if (mSdCardMonitor == null) mSdCardMonitor = new SdCardMonitor();
+ if (mSdCardMonitor == null) {
+ mSdCardMonitor = new SdCardMonitor();
+ }
mSdCardMonitor.startWatching();
}
private void stopSdCardMonitor() {
- if (mSdCardMonitor != null) mSdCardMonitor.stopWatching();
+ if (mSdCardMonitor != null) {
+ mSdCardMonitor.stopWatching();
+ }
}
private class SdCardMonitor {
diff --git a/src/com/android/certinstaller/CertInstaller.java b/src/com/android/certinstaller/CertInstaller.java
index 8814014..e07fc96 100644
--- a/src/com/android/certinstaller/CertInstaller.java
+++ b/src/com/android/certinstaller/CertInstaller.java
@@ -261,8 +261,8 @@ public class CertInstaller extends Activity
}
private void saveKeyPair() {
- byte[] privatekey = mCredentials.getData(Credentials.PRIVATE_KEY);
- String key = Util.toMd5(mCredentials.getData(Credentials.PUBLIC_KEY));
+ byte[] privatekey = mCredentials.getData(Credentials.EXTRA_PRIVATE_KEY);
+ String key = Util.toMd5(mCredentials.getData(Credentials.EXTRA_PUBLIC_KEY));
Map<String, byte[]> map = getPkeyMap();
map.put(key, privatekey);
savePkeyMap(map);
@@ -450,7 +450,9 @@ public class CertInstaller extends Activity
}
public void run(CertInstaller host) {
- if (hasRun) return;
+ if (hasRun) {
+ return;
+ }
hasRun = true;
host.extractPkcs12InBackground(mPassword);
}
diff --git a/src/com/android/certinstaller/CredentialHelper.java b/src/com/android/certinstaller/CredentialHelper.java
index f9bd0e9..db16559 100644
--- a/src/com/android/certinstaller/CredentialHelper.java
+++ b/src/com/android/certinstaller/CredentialHelper.java
@@ -21,6 +21,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.os.RemoteException;
import android.security.Credentials;
+import android.security.KeyChain;
import android.security.IKeyChainService;
import android.text.Html;
import android.util.Log;
@@ -88,7 +89,7 @@ class CredentialHelper {
Log.d(TAG, " " + key + ": " + ((bytes == null) ? -1 : bytes.length));
mBundle.put(key, bytes);
}
- parseCert(getData(Credentials.CERTIFICATE));
+ parseCert(getData(KeyChain.EXTRA_CERTIFICATE));
}
synchronized void onSaveStates(Bundle outStates) {
@@ -171,12 +172,12 @@ class CredentialHelper {
}
boolean hasPkcs12KeyStore() {
- return mBundle.containsKey(Credentials.PKCS12);
+ return mBundle.containsKey(KeyChain.EXTRA_PKCS12);
}
boolean hasKeyPair() {
- return mBundle.containsKey(Credentials.PUBLIC_KEY)
- && mBundle.containsKey(Credentials.PRIVATE_KEY);
+ return mBundle.containsKey(Credentials.EXTRA_PUBLIC_KEY)
+ && mBundle.containsKey(Credentials.EXTRA_PRIVATE_KEY);
}
boolean hasUserCertificate() {
@@ -211,7 +212,7 @@ class CredentialHelper {
}
void putPkcs12Data(byte[] data) {
- mBundle.put(Credentials.PKCS12, data);
+ mBundle.put(KeyChain.EXTRA_PKCS12, data);
}
CharSequence getDescription(Context context) {
@@ -303,7 +304,7 @@ class CredentialHelper {
// TODO: add test about this
java.security.KeyStore keystore = java.security.KeyStore.getInstance("PKCS12");
PasswordProtection passwordProtection = new PasswordProtection(password.toCharArray());
- keystore.load(new ByteArrayInputStream(getData(Credentials.PKCS12)),
+ keystore.load(new ByteArrayInputStream(getData(KeyChain.EXTRA_PKCS12)),
passwordProtection.getPassword());
Enumeration<String> aliases = keystore.aliases();
@@ -330,11 +331,11 @@ class CredentialHelper {
Certificate[] certs = entry.getCertificateChain();
Log.d(TAG, "# certs extracted = " + certs.length);
- List<X509Certificate> caCerts = mCaCerts = new ArrayList<X509Certificate>(certs.length);
- for (Certificate c : certs) {
+ List<X509Certificate> mCaCerts = new ArrayList<X509Certificate>(certs.length);
+ for (Certificate c : mCaCerts) {
X509Certificate cert = (X509Certificate) c;
if (isCa(cert)) {
- caCerts.add(cert);
+ mCaCerts.add(cert);
}
}
Log.d(TAG, "# ca certs extracted = " + mCaCerts.size());