mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
first code to manage merge with yubikey
This commit is contained in:
34
Gemfile.lock
34
Gemfile.lock
@@ -8,8 +8,8 @@ GEM
|
|||||||
artifactory (3.0.15)
|
artifactory (3.0.15)
|
||||||
atomos (0.1.3)
|
atomos (0.1.3)
|
||||||
aws-eventstream (1.2.0)
|
aws-eventstream (1.2.0)
|
||||||
aws-partitions (1.626.0)
|
aws-partitions (1.646.0)
|
||||||
aws-sdk-core (3.140.0)
|
aws-sdk-core (3.160.0)
|
||||||
aws-eventstream (~> 1, >= 1.0.2)
|
aws-eventstream (~> 1, >= 1.0.2)
|
||||||
aws-partitions (~> 1, >= 1.525.0)
|
aws-partitions (~> 1, >= 1.525.0)
|
||||||
aws-sigv4 (~> 1.1)
|
aws-sigv4 (~> 1.1)
|
||||||
@@ -21,7 +21,7 @@ GEM
|
|||||||
aws-sdk-core (~> 3, >= 3.127.0)
|
aws-sdk-core (~> 3, >= 3.127.0)
|
||||||
aws-sdk-kms (~> 1)
|
aws-sdk-kms (~> 1)
|
||||||
aws-sigv4 (~> 1.4)
|
aws-sigv4 (~> 1.4)
|
||||||
aws-sigv4 (1.5.1)
|
aws-sigv4 (1.5.2)
|
||||||
aws-eventstream (~> 1, >= 1.0.2)
|
aws-eventstream (~> 1, >= 1.0.2)
|
||||||
babosa (1.0.4)
|
babosa (1.0.4)
|
||||||
claide (1.1.0)
|
claide (1.1.0)
|
||||||
@@ -36,7 +36,7 @@ GEM
|
|||||||
unf (>= 0.0.5, < 1.0.0)
|
unf (>= 0.0.5, < 1.0.0)
|
||||||
dotenv (2.8.1)
|
dotenv (2.8.1)
|
||||||
emoji_regex (3.2.3)
|
emoji_regex (3.2.3)
|
||||||
excon (0.92.4)
|
excon (0.93.0)
|
||||||
faraday (1.10.2)
|
faraday (1.10.2)
|
||||||
faraday-em_http (~> 1.0)
|
faraday-em_http (~> 1.0)
|
||||||
faraday-em_synchrony (~> 1.0)
|
faraday-em_synchrony (~> 1.0)
|
||||||
@@ -66,7 +66,7 @@ GEM
|
|||||||
faraday_middleware (1.2.0)
|
faraday_middleware (1.2.0)
|
||||||
faraday (~> 1.0)
|
faraday (~> 1.0)
|
||||||
fastimage (2.2.6)
|
fastimage (2.2.6)
|
||||||
fastlane (2.209.1)
|
fastlane (2.210.1)
|
||||||
CFPropertyList (>= 2.3, < 4.0.0)
|
CFPropertyList (>= 2.3, < 4.0.0)
|
||||||
addressable (>= 2.8, < 3.0.0)
|
addressable (>= 2.8, < 3.0.0)
|
||||||
artifactory (~> 3.0)
|
artifactory (~> 3.0)
|
||||||
@@ -107,9 +107,9 @@ GEM
|
|||||||
xcpretty-travis-formatter (>= 0.0.3)
|
xcpretty-travis-formatter (>= 0.0.3)
|
||||||
fastlane-plugin-versioning_android (0.1.0)
|
fastlane-plugin-versioning_android (0.1.0)
|
||||||
gh_inspector (1.1.3)
|
gh_inspector (1.1.3)
|
||||||
google-apis-androidpublisher_v3 (0.25.0)
|
google-apis-androidpublisher_v3 (0.29.0)
|
||||||
google-apis-core (>= 0.7, < 2.a)
|
google-apis-core (>= 0.9.0, < 2.a)
|
||||||
google-apis-core (0.7.0)
|
google-apis-core (0.9.0)
|
||||||
addressable (~> 2.5, >= 2.5.1)
|
addressable (~> 2.5, >= 2.5.1)
|
||||||
googleauth (>= 0.16.2, < 2.a)
|
googleauth (>= 0.16.2, < 2.a)
|
||||||
httpclient (>= 2.8.1, < 3.a)
|
httpclient (>= 2.8.1, < 3.a)
|
||||||
@@ -118,23 +118,23 @@ GEM
|
|||||||
retriable (>= 2.0, < 4.a)
|
retriable (>= 2.0, < 4.a)
|
||||||
rexml
|
rexml
|
||||||
webrick
|
webrick
|
||||||
google-apis-iamcredentials_v1 (0.13.0)
|
google-apis-iamcredentials_v1 (0.15.0)
|
||||||
google-apis-core (>= 0.7, < 2.a)
|
google-apis-core (>= 0.9.0, < 2.a)
|
||||||
google-apis-playcustomapp_v1 (0.10.0)
|
google-apis-playcustomapp_v1 (0.11.0)
|
||||||
google-apis-core (>= 0.7, < 2.a)
|
google-apis-core (>= 0.9.0, < 2.a)
|
||||||
google-apis-storage_v1 (0.17.0)
|
google-apis-storage_v1 (0.19.0)
|
||||||
google-apis-core (>= 0.7, < 2.a)
|
google-apis-core (>= 0.9.0, < 2.a)
|
||||||
google-cloud-core (1.6.0)
|
google-cloud-core (1.6.0)
|
||||||
google-cloud-env (~> 1.0)
|
google-cloud-env (~> 1.0)
|
||||||
google-cloud-errors (~> 1.0)
|
google-cloud-errors (~> 1.0)
|
||||||
google-cloud-env (1.6.0)
|
google-cloud-env (1.6.0)
|
||||||
faraday (>= 0.17.3, < 3.0)
|
faraday (>= 0.17.3, < 3.0)
|
||||||
google-cloud-errors (1.2.0)
|
google-cloud-errors (1.3.0)
|
||||||
google-cloud-storage (1.39.0)
|
google-cloud-storage (1.43.0)
|
||||||
addressable (~> 2.8)
|
addressable (~> 2.8)
|
||||||
digest-crc (~> 0.4)
|
digest-crc (~> 0.4)
|
||||||
google-apis-iamcredentials_v1 (~> 0.1)
|
google-apis-iamcredentials_v1 (~> 0.1)
|
||||||
google-apis-storage_v1 (~> 0.17.0)
|
google-apis-storage_v1 (~> 0.19.0)
|
||||||
google-cloud-core (~> 1.6)
|
google-cloud-core (~> 1.6)
|
||||||
googleauth (>= 0.16.2, < 2.a)
|
googleauth (>= 0.16.2, < 2.a)
|
||||||
mini_mime (~> 1.0)
|
mini_mime (~> 1.0)
|
||||||
|
|||||||
@@ -90,8 +90,8 @@ abstract class DatabaseLockActivity : DatabaseModeActivity(),
|
|||||||
mDatabaseTaskProvider?.startDatabaseSave(save)
|
mDatabaseTaskProvider?.startDatabaseSave(save)
|
||||||
}
|
}
|
||||||
|
|
||||||
mDatabaseViewModel.mergeDatabase.observe(this) {
|
mDatabaseViewModel.mergeDatabase.observe(this) { save ->
|
||||||
mDatabaseTaskProvider?.startDatabaseMerge()
|
mDatabaseTaskProvider?.startDatabaseMerge(save)
|
||||||
}
|
}
|
||||||
|
|
||||||
mDatabaseViewModel.reloadDatabase.observe(this) { fixDuplicateUuid ->
|
mDatabaseViewModel.reloadDatabase.observe(this) { fixDuplicateUuid ->
|
||||||
@@ -227,6 +227,9 @@ abstract class DatabaseLockActivity : DatabaseModeActivity(),
|
|||||||
// Reload the current activity
|
// Reload the current activity
|
||||||
if (result.isSuccess) {
|
if (result.isSuccess) {
|
||||||
reloadActivity()
|
reloadActivity()
|
||||||
|
if (actionTask == DatabaseTaskNotificationService.ACTION_DATABASE_MERGE_TASK) {
|
||||||
|
Toast.makeText(this, R.string.merge_success, Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.showActionErrorIfNeeded(result)
|
this.showActionErrorIfNeeded(result)
|
||||||
finish()
|
finish()
|
||||||
@@ -270,11 +273,11 @@ abstract class DatabaseLockActivity : DatabaseModeActivity(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun mergeDatabase() {
|
fun mergeDatabase() {
|
||||||
mDatabaseTaskProvider?.startDatabaseMerge()
|
mDatabaseTaskProvider?.startDatabaseMerge(mAutoSaveEnable)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mergeDatabaseFrom(uri: Uri, mainCredential: MainCredential) {
|
fun mergeDatabaseFrom(uri: Uri, mainCredential: MainCredential) {
|
||||||
mDatabaseTaskProvider?.startDatabaseMerge(uri, mainCredential)
|
mDatabaseTaskProvider?.startDatabaseMerge(mAutoSaveEnable, uri, mainCredential)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reloadDatabase() {
|
fun reloadDatabase() {
|
||||||
|
|||||||
@@ -412,9 +412,11 @@ class DatabaseTaskProvider {
|
|||||||
, ACTION_DATABASE_LOAD_TASK)
|
, ACTION_DATABASE_LOAD_TASK)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun startDatabaseMerge(fromDatabaseUri: Uri? = null,
|
fun startDatabaseMerge(save: Boolean,
|
||||||
|
fromDatabaseUri: Uri? = null,
|
||||||
mainCredential: MainCredential? = null) {
|
mainCredential: MainCredential? = null) {
|
||||||
start(Bundle().apply {
|
start(Bundle().apply {
|
||||||
|
putBoolean(DatabaseTaskNotificationService.SAVE_DATABASE_KEY, save)
|
||||||
putParcelable(DatabaseTaskNotificationService.DATABASE_URI_KEY, fromDatabaseUri)
|
putParcelable(DatabaseTaskNotificationService.DATABASE_URI_KEY, fromDatabaseUri)
|
||||||
putParcelable(DatabaseTaskNotificationService.MAIN_CREDENTIAL_KEY, mainCredential)
|
putParcelable(DatabaseTaskNotificationService.MAIN_CREDENTIAL_KEY, mainCredential)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,25 +27,28 @@ import com.kunzisoft.keepass.database.element.binary.BinaryData
|
|||||||
import com.kunzisoft.keepass.database.exception.DatabaseException
|
import com.kunzisoft.keepass.database.exception.DatabaseException
|
||||||
import com.kunzisoft.keepass.hardware.HardwareKey
|
import com.kunzisoft.keepass.hardware.HardwareKey
|
||||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||||
import com.kunzisoft.keepass.tasks.ActionRunnable
|
|
||||||
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
|
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
|
||||||
|
|
||||||
class MergeDatabaseRunnable(private val context: Context,
|
class MergeDatabaseRunnable(
|
||||||
private val mDatabase: Database,
|
context: Context,
|
||||||
private val mDatabaseToMergeUri: Uri?,
|
private val mDatabaseToMergeUri: Uri?,
|
||||||
private val mDatabaseToMergeMainCredential: MainCredential?,
|
private val mDatabaseToMergeMainCredential: MainCredential?,
|
||||||
private val mDatabaseToMergeChallengeResponseRetriever: (HardwareKey, ByteArray?) -> ByteArray,
|
private val mDatabaseToMergeChallengeResponseRetriever: (HardwareKey, ByteArray?) -> ByteArray,
|
||||||
private val progressTaskUpdater: ProgressTaskUpdater?,
|
database: Database,
|
||||||
private val mLoadDatabaseResult: ((Result) -> Unit)?)
|
saveDatabase: Boolean,
|
||||||
: ActionRunnable() {
|
challengeResponseRetriever: (HardwareKey, ByteArray?) -> ByteArray,
|
||||||
|
private val progressTaskUpdater: ProgressTaskUpdater?,
|
||||||
|
private val mLoadDatabaseResult: ((Result) -> Unit)?)
|
||||||
|
: SaveDatabaseRunnable(context, database, saveDatabase, null, challengeResponseRetriever) {
|
||||||
|
|
||||||
override fun onStartRun() {
|
override fun onStartRun() {
|
||||||
mDatabase.wasReloaded = true
|
database.wasReloaded = true
|
||||||
|
super.onStartRun()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActionRun() {
|
override fun onActionRun() {
|
||||||
try {
|
try {
|
||||||
mDatabase.mergeData(
|
database.mergeData(
|
||||||
context.contentResolver,
|
context.contentResolver,
|
||||||
mDatabaseToMergeUri,
|
mDatabaseToMergeUri,
|
||||||
mDatabaseToMergeMainCredential,
|
mDatabaseToMergeMainCredential,
|
||||||
@@ -63,9 +66,11 @@ class MergeDatabaseRunnable(private val context: Context,
|
|||||||
// Register the current time to init the lock timer
|
// Register the current time to init the lock timer
|
||||||
PreferencesUtil.saveCurrentTime(context)
|
PreferencesUtil.saveCurrentTime(context)
|
||||||
}
|
}
|
||||||
|
super.onActionRun()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFinishRun() {
|
override fun onFinishRun() {
|
||||||
|
super.onFinishRun()
|
||||||
mLoadDatabaseResult?.invoke(result)
|
mLoadDatabaseResult?.invoke(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -753,9 +753,14 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
|
|||||||
|
|
||||||
return MergeDatabaseRunnable(
|
return MergeDatabaseRunnable(
|
||||||
this,
|
this,
|
||||||
database,
|
|
||||||
databaseToMergeUri,
|
databaseToMergeUri,
|
||||||
databaseToMergeMainCredential,
|
databaseToMergeMainCredential,
|
||||||
|
{ hardwareKey, seed ->
|
||||||
|
// TODO fix first challenge response
|
||||||
|
retrieveResponseFromChallenge(hardwareKey, seed)
|
||||||
|
},
|
||||||
|
database,
|
||||||
|
!database.isReadOnly && intent.getBooleanExtra(SAVE_DATABASE_KEY, false),
|
||||||
{ hardwareKey, seed ->
|
{ hardwareKey, seed ->
|
||||||
retrieveResponseFromChallenge(hardwareKey, seed)
|
retrieveResponseFromChallenge(hardwareKey, seed)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment(), DatabaseRetriev
|
|||||||
mDatabaseViewModel.saveDatabase(save)
|
mDatabaseViewModel.saveDatabase(save)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun mergeDatabase() {
|
private fun mergeDatabase(save: Boolean) {
|
||||||
mDatabaseViewModel.mergeDatabase(false)
|
mDatabaseViewModel.mergeDatabase(save)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun reloadDatabase() {
|
private fun reloadDatabase() {
|
||||||
@@ -671,7 +671,7 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment(), DatabaseRetriev
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.menu_merge_database -> {
|
R.id.menu_merge_database -> {
|
||||||
mergeDatabase()
|
mergeDatabase(!mDatabaseReadOnly)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.menu_reload_database -> {
|
R.id.menu_reload_database -> {
|
||||||
|
|||||||
@@ -87,8 +87,8 @@ class DatabaseViewModel: ViewModel() {
|
|||||||
_saveDatabase.value = save
|
_saveDatabase.value = save
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mergeDatabase(fixDuplicateUuid: Boolean) {
|
fun mergeDatabase(save: Boolean) {
|
||||||
_mergeDatabase.value = fixDuplicateUuid
|
_mergeDatabase.value = save
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reloadDatabase(fixDuplicateUuid: Boolean) {
|
fun reloadDatabase(fixDuplicateUuid: Boolean) {
|
||||||
@@ -196,6 +196,8 @@ class DatabaseViewModel: ViewModel() {
|
|||||||
data class SuperLong(val oldValue: Long,
|
data class SuperLong(val oldValue: Long,
|
||||||
val newValue: Long,
|
val newValue: Long,
|
||||||
val save: Boolean)
|
val save: Boolean)
|
||||||
|
data class SuperMerge(val fixDuplicateUuid: Boolean,
|
||||||
|
val save: Boolean)
|
||||||
data class SuperCompression(val oldValue: CompressionAlgorithm,
|
data class SuperCompression(val oldValue: CompressionAlgorithm,
|
||||||
val newValue: CompressionAlgorithm,
|
val newValue: CompressionAlgorithm,
|
||||||
val save: Boolean)
|
val save: Boolean)
|
||||||
|
|||||||
@@ -373,6 +373,7 @@
|
|||||||
<string name="warning_database_revoked">Access to the file revoked by the file manager, close the database and reopen it from its location.</string>
|
<string name="warning_database_revoked">Access to the file revoked by the file manager, close the database and reopen it from its location.</string>
|
||||||
<string name="warning_exact_alarm">You have not allowed the app to use an exact alarm. As a result, the features requiring a timer will not be done with an exact time.</string>
|
<string name="warning_exact_alarm">You have not allowed the app to use an exact alarm. As a result, the features requiring a timer will not be done with an exact time.</string>
|
||||||
<string name="warning_keyfile_integrity">The hash of the file is not guaranteed because Android can change its data on the fly. Change the file extension to .bin for correct integrity.</string>
|
<string name="warning_keyfile_integrity">The hash of the file is not guaranteed because Android can change its data on the fly. Change the file extension to .bin for correct integrity.</string>
|
||||||
|
<string name="merge_success">Merge successfully completed</string>
|
||||||
<string name="permission">Permission</string>
|
<string name="permission">Permission</string>
|
||||||
<string name="version_label">Version %1$s</string>
|
<string name="version_label">Version %1$s</string>
|
||||||
<string name="build_label">Build %1$s</string>
|
<string name="build_label">Build %1$s</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user