summaryrefslogtreecommitdiffstats
path: root/keystore/tests
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2013-04-18 17:57:03 -0700
committerKenny Root <kroot@google.com>2013-04-18 18:34:58 -0700
commit1c219f619291ba818bc2542390a2988539d94ed0 (patch)
treef9b17839a23ca3978cea2251767b4432d1d1f9a6 /keystore/tests
parenta454c5732cacffdda53ae277b1e43d87b43044b1 (diff)
downloadframeworks_base-1c219f619291ba818bc2542390a2988539d94ed0.zip
frameworks_base-1c219f619291ba818bc2542390a2988539d94ed0.tar.gz
frameworks_base-1c219f619291ba818bc2542390a2988539d94ed0.tar.bz2
Rename API AndroidKey* -> Key*
Bug: 8657552 Change-Id: Id9102b7c2c2f6d27fba7645f0629750cfe1eb510
Diffstat (limited to 'keystore/tests')
-rw-r--r--keystore/tests/src/android/security/AndroidKeyPairGeneratorTest.java18
-rw-r--r--keystore/tests/src/android/security/AndroidKeyStoreTest.java14
-rw-r--r--keystore/tests/src/android/security/KeyPairGeneratorSpecTest.java (renamed from keystore/tests/src/android/security/AndroidKeyPairGeneratorSpecTest.java)22
3 files changed, 28 insertions, 26 deletions
diff --git a/keystore/tests/src/android/security/AndroidKeyPairGeneratorTest.java b/keystore/tests/src/android/security/AndroidKeyPairGeneratorTest.java
index c5cf514..1582f74 100644
--- a/keystore/tests/src/android/security/AndroidKeyPairGeneratorTest.java
+++ b/keystore/tests/src/android/security/AndroidKeyPairGeneratorTest.java
@@ -65,7 +65,7 @@ public class AndroidKeyPairGeneratorTest extends AndroidTestCase {
assertFalse(mAndroidKeyStore.isUnlocked());
- mGenerator = java.security.KeyPairGenerator.getInstance("AndroidKeyStore");
+ mGenerator = java.security.KeyPairGenerator.getInstance("RSA", "AndroidKeyStore");
}
private void setupPassword() {
@@ -80,7 +80,7 @@ public class AndroidKeyPairGeneratorTest extends AndroidTestCase {
public void testKeyPairGenerator_Initialize_Params_Encrypted_Success() throws Exception {
setupPassword();
- mGenerator.initialize(new AndroidKeyPairGeneratorSpec.Builder(getContext())
+ mGenerator.initialize(new KeyPairGeneratorSpec.Builder(getContext())
.setAlias(TEST_ALIAS_1)
.setSubject(TEST_DN_1)
.setSerialNumber(TEST_SERIAL_1)
@@ -116,7 +116,7 @@ public class AndroidKeyPairGeneratorTest extends AndroidTestCase {
setupPassword();
mGenerator.initialize(
- new AndroidKeyPairGeneratorSpec.Builder(getContext())
+ new KeyPairGeneratorSpec.Builder(getContext())
.setAlias(TEST_ALIAS_1)
.setSubject(TEST_DN_1)
.setSerialNumber(TEST_SERIAL_1)
@@ -130,7 +130,7 @@ public class AndroidKeyPairGeneratorTest extends AndroidTestCase {
public void testKeyPairGenerator_GenerateKeyPair_Encrypted_Success() throws Exception {
setupPassword();
- mGenerator.initialize(new AndroidKeyPairGeneratorSpec.Builder(getContext())
+ mGenerator.initialize(new KeyPairGeneratorSpec.Builder(getContext())
.setAlias(TEST_ALIAS_1)
.setSubject(TEST_DN_1)
.setSerialNumber(TEST_SERIAL_1)
@@ -146,7 +146,7 @@ public class AndroidKeyPairGeneratorTest extends AndroidTestCase {
}
public void testKeyPairGenerator_GenerateKeyPair_Unencrypted_Success() throws Exception {
- mGenerator.initialize(new AndroidKeyPairGeneratorSpec.Builder(getContext())
+ mGenerator.initialize(new KeyPairGeneratorSpec.Builder(getContext())
.setAlias(TEST_ALIAS_1)
.setSubject(TEST_DN_1)
.setSerialNumber(TEST_SERIAL_1)
@@ -163,7 +163,7 @@ public class AndroidKeyPairGeneratorTest extends AndroidTestCase {
public void testKeyPairGenerator_GenerateKeyPair_Replaced_Success() throws Exception {
// Generate the first key
{
- mGenerator.initialize(new AndroidKeyPairGeneratorSpec.Builder(getContext())
+ mGenerator.initialize(new KeyPairGeneratorSpec.Builder(getContext())
.setAlias(TEST_ALIAS_1)
.setSubject(TEST_DN_1)
.setSerialNumber(TEST_SERIAL_1)
@@ -178,7 +178,7 @@ public class AndroidKeyPairGeneratorTest extends AndroidTestCase {
// Replace the original key
{
- mGenerator.initialize(new AndroidKeyPairGeneratorSpec.Builder(getContext())
+ mGenerator.initialize(new KeyPairGeneratorSpec.Builder(getContext())
.setAlias(TEST_ALIAS_2)
.setSubject(TEST_DN_2)
.setSerialNumber(TEST_SERIAL_2)
@@ -196,7 +196,7 @@ public class AndroidKeyPairGeneratorTest extends AndroidTestCase {
throws Exception {
// Generate the first key
{
- mGenerator.initialize(new AndroidKeyPairGeneratorSpec.Builder(getContext())
+ mGenerator.initialize(new KeyPairGeneratorSpec.Builder(getContext())
.setAlias(TEST_ALIAS_1)
.setSubject(TEST_DN_1)
.setSerialNumber(TEST_SERIAL_1)
@@ -211,7 +211,7 @@ public class AndroidKeyPairGeneratorTest extends AndroidTestCase {
// Attempt to replace previous key
{
- mGenerator.initialize(new AndroidKeyPairGeneratorSpec.Builder(getContext())
+ mGenerator.initialize(new KeyPairGeneratorSpec.Builder(getContext())
.setAlias(TEST_ALIAS_1)
.setSubject(TEST_DN_2)
.setSerialNumber(TEST_SERIAL_2)
diff --git a/keystore/tests/src/android/security/AndroidKeyStoreTest.java b/keystore/tests/src/android/security/AndroidKeyStoreTest.java
index 507d41c..8798fb5 100644
--- a/keystore/tests/src/android/security/AndroidKeyStoreTest.java
+++ b/keystore/tests/src/android/security/AndroidKeyStoreTest.java
@@ -1232,8 +1232,8 @@ public class AndroidKeyStoreTest extends AndroidTestCase {
try {
mKeyStore.setEntry(TEST_ALIAS_1, entry,
- new AndroidKeyStoreParameter.Builder(getContext())
- .setEncryptionRequired()
+ new KeyStoreParameter.Builder(getContext())
+ .setEncryptionRequired(true)
.build());
fail("Shouldn't be able to insert encrypted entry when KeyStore uninitialized");
} catch (KeyStoreException expected) {
@@ -1752,8 +1752,10 @@ public class AndroidKeyStoreTest extends AndroidTestCase {
Entry entry = mKeyStore.getEntry(TEST_ALIAS_1, null);
try {
- mKeyStore.setEntry(TEST_ALIAS_1, entry, new AndroidKeyStoreParameter.Builder(
- getContext()).setEncryptionRequired().build());
+ mKeyStore.setEntry(TEST_ALIAS_1, entry,
+ new KeyStoreParameter.Builder(getContext())
+ .setEncryptionRequired(true)
+ .build());
fail("Should not allow setting of Entry without unlocked keystore");
} catch (KeyStoreException success) {
}
@@ -1762,8 +1764,8 @@ public class AndroidKeyStoreTest extends AndroidTestCase {
assertTrue(mAndroidKeyStore.isUnlocked());
mKeyStore.setEntry(TEST_ALIAS_1, entry,
- new AndroidKeyStoreParameter.Builder(getContext())
- .setEncryptionRequired()
+ new KeyStoreParameter.Builder(getContext())
+ .setEncryptionRequired(true)
.build());
}
}
diff --git a/keystore/tests/src/android/security/AndroidKeyPairGeneratorSpecTest.java b/keystore/tests/src/android/security/KeyPairGeneratorSpecTest.java
index 5d4ab9c..113d730 100644
--- a/keystore/tests/src/android/security/AndroidKeyPairGeneratorSpecTest.java
+++ b/keystore/tests/src/android/security/KeyPairGeneratorSpecTest.java
@@ -23,7 +23,7 @@ import java.util.Date;
import javax.security.auth.x500.X500Principal;
-public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
+public class KeyPairGeneratorSpecTest extends AndroidTestCase {
private static final String TEST_ALIAS_1 = "test1";
private static final X500Principal TEST_DN_1 = new X500Principal("CN=test1");
@@ -39,8 +39,8 @@ public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
private static final Date NOW_PLUS_10_YEARS = new Date(NOW.getYear() + 10, 0, 1);
public void testConstructor_Success() throws Exception {
- AndroidKeyPairGeneratorSpec spec =
- new AndroidKeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, SERIAL_1,
+ KeyPairGeneratorSpec spec =
+ new KeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, SERIAL_1,
NOW, NOW_PLUS_10_YEARS, 0);
assertEquals("Context should be the one specified", getContext(), spec.getContext());
@@ -55,7 +55,7 @@ public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
}
public void testBuilder_Success() throws Exception {
- AndroidKeyPairGeneratorSpec spec = new AndroidKeyPairGeneratorSpec.Builder(getContext())
+ KeyPairGeneratorSpec spec = new KeyPairGeneratorSpec.Builder(getContext())
.setAlias(TEST_ALIAS_1)
.setSubject(TEST_DN_1)
.setSerialNumber(SERIAL_1)
@@ -79,7 +79,7 @@ public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
public void testConstructor_NullContext_Failure() throws Exception {
try {
- new AndroidKeyPairGeneratorSpec(null, TEST_ALIAS_1, TEST_DN_1, SERIAL_1, NOW,
+ new KeyPairGeneratorSpec(null, TEST_ALIAS_1, TEST_DN_1, SERIAL_1, NOW,
NOW_PLUS_10_YEARS, 0);
fail("Should throw IllegalArgumentException when context is null");
} catch (IllegalArgumentException success) {
@@ -88,7 +88,7 @@ public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
public void testConstructor_NullKeystoreAlias_Failure() throws Exception {
try {
- new AndroidKeyPairGeneratorSpec(getContext(), null, TEST_DN_1, SERIAL_1, NOW,
+ new KeyPairGeneratorSpec(getContext(), null, TEST_DN_1, SERIAL_1, NOW,
NOW_PLUS_10_YEARS, 0);
fail("Should throw IllegalArgumentException when keystoreAlias is null");
} catch (IllegalArgumentException success) {
@@ -97,7 +97,7 @@ public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
public void testConstructor_NullSubjectDN_Failure() throws Exception {
try {
- new AndroidKeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, null, SERIAL_1, NOW,
+ new KeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, null, SERIAL_1, NOW,
NOW_PLUS_10_YEARS, 0);
fail("Should throw IllegalArgumentException when subjectDN is null");
} catch (IllegalArgumentException success) {
@@ -106,7 +106,7 @@ public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
public void testConstructor_NullSerial_Failure() throws Exception {
try {
- new AndroidKeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, null, NOW,
+ new KeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, null, NOW,
NOW_PLUS_10_YEARS, 0);
fail("Should throw IllegalArgumentException when startDate is null");
} catch (IllegalArgumentException success) {
@@ -115,7 +115,7 @@ public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
public void testConstructor_NullStartDate_Failure() throws Exception {
try {
- new AndroidKeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, SERIAL_1, null,
+ new KeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, SERIAL_1, null,
NOW_PLUS_10_YEARS, 0);
fail("Should throw IllegalArgumentException when startDate is null");
} catch (IllegalArgumentException success) {
@@ -124,7 +124,7 @@ public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
public void testConstructor_NullEndDate_Failure() throws Exception {
try {
- new AndroidKeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, SERIAL_1, NOW,
+ new KeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, SERIAL_1, NOW,
null, 0);
fail("Should throw IllegalArgumentException when keystoreAlias is null");
} catch (IllegalArgumentException success) {
@@ -133,7 +133,7 @@ public class AndroidKeyPairGeneratorSpecTest extends AndroidTestCase {
public void testConstructor_EndBeforeStart_Failure() throws Exception {
try {
- new AndroidKeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, SERIAL_1,
+ new KeyPairGeneratorSpec(getContext(), TEST_ALIAS_1, TEST_DN_1, SERIAL_1,
NOW_PLUS_10_YEARS, NOW, 0);
fail("Should throw IllegalArgumentException when end is before start");
} catch (IllegalArgumentException success) {