nsIAuthPrompt

This interface allows the networking layer to pose a user/password prompt to obtain the values needed for authentication.
Inherits from: nsISupports Last changed in Gecko 1.9 (Firefox 3)

This interface is implemented by @mozilla.org/login-manager/prompter;1. To create an instance, use:

var authPrompt = Components.classes["@mozilla.org/login-manager/prompter;1"]
                 .createInstance(Components.interfaces.nsIAuthPrompt);

Method overview

boolean prompt(in wstring dialogTitle, in wstring text, in wstring passwordRealm, in PRUint32 savePassword, in wstring defaultText, out wstring result);
boolean promptPassword(in wstring dialogTitle, in wstring text, in wstring passwordRealm, in PRUint32 savePassword, inout wstring pwd);
boolean promptUsernameAndPassword(in wstring dialogTitle, in wstring text, in wstring passwordRealm, in PRUint32 savePassword, inout wstring user, inout wstring pwd);

Constants

Constant Value Description
SAVE_PASSWORD_NEVER 0 Never saves the password.
SAVE_PASSWORD_FOR_SESSION 1 Saves the password for the session.
SAVE_PASSWORD_PERMANENTLY 2 Saves the password permanently.

Methods

prompt()

This method puts up a text input dialog with OK and Cancel buttons.

boolean prompt(
  in wstring dialogTitle,
  in wstring text,
  in wstring passwordRealm,
  in PRUint32 savePassword,
  in wstring defaultText,
  out wstring result
);
Parameters
dialogTitle
The title of the dialog.
text
The text of the prompt message dialog box.
passwordRealm
The password realm. For example, ldap://localhost/dc=test.
savePassword
Saving password option. One of the SAVE_PASSWORD_* constants
defaultText
The default text for the text input dialog box.
result
The result of the dialog box, OK or Cancel buttons.
Return value

true for OK, false for Cancel.

promptPassword()

This method puts up a password dialog with OK and Cancel buttons.

Note: If a username is specified, the username should be escaped.

boolean promptPassword(
  in wstring dialogTitle,
  in wstring text,
  in wstring passwordRealm,
  in PRUint32 savePassword,
  inout wstring pwd
);
Parameters
dialogTitle
The title of the dialog.
text
The text of the prompt message dialog box.
passwordRealm
The password realm. For example, ldap://localhost/dc=test. If a username is specified (http://user@site.com) it will be used when matching existing logins or saving new ones. If no username is specified, only password-only logins will be matched or saved.
savePassword
Saving password option. One of the SAVE_PASSWORD_* constants
pwd
The password entered by the user if OK was selected.
Return value

true for OK, false for Cancel.

promptUsernameAndPassword()

This method puts up a username/password dialog with OK and Cancel buttons.

boolean promptUsernameAndPassword(
  in wstring dialogTitle,
  in wstring text,
  in wstring passwordRealm,
  in PRUint32 savePassword,
  inout wstring user,
  inout wstring pwd
);
Parameters
dialogTitle
The title of the dialog.
text
The text of the prompt message dialog box.
passwordRealm
The password realm. For example, ldap://localhost/dc=test.
savePassword
Saving password option. One of the SAVE_PASSWORD_* constants
user
The username entered in the dialog.
pwd
The password entered by the user if OK was selected.
Return value

true for OK, false for Cancel.