nsIAuthPrompt 编辑

netwerk/base/public/nsIAuthPrompt.idlScriptable 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

ConstantValueDescription
SAVE_PASSWORD_NEVER0Never saves the password.
SAVE_PASSWORD_FOR_SESSION1Saves the password for the session.
SAVE_PASSWORD_PERMANENTLY2Saves 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:90 次

字数:6265

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文