aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-09-05 20:40:33 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2020-09-05 22:49:38 +0530
commitc183dd82d62debcee99b4ab7ccdfa74df8d865fa (patch)
tree426329915fbbce44c1e1e43d2c7ee2d04a384d78 /app/src
parenteded073ef214743e546aa1c9d0aa73baf94c2090 (diff)
SshjConfig: use runCatching to replace exception handling
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/sshj/SshjConfig.kt6
1 files changed, 2 insertions, 4 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/sshj/SshjConfig.kt b/app/src/main/java/com/zeapo/pwdstore/git/sshj/SshjConfig.kt
index 0cd5459b..49a587f5 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/sshj/SshjConfig.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/git/sshj/SshjConfig.kt
@@ -6,6 +6,7 @@ package com.zeapo.pwdstore.git.sshj
import com.github.ajalt.timberkt.Timber
import com.github.ajalt.timberkt.d
+import com.github.michaelbull.result.runCatching
import com.hierynomus.sshj.key.KeyAlgorithms
import com.hierynomus.sshj.transport.cipher.BlockCiphers
import com.hierynomus.sshj.transport.kex.ExtInfoClientFactory
@@ -46,10 +47,7 @@ fun setUpBouncyCastleForSshj() {
// Replace Android BC with Java BC, inserted at the same position.
Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME)
// May be needed on Android Pie+ as per https://stackoverflow.com/a/57897224/297261
- try {
- Class.forName("sun.security.jca.Providers")
- } catch (e: ClassNotFoundException) {
- }
+ runCatching { Class.forName("sun.security.jca.Providers") }
Security.insertProviderAt(BouncyCastleProvider(), bcIndex + 1)
}
d { "JCE providers: ${Security.getProviders().joinToString { "${it.name} (${it.version})" }}" }