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.
false
.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.