summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBrian Carlstrom <bdc@google.com>2011-06-24 02:13:28 -0700
committerBrian Carlstrom <bdc@google.com>2011-06-26 15:27:48 -0700
commit65e649e856d88520ac04f5b16313a3f167e569e0 (patch)
tree514cd785e6cc5c98d564d45da5881be2ddd968e1 /tests
parentf5b50a4678120890d62bb07bb47cbd3f1ba4b243 (diff)
downloadKeyChain-65e649e856d88520ac04f5b16313a3f167e569e0.tar.gz
Replace KeyChainActivity placeholder UI with more polished dialog (5 of 5)
frameworks/base Extended KeyChain.chooserPrivateKeyAlias to allow caller to supply preferred choice to be selected in chooser. This allows Email settings to highlight the current choice when allowing user to change settings. keystore/java/android/security/KeyChain.java api/current.txt Implemented KeyChain functionality to pass host and port information to KeyChainActivity for display. keystore/java/android/security/KeyChain.java KeyChain now sends a PendingIntent as part of the Intent it sends to the KeyChainActivity which can be used to identify the caller in reliable way. keystore/java/android/security/KeyChain.java Moved .pfx/.p12/.cer/.crt constants to Credentials for reuse. Added Credentials.install variant with no value for use from KeyChainActivity keystore/java/android/security/Credentials.java packages/apps/CertInstaller Source of extension constants now in Credentials src/com/android/certinstaller/CertFile.java packages/apps/Browser Have browser supply host and port information to KeyChain.choosePrivateKeyAlias Tracking KeyChain.choosePrivateKeyAlias API change src/com/android/browser/Tab.java packages/apps/Email Tracking KeyChain.choosePrivateKeyAlias API change src/com/android/email/view/CertificateSelector.java packages/apps/KeyChain KeyChain now depends on bouncycastle X509Name for formatting X500Principals, since the 4 X500Principal formatting options could not format emailAddress attributes in a human readable way and its the most important attribute to display for client certificates in most cases. Android.mk Changing the UI to a dialog, make the activity style transparent. AndroidManifest.xml res/values/styles.xml Layout for chooser dialog res/layout/cert_chooser.xml Layout for list items in chooser res/layout/cert_item.xml New resources for dialog including comments for translators. res/values/strings.xml New dialog based KeyChainActivity. Now also shows requesting app and requesting server. Now can preselect a specified alias. New link directly to CertInstaller. src/com/android/keychain/KeyChainActivity.java Fix KeyChainTestActivity to work with TestKeyStore changes that were causing network activity on the UI to look up the name of localhost. Also track KeyChain.choosePrivateKeyAlias API change. tests/src/com/android/keychain/tests/KeyChainTestActivity.java Change-Id: I6923e5bf77041500a8ebb44a7972f5d01d297263
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/keychain/tests/KeyChainTestActivity.java39
1 files changed, 33 insertions, 6 deletions
diff --git a/tests/src/com/android/keychain/tests/KeyChainTestActivity.java b/tests/src/com/android/keychain/tests/KeyChainTestActivity.java
index 6c280a6..c5ff34f 100644
--- a/tests/src/com/android/keychain/tests/KeyChainTestActivity.java
+++ b/tests/src/com/android/keychain/tests/KeyChainTestActivity.java
@@ -21,6 +21,7 @@ import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.RemoteException;
+import android.os.StrictMode;
import android.security.Credentials;
import android.security.KeyChain;
import android.security.KeyChainAliasCallback;
@@ -59,7 +60,7 @@ public class KeyChainTestActivity extends Activity {
private TextView mTextView;
- private KeyChain mKeyChain;
+ private TestKeyStore mTestKeyStore;
private final Object mAliasLock = new Object();
private String mAlias;
@@ -79,6 +80,20 @@ public class KeyChainTestActivity extends Activity {
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
+ .detectDiskReads()
+ .detectDiskWrites()
+ .detectAll()
+ .penaltyLog()
+ .penaltyDeath()
+ .build());
+ StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
+ .detectLeakedSqlLiteObjects()
+ .detectLeakedClosableObjects()
+ .penaltyLog()
+ .penaltyDeath()
+ .build());
+
mTextView = new TextView(this);
mTextView.setMovementMethod(new ScrollingMovementMethod());
setContentView(mTextView);
@@ -86,7 +101,7 @@ public class KeyChainTestActivity extends Activity {
log("Starting test...");
testKeyChainImproperUse();
- testCaInstall();
+ new SetupTestKeyStore().execute();
}
private void testKeyChainImproperUse() {
@@ -135,10 +150,20 @@ public class KeyChainTestActivity extends Activity {
}
}
+ private class SetupTestKeyStore extends AsyncTask<Void, Void, Void> {
+ @Override protected Void doInBackground(Void... params) {
+ mTestKeyStore = TestKeyStore.getServer();
+ return null;
+ }
+ @Override protected void onPostExecute(Void result) {
+ testCaInstall();
+ }
+ }
+
private void testCaInstall() {
try {
log("Requesting install of server's CA...");
- X509Certificate ca = TestKeyStore.getServer().getRootCertificate("RSA");
+ X509Certificate ca = mTestKeyStore.getRootCertificate("RSA");
Intent intent = new Intent("android.credentials.INSTALL");
intent.putExtra("name", TAG); // "name" = CredentialHelper.CERT_NAME_KEY
intent.putExtra(Credentials.CERTIFICATE, Credentials.convertToPem(ca));
@@ -164,8 +189,8 @@ public class KeyChainTestActivity extends Activity {
}
}
private URL startWebServer() throws Exception {
- KeyStore serverKeyStore = TestKeyStore.getServer().keyStore;
- char[] serverKeyStorePassword = TestKeyStore.getServer().storePassword;
+ KeyStore serverKeyStore = mTestKeyStore.keyStore;
+ char[] serverKeyStorePassword = mTestKeyStore.storePassword;
String kmfAlgoritm = KeyManagerFactory.getDefaultAlgorithm();
KeyManagerFactory kmf = KeyManagerFactory.getInstance(kmfAlgoritm);
kmf.init(serverKeyStore, serverKeyStorePassword);
@@ -199,7 +224,9 @@ public class KeyChainTestActivity extends Activity {
log("KeyChainKeyManager chooseClientAlias...");
KeyChain.choosePrivateKeyAlias(KeyChainTestActivity.this, new AliasResponse(),
- null, null, null, -1);
+ keyTypes, issuers,
+ socket.getInetAddress().getHostName(), socket.getPort(),
+ "My Test Certificate");
String alias;
synchronized (mAliasLock) {
while (mAlias == null) {