CLI: fix keyring backend bug

This commit is contained in:
2026-09-01 14:09:37 +02:00
parent 768bb0c650
commit 7f92df1ca5
3 changed files with 10 additions and 3 deletions
@@ -14,7 +14,7 @@ object AuthHandlers {
if (handshake.version != ProtocolVersion.VERSION) {
Client.onClearServer()
ErrorResponse("Mismatched protocol version (server: ${handshake.version}, client: ${ProtocolVersion.VERSION})").error()
} else Unit.value()
} else Client.onSelectServer(useServer).value()
}
}
}
@@ -2,6 +2,7 @@ package com.jaytux.phoebench.clients.cli
import com.github.javakeyring.BackendNotSupportedException
import com.github.javakeyring.Keyring
import com.github.javakeyring.PasswordAccessException
import kotlinx.serialization.KSerializer
import kotlinx.serialization.json.Json
import kotlinx.serialization.serializer
@@ -22,7 +23,11 @@ object PersistentStorage {
private object KeyringBackend : IBackend {
override fun read(key: String): String? = try {
Keyring.create().use { it.getPassword(SERVICE, key) }
} catch(e: Exception) {
}
catch(e: PasswordAccessException) {
return null
}
catch(e: BackendNotSupportedException) {
_backend = PreferencesBackend
_backend.read(key)
}