diff --git a/netwerk/protocol/http/src/nsHttpChannel.cpp b/netwerk/protocol/http/src/nsHttpChannel.cpp index 0b3a99254392..dbc630c02fac 100644 --- a/netwerk/protocol/http/src/nsHttpChannel.cpp +++ b/netwerk/protocol/http/src/nsHttpChannel.cpp @@ -42,6 +42,7 @@ #include "plstr.h" #include "prprf.h" #include "nsEscape.h" +#include "nsIPasswordManager.h" static NS_DEFINE_CID(kStreamListenerTeeCID, NS_STREAMLISTENERTEE_CID); @@ -1441,6 +1442,7 @@ nsHttpChannel::GetCredentials(const char *challenges, LOG(("clearing bad credentials from the auth cache\n")); // ok, we've already tried this user:pass combo, so clear the // corresponding entry from the auth cache. + ClearPasswordManagerEntry(host, port, realm.get(), entry->User()); authCache->SetAuthEntry(host, port, nsnull, realm.get(), nsnull, nsnull, nsnull, nsnull, nsnull); entry = nsnull; @@ -2740,3 +2742,22 @@ nsHttpChannel::OnCacheEntryAvailable(nsICacheEntryDescriptor *entry, return NS_OK; } + +void +nsHttpChannel::ClearPasswordManagerEntry(const char *host, PRInt32 port, const char *realm, const PRUnichar *user) +{ + nsresult rv; + nsCOMPtr passWordManager = do_GetService(NS_PASSWORDMANAGER_CONTRACTID, &rv); + if (passWordManager) { + nsCAutoString domain; + domain.Assign(host); + domain.Append(':'); + domain.AppendInt(port); + + domain.Append(" ("); + domain.Append(realm); + domain.Append(')'); + + passWordManager->RemoveUser(domain.get(), user); + } +} diff --git a/netwerk/protocol/http/src/nsHttpChannel.h b/netwerk/protocol/http/src/nsHttpChannel.h index 3dfc243e6de5..92db00df82d2 100644 --- a/netwerk/protocol/http/src/nsHttpChannel.h +++ b/netwerk/protocol/http/src/nsHttpChannel.h @@ -117,6 +117,7 @@ private: void SetAuthorizationHeader(nsHttpAuthCache *, nsHttpAtom header, const char *host, PRInt32 port, const char *path, PRUnichar **user, PRUnichar **pass); void AddAuthorizationHeaders(); nsresult GetCurrentPath(char **); + void ClearPasswordManagerEntry(const char *host, PRInt32 port, const char *realm, const PRUnichar *user); static void *PR_CALLBACK AsyncRedirect_EventHandlerFunc(PLEvent *); static void PR_CALLBACK AsyncRedirect_EventCleanupFunc(PLEvent *);