CLI: fix keyring backend bug
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user