Class UserAuthKeyboardInteractive
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.client.auth.AbstractUserAuth
org.apache.sshd.client.auth.keyboard.UserAuthKeyboardInteractive
- All Implemented Interfaces:
UserAuth
,ClientSessionHolder
,UserAuthInstance<ClientSession>
,NamedResource
Manages a "keyboard-interactive" exchange according to
RFC4256
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
static final String
private int
private final AtomicBoolean
private boolean
private boolean
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
Fields inherited from interface org.apache.sshd.common.NamedResource
BY_NAME_COMPARATOR, NAME_EXTRACTOR
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
getAuthCommandName
(int cmd) protected String
protected String
getExchangeLanguageTag
(ClientSession session) protected String
getExchangeSubMethods
(ClientSession session) protected String[]
getUserResponses
(String name, String instruction, String lang, String[] prompt, boolean[] echo) void
init
(ClientSession session, String service) protected boolean
processAuthDataRequest
(ClientSession session, String service, Buffer buffer) protected boolean
sendAuthDataRequest
(ClientSession session, String service) protected boolean
useCurrentPassword
(ClientSession session, String password, String name, String instruction, String lang, String[] prompt, boolean[] echo) Checks if we have a candidate password and exactly one prompt is requested with no echo, and the prompt matches a configurable pattern.protected boolean
verifyTrialsCount
(ClientSession session, String service, int cmd, int nbTrials, int maxAllowed) Methods inherited from class org.apache.sshd.client.auth.AbstractUserAuth
destroy, getClientSession, getName, getService, getSession, isCancellable, process, setCancellable, toString
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.sshd.client.auth.UserAuth
signalAuthMethodFailure, signalAuthMethodSuccess
-
Field Details
-
NAME
- See Also:
-
requestPending
-
passwords
-
maxAttempts
private int maxAttempts -
nOfAttempts
private int nOfAttempts -
wasChallenged
private boolean wasChallenged -
withUserInteraction
private boolean withUserInteraction
-
-
Constructor Details
-
UserAuthKeyboardInteractive
public UserAuthKeyboardInteractive()
-
-
Method Details
-
init
- Specified by:
init
in interfaceUserAuth
- Overrides:
init
in classAbstractUserAuth
- Parameters:
session
- TheClientSession
service
- The requesting service name- Throws:
Exception
- If failed to initialize the mechanism
-
sendAuthDataRequest
- Specified by:
sendAuthDataRequest
in classAbstractUserAuth
- Throws:
Exception
-
processAuthDataRequest
protected boolean processAuthDataRequest(ClientSession session, String service, Buffer buffer) throws Exception - Specified by:
processAuthDataRequest
in classAbstractUserAuth
- Throws:
Exception
-
getExchangeLanguageTag
-
getExchangeSubMethods
-
getCurrentPasswordCandidate
-
verifyTrialsCount
protected boolean verifyTrialsCount(ClientSession session, String service, int cmd, int nbTrials, int maxAllowed) -
getUserResponses
protected String[] getUserResponses(String name, String instruction, String lang, String[] prompt, boolean[] echo) - Parameters:
name
- The interaction name - may be emptyinstruction
- The instruction - may be emptylang
- The language tag - may be emptyprompt
- The prompts - may be emptyecho
- Whether to echo the response for the prompt or not - same length as the prompts- Returns:
- The response for each prompt - if
null
then the assumption is that some internal error occurred and no response is sent. Note: according to RFC4256 the number of responses should be exactly the same as the number of prompts. However, since it is the server's responsibility to enforce this we do not validate the response (other than logging it as a warning...)
-
useCurrentPassword
protected boolean useCurrentPassword(ClientSession session, String password, String name, String instruction, String lang, String[] prompt, boolean[] echo) Checks if we have a candidate password and exactly one prompt is requested with no echo, and the prompt matches a configurable pattern.- Parameters:
session
- TheClientSession
through which the request is receivedpassword
- The current password candidate to usename
- The service nameinstruction
- The request instructionlang
- The reported language tagprompt
- The requested promptsecho
- The matching prompts echo flags- Returns:
- Whether to use the password candidate as reply to the prompts
- See Also:
-
getAuthCommandName
-