Class BasicAuthenticator

public abstract class BasicAuthenticator
extends Authenticator

BasicAuthenticator provides an implementation of HTTP Basic authentication. It is an abstract class and must be extended to provide an implementation of checkCredentials(String,String) which is called to verify each incoming request.

Nested Classes

Nested classes/interfaces declared in class com.sun.net.httpserver.Authenticator

Authenticator.Failure, Authenticator.Result, Authenticator.Retry, Authenticator.Success

Fields

Modifier and Type Field Description
protected String realm

Constructors

Constructor Description
BasicAuthenticator​(String realm)

Creates a BasicAuthenticator for the given HTTP realm

Methods

Modifier and Type Method Description
abstract boolean checkCredentials​(String username, String password)

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 BasicAuthenticator was created with

Methods declared in class com.sun.net.httpserver.Authenticator

authenticate

Methods declared in class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Fields

realm

protected String realm

Constructors

BasicAuthenticator

public BasicAuthenticator(String realm)

Creates a BasicAuthenticator for the given HTTP realm

Parameters:
realm - The HTTP Basic authentication realm
Throws:
NullPointerException - if the realm is an empty string

Methods

getRealm

public String getRealm()

returns the realm this BasicAuthenticator was created with

Returns:
the authenticator's realm string.

checkCredentials

public abstract boolean checkCredentials(String username,
                                         String password)

called for each incoming request to verify the given name and password in the context of this Authenticator's realm. Any caching of credentials must be done by the implementation of this method

Parameters:
username - the username from the request
password - the password from the request
Returns:
true if the credentials are valid, false otherwise.

© 1993, 2020, 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/11/docs/api/jdk.httpserver/com/sun/net/httpserver/BasicAuthenticator.html