Class BasicScheme

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  BasicScheme.State  
    • Constructor Summary

      Constructors 
      Constructor Description
      BasicScheme()
      Constructs a new BasicScheme with UTF-8 as the charset.
      BasicScheme​(java.nio.charset.Charset charset)
      Deprecated.
      This constructor is deprecated to enforce the use of StandardCharsets.UTF_8 encoding in compliance with RFC 7617 for HTTP Basic Authentication.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String generateAuthResponse​(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context)
      Generates an authorization response based on the current state.
      java.lang.String getName()
      Returns textual designation of the given authentication scheme.
      java.security.Principal getPrincipal()
      Returns Principal whose credentials are used to generate an authentication response.
      java.lang.String getRealm()
      Returns authentication realm.
      void initPreemptive​(Credentials credentials)  
      boolean isChallengeComplete()
      Authentication process may involve a series of challenge-response exchanges.
      boolean isConnectionBased()
      Determines if the authentication scheme is expected to provide an authorization response on a per connection basis instead of the standard per request basis
      boolean isResponseReady​(org.apache.hc.core5.http.HttpHost host, CredentialsProvider credentialsProvider, org.apache.hc.core5.http.protocol.HttpContext context)
      Determines whether or not an authorization response can be generated based on the actual authentication state.
      void processChallenge​(AuthChallenge authChallenge, org.apache.hc.core5.http.protocol.HttpContext context)
      Processes the given auth challenge.
      void restore​(BasicScheme.State state)  
      BasicScheme.State store()  
      java.lang.String toString()  
      private void validatePassword()  
      private void validateUsername()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • LOG

        private static final org.slf4j.Logger LOG
      • paramMap

        private final java.util.Map<java.lang.String,​java.lang.String> paramMap
      • base64codec

        private transient Base64 base64codec
      • complete

        private boolean complete
    • Constructor Detail

      • BasicScheme

        @Deprecated
        public BasicScheme​(java.nio.charset.Charset charset)
        Deprecated.
        This constructor is deprecated to enforce the use of StandardCharsets.UTF_8 encoding in compliance with RFC 7617 for HTTP Basic Authentication. Use the default constructor BasicScheme() instead.
        Parameters:
        charset - the Charset set to be used for encoding credentials. This parameter is ignored as UTF-8 is always used.
      • BasicScheme

        public BasicScheme()
        Constructs a new BasicScheme with UTF-8 as the charset.
        Since:
        4.3
    • Method Detail

      • initPreemptive

        public void initPreemptive​(Credentials credentials)
      • getName

        public java.lang.String getName()
        Description copied from interface: AuthScheme
        Returns textual designation of the given authentication scheme.
        Specified by:
        getName in interface AuthScheme
        Returns:
        the name of the given authentication scheme
      • isConnectionBased

        public boolean isConnectionBased()
        Description copied from interface: AuthScheme
        Determines if the authentication scheme is expected to provide an authorization response on a per connection basis instead of the standard per request basis
        Specified by:
        isConnectionBased in interface AuthScheme
        Returns:
        true if the scheme is connection based, false if the scheme is request based.
      • getRealm

        public java.lang.String getRealm()
        Description copied from interface: AuthScheme
        Returns authentication realm. If the concept of an authentication realm is not applicable to the given authentication scheme, returns null.
        Specified by:
        getRealm in interface AuthScheme
        Returns:
        the authentication realm
      • isChallengeComplete

        public boolean isChallengeComplete()
        Description copied from interface: AuthScheme
        Authentication process may involve a series of challenge-response exchanges. This method tests if the authorization process has been fully completed (either successfully or unsuccessfully), that is, all the required authorization challenges have been processed in their entirety.

        Please note if the scheme returns true from this method in response to a challenge, it effectively implies a failure to respond to this challenge and termination of the authentication process.

        Specified by:
        isChallengeComplete in interface AuthScheme
        Returns:
        true if the authentication process has been completed, false otherwise.
      • isResponseReady

        public boolean isResponseReady​(org.apache.hc.core5.http.HttpHost host,
                                       CredentialsProvider credentialsProvider,
                                       org.apache.hc.core5.http.protocol.HttpContext context)
                                throws AuthenticationException
        Description copied from interface: AuthScheme
        Determines whether or not an authorization response can be generated based on the actual authentication state. Generally the outcome of this method will depend upon availability of user credentials necessary to produce an authorization response.
        Specified by:
        isResponseReady in interface AuthScheme
        credentialsProvider - The credentials to be used for authentication
        context - HTTP context
        Returns:
        true if an authorization response can be generated and the authentication handshake can proceed, false otherwise.
        Throws:
        AuthenticationException - if authorization string cannot be generated due to an authentication failure
      • getPrincipal

        public java.security.Principal getPrincipal()
        Description copied from interface: AuthScheme
        Returns Principal whose credentials are used to generate an authentication response. Connection based schemes are required to return a user Principal if authorization applies to for the entire life span of connection.
        Specified by:
        getPrincipal in interface AuthScheme
        Returns:
        user principal
        See Also:
        AuthScheme.isConnectionBased()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object