Interface UserInteraction
public interface UserInteraction
Interface used by the ssh client to communicate with the end user.
- Author:
- Apache MINA SSHD Project
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Whether to auto-detect password challenge promptstatic final String
If password prompt detected then check it ends with any of the comma separated list of these values.static final boolean
Default value for "user-interaction-auto-detect-password-prompt"static final String
Default value of "user-interaction-check-password-delimiter"static final String
Default value for "user-interaction-password-prompt"static final String
Comma separated list of values used to detect request for a password in interactive mode.static final UserInteraction
A useful "placeholder" that indicates that no interaction is expected. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
findPromptComponentLastPosition
(String prompt, String tokensList) getUpdatedPassword
(ClientSession session, String prompt, String lang) Invoked when the server returns anSSH_MSG_USERAUTH_PASSWD_CHANGEREQ
response indicating that the password should be changed - e.g., expired or not strong enough (as per the server's policy).String[]
interactive
(ClientSession session, String name, String instruction, String lang, String[] prompt, boolean[] echo) Invoked when "keyboard-interactive" authentication mechanism is used in order to provide responses for the server's challenges (a.k.a.default boolean
isInteractionAllowed
(ClientSession session) default String
resolveAuthPasswordAttempt
(ClientSession session) Invoked during password authentication when no more pre-registered passwords are availabledefault KeyPair
Invoked during public key authentication when no more pre-registered keys are availabledefault void
serverVersionInfo
(ClientSession session, List<String> lines) Called if the server sent any extra information beyond the standard version linedefault void
welcome
(ClientSession session, String banner, String lang) Displays the welcome banner to the user.
-
Field Details
-
AUTO_DETECT_PASSWORD_PROMPT
Whether to auto-detect password challenge prompt -
DEFAULT_AUTO_DETECT_PASSWORD_PROMPT
static final boolean DEFAULT_AUTO_DETECT_PASSWORD_PROMPTDefault value for "user-interaction-auto-detect-password-prompt"- See Also:
-
INTERACTIVE_PASSWORD_PROMPT
Comma separated list of values used to detect request for a password in interactive mode. Note: the matched prompt is assumed to be lowercase.- See Also:
-
DEFAULT_INTERACTIVE_PASSWORD_PROMPT
Default value for "user-interaction-password-prompt"- See Also:
-
CHECK_INTERACTIVE_PASSWORD_DELIM
If password prompt detected then check it ends with any of the comma separated list of these values. Use "none" to disable this extra check. Note: the matched prompt is assumed to be lowercase.- See Also:
-
DEFAULT_CHECK_INTERACTIVE_PASSWORD_DELIM
Default value of "user-interaction-check-password-delimiter"- See Also:
-
NONE
A useful "placeholder" that indicates that no interaction is expected. Note: throwsIllegalStateException
is any of the interaction methods is called
-
-
Method Details
-
isInteractionAllowed
- Parameters:
session
- TheClientSession
- Returns:
true
if user interaction allowed for this session (default)
-
serverVersionInfo
Called if the server sent any extra information beyond the standard version line- Parameters:
session
- TheClientSession
through which this information was receivedlines
- The sent extra lines - without the server version- See Also:
-
welcome
Displays the welcome banner to the user.- Parameters:
session
- TheClientSession
through which the banner was receivedbanner
- The welcome bannerlang
- The banner language code - may be empty
-
interactive
String[] interactive(ClientSession session, String name, String instruction, String lang, String[] prompt, boolean[] echo) Invoked when "keyboard-interactive" authentication mechanism is used in order to provide responses for the server's challenges (a.k.a. prompts)- Parameters:
session
- TheClientSession
through which the request was receivedname
- The interaction name (may be empty)instruction
- The instruction (may be empty)lang
- The language for the data (may be empty)prompt
- The prompts to be displayed (may be empty)echo
- For each prompt whether to echo the user's response- Returns:
- The replies - Note: the protocol states that the number of replies should be exactly the same as the number of prompts, however we do not enforce it since it is defined as the server's job to check and manage this violation.
-
getUpdatedPassword
Invoked when the server returns anSSH_MSG_USERAUTH_PASSWD_CHANGEREQ
response indicating that the password should be changed - e.g., expired or not strong enough (as per the server's policy).- Parameters:
session
- TheClientSession
through which the request was receivedprompt
- The server's prompt (may be empty)lang
- The prompt's language (may be empty)- Returns:
- The password to use - if
null
/empty then no updated password was provided - thus failing the authentication via passwords (Note: authentication might still succeed via some other means - be it other passwords, public keys, etc...)
-
resolveAuthPasswordAttempt
Invoked during password authentication when no more pre-registered passwords are available- Parameters:
session
- TheClientSession
through which the request was received- Returns:
- The password to use -
null
signals no more passwords available - Throws:
Exception
- if failed to handle the request - Note: may cause session termination
-
resolveAuthPublicKeyIdentityAttempt
Invoked during public key authentication when no more pre-registered keys are available- Parameters:
session
- TheClientSession
through which the request was received- Returns:
- The
KeyPair
to use -null
signals no more keys available - Throws:
Exception
- if failed to handle the request - Note: may cause session termination
-
findPromptComponentLastPosition
- Parameters:
prompt
- The user interaction prompttokensList
- A comma-separated list of tokens whose last index is prompt is sought.- Returns:
- The position of any token in the prompt - negative if not found
-