Skip to content

Commit 2da3d73

Browse files
committed
rebase_3
1 parent 52e1962 commit 2da3d73

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/main/kotlin/com/vk/admstorm/ssh/SshConnectionService.kt

+18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.vk.admstorm.ssh
22

33
import com.intellij.openapi.Disposable
4+
import com.intellij.openapi.application.ApplicationManager
45
import com.intellij.openapi.components.Service
56
import com.intellij.openapi.components.service
67
import com.intellij.openapi.diagnostic.logger
@@ -14,6 +15,7 @@ import com.intellij.ssh.ConnectionBuilder
1415
import com.intellij.ssh.ExecBuilder
1516
import com.intellij.ssh.channels.SftpChannel
1617
import com.intellij.ssh.connectionBuilder
18+
import com.intellij.util.ConcurrencyUtil
1719
import com.jetbrains.plugins.remotesdk.console.SshConfigConnector
1820
import com.vk.admstorm.AdmStartupService
1921
import com.vk.admstorm.notifications.AdmErrorNotification
@@ -123,6 +125,14 @@ class SshConnectionService(private var myProject: Project) : Disposable {
123125
// Disconnect the current connection, if it exists.
124126
disconnect()
125127

128+
val scheduler = ConcurrencyUtil.newSingleScheduledThreadExecutor("YubiKeyTouchingNotification")
129+
scheduler.schedule({
130+
ApplicationManager.getApplication().invokeLater {
131+
AdmNotification("Did you forget to touch yubikey?")
132+
.show()
133+
}
134+
}, 5, TimeUnit.SECONDS)
135+
126136
executeOnPooledThread {
127137
// See also [com.jetbrains.plugins.remotesdk.tools.RemoteTool.startRemoteProcess]
128138
@Suppress("UnstableApiUsage")
@@ -153,6 +163,8 @@ class SshConnectionService(private var myProject: Project) : Disposable {
153163
onSuccessful?.run()
154164
}
155165
} catch (ex: OpenFailException) {
166+
scheduler.shutdownNow()
167+
156168
val message = "${ex.message}<br>" +
157169
"Plugin can try to automatically reset the Yubikey or you can do it yourself with " +
158170
code("ssh-agent")
@@ -179,6 +191,8 @@ class SshConnectionService(private var myProject: Project) : Disposable {
179191

180192
LOG.warn("Failed to connect", ex)
181193
} catch (ex: TimeoutException) {
194+
scheduler.shutdownNow()
195+
182196
if (indicator.isCanceled) {
183197
LOG.info("Cancelled by user", ex)
184198
return
@@ -193,6 +207,8 @@ class SshConnectionService(private var myProject: Project) : Disposable {
193207

194208
LOG.info("Yubikey waiting timeout", ex)
195209
} catch (ex: TransportException) {
210+
scheduler.shutdownNow()
211+
196212
if (ex.message == null) {
197213
LOG.error("Transport exception:", ex.javaClass.name)
198214
return
@@ -217,6 +233,8 @@ class SshConnectionService(private var myProject: Project) : Disposable {
217233
}).show()
218234
LOG.info("Corporate access error", ex)
219235
} catch (ex: Exception) {
236+
scheduler.shutdownNow()
237+
220238
val exceptionName = ex.javaClass.name
221239
LOG.error("Unhandled exception", ex)
222240
AdmErrorNotification("Unhandled exception $exceptionName").show()

0 commit comments

Comments
 (0)