Merge "Keystore 2.0: Fix getKey returns null on key not found." am: 2ced350043 am: d07d143e71
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1578023 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Ib908588b11a32b37871ac7e6f7af2e88fc7e887e
This commit is contained in:
@@ -352,14 +352,17 @@ public class AndroidKeyStoreProvider extends Provider {
|
|||||||
try {
|
try {
|
||||||
response = keyStore.getKeyEntry(descriptor);
|
response = keyStore.getKeyEntry(descriptor);
|
||||||
} catch (android.security.KeyStoreException e) {
|
} catch (android.security.KeyStoreException e) {
|
||||||
if (e.getErrorCode() == ResponseCode.KEY_PERMANENTLY_INVALIDATED) {
|
switch (e.getErrorCode()) {
|
||||||
throw new KeyPermanentlyInvalidatedException(
|
case ResponseCode.KEY_NOT_FOUND:
|
||||||
"User changed or deleted their auth credentials",
|
return null;
|
||||||
e);
|
case ResponseCode.KEY_PERMANENTLY_INVALIDATED:
|
||||||
} else {
|
throw new KeyPermanentlyInvalidatedException(
|
||||||
throw (UnrecoverableKeyException)
|
"User changed or deleted their auth credentials",
|
||||||
new UnrecoverableKeyException("Failed to obtain information about key")
|
e);
|
||||||
.initCause(e);
|
default:
|
||||||
|
throw (UnrecoverableKeyException)
|
||||||
|
new UnrecoverableKeyException("Failed to obtain information about key")
|
||||||
|
.initCause(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user