Interface AuthenticationHandler<ParameterType,​TokenType>

  • Type Parameters:
    ParameterType - defining the parameter type for setParams(Object)
    TokenType - defining the token type for getToken()
    All Superinterfaces:
    AutoCloseable, Closeable
    All Known Implementing Classes:
    AbstractAuthenticationHandler, BasicAuthentication, GssApiAuthentication

    public interface AuthenticationHandler<ParameterType,​TokenType>
    extends Closeable
    An AuthenticationHandler encapsulates a possibly multi-step authentication protocol. Intended usage:
     setParams(something);
     start();
     sendToken(getToken());
     while (!isDone()) {
            setParams(receiveMessageAndExtractParams());
            process();
            Object t = getToken();
            if (t != null) {
                    sendToken(t);
            }
     }
     
    An AuthenticationHandler may be stateful and therefore is a Closeable.
    • Method Detail

      • start

        void start()
            throws Exception
        Produces the initial authentication token that can be then retrieved via getToken().
        Throws:
        Exception - if an error occurs
      • process

        void process()
              throws Exception
        Produces the next authentication token, if any.
        Throws:
        Exception - if an error occurs
      • setParams

        void setParams​(ParameterType input)
        Sets the parameters for the next token generation via start() or process().
        Parameters:
        input - to set, may be null
      • getToken

        TokenType getToken()
                    throws Exception
        Retrieves the last token generated.
        Returns:
        the token, or null if there is none
        Throws:
        Exception - if an error occurs
      • isDone

        boolean isDone()
        Tells whether is authentication mechanism is done (successfully or unsuccessfully).
        Returns:
        whether this authentication is done