mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
Cleanup (formatting)
GitOrigin-RevId: fd98210215caa22b3c9adafdd63d790fedba8047
This commit is contained in:
committed by
intellij-monorepo-bot
parent
dffc787d4c
commit
d942bff777
@@ -11,15 +11,15 @@ import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.Messages
|
||||
import com.intellij.openapi.util.NlsSafe
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import externalApp.nativessh.NativeSshAskPassAppHandler
|
||||
import org.jetbrains.annotations.Nls
|
||||
import org.jetbrains.annotations.NonNls
|
||||
|
||||
class NativeSshGuiAuthenticator(private val project: Project,
|
||||
private val authenticationGate: AuthenticationGate,
|
||||
private val authenticationMode: AuthenticationMode,
|
||||
private val doNotRememberPasswords: Boolean) : NativeSshAskPassAppHandler {
|
||||
class NativeSshGuiAuthenticator(
|
||||
private val project: Project,
|
||||
private val authenticationGate: AuthenticationGate,
|
||||
private val authenticationMode: AuthenticationMode,
|
||||
private val doNotRememberPasswords: Boolean
|
||||
) : NativeSshAskPassAppHandler {
|
||||
private companion object {
|
||||
private val LOG = logger<NativeSshGuiAuthenticator>()
|
||||
}
|
||||
@@ -96,9 +96,9 @@ class NativeSshGuiAuthenticator(private val project: Project,
|
||||
private abstract inner class PasswordPromptHandler : PromptHandler {
|
||||
private var lastAskedKey: String? = null
|
||||
|
||||
protected abstract val title: String
|
||||
protected abstract val serviceName: String
|
||||
protected abstract fun parseDescription(description: String): Prompt?
|
||||
abstract val title: String
|
||||
abstract val serviceName: String
|
||||
abstract fun parseDescription(description: String): Prompt?
|
||||
|
||||
override fun handleInput(description: String): PromptAnswer {
|
||||
val prompt = parseDescription(description)
|
||||
@@ -111,7 +111,7 @@ class NativeSshGuiAuthenticator(private val project: Project,
|
||||
return PromptAnswer.Answer(answer)
|
||||
}
|
||||
|
||||
private fun askPassword(project: Project?, prompt: Prompt, resetPassword: Boolean): @NonNls String? {
|
||||
private fun askPassword(project: Project?, prompt: Prompt, resetPassword: Boolean): String? {
|
||||
if (authenticationMode == AuthenticationMode.NONE) return null
|
||||
|
||||
if (doNotRememberPasswords) {
|
||||
@@ -167,26 +167,16 @@ class NativeSshGuiAuthenticator(private val project: Project,
|
||||
return PromptAnswer.Answer(answer)
|
||||
}
|
||||
|
||||
private fun stripYesNoSuffix(description: String): @NlsSafe String {
|
||||
return StringUtil.replace(description,
|
||||
SshPrompts.CONFIRM_CONNECTION_PROMPT + " (yes/no)?",
|
||||
SshPrompts.CONFIRM_CONNECTION_PROMPT + "?")
|
||||
}
|
||||
private fun stripYesNoSuffix(description: String): @NlsSafe String =
|
||||
description.replace(SshPrompts.CONFIRM_CONNECTION_PROMPT + " (yes/no)?", SshPrompts.CONFIRM_CONNECTION_PROMPT + "?")
|
||||
}
|
||||
|
||||
private fun askGenericInput(description: @Nls String): String? {
|
||||
return askUserOnEdt {
|
||||
Messages.showPasswordDialog(project, description,
|
||||
ExternalProcessAuthHelperBundle.message("ssh.keyboard.interactive.title"),
|
||||
null)
|
||||
}
|
||||
private fun askGenericInput(description: @Nls String): String? = askUserOnEdt {
|
||||
Messages.showPasswordDialog(project, description, ExternalProcessAuthHelperBundle.message("ssh.keyboard.interactive.title"), null)
|
||||
}
|
||||
|
||||
private fun askUserOnEdt(query: () -> String?): String? {
|
||||
if (authenticationMode != AuthenticationMode.FULL) return null
|
||||
|
||||
return invokeAndWaitIfNeeded(ModalityState.any(), query)
|
||||
}
|
||||
private fun askUserOnEdt(query: () -> String?): String? =
|
||||
if (authenticationMode != AuthenticationMode.FULL) null else invokeAndWaitIfNeeded(ModalityState.any(), query)
|
||||
|
||||
private interface PromptHandler {
|
||||
fun handleInput(description: String): PromptAnswer
|
||||
@@ -197,6 +187,5 @@ class NativeSshGuiAuthenticator(private val project: Project,
|
||||
data class Answer(val value: String?) : PromptAnswer
|
||||
}
|
||||
|
||||
private data class Prompt(val askedKey: @NonNls String,
|
||||
val promptMessage: @Nls String)
|
||||
private data class Prompt(val askedKey: String, val promptMessage: @Nls String)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user