mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-11-25 19:41:34 -08:00
Remove biometric link if change credential
This commit is contained in:
1 parent
8c0d7ab9ed
commit
d97a85b997
6 files changed
+48
-33
No files matched your search
+6
@@ -21,12 +21,14 @@ package com.kunzisoft.keepass.database.action
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import com.kunzisoft.keepass.app.database.CipherDatabaseAction
|
||||
import com.kunzisoft.keepass.database.element.Database
|
||||
import com.kunzisoft.keepass.utils.UriUtil
|
||||
|
||||
open class AssignPasswordInDatabaseRunnable (
|
||||
context: Context,
|
||||
database: Database,
|
||||
protected val mDatabaseUri: Uri,
|
||||
withMasterPassword: Boolean,
|
||||
masterPassword: String?,
|
||||
withKeyFile: Boolean,
|
||||
@@ -66,6 +68,10 @@ open class AssignPasswordInDatabaseRunnable (
|
||||
override fun onFinishRun() {
|
||||
super.onFinishRun()
|
||||
|
||||
// Erase the biometric
|
||||
CipherDatabaseAction.getInstance(context)
|
||||
.deleteByDatabaseUri(mDatabaseUri)
|
||||
|
||||
if (!result.isSuccess) {
|
||||
// Erase the current master key
|
||||
erase(database.masterKey)
|
||||
|
||||
@@ -26,14 +26,14 @@ import com.kunzisoft.keepass.app.database.FileDatabaseHistoryAction
|
||||
import com.kunzisoft.keepass.database.element.Database
|
||||
|
||||
class CreateDatabaseRunnable(context: Context,
|
||||
private val mDatabaseUri: Uri,
|
||||
private val mDatabase: Database,
|
||||
databaseUri: Uri,
|
||||
withMasterPassword: Boolean,
|
||||
masterPassword: String?,
|
||||
withKeyFile: Boolean,
|
||||
keyFile: Uri?,
|
||||
save: Boolean)
|
||||
: AssignPasswordInDatabaseRunnable(context, mDatabase, withMasterPassword, masterPassword, withKeyFile, keyFile, save) {
|
||||
: AssignPasswordInDatabaseRunnable(context, mDatabase, databaseUri, withMasterPassword, masterPassword, withKeyFile, keyFile, save) {
|
||||
|
||||
override fun onStartRun() {
|
||||
try {
|
||||
|
||||
@@ -228,12 +228,14 @@ class ProgressDialogThread(private val activity: FragmentActivity,
|
||||
, ACTION_DATABASE_LOAD_TASK)
|
||||
}
|
||||
|
||||
fun startDatabaseAssignPassword(masterPasswordChecked: Boolean,
|
||||
fun startDatabaseAssignPassword(databaseUri: Uri,
|
||||
masterPasswordChecked: Boolean,
|
||||
masterPassword: String?,
|
||||
keyFileChecked: Boolean,
|
||||
keyFile: Uri?) {
|
||||
|
||||
start(Bundle().apply {
|
||||
putParcelable(DatabaseTaskNotificationService.DATABASE_URI_KEY, databaseUri)
|
||||
putBoolean(DatabaseTaskNotificationService.MASTER_PASSWORD_CHECKED_KEY, masterPasswordChecked)
|
||||
putString(DatabaseTaskNotificationService.MASTER_PASSWORD_KEY, masterPassword)
|
||||
putBoolean(DatabaseTaskNotificationService.KEY_FILE_CHECKED_KEY, keyFileChecked)
|
||||
|
||||
@@ -53,7 +53,9 @@ class Database {
|
||||
private var pwDatabaseV3: PwDatabaseV3? = null
|
||||
private var pwDatabaseV4: PwDatabaseV4? = null
|
||||
|
||||
private var mUri: Uri? = null
|
||||
var fileUri: Uri? = null
|
||||
private set
|
||||
|
||||
private var mSearchHelper: SearchDbHelper? = null
|
||||
|
||||
var isReadOnly = false
|
||||
@@ -283,7 +285,7 @@ class Database {
|
||||
fun createData(databaseUri: Uri) {
|
||||
// Always create a new database with the last version
|
||||
setDatabaseV4(PwDatabaseV4(dbNameFromUri(databaseUri)))
|
||||
this.mUri = databaseUri
|
||||
this.fileUri = databaseUri
|
||||
}
|
||||
|
||||
@Throws(LoadDatabaseException::class)
|
||||
@@ -295,7 +297,7 @@ class Database {
|
||||
fixDuplicateUUID: Boolean,
|
||||
progressTaskUpdater: ProgressTaskUpdater?) {
|
||||
|
||||
mUri = uri
|
||||
this.fileUri = uri
|
||||
isReadOnly = readOnly
|
||||
if (uri.scheme == "file") {
|
||||
val file = File(uri.path!!)
|
||||
@@ -425,7 +427,7 @@ class Database {
|
||||
|
||||
@Throws(IOException::class, DatabaseOutputException::class)
|
||||
fun saveData(contentResolver: ContentResolver) {
|
||||
mUri?.let {
|
||||
this.fileUri?.let {
|
||||
saveData(contentResolver, it)
|
||||
}
|
||||
}
|
||||
@@ -477,7 +479,7 @@ class Database {
|
||||
outputStream?.close()
|
||||
}
|
||||
}
|
||||
mUri = uri
|
||||
this.fileUri = uri
|
||||
}
|
||||
|
||||
// TODO Clear database when lock broadcast is receive in backstage
|
||||
@@ -493,10 +495,10 @@ class Database {
|
||||
Log.e(TAG, "Unable to clear the directory cache.", e)
|
||||
}
|
||||
|
||||
pwDatabaseV3 = null
|
||||
pwDatabaseV4 = null
|
||||
mUri = null
|
||||
loaded = false
|
||||
this.pwDatabaseV3 = null
|
||||
this.pwDatabaseV4 = null
|
||||
this.fileUri = null
|
||||
this.loaded = false
|
||||
}
|
||||
|
||||
fun validatePasswordEncoding(password: String?, containsKeyFile: Boolean): Boolean {
|
||||
|
||||
+4
-2
@@ -177,8 +177,8 @@ class DatabaseTaskNotificationService : NotificationService(), ProgressTaskUpdat
|
||||
val databaseUri: Uri = intent.getParcelableExtra(DATABASE_URI_KEY)
|
||||
val keyFileUri: Uri? = intent.getParcelableExtra(KEY_FILE_KEY)
|
||||
return CreateDatabaseRunnable(this,
|
||||
databaseUri,
|
||||
Database.getInstance(),
|
||||
databaseUri,
|
||||
intent.getBooleanExtra(MASTER_PASSWORD_CHECKED_KEY, false),
|
||||
intent.getStringExtra(MASTER_PASSWORD_KEY),
|
||||
intent.getBooleanExtra(KEY_FILE_CHECKED_KEY, false),
|
||||
@@ -233,13 +233,15 @@ class DatabaseTaskNotificationService : NotificationService(), ProgressTaskUpdat
|
||||
}
|
||||
|
||||
private fun buildDatabaseAssignPasswordActionTask(intent: Intent): ActionRunnable? {
|
||||
return if (intent.hasExtra(MASTER_PASSWORD_CHECKED_KEY)
|
||||
return if (intent.hasExtra(DATABASE_URI_KEY)
|
||||
&& intent.hasExtra(MASTER_PASSWORD_CHECKED_KEY)
|
||||
&& intent.hasExtra(MASTER_PASSWORD_KEY)
|
||||
&& intent.hasExtra(KEY_FILE_CHECKED_KEY)
|
||||
&& intent.hasExtra(KEY_FILE_KEY)
|
||||
) {
|
||||
AssignPasswordInDatabaseRunnable(this,
|
||||
Database.getInstance(),
|
||||
intent.getParcelableExtra<Uri>(DATABASE_URI_KEY),
|
||||
intent.getBooleanExtra(MASTER_PASSWORD_CHECKED_KEY, false),
|
||||
intent.getStringExtra(MASTER_PASSWORD_KEY),
|
||||
intent.getBooleanExtra(KEY_FILE_CHECKED_KEY, false),
|
||||
|
||||
@@ -129,25 +129,29 @@ open class SettingsActivity
|
||||
keyFileChecked: Boolean,
|
||||
keyFile: Uri?) {
|
||||
Database.getInstance().let { database ->
|
||||
// Show the progress dialog now or after dialog confirmation
|
||||
if (database.validatePasswordEncoding(masterPassword, keyFileChecked)) {
|
||||
progressDialogThread?.startDatabaseAssignPassword(
|
||||
masterPasswordChecked,
|
||||
masterPassword,
|
||||
keyFileChecked,
|
||||
keyFile
|
||||
)
|
||||
} else {
|
||||
PasswordEncodingDialogFragment().apply {
|
||||
positiveButtonClickListener = DialogInterface.OnClickListener { _, _ ->
|
||||
progressDialogThread?.startDatabaseAssignPassword(
|
||||
masterPasswordChecked,
|
||||
masterPassword,
|
||||
keyFileChecked,
|
||||
keyFile
|
||||
)
|
||||
database.fileUri?.let { databaseUri ->
|
||||
// Show the progress dialog now or after dialog confirmation
|
||||
if (database.validatePasswordEncoding(masterPassword, keyFileChecked)) {
|
||||
progressDialogThread?.startDatabaseAssignPassword(
|
||||
databaseUri,
|
||||
masterPasswordChecked,
|
||||
masterPassword,
|
||||
keyFileChecked,
|
||||
keyFile
|
||||
)
|
||||
} else {
|
||||
PasswordEncodingDialogFragment().apply {
|
||||
positiveButtonClickListener = DialogInterface.OnClickListener { _, _ ->
|
||||
progressDialogThread?.startDatabaseAssignPassword(
|
||||
databaseUri,
|
||||
masterPasswordChecked,
|
||||
masterPassword,
|
||||
keyFileChecked,
|
||||
keyFile
|
||||
)
|
||||
}
|
||||
show(supportFragmentManager, "passwordEncodingTag")
|
||||
}
|
||||
show(supportFragmentManager, "passwordEncodingTag")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -157,7 +161,6 @@ open class SettingsActivity
|
||||
masterPassword: String?,
|
||||
keyFileChecked: Boolean,
|
||||
keyFile: Uri?) {
|
||||
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
||||
Reference in new issue
Block a user