public abstract class Authenticator extends Object
Authenticator by setDefault(Authenticator a). Then it should override getPasswordAuthentication() which dictates how the authentication info is
obtained. Usually, it prompts the user for the required input.| Modifier and Type | Class and Description |
|---|---|
static class |
Authenticator.RequestorType
Enumeration class for the origin of the authentication request.
|
| Constructor and Description |
|---|
Authenticator() |
| Modifier and Type | Method and Description |
|---|---|
protected PasswordAuthentication |
getPasswordAuthentication()
Returns the collected username and password for authorization.
|
protected String |
getRequestingHost()
Returns the host name of the connection that requests authentication or
null if unknown. |
protected int |
getRequestingPort()
Returns the port of the connection that requests authorization.
|
protected String |
getRequestingPrompt()
Returns the realm (prompt string) of the connection that requests
authorization.
|
protected String |
getRequestingProtocol()
Returns the protocol of the connection that requests authorization.
|
protected String |
getRequestingScheme()
Returns the scheme of the connection that requests authorization, for
example HTTP Basic Authentication.
|
protected InetAddress |
getRequestingSite()
Returns the address of the connection that requests authorization or
null if unknown. |
protected URL |
getRequestingURL()
Returns the URL of the authentication request.
|
protected Authenticator.RequestorType |
getRequestorType()
Returns the type of this request, it can be
PROXY or SERVER. |
static PasswordAuthentication |
requestPasswordAuthentication(InetAddress rAddr,
int rPort,
String rProtocol,
String rPrompt,
String rScheme)
Invokes the methods of the registered
authenticator to get the authentication info.
|
static PasswordAuthentication |
requestPasswordAuthentication(String rHost,
InetAddress rAddr,
int rPort,
String rProtocol,
String rPrompt,
String rScheme)
Invokes the methods of the registered
authenticator to get the authentication info.
|
static PasswordAuthentication |
requestPasswordAuthentication(String rHost,
InetAddress rAddr,
int rPort,
String rProtocol,
String rPrompt,
String rScheme,
URL rURL,
Authenticator.RequestorType reqType)
Invokes the methods of the registered
authenticator to get the authentication info.
|
static void |
setDefault(Authenticator a)
Sets
a as the default authenticator. |
protected PasswordAuthentication getPasswordAuthentication()
null.
Returns null by default.
protected final int getRequestingPort()
protected final InetAddress getRequestingSite()
null if unknown.protected final String getRequestingPrompt()
protected final String getRequestingProtocol()
protected final String getRequestingScheme()
public static PasswordAuthentication requestPasswordAuthentication(InetAddress rAddr, int rPort, String rProtocol, String rPrompt, String rScheme)
rAddr - address of the connection that requests authentication.rPort - port of the connection that requests authentication.rProtocol - protocol of the connection that requests authentication.rPrompt - realm of the connection that requests authentication.rScheme - scheme of the connection that requests authentication.null if no authenticator
exists.public static void setDefault(Authenticator a)
a as the default authenticator. It will be called whenever
the realm that the URL is pointing to requires authorization.a - authenticator which has to be set as default.public static PasswordAuthentication requestPasswordAuthentication(String rHost, InetAddress rAddr, int rPort, String rProtocol, String rPrompt, String rScheme)
rHost - host name of the connection that requests authentication.rAddr - address of the connection that requests authentication.rPort - port of the connection that requests authentication.rProtocol - protocol of the connection that requests authentication.rPrompt - realm of the connection that requests authentication.rScheme - scheme of the connection that requests authentication.null if no authenticator
exists.protected final String getRequestingHost()
null if unknown.null.public static PasswordAuthentication requestPasswordAuthentication(String rHost, InetAddress rAddr, int rPort, String rProtocol, String rPrompt, String rScheme, URL rURL, Authenticator.RequestorType reqType)
rHost - host name of the connection that requests authentication.rAddr - address of the connection that requests authentication.rPort - port of the connection that requests authentication.rProtocol - protocol of the connection that requests authentication.rPrompt - realm of the connection that requests authentication.rScheme - scheme of the connection that requests authentication.rURL - url of the connection that requests authentication.reqType - requestor type of the connection that requests authentication.null if no authenticator
exists.protected URL getRequestingURL()
protected Authenticator.RequestorType getRequestorType()
PROXY or SERVER.