зеркало из https://github.com/mozilla/gecko-dev.git
bug 130306, preparing to freeze nsiPasswordManager, r/sr = alecf/darin, a=asa
This commit is contained in:
Родитель
bdbe542168
Коммит
6dcaf507ae
|
@ -687,25 +687,41 @@ function GetPasswordManager()
|
|||
if (passwordManager)
|
||||
gPasswordManager = passwordManager.QueryInterface(Components.interfaces.nsIPasswordManager);
|
||||
}
|
||||
return gPasswordManager
|
||||
return gPasswordManager;
|
||||
}
|
||||
|
||||
var gPasswordManagerInternal;
|
||||
function GetPasswordManagerInternal()
|
||||
{
|
||||
if (!gPasswordManagerInternal)
|
||||
{
|
||||
try {
|
||||
gPasswordManagerInternal =
|
||||
Components.classes["@mozilla.org/passwordmanager;1"].createInstance(
|
||||
Components.interfaces.nsIPasswordManagerInternal);
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
return gPasswordManagerInternal;
|
||||
}
|
||||
|
||||
function GetSavedPassword(publishData)
|
||||
{
|
||||
if (!publishData || !publishData.savePassword)
|
||||
return "";
|
||||
|
||||
var passwordManager = GetPasswordManager();
|
||||
if (!passwordManager)
|
||||
var passwordManagerInternal = GetPasswordManagerInternal();
|
||||
if (!passwordManagerInternal)
|
||||
return "";
|
||||
|
||||
var host = { value:publishData.publishUrl };
|
||||
var user = { value:publishData.username };
|
||||
var password = {};
|
||||
var host = {value:""};
|
||||
var user = {value:""};
|
||||
var password = {value:""};
|
||||
try {
|
||||
passwordManager.findPasswordEntry(host, user, password);
|
||||
passwordManagerInternal.findPasswordEntry
|
||||
(publishData.publishUrl, publishData.username, "", host, user, password);
|
||||
return password.value;
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
nsCPassword.h
|
||||
|
|
|
@ -35,5 +35,9 @@ XPIDLSRCS = \
|
|||
nsIPassword.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nsCPassword.h \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
|
|
@ -28,6 +28,9 @@ XPIDLSRCS= \
|
|||
.\nsIPassword.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = nsCPassword.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE = wallet
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications Corporation.
|
||||
* Portions created by Netscape Communications Corporation are
|
||||
* Copyright (C) 2002 Netscape Communications Corporation.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the LGPL or the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
/*
|
||||
* This is a "service" and not just an ordinary component. A consumer must talk
|
||||
* to the service manager, not the component manager.
|
||||
*/
|
||||
|
||||
#ifndef NSCPASSWORD_H
|
||||
#define NSCPASSWORD_H
|
||||
|
||||
#include "nsIPassword.h"
|
||||
#define NS_PASSWORD_CONTRACTID "@mozilla.org/password;1"
|
||||
|
||||
#endif
|
|
@ -23,19 +23,40 @@
|
|||
|
||||
[scriptable, uuid(CF39C2B0-1E4B-11d5-A549-0010A401EB10)]
|
||||
|
||||
/**
|
||||
This interface represents a password object.
|
||||
*/
|
||||
/**
|
||||
* An optional interface for clients wishing to access a
|
||||
* password object
|
||||
*
|
||||
* @status FROZEN
|
||||
*/
|
||||
|
||||
interface nsIPassword : nsISupports {
|
||||
readonly attribute string host;
|
||||
readonly attribute wstring user;
|
||||
readonly attribute wstring password;
|
||||
};
|
||||
|
||||
%{ C++
|
||||
// {CF39C2B0-1E4B-11d5-A549-0010A401EB10}
|
||||
#define NS_PASSWORD_CID \
|
||||
{ 0xcf39c2b0, 0x1e4b, 0x11d5, { 0xa5, 0x49, 0x0, 0x10, 0xa4, 0x1, 0xeb, 0x10 } }
|
||||
#define NS_PASSWORD_CONTRACTID "@mozilla.org/password;1"
|
||||
%}
|
||||
/**
|
||||
* the name of the host corresponding to the login being saved
|
||||
*
|
||||
* The form of the host depends on how the nsIPassword object was created
|
||||
*
|
||||
* - if it was created as a result of submitting a form to a site, then the
|
||||
* host is the url of the site, as obtained from a call to GetSpec
|
||||
*
|
||||
* - if it was created as a result of another app (e.g., mailnews) calling a
|
||||
* prompt routine such at PromptUsernameAndPassword, then the host is whatever
|
||||
* arbitrary string the app decided to pass in.
|
||||
*
|
||||
* Whatever form it is in, it will be used by the password manager to uniquely
|
||||
* identify the login realm, so that "newsserver:119" is not the same thing as
|
||||
* "newsserver".
|
||||
*/
|
||||
readonly attribute AUTF8String host;
|
||||
|
||||
/**
|
||||
* the user name portion of the login
|
||||
*/
|
||||
readonly attribute AString user;
|
||||
|
||||
/**
|
||||
* the password portion of the login
|
||||
*/
|
||||
readonly attribute AString password;
|
||||
};
|
||||
|
|
|
@ -61,25 +61,27 @@ nsPassword::~nsPassword(void) {
|
|||
CRTFREEIF(passwordPswd);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPassword::GetHost(char * *aHost) {
|
||||
NS_IMETHODIMP nsPassword::GetHost(nsACString& aHost) {
|
||||
//NS_IMETHODIMP nsPassword::GetHost(nsAUTF8String& aHost) {
|
||||
// using nsACString above instead of nsAUTF8String because the latter doesn't exist yet
|
||||
if (passwordHost) {
|
||||
*aHost = (char *) nsMemory::Clone(passwordHost, strlen(passwordHost) + 1);
|
||||
aHost = passwordHost;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPassword::GetUser(PRUnichar * *aUser) {
|
||||
NS_IMETHODIMP nsPassword::GetUser(nsAString& aUser) {
|
||||
if (passwordUser) {
|
||||
*aUser = (PRUnichar *) nsMemory::Clone(passwordUser, 2*(nsCRT::strlen(passwordUser) + 1));
|
||||
aUser = passwordUser;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPassword::GetPassword(PRUnichar * *aPswd) {
|
||||
NS_IMETHODIMP nsPassword::GetPassword(nsAString& aPswd) {
|
||||
if (passwordPswd) {
|
||||
*aPswd = (PRUnichar *) nsMemory::Clone(passwordPswd, 2*(nsCRT::strlen(passwordPswd) + 1));
|
||||
aPswd = passwordPswd;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
|
|
@ -62,4 +62,7 @@ protected:
|
|||
PRUnichar * passwordPswd;
|
||||
};
|
||||
|
||||
// {CF39C2B0-1E4B-11d5-A549-0010A401EB10}
|
||||
#define NS_PASSWORD_CID {0xcf39c2b0,0x1e4b,0x11d5,{0xa5,0x49,0x0,0x10,0xa4,0x1,0xeb,0x10}}
|
||||
|
||||
#endif /* nsPassword_h__ */
|
||||
|
|
|
@ -147,8 +147,8 @@ NS_IMPL_ISUPPORTS1(nsPasswordManagerRejectEnumerator, nsISimpleEnumerator);
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsPasswordManager Implementation
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsPasswordManager, nsIPasswordManager, nsISupportsWeakReference);
|
||||
|
||||
NS_IMPL_ISUPPORTS3(nsPasswordManager, nsIPasswordManager, nsIPasswordManagerInternal, nsISupportsWeakReference);
|
||||
|
||||
nsPasswordManager::nsPasswordManager()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
@ -175,14 +175,17 @@ NS_IMETHODIMP nsPasswordManager::GetEnumerator(nsISimpleEnumerator * *entries)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPasswordManager::AddUser(const char *host, const PRUnichar *user, const PRUnichar *pwd) {
|
||||
SINGSIGN_StorePassword(host, user, pwd);
|
||||
NS_IMETHODIMP nsPasswordManager::AddUser(const nsACString& aHost, const nsAString& aUser, const nsAString& aPwd) {
|
||||
SINGSIGN_StorePassword(PromiseFlatCString(aHost).get(),
|
||||
PromiseFlatString(aUser).get(),
|
||||
PromiseFlatString(aPwd).get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPasswordManager::RemoveUser(const char *host, const PRUnichar *user)
|
||||
NS_IMETHODIMP nsPasswordManager::RemoveUser(const nsACString& aHost, const nsAString& aUser)
|
||||
{
|
||||
return ::SINGSIGN_RemoveUser(host, user);
|
||||
return ::SINGSIGN_RemoveUser(PromiseFlatCString(aHost).get(),
|
||||
PromiseFlatString(aUser).get());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPasswordManager::GetRejectEnumerator(nsISimpleEnumerator * *entries)
|
||||
|
@ -197,68 +200,63 @@ NS_IMETHODIMP nsPasswordManager::GetRejectEnumerator(nsISimpleEnumerator * *entr
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPasswordManager::RemoveReject(const char *host)
|
||||
NS_IMETHODIMP nsPasswordManager::RemoveReject(const nsACString& aHost)
|
||||
{
|
||||
return ::SINGSIGN_RemoveReject(host);
|
||||
return ::SINGSIGN_RemoveReject(PromiseFlatCString(aHost).get());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPasswordManager::FindPasswordEntry(char **hostURI, PRUnichar **username, PRUnichar **password)
|
||||
nsPasswordManager::FindPasswordEntry
|
||||
(const nsACString& aHostURI, const nsAString& aUsername, const nsAString& aPassword,
|
||||
nsACString& aHostURIFound, nsAString& aUsernameFound, nsAString& aPasswordFound)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(hostURI);
|
||||
NS_ENSURE_ARG_POINTER(username);
|
||||
NS_ENSURE_ARG_POINTER(password);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPassword> passwordElem;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
rv = GetEnumerator(getter_AddRefs(enumerator));
|
||||
if(NS_SUCCEEDED(rv) && enumerator) {
|
||||
PRBool hasMoreElements = PR_FALSE;
|
||||
enumerator->HasMoreElements(&hasMoreElements);
|
||||
// Emumerate through password elements
|
||||
while (hasMoreElements) {
|
||||
rv = enumerator->GetNext(getter_AddRefs(passwordElem));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv; // could not unlock the database
|
||||
}
|
||||
|
||||
// Get the server URI stored as host
|
||||
nsXPIDLCString thisHostURI;
|
||||
passwordElem->GetHost(getter_Copies(thisHostURI));
|
||||
|
||||
nsXPIDLString thisUsername;
|
||||
passwordElem->GetUser(getter_Copies(thisUsername));
|
||||
|
||||
nsXPIDLString thisPassword;
|
||||
passwordElem->GetPassword(getter_Copies(thisPassword));
|
||||
|
||||
// Check if any of the params are null (set by getter_Copies as
|
||||
// preparation for output parameters) and treat them wild card
|
||||
// entry matches or if they match with current password element
|
||||
// attribute values.
|
||||
PRBool hostURIOK = !*hostURI || thisHostURI.Equals(*hostURI);
|
||||
PRBool usernameOK = !*username || thisUsername.Equals(*username);
|
||||
PRBool passwordOK = !*password || thisPassword.Equals(*password);
|
||||
|
||||
// If a password match is found based on given input params,
|
||||
// fill in those params which are passed in as empty strings.
|
||||
if (hostURIOK && usernameOK && passwordOK)
|
||||
{
|
||||
if (!*hostURI) {
|
||||
*hostURI = ToNewCString(thisHostURI);
|
||||
}
|
||||
if (!*username) {
|
||||
*username = ToNewUnicode(thisUsername);
|
||||
}
|
||||
if (!*password) {
|
||||
*password = ToNewUnicode(thisPassword);
|
||||
}
|
||||
break;
|
||||
}
|
||||
enumerator->HasMoreElements(&hasMoreElements);
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv; // could not unlock the database
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
PRBool hasMoreElements = PR_FALSE;
|
||||
enumerator->HasMoreElements(&hasMoreElements);
|
||||
|
||||
// Emumerate through set of saved logins
|
||||
while (hasMoreElements) {
|
||||
rv = enumerator->GetNext(getter_AddRefs(passwordElem));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv) && passwordElem) {
|
||||
|
||||
// Get the contents of this saved login
|
||||
nsCAutoString hostURI;
|
||||
nsAutoString username;
|
||||
nsAutoString password;
|
||||
|
||||
passwordElem->GetHost(hostURI);
|
||||
passwordElem->GetUser(username);
|
||||
passwordElem->GetPassword(password);
|
||||
|
||||
// Check for a match with the input parameters, treating null input values as
|
||||
// wild cards
|
||||
PRBool hostURIOK = aHostURI.IsEmpty() || hostURI.Equals(aHostURI);
|
||||
PRBool usernameOK = aUsername.IsEmpty() || username.Equals(aUsername);
|
||||
PRBool passwordOK = aPassword.IsEmpty() || password.Equals(aPassword);
|
||||
|
||||
// If a match is found, return success
|
||||
if (hostURIOK && usernameOK && passwordOK) {
|
||||
aHostURIFound = hostURI;
|
||||
aUsernameFound = username;
|
||||
aPasswordFound = password;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
enumerator->HasMoreElements(&hasMoreElements);
|
||||
}
|
||||
|
||||
// no match found
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -40,14 +40,16 @@
|
|||
#define nsPasswordManager_h___
|
||||
|
||||
#include "nsIPasswordManager.h"
|
||||
#include "nsIPasswordManagerInternal.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
class nsPasswordManager : public nsIPasswordManager,
|
||||
class nsPasswordManager : public nsIPasswordManager, public nsIPasswordManagerInternal,
|
||||
public nsSupportsWeakReference {
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPASSWORDMANAGER
|
||||
NS_DECL_NSIPASSWORDMANAGERINTERNAL
|
||||
|
||||
nsPasswordManager();
|
||||
nsresult Init();
|
||||
|
@ -56,5 +58,7 @@ protected:
|
|||
virtual ~nsPasswordManager();
|
||||
};
|
||||
|
||||
// {AAAB6710-0F2C-11d5-A53B-0010A401EB10}
|
||||
#define NS_PASSWORDMANAGER_CID {0x173562f0,0x2173,0x11d5,{0xa5,0x4c,0x0,0x10,0xa4,0x1,0xeb,0x10}}
|
||||
|
||||
#endif /* nsPasswordManager_h___ */
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "nsIGenericFactory.h"
|
||||
#include "nsWalletService.h"
|
||||
#include "nsPasswordManager.h"
|
||||
#include "nsCPasswordManager.h"
|
||||
|
||||
// Define the constructor function for the nsWalletlibService
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWalletlibService, Init)
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
#include "nsIInterfaceRequestorUtils.h"
|
||||
|
||||
#include "nsIMsgAccountManager.h"
|
||||
#include "nsIPasswordManager.h"
|
||||
#include "nsCPasswordManager.h"
|
||||
|
||||
#ifdef DEBUG_sspitzer
|
||||
#define DEBUG_MSGINCOMING_SERVER
|
||||
|
@ -1627,8 +1627,8 @@ nsMsgIncomingServer::GetIsAuthenticated(PRBool *isAuthenticated)
|
|||
*isAuthenticated = PR_FALSE;
|
||||
// If the password is empty, check to see if it is stored and to be retrieved
|
||||
if (m_password.IsEmpty()) {
|
||||
nsCOMPtr <nsIPasswordManager> passwordMgr = do_GetService(NS_PASSWORDMANAGER_CONTRACTID, &rv);
|
||||
if(NS_SUCCEEDED(rv) && passwordMgr) {
|
||||
nsCOMPtr <nsIPasswordManagerInternal> passwordMgrInt = do_GetService(NS_PASSWORDMANAGER_CONTRACTID, &rv);
|
||||
if(NS_SUCCEEDED(rv) && passwordMgrInt) {
|
||||
|
||||
// Get the current server URI
|
||||
nsXPIDLCString currServerUri;
|
||||
|
@ -1637,27 +1637,22 @@ nsMsgIncomingServer::GetIsAuthenticated(PRBool *isAuthenticated)
|
|||
|
||||
// Obtain the server URI which is in the format <protocol>://<userid>@<hostname>.
|
||||
// Password manager uses the same format when it stores the password on user's request.
|
||||
char* hostURI;
|
||||
hostURI = ToNewCString(currServerUri);
|
||||
|
||||
nsXPIDLString userName;
|
||||
nsXPIDLString password;
|
||||
nsCAutoString hostFound;
|
||||
nsAutoString userNameFound;
|
||||
nsAutoString passwordFound;
|
||||
|
||||
// Get password entry corresponding to the host URI we are passing in.
|
||||
rv = passwordMgr->FindPasswordEntry(&hostURI, getter_Copies(userName), getter_Copies(password));
|
||||
rv = passwordMgrInt->FindPasswordEntry(currServerUri, nsString(), nsString(),
|
||||
hostFound, userNameFound, passwordFound);
|
||||
if (NS_FAILED(rv)) {
|
||||
// release hostURI
|
||||
nsMemory::Free(hostURI);
|
||||
return rv;
|
||||
}
|
||||
|
||||
// release hostURI
|
||||
nsMemory::Free(hostURI);
|
||||
|
||||
// If a match is found, password element is filled in. Convert the
|
||||
// obtained password and store it for the session.
|
||||
if (!password.IsEmpty()) {
|
||||
rv = SetPassword(NS_ConvertUCS2toUTF8(password).get());
|
||||
if (!passwordFound.IsEmpty()) {
|
||||
rv = SetPassword(NS_ConvertUCS2toUTF8(passwordFound).get());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,3 +7,4 @@ nsNetUtil.h
|
|||
nsUnixColorPrintf.h
|
||||
nsReadLine.h
|
||||
nsIPasswordManagerUtils.h
|
||||
nsCPasswordManager.h
|
||||
|
|
|
@ -12,6 +12,7 @@ nsIFileChannel.idl
|
|||
nsIFileTransportService.idl
|
||||
nsIMIMEInputStream.idl
|
||||
nsIPasswordManager.idl
|
||||
nsIPasswordManagerInternal.idl
|
||||
nsIPrompt.idl
|
||||
nsIProtocolProxyService.idl
|
||||
nsIProxiedProtocolHandler.idl
|
||||
|
|
|
@ -44,6 +44,7 @@ XPIDLSRCS = \
|
|||
nsINetModuleMgr.idl \
|
||||
nsINetNotify.idl \
|
||||
nsIPasswordManager.idl \
|
||||
nsIPasswordManagerInternal.idl \
|
||||
nsIProgressEventSink.idl \
|
||||
nsIPrompt.idl \
|
||||
nsIProtocolHandler.idl \
|
||||
|
@ -88,6 +89,7 @@ EXPORTS = \
|
|||
nsNetUtil.h \
|
||||
nsUnixColorPrintf.h \
|
||||
nsReadLine.h \
|
||||
nsCPasswordManager.h \
|
||||
$(NULL)
|
||||
|
||||
PREF_JS_EXPORTS = $(srcdir)/security-prefs.js
|
||||
|
|
|
@ -29,11 +29,12 @@ EXPORTS = \
|
|||
nsNetUtil.h \
|
||||
nsUnixColorPrintf.h \
|
||||
nsReadLine.h \
|
||||
nsCPasswordManager.h \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS = \
|
||||
.\nsIAuthenticator.idl \
|
||||
.\nsIAuthPrompt.idl \
|
||||
.\nsIAuthPrompt.idl \
|
||||
.\nsIChannel.idl \
|
||||
.\nsIDirectoryListing.idl \
|
||||
.\nsIFileChannel.idl \
|
||||
|
@ -46,6 +47,7 @@ XPIDLSRCS = \
|
|||
.\nsINetModuleMgr.idl \
|
||||
.\nsINetNotify.idl \
|
||||
.\nsIPasswordManager.idl \
|
||||
.\nsIPasswordManagerInternal.idl \
|
||||
.\nsIProgressEventSink.idl \
|
||||
.\nsIPrompt.idl \
|
||||
.\nsIProtocolHandler.idl \
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications Corporation.
|
||||
* Portions created by Netscape Communications Corporation are
|
||||
* Copyright (C) 2002 Netscape Communications Corporation.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the LGPL or the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
/*
|
||||
* This is a "service" and not just an ordinary component. A consumer must talk
|
||||
* to the service manager, not the component manager.
|
||||
*/
|
||||
|
||||
#ifndef NSCPASSWORDMANAGERINTERNAL_H
|
||||
#define NSCPASSWORDMANAGERINTERNAL_H
|
||||
|
||||
#include "nsIPasswordManagerInternal.h"
|
||||
#define NS_PASSWORDMANAGERINTERNAL_CONTRACTID "@mozilla.org/passwordmanagerinternal;1"
|
||||
#define NS_PASSWORDMANAGERINTERNAL_CLASSNAME "Password Manager Internal"
|
||||
#endif
|
|
@ -21,37 +21,58 @@
|
|||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file contains an interface to the Password Manager.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsISimpleEnumerator.idl"
|
||||
|
||||
/**
|
||||
* An optional interface for clients accessing or removing
|
||||
* logins that were collected by the password manager
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
[scriptable, uuid(173562F0-2173-11d5-A54C-0010A401EB10)]
|
||||
interface nsIPasswordManager : nsISupports
|
||||
{
|
||||
void addUser(in string host, in wstring user, in wstring pwd);
|
||||
void removeUser(in string host, in wstring user);
|
||||
void removeReject(in string host);
|
||||
/**
|
||||
* Called to add an individual login to the list of saved logins
|
||||
*
|
||||
* @param aHost The host for which the login is being remembered
|
||||
* @param aUser The username portion of the login
|
||||
* @param aPassword The password portion of the login
|
||||
*
|
||||
*/
|
||||
void addUser(in AUTF8String aHost, in AString aUser, in AString aPassword);
|
||||
|
||||
// Takes hostname, username and password as input parameters and returns
|
||||
// set of filled-in hostname, username and password for the first
|
||||
// password element match. Empty string is treated as a wild
|
||||
// card entry and will be considered as a match for any of the input
|
||||
// parameters.
|
||||
void findPasswordEntry(inout string hostURI, inout wstring username, inout wstring password);
|
||||
/**
|
||||
* Called to remove an individual login from the list of save logins
|
||||
*
|
||||
* @param aHost The host for which the login is being remembered
|
||||
* @param aUser The username portion of the login
|
||||
*
|
||||
*/
|
||||
void removeUser(in AUTF8String aHost, in AString aUser);
|
||||
|
||||
/**
|
||||
* Called to remove a host from the list of rejected hosts -- i.e., hosts for which
|
||||
* the do-you-want-to-save dialog does not appear
|
||||
*
|
||||
* @param aHost The host for which the dialog is to not appear
|
||||
*
|
||||
*/
|
||||
void removeReject(in AUTF8String aHost);
|
||||
|
||||
/**
|
||||
* Called to enumerate through each login in the password-manager list
|
||||
* The objects enumerated over are of type nsIPassword
|
||||
*/
|
||||
readonly attribute nsISimpleEnumerator enumerator;
|
||||
|
||||
/**
|
||||
* Called to enumerate through each rejected site in the password-manager list
|
||||
* These are sites for which the user has indicated that he doesn't want passwords saved.
|
||||
* The objects enumerated over are of type nsIPassword, although the only member of
|
||||
* that object that is relevent is the host (the user and password members are ignored).
|
||||
*/
|
||||
readonly attribute nsISimpleEnumerator rejectEnumerator;
|
||||
};
|
||||
|
||||
%{ C++
|
||||
// {AAAB6710-0F2C-11d5-A53B-0010A401EB10}
|
||||
#define NS_PASSWORDMANAGER_CID \
|
||||
{ 0x173562f0, 0x2173, 0x11d5, { 0xa5, 0x4c, 0x0, 0x10, 0xa4, 0x1, 0xeb, 0x10 } }
|
||||
#define NS_PASSWORDMANAGER_CONTRACTID "@mozilla.org/passwordmanager;1"
|
||||
#define NS_PASSWORDMANAGER_CLASSNAME "Password Manager"
|
||||
%}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2002 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* An optional interface for obtaining fields of
|
||||
* logins that were collected by the password manager
|
||||
*/
|
||||
|
||||
[scriptable, uuid(F22CD1A0-3709-11d6-A63A-0010A401EB10)]
|
||||
interface nsIPasswordManagerInternal : nsISupports
|
||||
{
|
||||
|
||||
/**
|
||||
* A Call to find a login in the password manager list that matches the
|
||||
* specified parameters. If any input parameter is null, it is
|
||||
* not tested for when looking for the match.
|
||||
*
|
||||
* @param aHostURI The uri part of a login to search for, or null
|
||||
* @param aUsername The username part of a login to search for, or null
|
||||
* @param aPassword The password part of a login to search for, or null
|
||||
* @param aHostURIFound The uri found in the login
|
||||
* @param aUsernameFound The username found in the login
|
||||
* @param aPasswordFound The password found in the login
|
||||
*/
|
||||
void findPasswordEntry
|
||||
(in AUTF8String aHostURI, in AString aUsername, in AString aPassword,
|
||||
out AUTF8String aHostURIFound, out AString aUsernameFound, out AString aPasswordFound);
|
||||
|
||||
};
|
|
@ -60,7 +60,7 @@
|
|||
#include "nsEscape.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIDNSService.h" // for host error code
|
||||
#include "nsIPasswordManager.h"
|
||||
#include "nsCPasswordManager.h"
|
||||
#include "nsIMemory.h"
|
||||
#include "nsIStringStream.h"
|
||||
#include "nsIPref.h"
|
||||
|
@ -1141,13 +1141,13 @@ nsFtpState::R_pass() {
|
|||
// user can retry if they want to
|
||||
|
||||
if (!mPassword.IsEmpty()) {
|
||||
nsCOMPtr<nsIPasswordManager> pm = do_GetService("@mozilla.org/passwordmanager;1");
|
||||
nsCOMPtr<nsIPasswordManager> pm = do_GetService(NS_PASSWORDMANAGER_CONTRACTID);
|
||||
if (pm) {
|
||||
nsCAutoString prePath;
|
||||
nsresult rv = mURL->GetPrePath(prePath);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to get prepath");
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
pm->RemoveUser(prePath.get(), nsnull);
|
||||
pm->RemoveUser(prePath, NS_LITERAL_STRING(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "plstr.h"
|
||||
#include "prprf.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsIPasswordManager.h"
|
||||
#include "nsCPasswordManager.h"
|
||||
|
||||
static NS_DEFINE_CID(kStreamListenerTeeCID, NS_STREAMLISTENERTEE_CID);
|
||||
|
||||
|
@ -2861,7 +2861,7 @@ nsHttpChannel::ClearPasswordManagerEntry(const char *host, PRInt32 port, const c
|
|||
domain.Append(realm);
|
||||
domain.Append(')');
|
||||
|
||||
passWordManager->RemoveUser(domain.get(), user);
|
||||
passWordManager->RemoveUser(domain, nsDependentString(user));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче