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