Applications use this class by overriding getPasswordAuthentication()
in a sub-class. This method will
typically use 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.
An instance of this concrete sub-class is then registered
with the system by calling setDefault(Authenticator)
.
When authentication is required, the system will invoke one of the
requestPasswordAuthentication() methods which in turn will call the
getPasswordAuthentication() method of the registered object.
All methods that request authentication have a default implementation that fails.
java.net.Authenticator#setDefault(java.net.Authenticator)
, java.net.Authenticator#getPasswordAuthentication()
Modifier and Type | Class and Description |
---|---|
public static enum | Authenticator.
The type of the entity requesting authentication. |
Modifier and Type | Field and Description |
---|---|
private Authenticator. | |
private String | |
private int | |
private String | |
private String | |
private String | |
private InetAddress | |
private URL | |
private static volatile Authenticator |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
public static Authenticator | Returns: The default authenticator, if set,null otherwise.Gets the default authenticator. |
protected PasswordAuthentication | Returns: The PasswordAuthentication collected from the user, or null if none is provided.Called when password authorization is needed. |
protected final String | Returns: the hostname of the connection requiring authentication, or null if it's not available.Gets the |
protected final int | Returns: anint indicating the
port for the requested connection.Gets the port number for the requested connection. |
protected final String | Returns: the prompt string given by the requestor (realm for http requests)Gets the prompt string given by the requestor. |
protected final String | Returns: the protocol, optionally followed by "/version", where version is a version number.Give the protocol that's requesting the connection. |
protected final String | Returns: the scheme of the requestorGets the scheme of the requestor (the HTTP scheme for an HTTP firewall, for example). |
protected final InetAddress | Returns: the InetAddress of the site requesting authorization, or null if it's not available.Gets the |
protected URL | Returns: the requesting URLReturns the URL that resulted in this request for authentication. |
protected Authenticator. | Returns: the authentication type of the requestorReturns whether the requestor is a Proxy or a Server. |
public static PasswordAuthentication | Returns: The username/password, or null if one can't be gotten.The InetAddress of the site requesting authorization,
or null if not known. addr, int the port for the requested connection port, String The protocol that's requesting the connection
( protocol, String java. )A prompt string for the user prompt, String The authentication scheme scheme)Ask the authenticator that has been registered with the system for a password. |
public static PasswordAuthentication | Returns: The username/password, or null if one can't be gotten.The hostname of the site requesting authentication. host, InetAddress The InetAddress of the site requesting authentication,
or null if not known. addr, int the port for the requested connection. port, String The protocol that's requesting the connection
( protocol, String java. )A prompt string for the user which identifies the authentication realm. prompt, String The authentication scheme scheme)Ask the authenticator that has been registered with the system for a password. |
public static PasswordAuthentication | Returns: The username/password, or null if one can't be gotten.The hostname of the site requesting authentication. host, InetAddress The InetAddress of the site requesting authorization,
or null if not known. addr, int the port for the requested connection port, String The protocol that's requesting the connection
( protocol, String java. )A prompt string for the user prompt, String The authentication scheme scheme, URL The requesting URL that caused the authentication url, Authenticator.The type (server or proxy) of the entity requesting
authentication. reqTypeAsk the authenticator that has been registered with the system for a password. |
public static PasswordAuthentication | Returns: The username/password, ornull if one can't be gotten.the authenticator, or authenticator, String null .The hostname of the site requesting authentication. host, InetAddress The InetAddress of the site requesting authorization,
or null if not known. addr, int the port for the requested connection port, String The protocol that's requesting the connection
( protocol, String java. )A prompt string for the user prompt, String The authentication scheme scheme, URL The requesting URL that caused the authentication url, Authenticator.The type (server or proxy) of the entity requesting
authentication. reqTypeAsk the given |
public PasswordAuthentication | Returns: The username/password, or null if one can't be gottenThe hostname of the site requesting authentication. host, InetAddress The InetAddress of the site requesting authorization,
or null if not known. addr, int the port for the requested connection port, String The protocol that's requesting the connection
( protocol, String java. )A prompt string for the user prompt, String The authentication scheme scheme, URL The requesting URL that caused the authentication url, Authenticator.The type (server or proxy) of the entity requesting
authentication. reqTypeAsk this authenticator for a password. |
private void | |
public static synchronized void | setDefault(Authenticator
The authenticator to be set. If a is a)null then
any previously set authenticator is removed.Sets the authenticator that will be used by the networking code when a proxy or an HTTP server asks for authentication. |
requestingAuthType | back to summary |
---|---|
private Authenticator. |
requestingHost | back to summary |
---|---|
private String requestingHost |
requestingPort | back to summary |
---|---|
private int requestingPort |
requestingPrompt | back to summary |
---|---|
private String requestingPrompt |
requestingProtocol | back to summary |
---|---|
private String requestingProtocol |
requestingScheme | back to summary |
---|---|
private String requestingScheme |
requestingSite | back to summary |
---|---|
private InetAddress requestingSite |
requestingURL | back to summary |
---|---|
private URL requestingURL |
theAuthenticator | back to summary |
---|---|
private static volatile Authenticator theAuthenticator |
Authenticator | back to summary |
---|---|
public Authenticator() Constructor for subclasses to call. |
getDefault | back to summary |
---|---|
public static Authenticator getDefault() Gets the default authenticator.
First, if there is a security manager, its
|
getPasswordAuthentication | back to summary |
---|---|
protected PasswordAuthentication getPasswordAuthentication() Called when password authorization is needed. Subclasses should override the default implementation, which returns null.
|
getRequestingHost | back to summary |
---|---|
protected final String getRequestingHost() Gets the
|
getRequestingPort | back to summary |
---|---|
protected final int getRequestingPort() Gets the port number for the requested connection.
|
getRequestingPrompt | back to summary |
---|---|
protected final String getRequestingPrompt() Gets the prompt string given by the requestor.
|
getRequestingProtocol | back to summary |
---|---|
protected final String getRequestingProtocol() Give the protocol that's requesting the connection. Often this will be based on a URL, but in a future JDK it could be, for example, "SOCKS" for a password-protected SOCKS5 firewall.
|
getRequestingScheme | back to summary |
---|---|
protected final String getRequestingScheme() Gets the scheme of the requestor (the HTTP scheme for an HTTP firewall, for example).
|
getRequestingSite | back to summary |
---|---|
protected final InetAddress getRequestingSite() Gets the
|
getRequestingURL | back to summary |
---|---|
protected URL getRequestingURL() Returns the URL that resulted in this request for authentication.
|
getRequestorType | back to summary |
---|---|
protected Authenticator. Returns whether the requestor is a Proxy or a Server.
|
requestPasswordAuthentication | back to summary |
---|---|
public static PasswordAuthentication requestPasswordAuthentication(InetAddress addr, int port, String protocol, String prompt, String scheme) Ask the authenticator that has been registered with the system for a password.
First, if there is a security manager, its
|
requestPasswordAuthentication | back to summary |
---|---|
public static PasswordAuthentication requestPasswordAuthentication(String host, InetAddress addr, int port, String protocol, String prompt, String scheme) Ask the authenticator that has been registered with the system for a password. This is the preferred method for requesting a password because the hostname can be provided in cases where the InetAddress is not available.
First, if there is a security manager, its
|
requestPasswordAuthentication | back to summary |
---|---|
public static PasswordAuthentication requestPasswordAuthentication(String host, InetAddress addr, int port, String protocol, String prompt, String scheme, URL url, Authenticator. Ask the authenticator that has been registered with the system for a password.
First, if there is a security manager, its
|
requestPasswordAuthentication | back to summary |
---|---|
public static PasswordAuthentication requestPasswordAuthentication(Authenticator authenticator, String host, InetAddress addr, int port, String protocol, String prompt, String scheme, URL url, Authenticator. Ask the given
First, if there is a security manager, its
|
requestPasswordAuthenticationInstance | back to summary |
---|---|
public PasswordAuthentication requestPasswordAuthenticationInstance(String host, InetAddress addr, int port, String protocol, String prompt, String scheme, URL url, Authenticator. Ask this authenticator for a password.
|
reset | back to summary |
---|---|
private void reset() |
setDefault | back to summary |
---|---|
public static synchronized void setDefault(Authenticator a) Sets the authenticator that will be used by the networking code when a proxy or an HTTP server asks for authentication.
First, if there is a security manager, its
|
Modifier and Type | Field and Description |
---|---|
public static final Authenticator. | PROXY
Entity requesting authentication is a HTTP proxy server. |
public static final Authenticator. | SERVER
Entity requesting authentication is a HTTP origin server. |
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
public static Authenticator. | |
public static Authenticator. |
PROXY | back to summary |
---|---|
public static final Authenticator. Entity requesting authentication is a HTTP proxy server. |
SERVER | back to summary |
---|---|
public static final Authenticator. Entity requesting authentication is a HTTP origin server. |
RequestorType | back to summary |
---|---|
private RequestorType() |
valueOf | back to summary |
---|---|
public static Authenticator. |
values | back to summary |
---|---|
public static Authenticator. |