use of android.security.keystore.UserNotAuthenticatedException in project TinyKeePass by sorz.
the class BaseActivity method getKey.
private void getKey() {
int authMethod = preferences.getInt(PREF_KEY_AUTH_METHOD, AUTH_METHOD_UNDEFINED);
switch(authMethod) {
case AUTH_METHOD_UNDEFINED:
onKeyAuthFailed.accept(getString(R.string.broken_keys));
break;
case AUTH_METHOD_NONE:
case AUTH_METHOD_SCREEN_LOCK:
try {
Cipher cipher = secureStringStorage.getDecryptCipher();
decryptKey(cipher);
} catch (UserNotAuthenticatedException e) {
// should do authentication
Intent intent = keyguardManager.createConfirmDeviceCredentialIntent(getString(R.string.auth_key_title), getString(R.string.auth_key_description));
startActivityForResult(intent, REQUEST_CONFIRM_DEVICE_CREDENTIAL);
} catch (KeyException e) {
onKeyException(e);
} catch (SecureStringStorage.SystemException e) {
throw new RuntimeException(e);
}
break;
case DatabaseSetupActivity.AUTH_METHOD_FINGERPRINT:
getFragmentManager().beginTransaction().add(FingerprintDialogFragment.newInstance(Cipher.DECRYPT_MODE), "fingerprint").commit();
break;
}
}
Aggregations