Class UserAuthKeyboardInteractive

    • Field Detail

      • requestPending

        private final java.util.concurrent.atomic.AtomicBoolean requestPending
      • trialsCount

        private final java.util.concurrent.atomic.AtomicInteger trialsCount
      • emptyCount

        private final java.util.concurrent.atomic.AtomicInteger emptyCount
      • passwords

        private java.util.Iterator<java.lang.String> passwords
      • maxTrials

        private int maxTrials
    • Constructor Detail

      • UserAuthKeyboardInteractive

        public UserAuthKeyboardInteractive()
    • Method Detail

      • init

        public void init​(ClientSession session,
                         java.lang.String service)
                  throws java.lang.Exception
        Specified by:
        init in interface UserAuth
        Overrides:
        init in class AbstractUserAuth
        Parameters:
        session - The ClientSession
        service - The requesting service name
        Throws:
        java.lang.Exception - If failed to initialize the mechanism
      • getExchangeLanguageTag

        protected java.lang.String getExchangeLanguageTag​(ClientSession session)
      • getExchangeSubMethods

        protected java.lang.String getExchangeSubMethods​(ClientSession session)
      • getCurrentPasswordCandidate

        protected java.lang.String getCurrentPasswordCandidate()
      • verifyTrialsCount

        protected boolean verifyTrialsCount​(ClientSession session,
                                            java.lang.String service,
                                            int cmd,
                                            int nbTrials,
                                            int maxAllowed)
      • getUserResponses

        protected java.lang.String[] getUserResponses​(java.lang.String name,
                                                      java.lang.String instruction,
                                                      java.lang.String lang,
                                                      java.lang.String[] prompt,
                                                      boolean[] echo)
        Parameters:
        name - The interaction name - may be empty
        instruction - The instruction - may be empty
        lang - The language tag - may be empty
        prompt - The prompts - may be empty
        echo - 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,
                                             java.lang.String password,
                                             java.lang.String name,
                                             java.lang.String instruction,
                                             java.lang.String lang,
                                             java.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 - The ClientSession through which the request is received
        password - The current password candidate to use
        name - The service name
        instruction - The request instruction
        lang - The reported language tag
        prompt - The requested prompts
        echo - The matching prompts echo flags
        Returns:
        Whether to use the password candidate as reply to the prompts
        See Also:
        INTERACTIVE_PASSWORD_PROMPT, CHECK_INTERACTIVE_PASSWORD_DELIM
      • getAuthCommandName

        public static java.lang.String getAuthCommandName​(int cmd)