зеркало из https://github.com/mozilla/pjs.git
restore psm again but this time controlled by a pref
This commit is contained in:
Родитель
cced34d609
Коммит
c3cd558ae1
|
@ -24,6 +24,7 @@
|
|||
/* universal global variables */
|
||||
|
||||
var walleteditor = null; // walleteditor interface
|
||||
var walletservice = null; // walletservices interface
|
||||
var walletList = []; // input stream
|
||||
var bundle = null; // string bundle
|
||||
var JS_STRINGS_FILE = "chrome://communicator/locale/wallet/WalletEditor.properties";
|
||||
|
@ -49,13 +50,49 @@ function ViewSynonymsFromXul(){
|
|||
|
||||
/*** =================== STARTING AND STOPPING =================== ***/
|
||||
|
||||
/* decrypt a value */
|
||||
function Decrypt(crypt) {
|
||||
try {
|
||||
return walletservice.WALLET_Decrypt(crypt);
|
||||
} catch (ex) {
|
||||
return bundle.GetStringFromName("EncryptionFailure");
|
||||
}
|
||||
}
|
||||
|
||||
/* encrypt a value */
|
||||
function Encrypt(text) {
|
||||
try {
|
||||
return walletservice.WALLET_Encrypt(text);
|
||||
} catch (ex) {
|
||||
alert(bundle.GetStringFromName("UnableToUnlockDatabase"));
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/* see if user was able to unlock the database */
|
||||
function EncryptionTest() {
|
||||
try {
|
||||
walletservice.WALLET_Encrypt("dummy");
|
||||
} catch (ex) {
|
||||
alert(bundle.GetStringFromName("UnableToUnlockDatabase"));
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
|
||||
/* initializes the wallet editor dialog */
|
||||
function Startup()
|
||||
{
|
||||
walleteditor = Components.classes["component://netscape/walleteditor/walleteditor-world"].createInstance();
|
||||
walleteditor = walleteditor.QueryInterface(Components.interfaces.nsIWalletEditor);
|
||||
|
||||
walletservice = Components.classes['component://netscape/wallet'];
|
||||
walletservice = walletservice.getService();
|
||||
walletservice = walletservice.QueryInterface(Components.interfaces.nsIWalletService);
|
||||
|
||||
bundle = srGetStrBundle(JS_STRINGS_FILE); /* initialize string bundle */
|
||||
|
||||
EncryptionTest(); /* abort if user failed to unlock the database */
|
||||
|
||||
if (!FetchInput()) {
|
||||
return; /* user failed to unlock the database */
|
||||
}
|
||||
|
@ -121,7 +158,7 @@ function FetchInput()
|
|||
}
|
||||
}
|
||||
}
|
||||
entries[j] = stringsLength;
|
||||
entries[j] = stringsLength-1;
|
||||
j = 0;
|
||||
for (i=0; i<entriesLength; i++) {
|
||||
if (i == 0 || (strings[entries[i]] != strings[entries[i-1]])) {
|
||||
|
@ -381,7 +418,8 @@ function ViewEntries()
|
|||
var lastPlusOne = schemas[FirstSelectedSchema()+1];
|
||||
for (i=first; i<lastPlusOne; i++) {
|
||||
if (strings[entries[i]+1] != "") {
|
||||
AddItem("entrieslist", [strings[entries[i]+1]], "tree_", i-first);
|
||||
var text = Decrypt(strings[entries[i]+1]);
|
||||
AddItem("entrieslist", [text], "tree_", i-first);
|
||||
}
|
||||
}
|
||||
SchemaSelected();
|
||||
|
@ -401,7 +439,8 @@ function ViewSynonyms()
|
|||
var first = entries[schemas[FirstSelectedSchema()]+FirstSelectedEntry()]+2;
|
||||
var lastPlusOne = entries[schemas[FirstSelectedSchema()]+FirstSelectedEntry()+1]-1;
|
||||
for (i=first; i<lastPlusOne; i++) {
|
||||
AddItem("synonymslist", [strings[i]], "tree_", i-first);
|
||||
var text = Decrypt(strings[i]);
|
||||
AddItem("synonymslist", [text], "tree_", i-first);
|
||||
}
|
||||
EntrySelected();
|
||||
}
|
||||
|
@ -532,14 +571,19 @@ function AddEntry0() {
|
|||
if (text == "") {
|
||||
return;
|
||||
}
|
||||
var crypt = Encrypt(text);
|
||||
if (crypt == "") {
|
||||
/* user failed to unlock the database */
|
||||
return;
|
||||
}
|
||||
stringIndex = entries[schemas[FirstSelectedSchema()]+FirstSelectedEntry()];
|
||||
if(strings[entries[schemas[FirstSelectedSchema()]+FirstSelectedEntry()]+1]=="") {
|
||||
addString(entries[schemas[FirstSelectedSchema()]+FirstSelectedEntry()]+1, text);
|
||||
addString(entries[schemas[FirstSelectedSchema()]+FirstSelectedEntry()]+1, crypt);
|
||||
return;
|
||||
}
|
||||
|
||||
addString(stringIndex, strings[entries[schemas[FirstSelectedSchema()]]]);
|
||||
addString(stringIndex+1, text);
|
||||
addString(stringIndex+1, crypt);
|
||||
addString(stringIndex+2, "");
|
||||
|
||||
entriesLength++;
|
||||
|
@ -559,7 +603,12 @@ function AddSynonym0() {
|
|||
if (text == "") {
|
||||
return;
|
||||
}
|
||||
addString(entries[schemas[FirstSelectedSchema()]+FirstSelectedEntry()]+2, text);
|
||||
var crypt = Encrypt(text);
|
||||
if (crypt == "") {
|
||||
/* user failed to unlock the database */
|
||||
return;
|
||||
}
|
||||
addString(entries[schemas[FirstSelectedSchema()]+FirstSelectedEntry()]+2, crypt);
|
||||
}
|
||||
|
||||
function deleteString(stringToDelete) {
|
||||
|
|
|
@ -21,3 +21,5 @@
|
|||
EnterNewSchema=Enter a new field name
|
||||
EnterNewEntry=Enter a new value for the field
|
||||
EnterNewSynonym=Enter another value that means the same thing
|
||||
EncryptionFailure=Encryption Failure
|
||||
UnableToUnlockDatabase=Unable to unlock database
|
||||
|
|
|
@ -70,4 +70,7 @@ interface nsIWalletService : nsISupports {
|
|||
[noscript] void SI_GetSignonListForViewer(in nsAutoStringRef aSignonList);
|
||||
[noscript] void SI_GetRejectListForViewer(in nsAutoStringRef aRejectList);
|
||||
[noscript] void SI_SignonViewerReturn(in nsAutoString results);
|
||||
|
||||
string WALLET_Encrypt(in wstring text);
|
||||
wstring WALLET_Decrypt(in string crypt);
|
||||
};
|
||||
|
|
|
@ -25,19 +25,15 @@
|
|||
#include "nsIModule.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsWalletService.h"
|
||||
#include "nsBasicStreamGenerator.h"
|
||||
|
||||
// Define the constructor function for the nsWalletlibService
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWalletlibService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBasicStreamGenerator)
|
||||
|
||||
|
||||
// The list of components we register
|
||||
static nsModuleComponentInfo components[] = {
|
||||
{ NS_WALLETSERVICE_CLASSNAME, NS_WALLETSERVICE_CID,
|
||||
NS_WALLETSERVICE_PROGID, nsWalletlibServiceConstructor },
|
||||
{ NS_BASIC_STREAM_GENERATOR_CLASSNAME, NS_BASIC_STREAM_GENERATOR_CID,
|
||||
NS_BASIC_STREAM_GENERATOR_PROGID, nsBasicStreamGeneratorConstructor },
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("nsWalletModule", components)
|
||||
|
|
|
@ -43,9 +43,6 @@
|
|||
|
||||
static NS_DEFINE_IID(kDocLoaderServiceCID, NS_DOCUMENTLOADER_SERVICE_CID);
|
||||
|
||||
// Defined and used in wallet.cpp
|
||||
extern nsIKeyedStreamGenerator *gKeyedStreamGenerator;
|
||||
|
||||
nsWalletlibService::nsWalletlibService()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
@ -59,16 +56,13 @@ nsWalletlibService::~nsWalletlibService()
|
|||
#ifdef DEBUG_dp
|
||||
printf("Wallet Service destroyed successfully.\n");
|
||||
#endif /* DEBUG_dp */
|
||||
// Release the keyed stream generator that we might have acquired
|
||||
NS_IF_RELEASE(gKeyedStreamGenerator);
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS6(nsWalletlibService,
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS5(nsWalletlibService,
|
||||
nsIWalletService,
|
||||
nsIObserver,
|
||||
nsIFormSubmitObserver,
|
||||
nsIDocumentLoaderObserver,
|
||||
nsIPasswordSink,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
NS_IMETHODIMP nsWalletlibService::WALLET_PreEdit(nsAutoString& walletList) {
|
||||
|
@ -391,7 +385,7 @@ nsWalletlibService::OnEndURLLoad
|
|||
NS_IMETHODIMP
|
||||
nsWalletlibService::GetPassword(PRUnichar **password)
|
||||
{
|
||||
return Wallet_GetMasterPassword(password);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -399,3 +393,21 @@ nsWalletlibService::HaveData(const char *url, const PRUnichar *userName, PRBool
|
|||
{
|
||||
return ::SINGSIGN_HaveData(url, userName, stripUrl, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWalletlibService::WALLET_Encrypt (const PRUnichar *text, char **crypt) {
|
||||
nsAutoString textAutoString = text;
|
||||
nsAutoString cryptAutoString;
|
||||
PRBool rv = ::Wallet_Encrypt(textAutoString, cryptAutoString);
|
||||
*crypt = cryptAutoString.ToNewCString();
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWalletlibService::WALLET_Decrypt (const char *crypt, PRUnichar **text) {
|
||||
nsAutoString cryptAutoString = crypt;
|
||||
nsAutoString textAutoString;
|
||||
PRBool rv = ::Wallet_Decrypt(cryptAutoString, textAutoString);
|
||||
*text = textAutoString.ToNewUnicode();
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -75,6 +75,9 @@ public:
|
|||
NS_IMETHOD SI_GetRejectListForViewer(nsAutoString& aRejectList);
|
||||
NS_IMETHOD SI_SignonViewerReturn(nsAutoString results);
|
||||
|
||||
NS_IMETHOD WALLET_Encrypt (const PRUnichar *text, char **crypt);
|
||||
NS_IMETHOD WALLET_Decrypt (const char *crypt, PRUnichar **text);
|
||||
|
||||
// nsIObserver
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_IMETHOD Notify(nsIContent* formNode, nsIDOMWindow* window, nsIURI* actionURL);
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -73,8 +73,11 @@ WLLT_FetchFromNetCenter();
|
|||
extern void
|
||||
WLLT_ExpirePassword();
|
||||
|
||||
extern NS_METHOD
|
||||
Wallet_GetMasterPassword(PRUnichar **password);
|
||||
extern nsresult
|
||||
Wallet_Encrypt (nsAutoString text, nsAutoString& crypt);
|
||||
|
||||
extern nsresult
|
||||
Wallet_Decrypt (nsAutoString crypt, nsAutoString& text);
|
||||
|
||||
XP_END_PROTOS
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче