Top Description Fields Methods
org.apache.sshd.client.auth.keyboard

public Interface UserInteraction

Imports
java.security.KeyPair, java.util.List, org.apache.sshd.client.session.ClientSession, org.apache.sshd.common.util.GenericUtils

Interface used by the ssh client to communicate with the end user.
Author
Apache MINA SSHD Project
See Also
RFC 4256

Field Summary

Modifier and TypeField and Description
public static final String
AUTO_DETECT_PASSWORD_PROMPT

Whether to auto-detect password challenge prompt

public static final String
CHECK_INTERACTIVE_PASSWORD_DELIM

If password prompt detected then check it ends with any of the comma separated list of these values.

public static final boolean
DEFAULT_AUTO_DETECT_PASSWORD_PROMPT

Default value for user-interaction-auto-detect-password-prompt

public static final String
DEFAULT_CHECK_INTERACTIVE_PASSWORD_DELIM

Default value of user-interaction-check-password-delimiter

public static final String
DEFAULT_INTERACTIVE_PASSWORD_PROMPT

Default value for user-interaction-password-prompt

public static final String
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.

public static final UserInteraction
NONE

A useful "placeholder" that indicates that no interaction is expected

Note

throws IllegalStateException is any of the interaction methods is called

Method Summary

Modifier and TypeMethod and Description
public static int

Returns:

The position of any token in the prompt - negative if not found
findPromptComponentLastPosition
(String
The user interaction prompt
prompt
,
String
A comma-separated list of tokens whose last index is prompt is sought.
tokensList
)

public String

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...

getUpdatedPassword
(ClientSession
The ClientSession through which the request was received
session
,
String
The server's prompt (may be empty)
prompt
,
String
The prompt's language (may be empty)
lang
)

Invoked when the server returns an SSH_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).

public String[]

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.
interactive
(ClientSession
The ClientSession through which the request was received
session
,
String
The interaction name (may be empty)
name
,
String
The instruction (may be empty)
instruction
,
String
The language for the data (may be empty)
lang
,
String[]
The prompts to be displayed (may be empty)
prompt
,
boolean[]
For each prompt whether to echo the user's response
echo
)

Invoked when "keyboard-interactive" authentication mechanism is used in order to provide responses for the server's challenges (a.k.a. prompts)

public default boolean

Returns:

true if user interaction allowed for this session (default)
isInteractionAllowed
(ClientSession session)

public default String

Returns:

The password to use - null signals no more passwords available
resolveAuthPasswordAttempt
(ClientSession
The ClientSession through which the request was received
session
)

Invoked during password authentication when no more pre-registered passwords are available

public default KeyPair

Returns:

The KeyPair to use - null signals no more keys available
resolveAuthPublicKeyIdentityAttempt
(ClientSession
The ClientSession through which the request was received
session
)

Invoked during public key authentication when no more pre-registered keys are available

public default void
serverVersionInfo(ClientSession
The ClientSession through which this information was received
session
,
List<String>
The sent extra lines - without the server version
lines
)

Called if the server sent any extra information beyond the standard version line

public default void
welcome(ClientSession
The ClientSession through which the banner was received
session
,
String
The welcome banner
banner
,
String
The banner language code - may be empty
lang
)

Displays the welcome banner to the user.

Field Detail

AUTO_DETECT_PASSWORD_PROMPTback to summary
public static final String AUTO_DETECT_PASSWORD_PROMPT

Whether to auto-detect password challenge prompt

See Also
INTERACTIVE_PASSWORD_PROMPT, CHECK_INTERACTIVE_PASSWORD_DELIM
CHECK_INTERACTIVE_PASSWORD_DELIMback to summary
public static final String 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.

DEFAULT_AUTO_DETECT_PASSWORD_PROMPTback to summary
public static final boolean DEFAULT_AUTO_DETECT_PASSWORD_PROMPT

Default value for user-interaction-auto-detect-password-prompt

DEFAULT_CHECK_INTERACTIVE_PASSWORD_DELIMback to summary
public static final String DEFAULT_CHECK_INTERACTIVE_PASSWORD_DELIM

Default value of user-interaction-check-password-delimiter

DEFAULT_INTERACTIVE_PASSWORD_PROMPTback to summary
public static final String DEFAULT_INTERACTIVE_PASSWORD_PROMPT

Default value for user-interaction-password-prompt

INTERACTIVE_PASSWORD_PROMPTback to summary
public static final String 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.

NONEback to summary
public static final UserInteraction NONE

A useful "placeholder" that indicates that no interaction is expected

Note

throws IllegalStateException is any of the interaction methods is called

Method Detail

findPromptComponentLastPositionback to summary
public static int findPromptComponentLastPosition(String prompt, String tokensList)
Parameters
prompt:String

The user interaction prompt

tokensList:String

A comma-separated list of tokens whose last index is prompt is sought.

Returns:int

The position of any token in the prompt - negative if not found

getUpdatedPasswordback to summary
public String getUpdatedPassword(ClientSession session, String prompt, String lang)

Invoked when the server returns an SSH_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:ClientSession

The ClientSession through which the request was received

prompt:String

The server's prompt (may be empty)

lang:String

The prompt's language (may be empty)

Returns:String

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...

interactiveback to summary
public 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:ClientSession

The ClientSession through which the request was received

name:String

The interaction name (may be empty)

instruction:String

The instruction (may be empty)

lang:String

The language for the data (may be empty)

prompt:String[]

The prompts to be displayed (may be empty)

echo:boolean[]

For each prompt whether to echo the user's response

Returns:String[]

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.

isInteractionAllowedback to summary
public default boolean isInteractionAllowed(ClientSession session)
Parameters
session:ClientSession

The ClientSession

Returns:boolean

true if user interaction allowed for this session (default)

resolveAuthPasswordAttemptback to summary
public default String resolveAuthPasswordAttempt(ClientSession session) throws Exception

Invoked during password authentication when no more pre-registered passwords are available

Parameters
session:ClientSession

The ClientSession through which the request was received

Returns:String

The password to use - null signals no more passwords available

Exceptions
Exception:
if failed to handle the request - Note: may cause session termination
resolveAuthPublicKeyIdentityAttemptback to summary
public default KeyPair resolveAuthPublicKeyIdentityAttempt(ClientSession session) throws Exception

Invoked during public key authentication when no more pre-registered keys are available

Parameters
session:ClientSession

The ClientSession through which the request was received

Returns:KeyPair

The KeyPair to use - null signals no more keys available

Exceptions
Exception:
if failed to handle the request - Note: may cause session termination
serverVersionInfoback to summary
public default void serverVersionInfo(ClientSession session, List<String> lines)

Called if the server sent any extra information beyond the standard version line

Parameters
session:ClientSession

The ClientSession through which this information was received

lines:List<String>

The sent extra lines - without the server version

See Also
RFC 4253 - section 4.2
welcomeback to summary
public default void welcome(ClientSession session, String banner, String lang)

Displays the welcome banner to the user.

Parameters
session:ClientSession

The ClientSession through which the banner was received

banner:String

The welcome banner

lang:String

The banner language code - may be empty