Class BasicAuthentication<ParameterType,​TokenType>

  • Type Parameters:
    ParameterType - defining the parameter type for the authentication
    TokenType - defining the token type for the authentication
    All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, AuthenticationHandler<ParameterType,​TokenType>
    Direct Known Subclasses:
    HttpClientConnector.HttpBasicAuthentication, Socks5ClientConnector.SocksBasicAuthentication

    public abstract class BasicAuthentication<ParameterType,​TokenType>
    extends AbstractAuthenticationHandler<ParameterType,​TokenType>
    An abstract implementation of a username-password authentication. It can be given an initial known username-password pair; if so, this will be tried first. Subsequent rounds will then try to obtain a user name and password via the global Authenticator.
    • Field Detail

      • user

        protected java.lang.String user
        The current user name.
      • password

        protected byte[] password
        The current password.
    • Constructor Detail

      • BasicAuthentication

        public BasicAuthentication​(java.net.InetSocketAddress proxy,
                                   java.lang.String initialUser,
                                   char[] initialPassword)
        Creates a new BasicAuthentication to authenticate with the given proxy.
        Parameters:
        proxy - InetSocketAddress of the proxy to connect to
        initialUser - initial user name to try; may be null
        initialPassword - initial password to try, may be null
    • Method Detail

      • convert

        private byte[] convert​(char[] pass)
      • clearPassword

        protected void clearPassword()
        Clears the password.
      • close

        public final void close()
      • start

        public final void start()
                         throws java.lang.Exception
        Description copied from interface: AuthenticationHandler
        Produces the initial authentication token that can be then retrieved via AuthenticationHandler.getToken().
        Throws:
        java.lang.Exception - if an error occurs
      • process

        public void process()
                     throws java.lang.Exception
        Description copied from interface: AuthenticationHandler
        Produces the next authentication token, if any.
        Throws:
        java.lang.Exception - if an error occurs
      • askCredentials

        protected void askCredentials()
        Asks for credentials via the global Authenticator.