Visit Mozilla.org

nsILoginManagerStorage

From MDC

This article covers features introduced in Firefox 3

The nsILoginManagerStorage interface is implemented by modules that wish to provide storage mechanisms for the Login Manager. For example, if you wish to provide operating system integration with a native password manager system, implementing and registering a storage module for the Login Manager is how you do it. See Creating a Login Manager storage module for details.

Note: Extensions that simply want to access/store logins should use the Login Manager service and nsILoginManager interface instead. The Login Manager will handle selecting and using the correct nsILoginManangerStorage module.

Contents

nsILoginManagerStorage is defined in toolkit/components/passwordmgr/public/nsILoginManagerStorage.idl. It is scriptable and unfrozen (hasn't changed since Mozilla 1.9).

Inherits from: nsISupports

[edit] Method overview

void addLogin(in nsILoginInfo aLogin);
unsigned long countLogins(in AString aHostname, in AString aActionURL, in AString aHttpRealm);
void findLogins(out unsigned long count, in AString aHostname, in AString aActionURL, in AString aHttpRealm, [retval, array, size_is(count)] out nsILoginInfo logins);
void getAllDisabledHosts(out unsigned long count, [retval, array, size_is(count)] out wstring hostnames);
void getAllLogins(out unsigned long count, [retval, array, size_is(count)] out nsILoginInfo logins);
boolean getLoginSavingEnabled(in AString aHost);
void init();
void initWithFile(in nsIFile aInputFile, in nsIFile aOutputFile);
void modifyLogin(in nsILoginInfo oldLogin, in nsILoginInfo newLogin);
void removeAllLogins();
void removeLogin(in nsILoginInfo aLogin);
boolean setLoginSavingEnabled(in AString aHost, in boolean isEnabled);

[edit] Methods

[edit] addLogin()

Called by the Login Manager to store a new login.

 void addLogin(
   in nsILoginInfo aLogin
 );
[edit] Parameters
aLogin
The login to add to the login storage.

[edit] countLogins()

Implement this method to return the number of logins matching the specified criteria. This method is called, for example, to check to see if there is a login that will match the criteria without having to ask the user for their master password in order to decrypt the logins.

 unsigned long countLogins(
   in AString aHostname,
   in AString aActionURL,
   in AString aHttpRealm
 );
[edit] Parameters
aHostname
The hostname to which to restrict the search. Specify an empty string to match all hosts. Passing null should not match any logins, and should return 0.
aActionURL
The URL of the form to which the login will be submitted. To match any form login, specify an empty string. To not match to any form login, specify null.
aHttpRealm
The HTTP realm for which the login applies. To match logins for any realm, specify an empty string. To not match any realm, specify null.
[edit] Return value

The number of logins that match the specified criteria.

[edit] findLogins()

Implement this method to search the login store for logins matching the specified criteria. This method is called by the Login Manager when looking for saved logins that might apply to a 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
Return in this parameter the number of matching logins found by the search.
aHostname
The hostname to which to restrict the search. Specify an empty string to match all hosts. Passing null should not match any logins, and should return a count of 0.
aActionURL
The URL of the form to which the login will be submitted. To match any form login, specify an empty string. To not match to any form login, specify null.
aHttpRealm
The HTTP realm for which the login applies. To match logins for any realm, specify an empty string. To not match any realm, specify null.
logins
Return in this parameter an array of logins matching the search criteria.

[edit] getAllDisabledHosts()

Implement this method to return a list of all hosts for which password saving is disabled.

 void getAllDisabledHosts(
   out unsigned long count,
   [retval, array, size_is(count)] out wstring hostnames
 );
[edit] Parameters
count
Return in this parameter the number of disabled hostnames returned in the hostnames parameter.
hostnames
Return in this parameter an array of all hostnames for which password saving is disabled.

[edit] getAllLogins()

Implement this method to return a list of all logins in the login store.

 void getAllLogins(
   out unsigned long count,
   [retval, array, size_is(count)] out nsILoginInfo logins
 );
[edit] Parameters
count
Return in this parameter the number of logins returned in the logins array.
logins
Return in this parameter an array of all logins in the login store. This parameter must always be an array; if there are no logins in the login store, it must be an empty array, not null.

[edit] getLoginSavingEnabled()

Implement to report whether or not login saving has been disabled for a specific host.

 boolean getLoginSavingEnabled(
   in AString aHost
 );
[edit] Parameters
aHost
The hostname whose login saving status should be returned. This string will be in the origin URL format, without a pathname. For example, "http://mozilla.com".
[edit] Return value

Return true if login saving is enabled for the specified host; otherwise, return false.

[edit] init()

Implement this method to initialize the component. This is not called automatically; you must call it yourself if needed.

 void init();
[edit] Parameters

None.

[edit] initWithFile()

Implement this method to initialize the component, overriding the default filename locations with those specified. This method is primarily used for unit tests and during profile migration.

 void initWithFile(
   in nsIFile aInputFile, 
   in nsIFile aOutputFile
 );
[edit] Parameters
aInputFile
The file from which to read stored logins.
aOutputFile
The file to which to write stored logins, if not null. If this is null, use the default output file.

[edit] modifyLogin()

Implement this method to modify an existing login in the login store.

 void modifyLogin(
   in nsILoginInfo oldLogin
   in nsILoginInfo newLogin
 );
[edit] Parameters
oldLogin
The login to be modified.
newLogin
The login to replace the oldLogin with.

[edit] removeAllLogins()

Implement this method to remove all logins from the login store. This is called by the browser sanitization feature when the user asks to clear all stored passwords. The user interface allows this to be done without getting each login first (which might require knowing the master password). No password should be required in order to remove all logins.

 void removeAllLogins();
[edit] Parameters

None.

[edit] removeLogin()

Implement this method to remove the specified login from the login store.

 void removeLogin(
   in nsILoginInfo aLogin
 );
[edit] Parameters
aLogin
The login to remove from the login store.

[edit] setLoginSavingEnabled()

Implement this method to enable or disable login saving for the specified host. When login saving is disabled for a host, the Login Manager will not propt the user for permission to store logins for that host. Existing logins for the host should not be affected when setting this.

 void setLoginSavingEnabled(
   in AString aHost,
   in boolean isEnabled
 );
[edit] Parameters
aHost
The host for which to enable or disable login saving. The argument is in origin URL format, without a pathname (for example: "http://mozilla.com").
isEnabled
true if logins should be enabled for the host, or false if they should be disabled.

[edit] See also