Module bus.http

Class NetAuthenticator

java.lang.Object
org.miaixz.bus.http.secure.NetAuthenticator
All Implemented Interfaces:
Authenticator

public class NetAuthenticator extends Object implements Authenticator
An authenticator that bridges Httpd's authentication mechanism with Java's built-in Authenticator. This allows the client to use credentials configured globally in the JVM.
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • NetAuthenticator

      public NetAuthenticator()
  • Method Details

    • authenticate

      public Request authenticate(Route route, Response response) throws IOException
      Description copied from interface: Authenticator
      Returns a request that includes a credential to satisfy an authentication challenge in response. Returns null if the challenge cannot be satisfied.

      The route parameter is a best-effort and may not always be provided, especially when an authenticator is invoked manually in an application interceptor (e.g., for client-specific retries).

      Specified by:
      authenticate in interface Authenticator
      Parameters:
      route - The route that resulted in the challenge, or null if not available.
      response - The response containing the authentication challenge.
      Returns:
      A new request with the appropriate authentication header, or null if no response is possible.
      Throws:
      IOException - if an I/O error occurs.