Skip to content

Commit

Permalink
use IDEATrustManager in intellij-common (#718)
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Dietisheim <[email protected]>
  • Loading branch information
adietish committed Apr 9, 2024
1 parent ad2eb4f commit bfd0eca
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 438 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
package com.redhat.devtools.intellij.kubernetes.model.client

import com.redhat.devtools.intellij.common.kubernetes.ClusterHelper
import com.redhat.devtools.intellij.kubernetes.model.client.ssl.IDEATrustManager
import com.redhat.devtools.intellij.common.ssl.IDEATrustManager
import io.fabric8.kubernetes.client.Client
import io.fabric8.kubernetes.client.Config
import io.fabric8.kubernetes.client.KubernetesClient
Expand Down Expand Up @@ -59,7 +59,7 @@ abstract class ClientAdapter<C : KubernetesClient>(private val fabric8Client: C)
fun create(
namespace: String? = null,
context: String? = null,
trustManagerProvider: ((toIntegrate: Array<out X509ExtendedTrustManager>) -> X509TrustManager)
trustManagerProvider: ((toIntegrate: List<X509ExtendedTrustManager>) -> X509TrustManager)
= IDEATrustManager()::configure
): ClientAdapter<out KubernetesClient> {
val config = Config.autoConfigure(context)
Expand All @@ -69,7 +69,7 @@ abstract class ClientAdapter<C : KubernetesClient>(private val fabric8Client: C)
fun create(
namespace: String? = null,
config: Config,
externalTrustManagerProvider: (toIntegrate: Array<out X509ExtendedTrustManager>) -> X509TrustManager
externalTrustManagerProvider: (toIntegrate: List<X509ExtendedTrustManager>) -> X509TrustManager
= IDEATrustManager()::configure
): ClientAdapter<out KubernetesClient> {
setNamespace(namespace, config)
Expand All @@ -90,11 +90,10 @@ abstract class ClientAdapter<C : KubernetesClient>(private val fabric8Client: C)
private fun setSslContext(
builder: HttpClient.Builder,
config: Config,
externalTrustManagerProvider: (toIntegrate: Array<out X509ExtendedTrustManager>) -> X509TrustManager
externalTrustManagerProvider: (toIntegrate: List<X509ExtendedTrustManager>) -> X509TrustManager
) {
val clientTrustManagers = SSLUtils.trustManagers(config)
.filterIsInstance<X509ExtendedTrustManager>()
.toTypedArray()
val externalTrustManager = externalTrustManagerProvider.invoke(clientTrustManagers)
builder.sslContext(SSLUtils.keyManagers(config), arrayOf(externalTrustManager))
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ClientAdapterTest {
private val trustManager: X509TrustManager = mock {
on { acceptedIssuers } doReturn arrayOf(certificate)
}
private val trustManagerProvider: (toIntegrate: Array<out X509ExtendedTrustManager>) -> X509TrustManager = mock() {
private val trustManagerProvider: (toIntegrate: List<X509ExtendedTrustManager>) -> X509TrustManager = mock {
on { invoke(any()) } doReturn trustManager
}

Expand Down
Loading

0 comments on commit bfd0eca

Please sign in to comment.