nsILoginManager
From MDC
This article covers features introduced in Firefox 3
nsILoginManager is used to interface with the built-in Password Manager in Firefox 3. It replaces nsIPasswordManager which was used in older versions of Firefox.
See Using nsILoginManager for examples.
Contents |
nsILoginManager is defined in toolkit/components/passwordmgr/public/nsILoginManager.idl. It is scriptable and
unfrozen (hasn't changed since Mozilla 1.9).
Inherits from: nsILoginManager
Implemented by: @mozilla.org/login-manager;1. To create an instance, use:
var loginManager = Components.classes["@mozilla.org/login-manager;1"]
.getService(Components.interfaces.nsILoginManager);
[edit] Method overview
void addLogin(in nsILoginInfo aLogin);
|
void removeLogin(in nsILoginInfo aLogin);
|
void modifyLogin(in nsILoginInfo oldLogin, in nsILoginInfo newLogin);
|
void removeAllLogins();
|
void getAllLogins(out unsigned long count, [retval, array, size_is(count)] out nsILoginInfo logins);
|
void getAllDisabledHosts(out unsigned long count, [retval, array, size_is(count)] out wstring hostnames);
|
boolean getLoginSavingEnabled(in AString aHost);
|
void setLoginSavingEnabled(in AString aHost, in boolean isEnabled);
|
void findLogins(out unsigned long count, in AString aHostname, in AString aActionURL, in AString aHttpRealm, [retval, array, size_is(count)] out nsILoginInfo logins);
|
unsigned long countLogins(in AString aHostName, in AString aActionURL, in AString aHttpRealm,);
|
nsIAutoCompleteResult autoCompleteSearch(in AString aSearchString, in nsIAutoCompleteResult aPreviousResult, in nsIDOMHTMLInputElement aElement);
|
[edit] Methods
[edit] addLogin()
Stores a new login in the Login Manager.
void addLogin( in nsILoginInfo aLogin );
[edit] Parameters
- aLogin
- The login to store.
[edit] removeLogin()
Removes a login from the Login Manager.
void removeLogin( in nsILoginInfo aLogin );
[edit] Parameters
- aLogin
- The login to remove from the Login Manager.
[edit] modifyLogin()
Modifies an existing login by replacing it with a new one.
void modifyLogin( in nsILoginInfo oldLogin, in nsILoginInfo newLogin );
[edit] Parameters
- oldLogin
- The login to be updated.
- newLogin
- The login information to replace the
oldLoginwith.
[edit] removeAllLogins()
Removes all logins known by the Login Manager. This works without a need for the master password, if one is set.
void removeAllLogins();
[edit] Parameters
None.
[edit] getAllLogins()
Returns an array containing all logins recorded by the Login Manager.
void getAllLogins( out unsigned long count, [retval, array, size_is(count)] out nsILoginInfo logins );
[edit] Parameters
- count
- The number of elements in the returned array. JavaScript callers can simply use the array's
lengthproperty and supply a dummy argument for this parameter. - logins
- An array of
nsILoginInfoobjects containing all the logins the Login Manager has on record.
[edit] Remarks
You can call this method from JavaScript like this:
var logins = myLoginMgr.getAllLogins({});
On return, logins is an array of logins.
If you just want to see if any logins are stored, use .countLogins() instead. It's more efficient, and avoids the possibility of the user being prompted for their master password.
[edit] getAllDisabledHosts()
Returns a list of all hosts for which login saving is disabled.
void getAllDisabledHosts( out unsigned long count, [retval, array, size_is(count)] out wstring hostnames );
[edit] Parameters
- count
- The number of elements in the returned array. JavaScript callers can simply use the array's
lengthproperty and supply a dummy argument for this parameter. - hostnames
- An array of hostname strings in URL format without a pathname. For example: "https://www.site.com".
[edit] Remarks
You can call this method from JavaScript like this:
var disabledHosts = myLoginMgr.getAllDisabledHosts({});
[edit] getLoginSavingEnabled()
Reports whether or not saving login information is enabled for a host.
boolean getLoginSavingEnabled( in AString aHost );
[edit] Parameters
- aHost
- The hostname to check. This argument should be in the origin URL format, with no pathname. For example: "https://www.site.com".
[edit] Returns
true if login saving is enabled for the host, otherwise false.
[edit] setLoginSavingEnabled()
Enables or disables storing logins for a specified host. When login storing is disabled, the Login Manager won't prompt the user to store logins for that host. Existing logins are not affected.
void setLoginSavingEnabled( in AString aHost, in boolean isEnabled );
[edit] Parameters
- aHost
- The hostname to adjust the setting for. This argument should be in the origin URL format, with no pathname. For example: "https://www.site.com".
- isEnabled
- If
true, login saving is enabled for the specified host. Iffalse, login saving is disabled.
[edit] findLogins()
Searches for logins matching the specified criteria. Called when looking for logins that might be applicable to a given form or authentication request.
void findLogins( out unsigned long count, in AString aHostname, in AString aActionURL, in AString aHttpRealm, [retval, array, size_is(count)] out nsILoginInfo logins );
[edit] Parameters
- count
- The number of elements in the returned array. JavaScript callers can simply use the array's
lengthproperty and supply a dummy argument for this parameter. - aHostname
- The hostname to which to restrict searches, formatted as a URL. For example, "http://www.bar.com".
- aActionURL
- For form logins, this parameter should specify the URL to which the form will be submitted. For protocol logins, specify
null. - aHttpRealm
- For protocol logins, specify the HTTP Realm for which the login applies; this is obtained from the WWW-Authenticate header (see RFC 2617). For form logins, this parameter should be
null. - logins
- An array of
nsILoginInfoobjects.
[edit] Remarks
This method can be called from JavaScript like this:
var logins = myLoginMgr.findLogins({}, hostname, ...);
[edit] countLogins()
Returns the number of logins matching the specified criteria. Called when only the number of logins is needed, and not the actual logins (which avoids prompting the user for a Master Password, as the logins don't need to be decrypted).
unsigned login countLogins( in AString aHostname, in AString aActionURL, in AString aHttpRealm, );
[edit] Parameters
- aHostname
- The hostname to which to restrict searches, formatted as a URL. For example, "http://www.bar.com". To match all hostnames, specify
""(empty string). A value ofnullwill cause countLogins() to not match any logins. - aActionURL
- For form logins, this parameter should specify the URL to which the form will be submitted. To match any form login, specify
""(empty string). To not match any form logins (eg, when interested in protocol logins only), specifynull. - aHttpRealm
- For protocol logins, specify the HTTP Realm for which the login applies; this is obtained from the WWW-Authenticate header (see RFC 2617). To match any protocol login, specify
""(empty string). To not match any protocol logins (eg, when interested in form logins only), specifynull.
[edit] autoCompleteSearch()
Generates results for a user field autocomplete menu.
[edit] Remarks
Fill this out.