Expose e.getMessage() from the exceptions in RecoverableKeyStore

Bug: 77327780
Test: runtest frameworks-services -p \
      com.android.server.locksettings.recoverablekeystore

Change-Id: Ibf04d6405e6468bfdfef0a8cb8e6e96bffbbf3a2
This commit is contained in:
Bo Zhu
2018-03-30 12:20:06 -07:00
parent ae202c6fda
commit 41d2dd2f26
4 changed files with 17 additions and 21 deletions

View File

@@ -43,7 +43,7 @@ import java.util.Map;
/**
* Backs up cryptographic keys to remote secure hardware, encrypted with the user's lock screen.
*
* <p>A system app with the {@link android.Manifest#RECOVER_KEYSTORE} permission may generate or
* <p>A system app with the {@code android.permission.RECOVER_KEYSTORE} permission may generate or
* import recoverable keys using this class. To generate a key, the app must call
* {@link #generateKey(String)} with the desired alias for the key. This returns an AndroidKeyStore
* reference to a 256-bit {@link javax.crypto.SecretKey}, which can be used for AES/GCM/NoPadding.
@@ -292,7 +292,7 @@ public class RecoveryController {
} catch (ServiceSpecificException e) {
if (e.errorCode == ERROR_BAD_CERTIFICATE_FORMAT
|| e.errorCode == ERROR_INVALID_CERTIFICATE) {
throw new CertificateException(e.getMessage());
throw new CertificateException("Invalid certificate for recovery service", e);
}
throw wrapUnexpectedServiceSpecificException(e);
}
@@ -338,7 +338,7 @@ public class RecoveryController {
} catch (ServiceSpecificException e) {
if (e.errorCode == ERROR_BAD_CERTIFICATE_FORMAT
|| e.errorCode == ERROR_INVALID_CERTIFICATE) {
throw new CertificateException(e.getMessage());
throw new CertificateException("Invalid certificate for recovery service", e);
}
throw wrapUnexpectedServiceSpecificException(e);
}

View File

@@ -102,7 +102,7 @@ public class RecoverySession implements AutoCloseable {
} catch (ServiceSpecificException e) {
if (e.errorCode == RecoveryController.ERROR_BAD_CERTIFICATE_FORMAT
|| e.errorCode == RecoveryController.ERROR_INVALID_CERTIFICATE) {
throw new CertificateException(e.getMessage());
throw new CertificateException("Invalid certificate for recovery session", e);
}
throw mRecoveryController.wrapUnexpectedServiceSpecificException(e);
}
@@ -137,7 +137,7 @@ public class RecoverySession implements AutoCloseable {
} catch (ServiceSpecificException e) {
if (e.errorCode == RecoveryController.ERROR_BAD_CERTIFICATE_FORMAT
|| e.errorCode == RecoveryController.ERROR_INVALID_CERTIFICATE) {
throw new CertificateException(e.getMessage());
throw new CertificateException("Invalid certificate for recovery session", e);
}
throw mRecoveryController.wrapUnexpectedServiceSpecificException(e);
}
@@ -191,7 +191,7 @@ public class RecoverySession implements AutoCloseable {
} catch (ServiceSpecificException e) {
if (e.errorCode == RecoveryController.ERROR_BAD_CERTIFICATE_FORMAT
|| e.errorCode == RecoveryController.ERROR_INVALID_CERTIFICATE) {
throw new CertificateException(e.getMessage());
throw new CertificateException("Invalid certificate for recovery session", e);
}
throw mRecoveryController.wrapUnexpectedServiceSpecificException(e);
}