mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
convert fileStore to native credential store if eap or snapshot
This commit is contained in:
@@ -155,6 +155,12 @@ class FileCredentialStore(keyToValue: Map<String, String>? = null, baseDirectory
|
||||
needToSave.set(true)
|
||||
}
|
||||
}
|
||||
|
||||
fun copyTo(store: PasswordStorage) {
|
||||
for ((k, v) in db) {
|
||||
store.setPassword(k, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun getRawKey(key: String?, requestor: Class<*>?) = "${if (requestor == null) "" else "${requestor.name}/"}$key"
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.ide.passwordSafe.config.PasswordSafeSettings
|
||||
import com.intellij.ide.passwordSafe.config.PasswordSafeSettings.ProviderType
|
||||
import com.intellij.ide.passwordSafe.macOs.isMacOsCredentialStoreSupported
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.ex.ApplicationInfoEx
|
||||
import com.intellij.openapi.components.SettingsSavingComponent
|
||||
import com.intellij.openapi.diagnostic.catchAndLog
|
||||
|
||||
@@ -39,7 +40,8 @@ class PasswordSafeImpl(/* public - backward compatibility */val settings: Passwo
|
||||
currentProvider = FileCredentialStore(memoryOnly = true)
|
||||
}
|
||||
else {
|
||||
currentProvider = createPersistentCredentialStore()
|
||||
val appInfo = ApplicationInfoEx.getInstanceEx()
|
||||
currentProvider = createPersistentCredentialStore(convertFileStore = appInfo.build.isSnapshot || appInfo.isEAP)
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().messageBus.connect().subscribe(PasswordSafeSettings.TOPIC, object: PasswordSafeSettingsListener {
|
||||
@@ -124,10 +126,19 @@ class PasswordSafeImpl(/* public - backward compatibility */val settings: Passwo
|
||||
|
||||
internal const val CREDENTIAL_STORE_SERVICE_NAME = "IntelliJ Platform"
|
||||
|
||||
private fun createPersistentCredentialStore(existing: FileCredentialStore? = null): PasswordStorage {
|
||||
private fun createPersistentCredentialStore(existing: FileCredentialStore? = null, convertFileStore: Boolean = false): PasswordStorage {
|
||||
LOG.catchAndLog {
|
||||
if (isMacOsCredentialStoreSupported && com.intellij.util.SystemProperties.getBooleanProperty("use.mac.keychain", true)) {
|
||||
return MacOsCredentialStore(CREDENTIAL_STORE_SERVICE_NAME)
|
||||
val store = MacOsCredentialStore(CREDENTIAL_STORE_SERVICE_NAME)
|
||||
if (convertFileStore) {
|
||||
LOG.catchAndLog {
|
||||
val fileStore = FileCredentialStore()
|
||||
fileStore.copyTo(store)
|
||||
fileStore.clear()
|
||||
fileStore.save()
|
||||
}
|
||||
}
|
||||
return store
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user