public abstract class BasicAuthenticator extends Authenticator
checkCredentials(String,String) which is called to verify each incoming request.Authenticator.Failure, Authenticator.Result, Authenticator.Retry, Authenticator.Success
| Modifier and Type | Field | Description | 
|---|---|---|
| protected final String | realm | The HTTP Basic authentication realm. | 
| Constructor | Description | 
|---|---|
| BasicAuthenticator | Creates a  BasicAuthenticatorfor the given HTTP realm. | 
| BasicAuthenticator | Creates a  BasicAuthenticatorfor the given HTTP realm and using the givenCharsetto decode the Basic authentication credentials (username and password). | 
| Modifier and Type | Method | Description | 
|---|---|---|
| Authenticator.Result | authenticate | Called to authenticate each incoming request. | 
| abstract boolean | checkCredentials | Called for each incoming request to verify the given name and password in the context of this authenticator's realm. | 
| String | getRealm() | Returns the realm this  BasicAuthenticatorwas created with. | 
protected final String realm
public BasicAuthenticator(String realm)
BasicAuthenticator for the given HTTP realm. The Basic authentication credentials (username and password) are decoded using the platform's default character set.realm parameter will be embedded in a quoted string.realm - the HTTP Basic authentication realmNullPointerException - if realm is null
IllegalArgumentException - if realm is an empty string or is not correctly quoted, as specified in  RFC 7230 section-3.2. Note, any \ character used for quoting must itself be quoted in source code.public BasicAuthenticator(String realm, Charset charset)
BasicAuthenticator for the given HTTP realm and using the given Charset to decode the Basic authentication credentials (username and password).UTF-8 is the recommended charset because its usage is communicated to the client, and therefore more likely to be used also by the client. The value of the realm parameter will be embedded in a quoted string.
realm - the HTTP Basic authentication realmcharset - the Charset to decode incoming credentials from the clientNullPointerException - if realm or charset are null
IllegalArgumentException - if realm is an empty string or is not correctly quoted, as specified in  RFC 7230 section-3.2. Note, any \ character used for quoting must itself be quoted in source code.public String getRealm()
BasicAuthenticator was created with.public Authenticator.Result authenticate(HttpExchange t)
AuthenticatorAuthenticator.Failure, Authenticator.Success or Authenticator.Retry object as appropriate: Failure means the authentication has completed, but has failed due to invalid credentials. Success means that the authentication has succeeded, and a Principal object representing the user can be retrieved by calling Authenticator.Success.getPrincipal(). Retry means that another HTTP exchange is required. Any response headers needing to be sent back to the client are set in the given HttpExchange. The response code to be returned must be provided in the Retry object. Retry may occur multiple times. authenticate in class Authenticator
t - the HttpExchange upon which authenticate is calledpublic abstract boolean checkCredentials(String username, String password)
username - the username from the requestpassword - the password from the requesttrue if the credentials are valid, false otherwise
    © 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
    https://docs.oracle.com/en/java/javase/21/docs/api/jdk.httpserver/com/sun/net/httpserver/BasicAuthenticator.html