CLI: fix keyring backend bug
This commit is contained in:
@@ -80,7 +80,9 @@ kotlin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<ShadowJar> {
|
tasks.withType<ShadowJar> {
|
||||||
archiveFileName = if(isDebug) "phoebench-cli-debug.jar" else "phoebench-cli.jar"
|
val archive = if(isDebug) "phoebench-cli-debug.jar" else "phoebench-cli.jar"
|
||||||
|
println("Using archive '$archive'")
|
||||||
|
archiveFileName = archive
|
||||||
}
|
}
|
||||||
|
|
||||||
buildConfig {
|
buildConfig {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ object AuthHandlers {
|
|||||||
if (handshake.version != ProtocolVersion.VERSION) {
|
if (handshake.version != ProtocolVersion.VERSION) {
|
||||||
Client.onClearServer()
|
Client.onClearServer()
|
||||||
ErrorResponse("Mismatched protocol version (server: ${handshake.version}, client: ${ProtocolVersion.VERSION})").error()
|
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.BackendNotSupportedException
|
||||||
import com.github.javakeyring.Keyring
|
import com.github.javakeyring.Keyring
|
||||||
|
import com.github.javakeyring.PasswordAccessException
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlinx.serialization.serializer
|
import kotlinx.serialization.serializer
|
||||||
@@ -22,7 +23,11 @@ object PersistentStorage {
|
|||||||
private object KeyringBackend : IBackend {
|
private object KeyringBackend : IBackend {
|
||||||
override fun read(key: String): String? = try {
|
override fun read(key: String): String? = try {
|
||||||
Keyring.create().use { it.getPassword(SERVICE, key) }
|
Keyring.create().use { it.getPassword(SERVICE, key) }
|
||||||
} catch(e: Exception) {
|
}
|
||||||
|
catch(e: PasswordAccessException) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
catch(e: BackendNotSupportedException) {
|
||||||
_backend = PreferencesBackend
|
_backend = PreferencesBackend
|
||||||
_backend.read(key)
|
_backend.read(key)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user