summaryrefslogtreecommitdiff
path: root/keystore/java/android/security/Credentials.java
diff options
context:
space:
mode:
authorRobin Lee <rgl@google.com>2016-02-29 17:43:54 +0000
committerRobin Lee <rgl@google.com>2016-03-01 18:56:14 +0000
commite4487ea288e9fea837995d9bc4608c8a4a253ec8 (patch)
treedca512b8025bfdc8d858ceec8964ebb040b34055 /keystore/java/android/security/Credentials.java
parent42d8b7d7abe4ecab049e020c3836dae97660dd4d (diff)
More sensible return code for Credentials.deleteAll
Was: result = True iff nDeleted != 0 Now: result = True iff nDeleted == nExisted The most common reason you'd want to delete all credentials under an alias is to be sure they no longer exist. The new contract gives a way to do this without multiple IPCs to the same service. Bug: 27335182 Change-Id: I8762b9b4fcc48037387dd805dbd0dbbe141d5b24
Diffstat (limited to 'keystore/java/android/security/Credentials.java')
-rw-r--r--keystore/java/android/security/Credentials.java36
1 files changed, 18 insertions, 18 deletions
diff --git a/keystore/java/android/security/Credentials.java b/keystore/java/android/security/Credentials.java
index 302b0bd73065..6830a7487dbc 100644
--- a/keystore/java/android/security/Credentials.java
+++ b/keystore/java/android/security/Credentials.java
@@ -217,42 +217,42 @@ public class Credentials {
}
/**
- * Delete all types (private key, certificate, CA certificate) for a
+ * Delete all types (private key, user certificate, CA certificate) for a
* particular {@code alias}. All three can exist for any given alias.
- * Returns {@code true} if there was at least one of those types.
+ * Returns {@code true} if the alias no longer contains any types.
*/
public static boolean deleteAllTypesForAlias(KeyStore keystore, String alias) {
return deleteAllTypesForAlias(keystore, alias, KeyStore.UID_SELF);
}
/**
- * Delete all types (private key, certificate, CA certificate) for a
+ * Delete all types (private key, user certificate, CA certificate) for a
* particular {@code alias}. All three can exist for any given alias.
- * Returns {@code true} if there was at least one of those types.
+ * Returns {@code true} if the alias no longer contains any types.
*/
public static boolean deleteAllTypesForAlias(KeyStore keystore, String alias, int uid) {
/*
* Make sure every type is deleted. There can be all three types, so
* don't use a conditional here.
*/
- return keystore.delete(Credentials.USER_PRIVATE_KEY + alias, uid)
- | keystore.delete(Credentials.USER_SECRET_KEY + alias, uid)
- | deleteCertificateTypesForAlias(keystore, alias, uid);
+ return deletePrivateKeyTypeForAlias(keystore, alias, uid)
+ & deleteSecretKeyTypeForAlias(keystore, alias, uid)
+ & deleteCertificateTypesForAlias(keystore, alias, uid);
}
/**
- * Delete all types (private key, certificate, CA certificate) for a
- * particular {@code alias}. All three can exist for any given alias.
- * Returns {@code true} if there was at least one of those types.
+ * Delete certificate types (user certificate, CA certificate) for a
+ * particular {@code alias}. Both can exist for any given alias.
+ * Returns {@code true} if the alias no longer contains either type.
*/
public static boolean deleteCertificateTypesForAlias(KeyStore keystore, String alias) {
return deleteCertificateTypesForAlias(keystore, alias, KeyStore.UID_SELF);
}
/**
- * Delete all types (private key, certificate, CA certificate) for a
- * particular {@code alias}. All three can exist for any given alias.
- * Returns {@code true} if there was at least one of those types.
+ * Delete certificate types (user certificate, CA certificate) for a
+ * particular {@code alias}. Both can exist for any given alias.
+ * Returns {@code true} if the alias no longer contains either type.
*/
public static boolean deleteCertificateTypesForAlias(KeyStore keystore, String alias, int uid) {
/*
@@ -260,12 +260,12 @@ public class Credentials {
* so don't use a conditional here.
*/
return keystore.delete(Credentials.USER_CERTIFICATE + alias, uid)
- | keystore.delete(Credentials.CA_CERTIFICATE + alias, uid);
+ & keystore.delete(Credentials.CA_CERTIFICATE + alias, uid);
}
/**
* Delete private key for a particular {@code alias}.
- * Returns {@code true} if an entry was was deleted.
+ * Returns {@code true} if the entry no longer exists.
*/
static boolean deletePrivateKeyTypeForAlias(KeyStore keystore, String alias) {
return deletePrivateKeyTypeForAlias(keystore, alias, KeyStore.UID_SELF);
@@ -273,7 +273,7 @@ public class Credentials {
/**
* Delete private key for a particular {@code alias}.
- * Returns {@code true} if an entry was was deleted.
+ * Returns {@code true} if the entry no longer exists.
*/
static boolean deletePrivateKeyTypeForAlias(KeyStore keystore, String alias, int uid) {
return keystore.delete(Credentials.USER_PRIVATE_KEY + alias, uid);
@@ -281,7 +281,7 @@ public class Credentials {
/**
* Delete secret key for a particular {@code alias}.
- * Returns {@code true} if an entry was was deleted.
+ * Returns {@code true} if the entry no longer exists.
*/
public static boolean deleteSecretKeyTypeForAlias(KeyStore keystore, String alias) {
return deleteSecretKeyTypeForAlias(keystore, alias, KeyStore.UID_SELF);
@@ -289,7 +289,7 @@ public class Credentials {
/**
* Delete secret key for a particular {@code alias}.
- * Returns {@code true} if an entry was was deleted.
+ * Returns {@code true} if the entry no longer exists.
*/
public static boolean deleteSecretKeyTypeForAlias(KeyStore keystore, String alias, int uid) {
return keystore.delete(Credentials.USER_SECRET_KEY + alias, uid);