|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.mail Class Authenticator
java.lang.Objectjavax.mail.Authenticator
public abstract class Authenticator
- extends Object
Authenticator 类表示懂得如何获得网络连接验证的对象。通常,它通过提示用户输入信息来完成此操作。
应用程序通过创建子类,并在创建该子类时向会话注册其实例使用此类。在需要验证时,系统将调用该子类上的一个方法(比如 getPasswordAuthentication)。子类的方法可使用许多继承的方法 (getRequestingXXX()) 查询正在请求的验证,并为用户形成适当的消息。
请求验证的所有方法都有一个失败的默认实现。
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 session when it is created. 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.
- Version:
- 1.9, 05/04/07
- Author:
- Bill Foote, Bill Shannon
- See Also:
Authenticator
,Session.getInstance(java.util.Properties, javax.mail.Authenticator)
,Session.getDefaultInstance(java.util.Properties, javax.mail.Authenticator)
,Session.requestPasswordAuthentication(java.net.InetAddress, int, java.lang.String, java.lang.String, java.lang.String)
,PasswordAuthentication
Constructor Summary | |
---|---|
Authenticator()
|
Method Summary | |
---|---|
protected String |
getDefaultUserName()
|
protected PasswordAuthentication |
getPasswordAuthentication()
Called when password authentication is needed. |
protected int |
getRequestingPort()
|
protected String |
getRequestingPrompt()
|
protected String |
getRequestingProtocol()
Give the protocol that's requesting the connection. |
protected InetAddress |
getRequestingSite()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public
Authenticator()
英文文档:
Authenticator
public Authenticator()
Method Detail |
---|
final protected java.net.InetAddress
getRequestingSite()
return | 请求授权的站点的 InetAddress;如果不可用,则返回 null。 |
getRequestingSite
protected final InetAddress getRequestingSite()
- Returns:
- the InetAddress of the site requesting authorization, or null if it's not available.
final protected int
getRequestingPort()
return | 所请求的连接的端口 |
getRequestingPort
protected final int getRequestingPort()
- Returns:
- the port for the requested connection
final protected String
getRequestingProtocol()
给出正在请求连接的协议。通常此操作是基于 URLName 的。
return | 协议 |
See also | getProtocol |
getRequestingProtocol
protected final String getRequestingProtocol()
- Give the protocol that's requesting the connection. Often this
will be based on a URLName.
- Returns:
- the protcol
- See Also:
URLName.getProtocol()
final protected String
getRequestingPrompt()
return | 请求方给出的提示字符串 |
getRequestingPrompt
protected final String getRequestingPrompt()
- Returns:
- the prompt string given by the requestor
final protected String
getDefaultUserName()
return | 请求方给出的默认用户名 |
getDefaultUserName
protected final String getDefaultUserName()
- Returns:
- the default user name given by the requestor
protected PasswordAuthentication
getPasswordAuthentication()
需要密码验证时调用。子类应该重写默认实现,默认实现返回 null。
注意,如果此方法使用对话框提示用户输入此信息,那么对话框需要一直阻塞直到用户提供该信息。此方法不能在显示对话框后简单地返回。
return | 从用户收集的 PasswordAuthentication;如果一个也没有提供,则返回 null。 |
getPasswordAuthentication
protected PasswordAuthentication getPasswordAuthentication()
- Called when password authentication is needed. Subclasses should
override the default implementation, which returns null.
Note that if this method uses a dialog to prompt the user for this information, the dialog needs to block until the user supplies the information. This method can not simply return after showing the dialog.
- Returns:
- The PasswordAuthentication collected from the user, or null if none is provided.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!