aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/com/zeapo/pwdstore/git/config
diff options
context:
space:
mode:
authorFabian Henneke <FabianHenneke@users.noreply.github.com>2020-06-04 16:31:25 +0200
committerGitHub <noreply@github.com>2020-06-04 20:01:25 +0530
commit2ab44a45803a98a69379b865b711a1325f999ef7 (patch)
treebe8081cfd36d197562546623e255bb3c5280c3ca /app/src/main/java/com/zeapo/pwdstore/git/config
parent4172c70c86238d4b6c9181df31de71047749bffc (diff)
downloadHardenedPass-2ab44a45803a98a69379b865b711a1325f999ef7.tar.gz
HardenedPass-2ab44a45803a98a69379b865b711a1325f999ef7.zip
Don't show an error if password prompt is cancelled (#833)
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/git/config')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/config/SshjSessionFactory.kt14
1 files changed, 5 insertions, 9 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/config/SshjSessionFactory.kt b/app/src/main/java/com/zeapo/pwdstore/git/config/SshjSessionFactory.kt
index 4d961137..f643c714 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/config/SshjSessionFactory.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/git/config/SshjSessionFactory.kt
@@ -12,6 +12,8 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import net.schmizz.sshj.SSHClient
import net.schmizz.sshj.common.Buffer.PlainBuffer
+import net.schmizz.sshj.common.DisconnectReason
+import net.schmizz.sshj.common.SSHException
import net.schmizz.sshj.common.SSHRuntimeException
import net.schmizz.sshj.common.SecurityUtils
import net.schmizz.sshj.connection.channel.direct.Session
@@ -54,12 +56,10 @@ abstract class InteractivePasswordFinder : PasswordFinder {
abstract fun askForPassword(cont: Continuation<String?>, isRetry: Boolean)
private var isRetry = false
- private var shouldRetry = true
private var lastPassword: CharArray? = null
fun resetForReuse() {
isRetry = false
- shouldRetry = true
}
fun clearPassword() {
@@ -82,15 +82,11 @@ abstract class InteractivePasswordFinder : PasswordFinder {
}
}
isRetry = true
- return if (password != null) {
- password.toCharArray().also { lastPassword = it }
- } else {
- shouldRetry = false
- CharArray(0)
- }
+ return password?.toCharArray()?.also { lastPassword = it }
+ ?: throw SSHException(DisconnectReason.AUTH_CANCELLED_BY_USER)
}
- final override fun shouldRetry(resource: Resource<*>?) = shouldRetry
+ final override fun shouldRetry(resource: Resource<*>?) = true
}
class SshjSessionFactory(private val username: String, private val authData: SshAuthData, private val hostKeyFile: File) : SshSessionFactory() {