diff --git a/mailnews/news/public/nsIMsgNewsFolder.idl b/mailnews/news/public/nsIMsgNewsFolder.idl index 06718e507d..291fe3bfd2 100644 --- a/mailnews/news/public/nsIMsgNewsFolder.idl +++ b/mailnews/news/public/nsIMsgNewsFolder.idl @@ -15,7 +15,7 @@ interface nsINntpIncomingServer; [ref] native nsMsgKeyArrayRef(nsTArray); -[scriptable, uuid(3bf5c65d-71bd-4560-a337-435797d249a6)] +[scriptable, uuid(9a12c3a5-9de5-4c57-ace3-d51802b525a9)] interface nsIMsgNewsFolder : nsISupports { readonly attribute AString unicodeName; /**|rawName| is an 8-bit string to represent the name of a newsgroup used by @@ -80,20 +80,6 @@ interface nsIMsgNewsFolder : nsISupports { bool getAuthenticationCredentials(in nsIMsgWindow aMsgWindow, in bool mayPrompt, in bool mustPrompt); - /** - * Force migration of credentials from older versions of this codebase. - * - * This method is normally called during the creation of newsgroup folders, - * and it should not be necessary to call this method. This method also - * forcibly deletes the old credentials, so that passwords would not be - * leaked. - * - * It is expected that this method will be removed once it is decided that - * supporting migration from old versions of Thunderbird and SeaMonkey should - * not be supported. - */ - void migrateLegacyCredentials(); - /// The username that should be used for this group attribute ACString groupUsername; diff --git a/mailnews/news/src/nsNewsFolder.cpp b/mailnews/news/src/nsNewsFolder.cpp index a86086c5be..2d8b6ed9d1 100644 --- a/mailnews/news/src/nsNewsFolder.cpp +++ b/mailnews/news/src/nsNewsFolder.cpp @@ -78,56 +78,6 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); #define NEWS_SCHEME "news:" #define SNEWS_SCHEME "snews:" -//////////////////////////////////////////////////////////////////////////////// - -namespace { -class AsyncAuthMigrator : public nsIMsgAsyncPromptListener { -public: - AsyncAuthMigrator(nsIMsgNewsFolder *folder) : m_folder(folder) {} - - NS_DECL_ISUPPORTS - NS_DECL_NSIMSGASYNCPROMPTLISTENER - - void EnqueuePrompt(); - -private: - nsCOMPtr m_folder; -}; - -NS_IMPL_ISUPPORTS(AsyncAuthMigrator, nsIMsgAsyncPromptListener) - -NS_IMETHODIMP AsyncAuthMigrator::OnPromptStart(bool *retval) -{ - *retval = true; - return m_folder->MigrateLegacyCredentials(); -} - -NS_IMETHODIMP AsyncAuthMigrator::OnPromptAuthAvailable() -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP AsyncAuthMigrator::OnPromptCanceled() -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -void AsyncAuthMigrator::EnqueuePrompt() -{ - nsCOMPtr prompter = - do_GetService(NS_MSGASYNCPROMPTER_CONTRACTID); - - // Make up a fake unique key to prevent coalescing of prompts - // The address of this object should be sufficient - nsAutoCString queueKey; - queueKey.AppendInt((int32_t)(uint64_t)this); - prompter->QueueAsyncAuthPrompt(queueKey, false, this); -} - -} - - - //////////////////////////////////////////////////////////////////////////////// nsMsgNewsFolder::nsMsgNewsFolder(void) : @@ -235,10 +185,6 @@ nsMsgNewsFolder::AddNewsgroup(const nsACString &name, const nsACString& setStr, // cache this for when we open the db rv = newsFolder->SetReadSetFromStr(setStr); - // I don't have a good time to do this, but this is as good as any... - nsRefPtr delayedPrompt(new AsyncAuthMigrator(newsFolder)); - delayedPrompt->EnqueuePrompt(); - rv = folder->SetParent(this); NS_ENSURE_SUCCESS(rv,rv); @@ -1218,80 +1164,6 @@ nsresult nsMsgNewsFolder::CreateNewsgroupUrlForSignon(const char *ref, return NS_OK; } -NS_IMETHODIMP -nsMsgNewsFolder::MigrateLegacyCredentials() -{ - // The original ways that authentication credentials were stored was rather - // complicated and messy. We used separate URLs as the "HTTP realm" field to - // permit prompting for username and password as separate dialogs. In this - // method, we check for this, and store them in the new unified credentials - // dialog. - - // Create the URLs that the login manager needs - nsString signonUrl; - nsresult rv = CreateNewsgroupUrlForSignon(nullptr, signonUrl); - NS_ENSURE_SUCCESS(rv, rv); - - nsString usernameUrl; - rv = CreateNewsgroupUrlForSignon("username", usernameUrl); - NS_ENSURE_SUCCESS(rv, rv); - - nsString passwordUrl; - rv = CreateNewsgroupUrlForSignon("password", passwordUrl); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr loginMgr = - do_GetService(NS_LOGINMANAGER_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - // Grab out the saved username - uint32_t count = 0; - nsILoginInfo **logins = nullptr; - rv = loginMgr->FindLogins(&count, signonUrl, EmptyString(), usernameUrl, - &logins); - NS_ENSURE_SUCCESS(rv, rv); - NS_ASSERTION(count <= 1, "Too many usernames?"); - - nsString username; - if (count > 0) - { - rv = logins[0]->GetPassword(username); - // Remove the saved login - loginMgr->RemoveLogin(logins[0]); - } - - NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, logins); - NS_ENSURE_SUCCESS(rv, rv); - - // Do the same things for the password - rv = loginMgr->FindLogins(&count, signonUrl, EmptyString(), passwordUrl, - &logins); - NS_ENSURE_SUCCESS(rv, rv); - NS_ASSERTION(count <= 1, "Too many passwords?"); - - nsString password; - if (count > 0) - { - rv = logins[0]->GetPassword(password); - loginMgr->RemoveLogin(logins[0]); - } - NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, logins); - NS_ENSURE_SUCCESS(rv, rv); - - // If there is nothing to migrate, then do nothing - if (username.IsEmpty() && password.IsEmpty()) - return NS_OK; - - // Make and add the new logon - nsCOMPtr newLogin = do_CreateInstance(NS_LOGININFO_CONTRACTID); - // We need to pass in JS equivalent to "null"; empty ("") isn't good enough - nsString voidString; - voidString.SetIsVoid(true); - newLogin->Init(signonUrl, voidString, signonUrl, username, password, - EmptyString(), EmptyString()); - return loginMgr->AddLogin(newLogin); -} - NS_IMETHODIMP nsMsgNewsFolder::GetAuthenticationCredentials(nsIMsgWindow *aMsgWindow, bool mayPrompt, bool mustPrompt, bool *validCredentials) diff --git a/mailnews/news/test/unit/test_nntpPassword3.js b/mailnews/news/test/unit/test_nntpPassword3.js index d831f3dc70..bcda7f8a75 100644 --- a/mailnews/news/test/unit/test_nntpPassword3.js +++ b/mailnews/news/test/unit/test_nntpPassword3.js @@ -24,10 +24,6 @@ add_task(function *() { var incomingServer = MailServices.accounts.createIncomingServer(null, kHostname, kProtocol); - // Force move to new credentials - incomingServer.rootFolder.QueryInterface(Ci.nsIMsgNewsFolder) - .migrateLegacyCredentials(); - var i; var count = {};