Java Authenticator class

The class Authenticator represents an object that knows how to obtain authentication for a network connection. Usually, it does this by prompting the user for information. Applications use this class by overriding getPasswordAuthentication() in a sub-class. This method typically uses the various getXXX() accessor methods to get information about the entity requesting authentication. It must then acquire a username and password either by interacting with the user or through some other non-interactive means. The credentials are then returned as a PasswordAuthentication return value.

Java ForkJoinPool class declaration

List of Authenticator Methods

NOMethodDescription
1.protected PasswordAuthentication getPasswordAuthentication()The getPasswordAuthentication () method of Authenticator class is Called when password authorization is needed. Subclasses should override the default implementation, of getPasswordAuthentication () which returns null.
2.protected final String getRequestingHost()The getRequestingHost() method of Authenticator Class Gets the hostname of the site or proxy requesting authentication, or null if not available.
3.protected final int getRequestingPort()The getRequestingPort() method of Authenticator class Gets the port number for the requested connection.
4.protected final String getRequestingPrompt()The getRequestingPrompt() method of Authenticator Class Gets the prompt string given by the requestor.
5.protected final int getRequestingPort()The getRequestingProtocol() method of Authenticator class give the protocol that's requesting the connection. This will be based on a URL.
6.protected final String getRequestingScheme()The getRequestingScheme() method of Authenticator Class gets the scheme of the requestor (the HTTP scheme for an HTTP firewall, for example).
7.protected final InetAddress getRequestingSite()The getRequestingSite() method of Authenticator class gets the InetAddress of the site requesting for authorization, or null if not available.
8.protected URL getRequestingURL()The getRequestingURL() method of Authenticator Class returns the URL that resulted in this request for authentication.
9.public static void setDefault(Authenticator a)The setDefault() method of Authenticator class sets the authenticator that will be used by the networking code when a proxy or an HTTP server asks for authentication.
10.protected Authenticator.RequestorType getRequestorType()The getRequestorType() method of Authenticator Class returns whether the requestor is a Proxy or a Server.

Java Authenticator Class Example: getRequestingPort ()

Test it Now

Output:

Host using url.getHost ::www.javaTpoint.com
Port Requesting :8080
// Source code of https://www.javatpoint.com is printed. 

Java ForkJoinPool Class Example: getRequestingProtocol()

Test it Now

Output:

Protocol Used:  https
Host using url.getHost ::www.javatpoint.com
Protocol:null
// Source code of https://www.javatpoint.com is printed.  

Java ForkJoinPool Class Example: setDefault ()

Test it Now

Output:

Port info ::-1
URL :null
// Source code of https://www.javatpoint.com is printed. 





Latest Courses