| java.lang.Object java.net.Authenticator
Authenticator | abstract public class Authenticator (Code) | | The class Authenticator represents an object that knows how to obtain
authentication for a network connection. Usually, it will do this
by prompting the user for information.
Applications use this class by creating a subclass, and registering
an instance of that subclass with the system with setDefault().
When authentication is required, the system will invoke a method
on the subclass (like getPasswordAuthentication). The subclass's
method can query about the authentication being requested with a
number of inherited methods (getRequestingXXX()), and form an
appropriate message for the user.
All methods that request authentication have a default implementation
that fails.
See Also: java.net.Authenticator.setDefault(java.net.Authenticator) See Also: java.net.Authenticator.getPasswordAuthentication version: 1.20, 02/02/00 since: 1.2 |
Method Summary | |
protected PasswordAuthentication | getPasswordAuthentication() Called when password authorization is needed. | final protected String | getRequestingHost() Gets the hostname of the
site or proxy requesting authentication, or null
if not available. | final protected int | getRequestingPort() Gets the port number for the requested connection. | final protected String | getRequestingPrompt() Gets the prompt string given by the requestor. | final protected String | getRequestingProtocol() Give the protocol that's requesting the connection. | final protected String | getRequestingScheme() Gets the scheme of the requestor (the HTTP scheme
for an HTTP firewall, for example). | final protected InetAddress | getRequestingSite() Gets the InetAddress of the
site requesting authorization, or null
if not available. | 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 checkPermission
method is called with a
NetPermission("requestPasswordAuthentication") permission.
This may result in a java.lang.SecurityException. | 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. | 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 checkPermission
method is called with a
NetPermission("setDefaultAuthenticator") permission.
This may result in a java.lang.SecurityException. |
getPasswordAuthentication | protected PasswordAuthentication getPasswordAuthentication()(Code) | | Called when password authorization is needed. Subclasses should
override the default implementation, which returns null.
The PasswordAuthentication collected from theuser, or null if none is provided. |
getRequestingHost | final protected String getRequestingHost()(Code) | | Gets the hostname of the
site or proxy requesting authentication, or null
if not available.
the hostname of the connection requiring authentication, or nullif it's not available. since: 1.4 |
getRequestingPort | final protected int getRequestingPort()(Code) | | Gets the port number for the requested connection.
an int indicating the port for the requested connection. |
getRequestingPrompt | final protected String getRequestingPrompt()(Code) | | Gets the prompt string given by the requestor.
the prompt string given by the requestor (realm forhttp requests) |
getRequestingProtocol | final protected String getRequestingProtocol()(Code) | | Give the protocol that's requesting the connection. Often this
will be based on a URL, but in a future SDK it could be, for
example, "SOCKS" for a password-protected SOCKS5 firewall.
the protcol, optionally followed by "/version", whereversion is a version number. See Also: java.net.URL.getProtocol |
getRequestingScheme | final protected String getRequestingScheme()(Code) | | Gets the scheme of the requestor (the HTTP scheme
for an HTTP firewall, for example).
the scheme of the requestor |
getRequestingSite | final protected InetAddress getRequestingSite()(Code) | | Gets the InetAddress of the
site requesting authorization, or null
if not available.
the InetAddress of the site requesting authorization, or nullif it's not available. |
requestPasswordAuthentication | public static PasswordAuthentication requestPasswordAuthentication(InetAddress addr, int port, String protocol, String prompt, String scheme)(Code) | | Ask the authenticator that has been registered with the system
for a password.
First, if there is a security manager, its checkPermission
method is called with a
NetPermission("requestPasswordAuthentication") permission.
This may result in a java.lang.SecurityException.
Parameters: addr - The InetAddress of the site requesting authorization,or null if not known. Parameters: port - the port for the requested connection Parameters: protocol - The protocol that's requesting the connection(java.net.Authenticator.getRequestingProtocol) Parameters: prompt - A prompt string for the user Parameters: scheme - The authentication scheme The username/password, or null if one can't be gotten. throws: SecurityException - if a security manager exists and its checkPermission method doesn't allow the password authentication request. See Also: SecurityManager.checkPermission See Also: java.net.NetPermission |
requestPasswordAuthentication | public static PasswordAuthentication requestPasswordAuthentication(String host, InetAddress addr, int port, String protocol, String prompt, String scheme)(Code) | | 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 checkPermission
method is called with a
NetPermission("requestPasswordAuthentication") permission.
This may result in a java.lang.SecurityException.
Parameters: host - The hostname of the site requesting authentication. Parameters: addr - The InetAddress of the site requesting authentication,or null if not known. Parameters: port - the port for the requested connection. Parameters: protocol - The protocol that's requesting the connection(java.net.Authenticator.getRequestingProtocol) Parameters: prompt - A prompt string for the user which identifies the authentication realm. Parameters: scheme - The authentication scheme The username/password, or null if one can't be gotten. throws: SecurityException - if a security manager exists and its checkPermission method doesn't allow the password authentication request. See Also: SecurityManager.checkPermission See Also: java.net.NetPermission since: 1.4 |
setDefault | public static synchronized void setDefault(Authenticator a)(Code) | | 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 checkPermission
method is called with a
NetPermission("setDefaultAuthenticator") permission.
This may result in a java.lang.SecurityException.
Parameters: a - The authenticator to be set. If a is null thenany previously set authenticator is removed. throws: SecurityException - if a security manager exists and its checkPermission method doesn't allow setting the default authenticator. See Also: SecurityManager.checkPermission See Also: java.net.NetPermission |
|
|