nsIAuthPrompt2 编辑
netwerk/base/public/nsIAuthPrompt2.idl
Scriptable An interface allowing to prompt for a username and password. 1.0 66 Introduced Gecko 1.9 Inherits from: nsISupports
Last changed in Gecko 1.9 (Firefox 3)This interface is usually acquired using getInterface on notification callbacks or similar. It can be used to prompt users for authentication information, either synchronously or asynchronously.
This interface is implemented by @mozilla.org/login-manager/prompter;1
. To create an instance, use:
var authPrompt2 = Components.classes["@mozilla.org/login-manager/prompter;1"]
.createInstance(Components.interfaces.nsIAuthPrompt2);
Method overview
nsICancelable asyncPromptAuth(in nsIChannel aChannel, in nsIAuthPromptCallback aCallback, in nsISupports aContext, in PRUint32 level, in nsIAuthInformation authInfo); |
boolean promptAuth(in nsIChannel aChannel, in PRUint32 level, in nsIAuthInformation authInfo); |
Constants
Constant | Value | Description |
LEVEL_NONE | 0 | The password will be sent unencrypted. No security provided. |
LEVEL_PW_ENCRYPTED | 1 | Password will be sent encrypted, but the connection is otherwise insecure. |
LEVEL_SECURE | 2 | The connection, both for password and data, is secure. |
Methods
asyncPromptAuth()
Asynchronously prompt the user for a username and password. This has largely the same semantics as nsIAuthPrompt.promptUsernameAndPassword()
, but must return immediately after calling and return the entered data in a callback.
If the user closes the dialog using a cancel button or similar, the callback's nsIAuthPromptCallback.onAuthCancelled()
method must be called. Calling nsICancelable.cancel()
on the returned object should close the dialog and must call nsIAuthPromptCallback.onAuthCancelled()
on the provided callback.
This implementation may:
- Coalesce identical prompts. This means prompts that are guaranteed to want the same authentication information from the user. A single prompt will be shown; then the callbacks for all the coalesced prompts will be notified with the resulting authentication information.
- Serialize prompts that are all in the same "context" (this might mean application-wide, for a given window, or something else depending on the user interface) so that the user is not deluged with prompts.
nsICancelable asyncPromptAuth( in nsIChannel aChannel, in nsIAuthPromptCallback aCallback, in nsISupports aContext, in PRUint32 level, in nsIAuthInformation authInfo );
Parameters
aChannel
- The channel that requires authentication.
aCallback
aContext
level
- One of the level constants.
authInfo
- Authentication information object. The implementation should fill in this object with the information entered by the user before returning.
Return value
promptAuth()
Requests a username and a password. Implementations will commonly show a dialog with a username and password field, depending on flags also a domain field.
Note: Exceptions thrown from this function will be treated like a return value offalse
.boolean promptAuth( in nsIChannel aChannel, in PRUint32 level, in nsIAuthInformation authInfo );
Parameters
aChannel
- The channel that requires authentication.
level
- One of the level constants.
authInfo
- Authentication information object. The implementation should fill in this object with the information entered by the user before returning.
Return value
false
, authentication should be cancelled, usually because the user did not provide username/password. true
, authentication can proceed using the values in the authInfo object.
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论