mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-200849 Password Safe: incorrect reaction on custom location setting for the (not existing) KeePass database
This commit is contained in:
@@ -126,7 +126,7 @@ internal open class KeePassFileManager(private val file: Path,
|
||||
return true
|
||||
}
|
||||
|
||||
fun askAndSetMasterKey(event: AnActionEvent?): Boolean {
|
||||
fun askAndSetMasterKey(event: AnActionEvent?, topNote: String? = null): Boolean {
|
||||
val contextComponent = event?.getData(PlatformDataKeys.CONTEXT_COMPONENT)
|
||||
|
||||
// to open old database, key can be required, so, to avoid showing 2 dialogs, check it before
|
||||
@@ -138,7 +138,7 @@ internal open class KeePassFileManager(private val file: Path,
|
||||
return requestCurrentAndNewKeys(contextComponent)
|
||||
}
|
||||
|
||||
return requestMasterPassword("Set Master Password", contextComponent = contextComponent) {
|
||||
return requestMasterPassword("Set Master Password", topNote = topNote, contextComponent = contextComponent) {
|
||||
saveDatabase(file, db, createMasterKey(it), masterKeyFileStorage, secureRandom.value)
|
||||
null
|
||||
}
|
||||
@@ -242,9 +242,6 @@ internal open class KeePassFileManager(private val file: Path,
|
||||
return
|
||||
}
|
||||
|
||||
requestMasterPassword("Set Master Password", topNote = "Database file located in custom location,\ntherefore custom master password is required.") {
|
||||
masterKeyFileStorage.save(createMasterKey(it))
|
||||
null
|
||||
}
|
||||
askAndSetMasterKey(null, topNote = "Database file located in custom location,\ntherefore custom master password is required.")
|
||||
}
|
||||
}
|
||||
@@ -255,6 +255,7 @@ internal class KeePassFileManagerTest {
|
||||
@Test
|
||||
fun `require custom master password if need - not custom`() {
|
||||
val store = createStore()
|
||||
store.save(defaultEncryptionSpec)
|
||||
TestKeePassFileManager(store, masterPasswordRequestAnswer = "bar42").setCustomMasterPasswordIfNeed(fsRule.fs.getPath("/someDefault"))
|
||||
assertThat(MasterKeyFileStorage(store.masterKeyFile).load()!!.toString(Charsets.UTF_8)).isEqualTo("bar42")
|
||||
assertThat(createTestStoreWithCustomMasterKey().get(testCredentialAttributes)!!.password!!.toString()).isEqualTo("p")
|
||||
|
||||
Reference in New Issue
Block a user