Search in sources :

Example 1 with UserNotAuthenticatedException

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;
    }
}
Also used : SecureStringStorage(org.sorz.lab.tinykeepass.auth.SecureStringStorage) UserNotAuthenticatedException(android.security.keystore.UserNotAuthenticatedException) Intent(android.content.Intent) Cipher(javax.crypto.Cipher) KeyException(java.security.KeyException)

Aggregations

Intent (android.content.Intent)1 UserNotAuthenticatedException (android.security.keystore.UserNotAuthenticatedException)1 KeyException (java.security.KeyException)1 Cipher (javax.crypto.Cipher)1 SecureStringStorage (org.sorz.lab.tinykeepass.auth.SecureStringStorage)1