mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-160058 notify if cannot use native keychain
This commit is contained in:
@@ -19,6 +19,9 @@ import com.intellij.credentialStore.linux.SecretCredentialStore
|
||||
import com.intellij.credentialStore.macOs.KeyChainCredentialStore
|
||||
import com.intellij.credentialStore.macOs.isMacOsCredentialStoreSupported
|
||||
import com.intellij.ide.passwordSafe.PasswordStorage
|
||||
import com.intellij.notification.NotificationGroup
|
||||
import com.intellij.notification.NotificationType
|
||||
import com.intellij.notification.SingletonNotificationManager
|
||||
import com.intellij.openapi.application.ex.ApplicationInfoEx
|
||||
import com.intellij.openapi.diagnostic.catchAndLog
|
||||
import com.intellij.openapi.util.SystemInfo
|
||||
@@ -28,6 +31,11 @@ import com.intellij.util.containers.ContainerUtil
|
||||
|
||||
private val nullPassword = Credentials("\u0000", "\u0000")
|
||||
|
||||
private val NOTIFICATION_MANAGER by lazy {
|
||||
// we use name "Password Safe" instead of "Credentials Store" because it was named so previously (and no much sense to rename it)
|
||||
SingletonNotificationManager(NotificationGroup.balloonGroup("Password Safe"), NotificationType.WARNING, null)
|
||||
}
|
||||
|
||||
private class CredentialStoreWrapper(private val store: CredentialStore) : PasswordStorage {
|
||||
private val fallbackStore = lazy { FileCredentialStore(memoryOnly = true) }
|
||||
|
||||
@@ -78,6 +86,7 @@ private class CredentialStoreWrapper(private val store: CredentialStore) : Passw
|
||||
catch (e: UnsatisfiedLinkError) {
|
||||
store = fallbackStore.value
|
||||
LOG.error(e)
|
||||
NOTIFICATION_MANAGER.notify("Native Keychain is not used", "Failed to use native keychain — credentials will be stored in memory (until application is closed).")
|
||||
return store.get(attributes)
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
|
||||
Reference in New Issue
Block a user