use of org.sorz.lab.tinykeepass.auth.SecureStringStorage in project TinyKeePass by sorz.
the class BaseActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
preferences = PreferenceManager.getDefaultSharedPreferences(this);
keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
try {
secureStringStorage = new SecureStringStorage(this);
} catch (SecureStringStorage.SystemException e) {
throw new RuntimeException(e);
}
}
use of org.sorz.lab.tinykeepass.auth.SecureStringStorage in project TinyKeePass by sorz.
the class DatabaseSetupActivity method saveDatabaseConfigs.
private void saveDatabaseConfigs() {
preferences.edit().putString(PREF_DB_URL, editDatabaseUrl.getText().toString()).putString(PREF_DB_AUTH_USERNAME, editAuthUsername.getText().toString()).putBoolean(PREF_DB_AUTH_REQUIRED, checkBasicAuth.isChecked()).putInt(PREF_KEY_AUTH_METHOD, spinnerAuthMethod.getSelectedItemPosition()).apply();
if (secureStringStorage == null) {
try {
secureStringStorage = new SecureStringStorage(this);
} catch (SecureStringStorage.SystemException e) {
throw new RuntimeException("cannot get SecureStringStorage", e);
}
}
try {
switch(spinnerAuthMethod.getSelectedItemPosition()) {
case AUTH_METHOD_NONE:
secureStringStorage.generateNewKey(false, -1);
saveKeys(null);
break;
case AUTH_METHOD_SCREEN_LOCK:
secureStringStorage.generateNewKey(true, 60);
Intent intent = keyguardManager.createConfirmDeviceCredentialIntent(getString(R.string.auth_key_title), getString(R.string.auth_key_description));
startActivityForResult(intent, REQUEST_CONFIRM_DEVICE_CREDENTIAL);
break;
case AUTH_METHOD_FINGERPRINT:
secureStringStorage.generateNewKey(true, -1);
requestFingerprintToSaveKeys();
break;
}
} catch (SecureStringStorage.SystemException e) {
throw new RuntimeException("cannot generate new key", e);
}
}
Aggregations