зеркало из https://github.com/mozilla/pjs.git
Bug 374723: remove files that are no longer built now that we've determined that the patch won't be backed out
This commit is contained in:
Родитель
d53e59d810
Коммит
b12abd57dc
|
@ -1,79 +0,0 @@
|
|||
# vim:set ts=8 sw=8 sts=8 noet:
|
||||
# ***** 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 the Mozilla Password Manager code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Brian Ryner.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2003
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Brian Ryner <bryner@brianryner.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either 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 GPL or the LGPL. 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 *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = passwordmgr
|
||||
LIBRARY_NAME = passwordmgr_s
|
||||
FORCE_STATIC_LIB = 1
|
||||
LIBXUL_LIBRARY = 1
|
||||
|
||||
REQUIRES = \
|
||||
necko \
|
||||
xpcom \
|
||||
string \
|
||||
windowwatcher \
|
||||
uriloader \
|
||||
pref \
|
||||
intl \
|
||||
dom \
|
||||
content \
|
||||
layout \
|
||||
widget \
|
||||
autocomplete \
|
||||
pipnss \
|
||||
unicharutil \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIPassword.idl \
|
||||
nsIPasswordInternal.idl \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsPasswordManager.cpp \
|
||||
nsSingleSignonPrompt.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -1,79 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications, Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either 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 GPL or the LGPL. 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 ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(CF39C2B0-1E4B-11d5-A549-0010A401EB10)]
|
||||
|
||||
/**
|
||||
* An optional interface for clients wishing to access a
|
||||
* password object
|
||||
*
|
||||
* @status FROZEN
|
||||
*/
|
||||
|
||||
interface nsIPassword : nsISupports {
|
||||
|
||||
/**
|
||||
* 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;
|
||||
};
|
|
@ -1,57 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Google Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Darin Fisher <darin@meer.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either 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 GPL or the LGPL. 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 ***** */
|
||||
|
||||
#include "nsIPassword.idl"
|
||||
|
||||
/**
|
||||
* This interface is supported by password manager entries to expose the
|
||||
* fieldnames passed to nsIPasswordManagerInternal's addUserFull method.
|
||||
*/
|
||||
[scriptable, uuid(2cc35c67-978f-42a9-a958-16e97ad2f4c8)]
|
||||
interface nsIPasswordInternal : nsIPassword
|
||||
{
|
||||
/**
|
||||
* The name of the field that contained the username.
|
||||
*/
|
||||
readonly attribute AString userFieldName;
|
||||
|
||||
/**
|
||||
* The name of the field that contained the password.
|
||||
*/
|
||||
readonly attribute AString passwordFieldName;
|
||||
};
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,191 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; 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 Mozilla Password Manager.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Brian Ryner.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either 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 GPL or the LGPL. 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 ***** */
|
||||
|
||||
#include "nsCPasswordManager.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIFormSubmitObserver.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsIDOMFocusListener.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPromptFactory.h"
|
||||
|
||||
/* 360565c4-2ef3-4f6a-bab9-94cca891b2a7 */
|
||||
#define NS_PASSWORDMANAGER_CID \
|
||||
{0x360565c4, 0x2ef3, 0x4f6a, {0xba, 0xb9, 0x94, 0xcc, 0xa8, 0x91, 0xb2, 0xa7}}
|
||||
|
||||
class nsIFile;
|
||||
class nsIStringBundle;
|
||||
class nsIComponentManager;
|
||||
class nsIDOMWindowInternal;
|
||||
class nsIForm;
|
||||
class nsIURI;
|
||||
class nsIDOMHTMLInputElement;
|
||||
class nsIAutoCompleteResult;
|
||||
struct nsModuleComponentInfo;
|
||||
|
||||
class nsPasswordManager : public nsIPasswordManager,
|
||||
public nsIPasswordManagerInternal,
|
||||
public nsIObserver,
|
||||
public nsIFormSubmitObserver,
|
||||
public nsIWebProgressListener,
|
||||
public nsIDOMFocusListener,
|
||||
public nsIPromptFactory,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
class SignonDataEntry;
|
||||
class SignonHashEntry;
|
||||
class PasswordEntry;
|
||||
|
||||
nsPasswordManager();
|
||||
virtual ~nsPasswordManager();
|
||||
|
||||
static nsPasswordManager* GetInstance();
|
||||
|
||||
nsresult Init();
|
||||
static PRBool SingleSignonEnabled();
|
||||
|
||||
static NS_METHOD Register(nsIComponentManager* aCompMgr,
|
||||
nsIFile* aPath,
|
||||
const char* aRegistryLocation,
|
||||
const char* aComponentType,
|
||||
const nsModuleComponentInfo* aInfo);
|
||||
|
||||
static NS_METHOD Unregister(nsIComponentManager* aCompMgr,
|
||||
nsIFile* aPath,
|
||||
const char* aRegistryLocation,
|
||||
const nsModuleComponentInfo* aInfo);
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
static void GetLocalizedString(const nsAString& key,
|
||||
nsAString& aResult,
|
||||
PRBool aFormatted = PR_FALSE,
|
||||
const PRUnichar** aFormatArgs = nsnull,
|
||||
PRUint32 aFormatArgsLength = 0);
|
||||
|
||||
static nsresult DecryptData(const nsAString& aData, nsAString& aPlaintext);
|
||||
static nsresult EncryptData(const nsAString& aPlaintext,
|
||||
nsACString& aEncrypted);
|
||||
static nsresult EncryptDataUCS2(const nsAString& aPlaintext,
|
||||
nsAString& aEncrypted);
|
||||
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPASSWORDMANAGER
|
||||
NS_DECL_NSIPASSWORDMANAGERINTERNAL
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
NS_DECL_NSIPROMPTFACTORY
|
||||
|
||||
// nsIFormSubmitObserver
|
||||
NS_IMETHOD Notify(nsIDOMHTMLFormElement* aDOMForm,
|
||||
nsIDOMWindowInternal* aWindow,
|
||||
nsIURI* aActionURL,
|
||||
PRBool* aCancelSubmit);
|
||||
|
||||
// nsIDOMFocusListener
|
||||
NS_IMETHOD Focus(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Blur(nsIDOMEvent* aEvent);
|
||||
|
||||
// nsIDOMEventListener
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
||||
|
||||
// Autocomplete
|
||||
PRBool AutoCompleteSearch(const nsAString& aSearchString,
|
||||
nsIAutoCompleteResult* aPreviousResult,
|
||||
nsIDOMHTMLInputElement* aElement,
|
||||
nsIAutoCompleteResult** aResult);
|
||||
|
||||
protected:
|
||||
void LoadPasswords();
|
||||
void WritePasswords(nsIFile* aPasswordFile);
|
||||
void AddSignonData(const nsACString& aRealm, SignonDataEntry* aEntry);
|
||||
|
||||
nsresult FindPasswordEntryInternal(const SignonDataEntry* aEntry,
|
||||
const nsAString& aUser,
|
||||
const nsAString& aPassword,
|
||||
const nsAString& aUserField,
|
||||
SignonDataEntry** aResult);
|
||||
|
||||
nsresult FillDocument(nsIDOMDocument* aDomDoc);
|
||||
nsresult FillPassword(nsIDOMEvent* aEvent);
|
||||
void AttachToInput(nsIDOMHTMLInputElement* aElement);
|
||||
static PRBool GetPasswordRealm(nsIURI* aURI, nsACString& aRealm);
|
||||
|
||||
static nsresult GetActionRealm(nsIForm* aForm, nsCString& aURL);
|
||||
|
||||
static PLDHashOperator PR_CALLBACK FindEntryEnumerator(const nsACString& aKey,
|
||||
SignonHashEntry* aEntry,
|
||||
void* aUserData);
|
||||
|
||||
static PLDHashOperator PR_CALLBACK WriteRejectEntryEnumerator(const nsACString& aKey,
|
||||
PRInt32 aEntry,
|
||||
void* aUserData);
|
||||
|
||||
static PLDHashOperator PR_CALLBACK WriteSignonEntryEnumerator(const nsACString& aKey,
|
||||
SignonHashEntry* aEntry,
|
||||
void* aUserData);
|
||||
|
||||
static PLDHashOperator PR_CALLBACK BuildArrayEnumerator(const nsACString& aKey,
|
||||
SignonHashEntry* aEntry,
|
||||
void* aUserData);
|
||||
|
||||
static PLDHashOperator PR_CALLBACK BuildRejectArrayEnumerator(const nsACString& aKey,
|
||||
PRInt32 aEntry,
|
||||
void* aUserData);
|
||||
|
||||
static PLDHashOperator PR_CALLBACK RemoveForDOMDocumentEnumerator(nsISupports* aKey,
|
||||
PRInt32& aEntry,
|
||||
void* aUserData);
|
||||
|
||||
static void EnsureDecoderRing();
|
||||
|
||||
nsClassHashtable<nsCStringHashKey,SignonHashEntry> mSignonTable;
|
||||
nsDataHashtable<nsCStringHashKey,PRInt32> mRejectTable;
|
||||
nsDataHashtable<nsISupportsHashKey,PRInt32> mAutoCompleteInputs;
|
||||
|
||||
nsCOMPtr<nsIFile> mSignonFile;
|
||||
nsCOMPtr<nsIPrefBranch> mPrefBranch;
|
||||
nsIDOMHTMLInputElement* mAutoCompletingField;
|
||||
};
|
|
@ -1,369 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; 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 Mozilla Password Manager.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Brian Ryner.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either 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 GPL or the LGPL. 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 ***** */
|
||||
|
||||
#include "nsSingleSignonPrompt.h"
|
||||
#include "nsPasswordManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsIAuthInformation.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIIDNService.h"
|
||||
#include "nsIPromptService2.h"
|
||||
#include "nsIProxiedChannel.h"
|
||||
#include "nsIProxyInfo.h"
|
||||
#include "nsIURI.h"
|
||||
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsPromptUtils.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsSingleSignonPrompt,
|
||||
nsIAuthPromptWrapper,
|
||||
nsIAuthPrompt)
|
||||
|
||||
// nsIAuthPrompt
|
||||
NS_IMETHODIMP
|
||||
nsSingleSignonPrompt::Prompt(const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aText,
|
||||
const PRUnichar* aPasswordRealm,
|
||||
PRUint32 aSavePassword,
|
||||
const PRUnichar* aDefaultText,
|
||||
PRUnichar** aResult,
|
||||
PRBool* aConfirm)
|
||||
{
|
||||
nsAutoString checkMsg;
|
||||
nsString emptyString;
|
||||
PRBool checkValue = PR_FALSE;
|
||||
PRBool *checkPtr = nsnull;
|
||||
PRUnichar* value = nsnull;
|
||||
nsCOMPtr<nsIPasswordManagerInternal> mgrInternal;
|
||||
|
||||
if (nsPasswordManager::SingleSignonEnabled() && aPasswordRealm) {
|
||||
if (aSavePassword == SAVE_PASSWORD_PERMANENTLY) {
|
||||
nsPasswordManager::GetLocalizedString(NS_LITERAL_STRING("rememberValue"),
|
||||
checkMsg);
|
||||
checkPtr = &checkValue;
|
||||
}
|
||||
|
||||
mgrInternal = do_GetService(NS_PASSWORDMANAGER_CONTRACTID);
|
||||
nsCAutoString outHost;
|
||||
nsAutoString outUser, outPassword;
|
||||
|
||||
mgrInternal->FindPasswordEntry(NS_ConvertUTF16toUTF8(aPasswordRealm),
|
||||
emptyString,
|
||||
emptyString,
|
||||
outHost,
|
||||
outUser,
|
||||
outPassword);
|
||||
|
||||
if (!outUser.IsEmpty()) {
|
||||
value = ToNewUnicode(outUser);
|
||||
checkValue = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!value && aDefaultText)
|
||||
value = ToNewUnicode(nsDependentString(aDefaultText));
|
||||
|
||||
mPrompt->Prompt(aDialogTitle,
|
||||
aText,
|
||||
&value,
|
||||
checkMsg.get(),
|
||||
checkPtr,
|
||||
aConfirm);
|
||||
|
||||
if (*aConfirm) {
|
||||
if (checkValue && value && value[0] != '\0') {
|
||||
// The user requested that we save the value
|
||||
// TODO: support SAVE_PASSWORD_FOR_SESSION
|
||||
|
||||
nsCOMPtr<nsIPasswordManager> manager = do_QueryInterface(mgrInternal);
|
||||
|
||||
manager->AddUser(NS_ConvertUTF16toUTF8(aPasswordRealm),
|
||||
nsDependentString(value),
|
||||
emptyString);
|
||||
}
|
||||
|
||||
*aResult = value;
|
||||
} else {
|
||||
if (value)
|
||||
nsMemory::Free(value);
|
||||
*aResult = nsnull;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSingleSignonPrompt::PromptUsernameAndPassword(const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aText,
|
||||
const PRUnichar* aPasswordRealm,
|
||||
PRUint32 aSavePassword,
|
||||
PRUnichar** aUser,
|
||||
PRUnichar** aPassword,
|
||||
PRBool* aConfirm)
|
||||
{
|
||||
nsAutoString checkMsg;
|
||||
nsString emptyString;
|
||||
PRBool checkValue = PR_FALSE;
|
||||
PRBool *checkPtr = nsnull;
|
||||
PRUnichar *user = nsnull, *password = nsnull;
|
||||
nsCOMPtr<nsIPasswordManagerInternal> mgrInternal;
|
||||
|
||||
if (nsPasswordManager::SingleSignonEnabled() && aPasswordRealm) {
|
||||
if (aSavePassword == SAVE_PASSWORD_PERMANENTLY) {
|
||||
nsPasswordManager::GetLocalizedString(NS_LITERAL_STRING("rememberPassword"),
|
||||
checkMsg);
|
||||
checkPtr = &checkValue;
|
||||
}
|
||||
|
||||
mgrInternal = do_GetService(NS_PASSWORDMANAGER_CONTRACTID);
|
||||
nsCAutoString outHost;
|
||||
nsAutoString outUser, outPassword;
|
||||
|
||||
mgrInternal->FindPasswordEntry(NS_ConvertUTF16toUTF8(aPasswordRealm),
|
||||
emptyString,
|
||||
emptyString,
|
||||
outHost,
|
||||
outUser,
|
||||
outPassword);
|
||||
|
||||
user = ToNewUnicode(outUser);
|
||||
password = ToNewUnicode(outPassword);
|
||||
if (!outUser.IsEmpty() || !outPassword.IsEmpty())
|
||||
checkValue = PR_TRUE;
|
||||
}
|
||||
|
||||
mPrompt->PromptUsernameAndPassword(aDialogTitle,
|
||||
aText,
|
||||
&user,
|
||||
&password,
|
||||
checkMsg.get(),
|
||||
checkPtr,
|
||||
aConfirm);
|
||||
|
||||
if (*aConfirm) {
|
||||
if (checkValue && user && password && (user[0] != '\0' || password[0] != '\0')) {
|
||||
// The user requested that we save the values
|
||||
// TODO: support SAVE_PASSWORD_FOR_SESSION
|
||||
|
||||
nsCOMPtr<nsIPasswordManager> manager = do_QueryInterface(mgrInternal);
|
||||
|
||||
manager->AddUser(NS_ConvertUTF16toUTF8(aPasswordRealm),
|
||||
nsDependentString(user),
|
||||
nsDependentString(password));
|
||||
}
|
||||
|
||||
*aUser = user;
|
||||
*aPassword = password;
|
||||
|
||||
} else {
|
||||
if (user)
|
||||
nsMemory::Free(user);
|
||||
if (password)
|
||||
nsMemory::Free(password);
|
||||
|
||||
*aUser = *aPassword = nsnull;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSingleSignonPrompt::PromptPassword(const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aText,
|
||||
const PRUnichar* aPasswordRealm,
|
||||
PRUint32 aSavePassword,
|
||||
PRUnichar** aPassword,
|
||||
PRBool* aConfirm)
|
||||
{
|
||||
nsAutoString checkMsg;
|
||||
nsString emptyString;
|
||||
PRBool checkValue = PR_FALSE;
|
||||
PRBool *checkPtr = nsnull;
|
||||
PRUnichar* password = nsnull;
|
||||
nsCOMPtr<nsIPasswordManagerInternal> mgrInternal;
|
||||
|
||||
if (nsPasswordManager::SingleSignonEnabled() && aPasswordRealm) {
|
||||
if (aSavePassword == SAVE_PASSWORD_PERMANENTLY) {
|
||||
nsPasswordManager::GetLocalizedString(NS_LITERAL_STRING("rememberPassword"),
|
||||
checkMsg);
|
||||
checkPtr = &checkValue;
|
||||
}
|
||||
|
||||
mgrInternal = do_GetService(NS_PASSWORDMANAGER_CONTRACTID);
|
||||
nsCAutoString outHost;
|
||||
nsAutoString outUser, outPassword;
|
||||
|
||||
mgrInternal->FindPasswordEntry(NS_ConvertUTF16toUTF8(aPasswordRealm),
|
||||
emptyString,
|
||||
emptyString,
|
||||
outHost,
|
||||
outUser,
|
||||
outPassword);
|
||||
|
||||
password = ToNewUnicode(outPassword);
|
||||
if (!outPassword.IsEmpty())
|
||||
checkValue = PR_TRUE;
|
||||
}
|
||||
|
||||
mPrompt->PromptPassword(aDialogTitle,
|
||||
aText,
|
||||
&password,
|
||||
checkMsg.get(),
|
||||
checkPtr,
|
||||
aConfirm);
|
||||
|
||||
if (*aConfirm) {
|
||||
if (checkValue && password && password[0] != '\0') {
|
||||
// The user requested that we save the password
|
||||
// TODO: support SAVE_PASSWORD_FOR_SESSION
|
||||
|
||||
nsCOMPtr<nsIPasswordManager> manager = do_QueryInterface(mgrInternal);
|
||||
|
||||
manager->AddUser(NS_ConvertUTF16toUTF8(aPasswordRealm),
|
||||
emptyString,
|
||||
nsDependentString(password));
|
||||
}
|
||||
|
||||
*aPassword = password;
|
||||
|
||||
} else {
|
||||
if (password)
|
||||
nsMemory::Free(password);
|
||||
*aPassword = nsnull;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIAuthPromptWrapper
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSingleSignonPrompt::SetPromptDialogs(nsIPrompt* aDialogs)
|
||||
{
|
||||
mPrompt = aDialogs;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// nsSingleSignonPrompt2
|
||||
|
||||
nsSingleSignonPrompt2::nsSingleSignonPrompt2(nsIPromptService2* aService,
|
||||
nsIDOMWindow* aParent)
|
||||
: mService(aService), mParent(aParent)
|
||||
{
|
||||
}
|
||||
|
||||
nsSingleSignonPrompt2::~nsSingleSignonPrompt2()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsSingleSignonPrompt2, nsIAuthPrompt2)
|
||||
|
||||
// nsIAuthPrompt2
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSingleSignonPrompt2::PromptAuth(nsIChannel* aChannel,
|
||||
PRUint32 aLevel,
|
||||
nsIAuthInformation* aAuthInfo,
|
||||
PRBool* aConfirm)
|
||||
{
|
||||
nsCAutoString key;
|
||||
NS_GetAuthKey(aChannel, aAuthInfo, key);
|
||||
|
||||
nsAutoString checkMsg;
|
||||
PRBool checkValue = PR_FALSE;
|
||||
PRBool *checkPtr = nsnull;
|
||||
nsCOMPtr<nsIPasswordManagerInternal> mgrInternal;
|
||||
|
||||
if (nsPasswordManager::SingleSignonEnabled()) {
|
||||
nsPasswordManager::GetLocalizedString(NS_LITERAL_STRING("rememberPassword"),
|
||||
checkMsg);
|
||||
checkPtr = &checkValue;
|
||||
|
||||
mgrInternal = do_GetService(NS_PASSWORDMANAGER_CONTRACTID);
|
||||
nsCAutoString outHost;
|
||||
nsAutoString outUser, outPassword;
|
||||
|
||||
const nsString& emptyString = EmptyString();
|
||||
mgrInternal->FindPasswordEntry(key,
|
||||
emptyString,
|
||||
emptyString,
|
||||
outHost,
|
||||
outUser,
|
||||
outPassword);
|
||||
|
||||
NS_SetAuthInfo(aAuthInfo, outUser, outPassword);
|
||||
|
||||
if (!outUser.IsEmpty() || !outPassword.IsEmpty())
|
||||
checkValue = PR_TRUE;
|
||||
}
|
||||
|
||||
mService->PromptAuth(mParent, aChannel, aLevel, aAuthInfo,
|
||||
checkMsg.get(), checkPtr, aConfirm);
|
||||
|
||||
if (*aConfirm) {
|
||||
// XXX domain
|
||||
nsAutoString user, password;
|
||||
aAuthInfo->GetUsername(user);
|
||||
aAuthInfo->GetPassword(password);
|
||||
if (checkValue && (!user.IsEmpty() || !password.IsEmpty())) {
|
||||
// The user requested that we save the password
|
||||
|
||||
nsCOMPtr<nsIPasswordManager> manager = do_QueryInterface(mgrInternal);
|
||||
|
||||
manager->AddUser(key, user, password);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSingleSignonPrompt2::AsyncPromptAuth(nsIChannel*,
|
||||
nsIAuthPromptCallback*,
|
||||
nsISupports*,
|
||||
PRUint32,
|
||||
nsIAuthInformation*,
|
||||
nsICancelable**)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; 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 Mozilla Password Manager.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Brian Ryner.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either 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 GPL or the LGPL. 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 ***** */
|
||||
|
||||
#ifndef NSSINGLESIGNONPROMPT_H_
|
||||
#define NSSINGLESIGNONPROMPT_H_
|
||||
|
||||
#include "nsIAuthPromptWrapper.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt2.h"
|
||||
|
||||
/* 1baf3398-f759-4a72-a21f-0abdc9cc9960 */
|
||||
#define NS_SINGLE_SIGNON_PROMPT_CID \
|
||||
{0x1baf3398, 0xf759, 0x4a72, {0xa2, 0x1f, 0x0a, 0xbd, 0xc9, 0xcc, 0x99, 0x60}}
|
||||
|
||||
class nsIDOMWindow;
|
||||
class nsIPromptService2;
|
||||
|
||||
// Our wrapper for username/password prompts - this allows us to prefill
|
||||
// the password dialog and add a "remember this password" checkbox.
|
||||
|
||||
class nsSingleSignonPrompt : public nsIAuthPromptWrapper
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIAUTHPROMPT
|
||||
NS_DECL_NSIAUTHPROMPTWRAPPER
|
||||
|
||||
nsSingleSignonPrompt() { }
|
||||
virtual ~nsSingleSignonPrompt() { }
|
||||
|
||||
protected:
|
||||
void GetLocalizedString(const nsAString& aKey, nsAString& aResult);
|
||||
|
||||
nsCOMPtr<nsIPrompt> mPrompt;
|
||||
};
|
||||
|
||||
// A wrapper for the newer nsIAuthPrompt2 interface
|
||||
// Its purpose is the same as nsSingleSignonPrompt, but wraps an nsIDOMWindow
|
||||
// instead of an nsIPrompt.
|
||||
|
||||
class nsSingleSignonPrompt2 : public nsIAuthPrompt2
|
||||
{
|
||||
public:
|
||||
nsSingleSignonPrompt2(nsIPromptService2* aService, nsIDOMWindow* aParent);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIAUTHPROMPT2
|
||||
|
||||
private:
|
||||
~nsSingleSignonPrompt2();
|
||||
|
||||
nsCOMPtr<nsIPromptService2> mService;
|
||||
nsCOMPtr<nsIDOMWindow> mParent;
|
||||
};
|
||||
|
||||
#endif // NSSINGLESIGNONPROMPT_H_
|
Загрузка…
Ссылка в новой задаче