|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.net.Authenticator
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.
setDefault(java.net.Authenticator)
,
getPasswordAuthentication()
Constructor Summary | |
Authenticator()
|
Method Summary | |
protected PasswordAuthentication |
getPasswordAuthentication()
Called when password authorization is needed. |
protected int |
getRequestingPort()
Gets the port number for the requested connection. |
protected String |
getRequestingPrompt()
Gets the prompt string given by the requestor. |
protected String |
getRequestingProtocol()
Give the protocol that's requesting the connection. |
protected String |
getRequestingScheme()
Gets the scheme of the requestor (the HTTP scheme for an HTTP firewall, for example). |
protected InetAddress |
getRequestingSite()
Gets the InetAddress of the
site requesting authorization, or null
if not available. |
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. |
static void |
setDefault(Authenticator a)
Sets the authenticator that will be used by the networking code when a proxy or an HTTP server asks for authenticator. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Authenticator()
Method Detail |
public static void setDefault(Authenticator a)
null
and no
authenticator has been established, then no action is taken
and the method simply returns.
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.
Typically, this method will be called exactly once, at system startup.
a
- The authenticatorSecurityException
- if a security manager exists and its
checkPermission
method doesn't allow
setting the default authenticator.SecurityManager.checkPermission(java.security.Permission)
,
NetPermission
public static PasswordAuthentication requestPasswordAuthentication(InetAddress addr, int port, String protocol, String prompt, String scheme)
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.
addr
- The InetAddress of the site requesting authorization,
or null if not known.port
- the port for the requested connectionprotocol
- The protocol that's requesting the connection
(java.net.Authenticator#getProtocol()
)prompt
- A prompt string for the userscheme
- The authentication schemeSecurityException
- if a security manager exists and its
checkPermission
method doesn't allow
the password authentication request.SecurityManager.checkPermission(java.security.Permission)
,
NetPermission
protected final InetAddress getRequestingSite()
InetAddress
of the
site requesting authorization, or null
if not available.protected final int getRequestingPort()
int
indicating the
port for the requested connection.protected final String getRequestingProtocol()
URL.getProtocol()
protected final String getRequestingPrompt()
protected final String getRequestingScheme()
protected PasswordAuthentication getPasswordAuthentication()
|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Java, Java 2D, and JDBC are trademarks or registered trademarks of Oracle and/or its affiliates, in the US and other countries.
Copyright © 1995, 2010 Oracle and/or its affiliates. All rights reserved.