diff --git a/components/ide/jetbrains/gateway-plugin/build.gradle.kts b/components/ide/jetbrains/gateway-plugin/build.gradle.kts index a6498d056107b8..6d9b19abf57517 100644 --- a/components/ide/jetbrains/gateway-plugin/build.gradle.kts +++ b/components/ide/jetbrains/gateway-plugin/build.gradle.kts @@ -3,9 +3,9 @@ // See License.AGPL.txt in the project root for license information. import io.gitlab.arturbosch.detekt.Detekt -import org.jetbrains.changelog.Changelog import org.jetbrains.changelog.markdownToHTML import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile fun properties(key: String) = project.findProperty(key).toString() @@ -146,7 +146,9 @@ tasks.withType { } tasks.withType { - kotlinOptions.jvmTarget = "21" + compilerOptions { + jvmTarget.set(JvmTarget.JVM_21) + } } tasks.withType { diff --git a/components/ide/jetbrains/gateway-plugin/gradle-latest.properties b/components/ide/jetbrains/gateway-plugin/gradle-latest.properties index e49f6e03908f8a..556e5d3b2e9cbf 100644 --- a/components/ide/jetbrains/gateway-plugin/gradle-latest.properties +++ b/components/ide/jetbrains/gateway-plugin/gradle-latest.properties @@ -1,10 +1,11 @@ # Code generated by gha-update-image/index-jb-platform-update.ts. DO NOT EDIT. # See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html # for insight into build numbers and IntelliJ Platform versions. -pluginSinceBuild=242.20224 -pluginUntilBuild=242.* +# revert pluginSinceBuild if it's unnecessary +pluginSinceBuild=243.18137 +pluginUntilBuild=243.* # Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl # See https://jb.gg/intellij-platform-builds-list for available build versions. -pluginVerifierIdeVersions=2024.2 +pluginVerifierIdeVersions=2024.3 # Version from "com.jetbrains.gateway" which can be found at https://www.jetbrains.com/intellij-repository/snapshots -platformVersion=242.20224.368 +platformVersion=243.18137.22 diff --git a/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/auth/GitpodAuthCallbackHandler.kt b/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/auth/GitpodAuthCallbackHandler.kt index 95b53df848b6d4..a1e48389f7bacc 100644 --- a/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/auth/GitpodAuthCallbackHandler.kt +++ b/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/auth/GitpodAuthCallbackHandler.kt @@ -25,7 +25,7 @@ internal class GitpodAuthCallbackHandler : RestService() { request: FullHttpRequest, context: ChannelHandlerContext ): String? { - service.handleServerCallback(urlDecoder.path(), urlDecoder.parameters()) + service.handleOAuthServerCallback(urlDecoder.path(), urlDecoder.parameters()) sendResponse( request, context, diff --git a/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/auth/GitpodAuthService.kt b/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/auth/GitpodAuthService.kt index eafa000b8b54c0..eae72c36c46f42 100644 --- a/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/auth/GitpodAuthService.kt +++ b/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/auth/GitpodAuthService.kt @@ -19,7 +19,6 @@ import com.intellij.ide.passwordSafe.PasswordSafe import com.intellij.openapi.Disposable import com.intellij.openapi.components.Service import com.intellij.openapi.components.service -import com.intellij.util.Base64 import com.intellij.util.EventDispatcher import com.intellij.util.Url import com.intellij.util.Urls.encodeParameters @@ -138,7 +137,7 @@ internal class GitpodAuthService : OAuthServiceBase() { val jwt = with(jacksonMapper) { propertyNamingStrategy = PropertyNamingStrategies.LowerCaseStrategy() - readValue(Base64.decode(responseData.accessToken.split('.')[1]), JsonWebToken::class.java) + readValue(Base64.getDecoder().decode(responseData.accessToken.split('.')[1]), JsonWebToken::class.java) } SimpleCredentials(jwt.jti) } @@ -178,7 +177,7 @@ internal class GitpodAuthService : OAuthServiceBase() { suspend fun authorize(gitpodHost: String): String { val accessToken = instance.authorize(gitpodHost).await().accessToken - setAccessToken(gitpodHost, accessToken!!) + setAccessToken(gitpodHost, accessToken) return accessToken } diff --git a/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodConnectionProvider.kt b/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodConnectionProvider.kt index 701ac62911fc9e..f85f4ba905b315 100644 --- a/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodConnectionProvider.kt +++ b/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodConnectionProvider.kt @@ -26,10 +26,9 @@ import com.intellij.ui.dsl.builder.AlignY import com.intellij.ui.dsl.builder.panel import com.intellij.util.application import com.intellij.util.io.DigestUtil -import com.intellij.util.io.await import com.intellij.util.io.delete +import com.intellij.util.net.JdkProxyProvider import com.intellij.util.net.ssl.CertificateManager -import com.intellij.util.proxy.CommonProxy import com.intellij.util.ui.JBFont import com.intellij.util.ui.JBUI import com.intellij.util.ui.UIUtil @@ -43,8 +42,10 @@ import com.jetbrains.rd.util.URI import com.jetbrains.rd.util.lifetime.Lifetime import com.jetbrains.rd.util.lifetime.LifetimeDefinition import io.gitpod.gitpodprotocol.api.entities.WorkspaceInstance +import io.gitpod.jetbrains.gateway.common.GitpodConnectionHandleFactory import io.gitpod.jetbrains.icons.GitpodIcons import kotlinx.coroutines.* +import kotlinx.coroutines.future.await import java.net.URL import java.net.http.HttpClient import java.net.http.HttpRequest @@ -64,15 +65,15 @@ class GitpodConnectionProvider : GatewayConnectionProvider { private val settings = service() private val httpClient = HttpClient.newBuilder() - .followRedirects(HttpClient.Redirect.ALWAYS) - .build() + .followRedirects(HttpClient.Redirect.ALWAYS) + .build() private val jacksonMapper = jacksonObjectMapper() - .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) override suspend fun connect( - parameters: Map, - requestor: ConnectionRequestor + parameters: Map, + requestor: ConnectionRequestor ): GatewayConnectionHandle { if (parameters["gitpodHost"] == null) { throw IllegalArgumentException("bad gitpodHost parameter") @@ -81,14 +82,14 @@ class GitpodConnectionProvider : GatewayConnectionProvider { throw IllegalArgumentException("bad workspaceId parameter") } val connectParams = ConnectParams( - parameters["gitpodHost"]!!, - parameters["workspaceId"]!!, - parameters["backendPort"], - parameters["debugWorkspace"] == "true" + parameters["gitpodHost"]!!, + parameters["workspaceId"]!!, + parameters["backendPort"], + parameters["debugWorkspace"] == "true" ) var connectionKeyId = - "${connectParams.gitpodHost}-${connectParams.resolvedWorkspaceId}-${connectParams.backendPort}" + "${connectParams.gitpodHost}-${connectParams.resolvedWorkspaceId}-${connectParams.backendPort}" var found = true val connectionLifetime = activeConnections.computeIfAbsent(connectionKeyId) { @@ -98,7 +99,7 @@ class GitpodConnectionProvider : GatewayConnectionProvider { if (found) { val message = - "You are trying to connect to a workspace that has a client already open. Check for opened JetBrains clients on your machine" + "You are trying to connect to a workspace that has a client already open. Check for opened JetBrains clients on your machine" val title = connectParams.title val okButton = Messages.getOkButton() val options = arrayOf(okButton) @@ -142,15 +143,15 @@ class GitpodConnectionProvider : GatewayConnectionProvider { } row { cell(phaseMessage) - .bold() - .align(AlignX.CENTER) + .bold() + .align(AlignX.CENTER) } row { cell(statusMessage) - .align(AlignX.CENTER) - .applyToComponent { - foreground = JBUI.CurrentTheme.ContextHelp.FOREGROUND - } + .align(AlignX.CENTER) + .applyToComponent { + foreground = JBUI.CurrentTheme.ContextHelp.FOREGROUND + } } panel { row { @@ -194,7 +195,7 @@ class GitpodConnectionProvider : GatewayConnectionProvider { continue } resolvedIdeUrl = - update.ideUrl.replace(connectParams.actualWorkspaceId, connectParams.resolvedWorkspaceId) + update.ideUrl.replace(connectParams.actualWorkspaceId, connectParams.resolvedWorkspaceId) lastUpdate = update if (!update.status.conditions.failed.isNullOrBlank()) { setErrorMessage(update.status.conditions.failed) @@ -267,16 +268,16 @@ class GitpodConnectionProvider : GatewayConnectionProvider { val ownerToken = client.server.getOwnerToken(update.workspaceId).await() var credentials = resolveCredentialsWithDirectSSH( - ideUrl, - ownerToken, - connectParams, + ideUrl, + ownerToken, + connectParams, ) if (credentials == null) { credentials = resolveCredentialsWithWebSocketTunnel( - ideUrl, - ownerToken, - connectParams, - connectionLifetime + ideUrl, + ownerToken, + connectParams, + connectionLifetime ) } if (credentials == null) { @@ -290,9 +291,9 @@ class GitpodConnectionProvider : GatewayConnectionProvider { return@thinClientJob } val clientHandle = connectionHandleFactory.connect( - connectionLifetime, - SshHostTunnelConnector(credentials), - URI(joinLinkResp.joinLink) + connectionLifetime, + SshHostTunnelConnector(credentials), + URI(joinLinkResp.joinLink) ) clientHandle.clientClosed.advise(connectionLifetime) { application.invokeLater { @@ -323,8 +324,8 @@ class GitpodConnectionProvider : GatewayConnectionProvider { return@backendStatusJob } thisLogger().error( - "${connectParams.gitpodHost}: ${connectParams.resolvedWorkspaceId}: failed to reconnect:", - t + "${connectParams.gitpodHost}: ${connectParams.resolvedWorkspaceId}: failed to reconnect:", + t ) } } @@ -339,8 +340,8 @@ class GitpodConnectionProvider : GatewayConnectionProvider { throw t } thisLogger().error( - "${connectParams.gitpodHost}: ${connectParams.resolvedWorkspaceId}: failed to connect:", - t + "${connectParams.gitpodHost}: ${connectParams.resolvedWorkspaceId}: failed to connect:", + t ) setErrorMessage("" + t.message) } @@ -348,16 +349,16 @@ class GitpodConnectionProvider : GatewayConnectionProvider { } } catch (e: Throwable) { thisLogger().error( - "${connectParams.gitpodHost}: ${connectParams.resolvedWorkspaceId}: failed to process workspace update:", - e + "${connectParams.gitpodHost}: ${connectParams.resolvedWorkspaceId}: failed to process workspace update:", + e ) } } connectionLifetime.terminate() } catch (t: Throwable) { thisLogger().error( - "${connectParams.gitpodHost}: ${connectParams.resolvedWorkspaceId}: failed to process workspace updates:", - t + "${connectParams.gitpodHost}: ${connectParams.resolvedWorkspaceId}: failed to process workspace updates:", + t ) setErrorMessage("failed to process workspace updates ${t.message}") } @@ -367,10 +368,10 @@ class GitpodConnectionProvider : GatewayConnectionProvider { } private suspend fun resolveCredentialsWithWebSocketTunnel( - ideUrl: URL, - ownerToken: String, - connectParams: ConnectParams, - connectionLifetime: Lifetime, + ideUrl: URL, + ownerToken: String, + connectParams: ConnectParams, + connectionLifetime: Lifetime, ): RemoteCredentialsHolder? { val keyPair = createSSHKeyPair(ideUrl, connectParams, ownerToken) if (keyPair == null || keyPair.privateKey.isNullOrEmpty()) { @@ -384,13 +385,13 @@ class GitpodConnectionProvider : GatewayConnectionProvider { privateKeyFile.delete() } - val proxies = CommonProxy.getInstance().select(ideUrl) + val proxies = JdkProxyProvider.getInstance().proxySelector.select(ideUrl.toURI()) val sslContext = CertificateManager.getInstance().sslContext val sshWebSocketServer = GitpodWebSocketTunnelServer( - "wss://${ideUrl.host}/_supervisor/tunnel/ssh", - ownerToken, - proxies, - sslContext + "wss://${ideUrl.host}/_supervisor/tunnel/ssh", + ownerToken, + proxies, + sslContext ) sshWebSocketServer.start(connectionLifetime) @@ -407,26 +408,26 @@ class GitpodConnectionProvider : GatewayConnectionProvider { } return resolveCredentials( - "localhost", - sshWebSocketServer.port, - userName, - null, - privateKeyFile.absolutePathString(), - hostKeys + "localhost", + sshWebSocketServer.port, + userName, + null, + privateKeyFile.absolutePathString(), + hostKeys ) } catch (t: Throwable) { thisLogger().error( - "${connectParams.gitpodHost}: web socket tunnel: failed to connect:", - t + "${connectParams.gitpodHost}: web socket tunnel: failed to connect:", + t ) return null } } private suspend fun resolveCredentialsWithDirectSSH( - ideUrl: URL, - ownerToken: String, - connectParams: ConnectParams + ideUrl: URL, + ownerToken: String, + connectParams: ConnectParams ): RemoteCredentialsHolder? { if (settings.forceHttpTunnel) { return null @@ -446,26 +447,26 @@ class GitpodConnectionProvider : GatewayConnectionProvider { ) ) return resolveCredentials( - sshHostUrl.host, - 22, - connectParams.resolvedWorkspaceId, - ownerToken, - null, - hostKeys + sshHostUrl.host, + 22, + connectParams.resolvedWorkspaceId, + ownerToken, + null, + hostKeys ) } catch (t: Throwable) { thisLogger().error( - "${connectParams.gitpodHost}: direct SSH: failed to resolve credentials", - t + "${connectParams.gitpodHost}: direct SSH: failed to resolve credentials", + t ) return null } } private suspend fun resolveJoinLink( - ideUrl: URL, - ownerToken: String, - connectParams: ConnectParams + ideUrl: URL, + ownerToken: String, + connectParams: ConnectParams ): JoinLinkResp? { var resolveJoinLinkUrl = "https://24000-${ideUrl.host}/joinLink2" if (!connectParams.backendPort.isNullOrBlank()) { @@ -492,12 +493,12 @@ class GitpodConnectionProvider : GatewayConnectionProvider { } private fun resolveCredentials( - host: String, - port: Int, - userName: String?, - password: String?, - privateKeyFile: String?, - hostKeys: List + host: String, + port: Int, + userName: String?, + password: String?, + privateKeyFile: String?, + hostKeys: List ): RemoteCredentialsHolder { val credentials = RemoteCredentialsHolder() credentials.setHost(host) @@ -512,9 +513,9 @@ class GitpodConnectionProvider : GatewayConnectionProvider { credentials.authType = AuthType.KEY_PAIR } var builder = credentials.connectionBuilder( - null, - ProgressManager.getGlobalProgressIndicator(), - false + null, + ProgressManager.getGlobalProgressIndicator(), + false ).withParsingOpenSSHConfig(true) if (hostKeys.isNotEmpty()) { builder = builder.withSshConnectionConfig { @@ -522,10 +523,10 @@ class GitpodConnectionProvider : GatewayConnectionProvider { if (hostKeyVerifier is OpenSshLikeHostKeyVerifier) { val acceptHostKey = acceptHostKey(host, hostKeys) it.copy( - hostKeyVerifier = hostKeyVerifier.copy( - acceptChangedHostKey = acceptHostKey, - acceptUnknownHostKey = acceptHostKey - ) + hostKeyVerifier = hostKeyVerifier.copy( + acceptChangedHostKey = acceptHostKey, + acceptUnknownHostKey = acceptHostKey + ) ) } else { it @@ -537,12 +538,12 @@ class GitpodConnectionProvider : GatewayConnectionProvider { } private suspend fun createSSHKeyPair( - ideUrl: URL, - connectParams: ConnectParams, - ownerToken: String + ideUrl: URL, + connectParams: ConnectParams, + ownerToken: String ): CreateSSHKeyPairResponse? { val value = - fetchWS("https://${ideUrl.host}/_supervisor/v1/ssh_keys/create", connectParams, ownerToken) + fetchWS("https://${ideUrl.host}/_supervisor/v1/ssh_keys/create", connectParams, ownerToken) if (value.isNullOrBlank()) { return null } @@ -553,11 +554,11 @@ class GitpodConnectionProvider : GatewayConnectionProvider { } private suspend fun resolveHostKeys( - ideUrl: URL, - connectParams: ConnectParams + ideUrl: URL, + connectParams: ConnectParams ): List? { val hostKeysValue = - fetchWS("https://${ideUrl.host}/_ssh/host_keys", connectParams, null) + fetchWS("https://${ideUrl.host}/_ssh/host_keys", connectParams, null) if (hostKeysValue.isNullOrBlank()) { return null } @@ -591,8 +592,8 @@ class GitpodConnectionProvider : GatewayConnectionProvider { } private fun acceptHostKey( - host: String, - hostKeys: List + host: String, + hostKeys: List ): AskAboutHostKey { val hostKeysByType = hostKeys.groupBy({ it.type.lowercase() }) { it.hostKey } val acceptHostKey: AskAboutHostKey = { hostName, keyType, fingerprint, _ -> @@ -606,12 +607,12 @@ class GitpodConnectionProvider : GatewayConnectionProvider { var matchedFingerprint = false for (hostKey in matchedHostKeys!!) { for (digest in listOf( - DigestUtil.md5(), - DigestUtil.sha256(), - DigestUtil.sha1() + DigestUtil.md5(), + DigestUtil.sha256(), + DigestUtil.sha1() )) { val bytes = - digest.digest(Base64.getDecoder().decode(hostKey)) + digest.digest(Base64.getDecoder().decode(hostKey)) val hostKeyFingerprint = toHexString(bytes, "", ":") if (hostKeyFingerprint == fingerprint) { matchedFingerprint = true @@ -625,9 +626,9 @@ class GitpodConnectionProvider : GatewayConnectionProvider { } private suspend fun fetchWS( - endpointUrl: String, - connectParams: ConnectParams, - ownerToken: String?, + endpointUrl: String, + connectParams: ConnectParams, + ownerToken: String?, ): String? { val maxRequestTimeout = 30 * 1000L val timeoutDelayGrowFactor = 1.5 @@ -636,15 +637,15 @@ class GitpodConnectionProvider : GatewayConnectionProvider { coroutineContext.job.ensureActive() try { var httpRequestBuilder = HttpRequest.newBuilder() - .uri(URI.create(endpointUrl)) - .GET() - .timeout(Duration.ofMillis(requestTimeout)) + .uri(URI.create(endpointUrl)) + .GET() + .timeout(Duration.ofMillis(requestTimeout)) if (!ownerToken.isNullOrBlank()) { httpRequestBuilder = httpRequestBuilder.header("x-gitpod-owner-token", ownerToken) } val httpRequest = httpRequestBuilder.build() val response = - httpClient.sendAsync(httpRequest, HttpResponse.BodyHandlers.ofString()).await() + httpClient.sendAsync(httpRequest, HttpResponse.BodyHandlers.ofString()).await() if (response.statusCode() == 200) { return response.body() } @@ -658,8 +659,8 @@ class GitpodConnectionProvider : GatewayConnectionProvider { throw t } thisLogger().warn( - "${connectParams.gitpodHost}: ${connectParams.resolvedWorkspaceId}: failed to fetch '$endpointUrl', trying again...:", - t + "${connectParams.gitpodHost}: ${connectParams.resolvedWorkspaceId}: failed to fetch '$endpointUrl', trying again...:", + t ) } requestTimeout = (requestTimeout * timeoutDelayGrowFactor).toLong() @@ -670,13 +671,13 @@ class GitpodConnectionProvider : GatewayConnectionProvider { } override fun isApplicable(parameters: Map): Boolean = - parameters.containsKey("gitpodHost") + parameters.containsKey("gitpodHost") data class ConnectParams( - val gitpodHost: String, - val actualWorkspaceId: String, - val backendPort: String?, - val debugWorkspace: Boolean, + val gitpodHost: String, + val actualWorkspaceId: String, + val backendPort: String?, + val debugWorkspace: Boolean, ) { val resolvedWorkspaceId = "${if (debugWorkspace) "debug-" else ""}$actualWorkspaceId" val title = "$resolvedWorkspaceId ($gitpodHost)" diff --git a/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodConnectionService.kt b/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodConnectionService.kt index f898b17891e759..1c877073b3092c 100644 --- a/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodConnectionService.kt +++ b/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodConnectionService.kt @@ -11,8 +11,8 @@ import com.intellij.openapi.extensions.PluginId import com.intellij.remoteDev.util.onTerminationOrNow import com.intellij.util.ExceptionUtil import com.intellij.util.io.DigestUtil +import com.intellij.util.net.JdkProxyProvider import com.intellij.util.net.ssl.CertificateManager -import com.intellij.util.proxy.CommonProxy import com.jetbrains.rd.util.concurrentMapOf import com.jetbrains.rd.util.lifetime.Lifetime import io.gitpod.gitpodprotocol.api.GitpodServerLauncher @@ -50,7 +50,7 @@ class GitpodConnectionService { val originalClassLoader = Thread.currentThread().contextClassLoader val connection = try { val origin = "https://$gitpodHost/" - val proxies = CommonProxy.getInstance().select(URL(origin)) + val proxies = JdkProxyProvider.getInstance().proxySelector.select(URL(origin).toURI()) val sslContext = CertificateManager.getInstance().sslContext // see https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003146180/comments/360000376240 diff --git a/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodWorkspacesView.kt b/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodWorkspacesView.kt index 047803b80ef99e..cc2e0d867d5969 100644 --- a/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodWorkspacesView.kt +++ b/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodWorkspacesView.kt @@ -307,12 +307,12 @@ class GitpodWorkspacesView( button("Connect") { if (!canConnect) { val startUrl = URIBuilder() - .setScheme("https") - .setHost(gitpodHost) - .setPath("start") - .setFragment(info.workspace.id) - .build() - .toString() + .setScheme("https") + .setHost(gitpodHost) + .setPath("start") + .setFragment(info.workspace.id) + .build() + .toString() BrowserUtil.browse(startUrl) } else { GatewayUI.getInstance().connect( diff --git a/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodConnectionHandle.kt b/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/common/GitpodConnectionHandleFactory.kt similarity index 66% rename from components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodConnectionHandle.kt rename to components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/common/GitpodConnectionHandleFactory.kt index b12cf48891d528..aa22bed274b0f1 100644 --- a/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodConnectionHandle.kt +++ b/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/common/GitpodConnectionHandleFactory.kt @@ -2,13 +2,11 @@ // Licensed under the GNU Affero General Public License (AGPL). // See License.AGPL.txt in the project root for license information. -package io.gitpod.jetbrains.gateway +package io.gitpod.jetbrains.gateway.common -import com.intellij.openapi.components.Service import com.jetbrains.gateway.api.CustomConnectionFrameComponentProvider import com.jetbrains.gateway.api.CustomConnectionFrameContext import com.jetbrains.gateway.api.GatewayConnectionHandle -import com.jetbrains.gateway.ssh.ClientOverSshTunnelConnector import com.jetbrains.gateway.ssh.HostTunnelConnector import com.jetbrains.gateway.thinClientLink.ThinClientHandle import com.jetbrains.rd.util.lifetime.Lifetime @@ -16,10 +14,21 @@ import io.gitpod.jetbrains.gateway.GitpodConnectionProvider.ConnectParams import java.net.URI import javax.swing.JComponent -class GitpodConnectionHandle( +@Suppress("UnstableApiUsage") +interface GitpodConnectionHandleFactory { + fun createGitpodConnectionHandle( lifetime: Lifetime, - private val component: JComponent, - private val params: ConnectParams + component: JComponent, + params: ConnectParams + ): GatewayConnectionHandle + + suspend fun connect(lifetime: Lifetime, connector: HostTunnelConnector, tcpJoinLink: URI): ThinClientHandle +} + +class GitpodConnectionHandle( + lifetime: Lifetime, + private val component: JComponent, + private val params: ConnectParams ) : GatewayConnectionHandle(lifetime) { override fun customComponentProvider(lifetime: Lifetime) = object : CustomConnectionFrameComponentProvider { override val closeConfirmationText = "Disconnect from ${getTitle()}?" @@ -33,22 +42,4 @@ class GitpodConnectionHandle( override fun hideToTrayOnStart(): Boolean { return false } -} -@Suppress("UnstableApiUsage") -@Service -class GitpodConnectionHandleFactory { - fun createGitpodConnectionHandle( - lifetime: Lifetime, - component: JComponent, - params: ConnectParams - ): GatewayConnectionHandle { - return GitpodConnectionHandle(lifetime, component, params) - } - - suspend fun connect(lifetime: Lifetime, connector: HostTunnelConnector, tcpJoinLink: URI): ThinClientHandle { - return ClientOverSshTunnelConnector( - lifetime, - connector - ).connect(tcpJoinLink) - } -} +} \ No newline at end of file diff --git a/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/latest/GitpodConnectionHandleFactory.kt b/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/latest/GitpodConnectionHandleFactory.kt new file mode 100644 index 00000000000000..f0a06f568cb933 --- /dev/null +++ b/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/latest/GitpodConnectionHandleFactory.kt @@ -0,0 +1,35 @@ +// Copyright (c) 2024 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License.AGPL.txt in the project root for license information. + +package io.gitpod.jetbrains.gateway.latest + +import com.intellij.openapi.components.Service +import com.jetbrains.gateway.api.GatewayConnectionHandle +import com.jetbrains.gateway.ssh.ClientOverSshTunnelConnector +import com.jetbrains.gateway.ssh.HostTunnelConnector +import com.jetbrains.gateway.thinClientLink.ThinClientHandle +import com.jetbrains.rd.util.lifetime.Lifetime +import io.gitpod.jetbrains.gateway.GitpodConnectionProvider.ConnectParams +import io.gitpod.jetbrains.gateway.common.GitpodConnectionHandle +import io.gitpod.jetbrains.gateway.common.GitpodConnectionHandleFactory +import java.net.URI +import javax.swing.JComponent + +@Suppress("UnstableApiUsage") +class LatestGitpodConnectionHandleFactory: GitpodConnectionHandleFactory { + override fun createGitpodConnectionHandle( + lifetime: Lifetime, + component: JComponent, + params: ConnectParams + ): GatewayConnectionHandle { + return GitpodConnectionHandle(lifetime, component, params) + } + + override suspend fun connect(lifetime: Lifetime, connector: HostTunnelConnector, tcpJoinLink: URI): ThinClientHandle { + return ClientOverSshTunnelConnector( + lifetime, + connector + ).connect(tcpJoinLink, null) + } +} diff --git a/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/stable/GitpodConnectionHandleFactory.kt b/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/stable/GitpodConnectionHandleFactory.kt new file mode 100644 index 00000000000000..a2d266669b2ff4 --- /dev/null +++ b/components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/stable/GitpodConnectionHandleFactory.kt @@ -0,0 +1,35 @@ +// Copyright (c) 2024 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License.AGPL.txt in the project root for license information. + +package io.gitpod.jetbrains.gateway.stable + +import com.intellij.openapi.components.Service +import com.jetbrains.gateway.api.GatewayConnectionHandle +import com.jetbrains.gateway.ssh.ClientOverSshTunnelConnector +import com.jetbrains.gateway.ssh.HostTunnelConnector +import com.jetbrains.gateway.thinClientLink.ThinClientHandle +import com.jetbrains.rd.util.lifetime.Lifetime +import io.gitpod.jetbrains.gateway.GitpodConnectionProvider.ConnectParams +import io.gitpod.jetbrains.gateway.common.GitpodConnectionHandle +import io.gitpod.jetbrains.gateway.common.GitpodConnectionHandleFactory +import java.net.URI +import javax.swing.JComponent + +@Suppress("UnstableApiUsage") +class StableGitpodConnectionHandleFactory: GitpodConnectionHandleFactory { + override fun createGitpodConnectionHandle( + lifetime: Lifetime, + component: JComponent, + params: ConnectParams + ): GatewayConnectionHandle { + return GitpodConnectionHandle(lifetime, component, params) + } + + override suspend fun connect(lifetime: Lifetime, connector: HostTunnelConnector, tcpJoinLink: URI): ThinClientHandle { + return ClientOverSshTunnelConnector( + lifetime, + connector + ).connect(tcpJoinLink) + } +} diff --git a/components/ide/jetbrains/gateway-plugin/src/main/resources-latest/META-INF/extensions.xml b/components/ide/jetbrains/gateway-plugin/src/main/resources-latest/META-INF/extensions.xml index c64c3219ac6cd1..47027bd7b1f71d 100644 --- a/components/ide/jetbrains/gateway-plugin/src/main/resources-latest/META-INF/extensions.xml +++ b/components/ide/jetbrains/gateway-plugin/src/main/resources-latest/META-INF/extensions.xml @@ -5,6 +5,8 @@ --> + diff --git a/components/ide/jetbrains/gateway-plugin/src/main/resources-stable/META-INF/extensions.xml b/components/ide/jetbrains/gateway-plugin/src/main/resources-stable/META-INF/extensions.xml index c64c3219ac6cd1..e17c81e0830fc8 100644 --- a/components/ide/jetbrains/gateway-plugin/src/main/resources-stable/META-INF/extensions.xml +++ b/components/ide/jetbrains/gateway-plugin/src/main/resources-stable/META-INF/extensions.xml @@ -5,6 +5,8 @@ --> +