reformat kotlin

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-03-17 14:11:15 +01:00
parent 70edda976f
commit 4685bced16
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
2 changed files with 49 additions and 35 deletions

View File

@ -59,11 +59,10 @@ import java.security.cert.CertificateException
import javax.inject.Inject import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class) @AutoInjector(NextcloudTalkApplication::class)
class ServerSelectionController : NewBaseController(R.layout.controller_server_selection) { class ServerSelectionController :
private val binding: ControllerServerSelectionBinding by viewBinding(ControllerServerSelectionBinding::bind) NewBaseController(R.layout.controller_server_selection) {
override val appBarLayoutType: AppBarLayoutType private val binding: ControllerServerSelectionBinding by viewBinding(ControllerServerSelectionBinding::bind)
get() = AppBarLayoutType.EMPTY
@Inject @Inject
lateinit var ncApi: NcApi lateinit var ncApi: NcApi
@ -75,14 +74,18 @@ class ServerSelectionController : NewBaseController(R.layout.controller_server_s
fun onCertClick() { fun onCertClick() {
if (activity != null) { if (activity != null) {
KeyChain.choosePrivateKeyAlias(activity!!, { alias: String? -> KeyChain.choosePrivateKeyAlias(
if (alias != null) { activity!!,
appPreferences!!.temporaryClientCertAlias = alias { alias: String? ->
} else { if (alias != null) {
appPreferences!!.removeTemporaryClientCertAlias() appPreferences!!.temporaryClientCertAlias = alias
} } else {
setCertTextView() appPreferences!!.removeTemporaryClientCertAlias()
}, arrayOf("RSA", "EC"), null, null, -1, null) }
setCertTextView()
},
arrayOf("RSA", "EC"), null, null, -1, null
)
} }
} }
@ -367,6 +370,9 @@ class ServerSelectionController : NewBaseController(R.layout.controller_server_s
statusQueryDisposable = null statusQueryDisposable = null
} }
override val appBarLayoutType: AppBarLayoutType
get() = AppBarLayoutType.EMPTY
companion object { companion object {
const val TAG = "ServerSelectionController" const val TAG = "ServerSelectionController"
const val MIN_SERVER_MAJOR_VERSION = 13 const val MIN_SERVER_MAJOR_VERSION = 13

View File

@ -241,31 +241,39 @@ class WebViewLoginController(args: Bundle? = null) : NewBaseController(
} }
}.start() }.start()
} else { } else {
KeyChain.choosePrivateKeyAlias(activity!!, { chosenAlias: String? -> KeyChain.choosePrivateKeyAlias(
if (chosenAlias != null) { activity!!,
appPreferences!!.temporaryClientCertAlias = chosenAlias { chosenAlias: String? ->
Thread { if (chosenAlias != null) {
var privateKey: PrivateKey? = null appPreferences!!.temporaryClientCertAlias = chosenAlias
try { Thread {
privateKey = KeyChain.getPrivateKey(activity!!, chosenAlias) var privateKey: PrivateKey? = null
val certificates = KeyChain.getCertificateChain( try {
activity!!, chosenAlias privateKey = KeyChain.getPrivateKey(activity!!, chosenAlias)
) val certificates = KeyChain.getCertificateChain(
if (privateKey != null && certificates != null) { activity!!, chosenAlias
request.proceed(privateKey, certificates) )
} else { if (privateKey != null && certificates != null) {
request.proceed(privateKey, certificates)
} else {
request.cancel()
}
} catch (e: KeyChainException) {
request.cancel()
} catch (e: InterruptedException) {
request.cancel() request.cancel()
} }
} catch (e: KeyChainException) { }.start()
request.cancel() } else {
} catch (e: InterruptedException) { request.cancel()
request.cancel() }
} },
}.start() arrayOf("RSA", "EC"),
} else { null,
request.cancel() request.host,
} request.port,
}, arrayOf("RSA", "EC"), null, request.host, request.port, null) null
)
} }
} }