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 intstatic final Stringprivate intprivate final AtomicBooleanprivate booleanprivate booleanFields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
logFields inherited from interface org.apache.sshd.common.NamedResource
BY_NAME_COMPARATOR, NAME_EXTRACTOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetAuthCommandName(int cmd) protected Stringprotected StringgetExchangeLanguageTag(ClientSession session) protected StringgetExchangeSubMethods(ClientSession session) protected String[]getUserResponses(String name, String instruction, String lang, String[] prompt, boolean[] echo) voidinit(ClientSession session, String service) protected booleanprocessAuthDataRequest(ClientSession session, String service, Buffer buffer) protected booleansendAuthDataRequest(ClientSession session, String service) protected booleanuseCurrentPassword(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 booleanverifyTrialsCount(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, toStringMethods 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, warnMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:
initin interfaceUserAuth- Overrides:
initin classAbstractUserAuth- Parameters:
session- TheClientSessionservice- The requesting service name- Throws:
Exception- If failed to initialize the mechanism
-
sendAuthDataRequest
- Specified by:
sendAuthDataRequestin classAbstractUserAuth- Throws:
Exception
-
processAuthDataRequest
protected boolean processAuthDataRequest(ClientSession session, String service, Buffer buffer) throws Exception - Specified by:
processAuthDataRequestin 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
nullthen 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- TheClientSessionthrough 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
-