summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ricky Wai <rickywai@google.com> 2016-11-18 01:52:08 +0000
committer android-build-merger <android-build-merger@google.com> 2016-11-18 01:52:08 +0000
commita79a655e4b97d204c220d20ad5352e48d261afd5 (patch)
tree5ff9d08eb6ede273524e41207d52ad3e35b34423
parent428d4847d4ab5ee69f17c69c9b3375fe6d885f50 (diff)
parentb5ddc22675ac8a41b18d3a1fa09a253082312ab5 (diff)
Catch KeyStoreException for setting profile lock am: c8fa5ed8f2 am: 3b546019dc am: c40b9a8ee2
am: b5ddc22675 Change-Id: Idc10bc9e849e4f5d23bba8ee33a7caf72626428b
-rw-r--r--services/core/java/com/android/server/LockSettingsService.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/LockSettingsService.java b/services/core/java/com/android/server/LockSettingsService.java
index 67014314595f..f4ddc06d381c 100644
--- a/services/core/java/com/android/server/LockSettingsService.java
+++ b/services/core/java/com/android/server/LockSettingsService.java
@@ -249,13 +249,16 @@ public class LockSettingsService extends ILockSettings.Stub {
try {
randomLockSeed = SecureRandom.getInstance("SHA1PRNG").generateSeed(40);
String newPassword = String.valueOf(HexEncoding.encode(randomLockSeed));
+ tieProfileLockToParent(managedUserId, newPassword);
setLockPasswordInternal(newPassword, managedUserPassword, managedUserId);
// We store a private credential for the managed user that's unlocked by the primary
// account holder's credential. As such, the user will never be prompted to enter this
// password directly, so we always store a password.
setLong(LockPatternUtils.PASSWORD_TYPE_KEY,
DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC, managedUserId);
- tieProfileLockToParent(managedUserId, newPassword);
+ } catch (KeyStoreException e) {
+ // Bug: 32490092
+ Slog.e(TAG, "Not able to set keys to keystore", e);
} catch (NoSuchAlgorithmException | RemoteException e) {
Slog.e(TAG, "Fail to tie managed profile", e);
// Nothing client can do to fix this issue, so we do not throw exception out
@@ -776,6 +779,7 @@ public class LockSettingsService extends ILockSettings.Stub {
}
private void unlockChildProfile(int profileHandle) throws RemoteException {
+ if (DEBUG) Slog.v(TAG, "Unlock child profile");
try {
doVerifyPassword(getDecryptedPasswordForTiedProfile(profileHandle), false,
0 /* no challenge */, profileHandle, null /* progressCallback */);
@@ -1035,7 +1039,7 @@ public class LockSettingsService extends ILockSettings.Stub {
}
}
- private void tieProfileLockToParent(int userId, String password) {
+ private void tieProfileLockToParent(int userId, String password) throws KeyStoreException {
if (DEBUG) Slog.v(TAG, "tieProfileLockToParent for user: " + userId);
byte[] randomLockSeed = password.getBytes(StandardCharsets.UTF_8);
byte[] encryptionResult;
@@ -1077,7 +1081,7 @@ public class LockSettingsService extends ILockSettings.Stub {
keyStore.deleteEntry(LockPatternUtils.PROFILE_KEY_NAME_ENCRYPT + userId);
}
} catch (CertificateException | UnrecoverableKeyException
- | IOException | BadPaddingException | IllegalBlockSizeException | KeyStoreException
+ | IOException | BadPaddingException | IllegalBlockSizeException
| NoSuchPaddingException | NoSuchAlgorithmException | InvalidKeyException e) {
throw new RuntimeException("Failed to encrypt key", e);
}
@@ -1219,7 +1223,11 @@ public class LockSettingsService extends ILockSettings.Stub {
} finally {
if (managedUserId != -1 && managedUserDecryptedPassword != null) {
if (DEBUG) Slog.v(TAG, "Restore tied profile lock");
- tieProfileLockToParent(managedUserId, managedUserDecryptedPassword);
+ try {
+ tieProfileLockToParent(managedUserId, managedUserDecryptedPassword);
+ } catch (KeyStoreException e) {
+ throw new RuntimeException("Failed to tie profile lock", e);
+ }
}
}
}