1
1
package com.vk.admstorm.ssh
2
2
3
3
import com.intellij.openapi.Disposable
4
+ import com.intellij.openapi.application.ApplicationManager
4
5
import com.intellij.openapi.components.Service
5
6
import com.intellij.openapi.components.service
6
7
import com.intellij.openapi.diagnostic.logger
@@ -14,6 +15,7 @@ import com.intellij.ssh.ConnectionBuilder
14
15
import com.intellij.ssh.ExecBuilder
15
16
import com.intellij.ssh.channels.SftpChannel
16
17
import com.intellij.ssh.connectionBuilder
18
+ import com.intellij.util.ConcurrencyUtil
17
19
import com.jetbrains.plugins.remotesdk.console.SshConfigConnector
18
20
import com.vk.admstorm.AdmStartupService
19
21
import com.vk.admstorm.notifications.AdmErrorNotification
@@ -123,6 +125,14 @@ class SshConnectionService(private var myProject: Project) : Disposable {
123
125
// Disconnect the current connection, if it exists.
124
126
disconnect()
125
127
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
+
126
136
executeOnPooledThread {
127
137
// See also [com.jetbrains.plugins.remotesdk.tools.RemoteTool.startRemoteProcess]
128
138
@Suppress(" UnstableApiUsage" )
@@ -153,6 +163,8 @@ class SshConnectionService(private var myProject: Project) : Disposable {
153
163
onSuccessful?.run ()
154
164
}
155
165
} catch (ex: OpenFailException ) {
166
+ scheduler.shutdownNow()
167
+
156
168
val message = " ${ex.message} <br>" +
157
169
" Plugin can try to automatically reset the Yubikey or you can do it yourself with " +
158
170
code(" ssh-agent" )
@@ -179,6 +191,8 @@ class SshConnectionService(private var myProject: Project) : Disposable {
179
191
180
192
LOG .warn(" Failed to connect" , ex)
181
193
} catch (ex: TimeoutException ) {
194
+ scheduler.shutdownNow()
195
+
182
196
if (indicator.isCanceled) {
183
197
LOG .info(" Cancelled by user" , ex)
184
198
return
@@ -193,6 +207,8 @@ class SshConnectionService(private var myProject: Project) : Disposable {
193
207
194
208
LOG .info(" Yubikey waiting timeout" , ex)
195
209
} catch (ex: TransportException ) {
210
+ scheduler.shutdownNow()
211
+
196
212
if (ex.message == null ) {
197
213
LOG .error(" Transport exception:" , ex.javaClass.name)
198
214
return
@@ -217,6 +233,8 @@ class SshConnectionService(private var myProject: Project) : Disposable {
217
233
}).show()
218
234
LOG .info(" Corporate access error" , ex)
219
235
} catch (ex: Exception ) {
236
+ scheduler.shutdownNow()
237
+
220
238
val exceptionName = ex.javaClass.name
221
239
LOG .error(" Unhandled exception" , ex)
222
240
AdmErrorNotification (" Unhandled exception $exceptionName " ).show()
0 commit comments