зеркало из https://github.com/mozilla/gecko-dev.git
add ability to change password
This commit is contained in:
Родитель
29535afa18
Коммит
05463d9c74
|
@ -45,6 +45,7 @@
|
|||
struct nsIWalletService : public nsISupports
|
||||
{
|
||||
NS_IMETHOD WALLET_PreEdit(nsIURL* url) = 0;
|
||||
NS_IMETHOD WALLET_ChangePassword() = 0;
|
||||
NS_IMETHOD WALLET_Prefill(nsIPresShell* shell, PRBool quick) = 0;
|
||||
NS_IMETHOD WALLET_Capture(nsIDocument* doc, nsString name, nsString value) = 0;
|
||||
NS_IMETHOD WALLET_OKToCapture(PRBool* result, PRInt32 count, char* URLName) = 0;
|
||||
|
|
|
@ -53,6 +53,11 @@ nsWalletlibService::QueryInterface(REFNSIID iid, void** result)
|
|||
NS_IMPL_ADDREF(nsWalletlibService);
|
||||
NS_IMPL_RELEASE(nsWalletlibService);
|
||||
|
||||
NS_IMETHODIMP nsWalletlibService::WALLET_ChangePassword() {
|
||||
::WLLT_ChangePassword();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWalletlibService::WALLET_PreEdit(nsIURL* url) {
|
||||
::WLLT_PreEdit(url);
|
||||
return NS_OK;
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
nsWalletlibService();
|
||||
|
||||
/* Implementation of the nsIWalletService interface */
|
||||
NS_IMETHOD WALLET_ChangePassword();
|
||||
NS_IMETHOD WALLET_PreEdit(nsIURL* url);
|
||||
NS_IMETHOD WALLET_Prefill(nsIPresShell* shell, PRBool quick);
|
||||
NS_IMETHOD WALLET_Capture(nsIDocument* doc, nsString name, nsString value);
|
||||
|
|
|
@ -321,7 +321,7 @@ MyFE_SelectDialog
|
|||
extern void Wallet_RestartKey();
|
||||
extern char Wallet_GetKey();
|
||||
extern PRBool Wallet_BadKey();
|
||||
extern PRBool Wallet_SetKey();
|
||||
extern PRBool Wallet_SetKey(PRBool newkey);
|
||||
extern char * Wallet_Localize(char * genericString);
|
||||
|
||||
void
|
||||
|
@ -341,7 +341,7 @@ si_BadKey() {
|
|||
|
||||
PRBool
|
||||
si_SetKey() {
|
||||
return Wallet_SetKey();
|
||||
return Wallet_SetKey(PR_FALSE);
|
||||
}
|
||||
|
||||
/* end of temporary */
|
||||
|
@ -406,11 +406,11 @@ PRIVATE PRBool si_RememberSignons = PR_FALSE;
|
|||
PRIVATE int
|
||||
si_SaveSignonDataLocked();
|
||||
|
||||
PRIVATE int
|
||||
si_SaveSignonData();
|
||||
PUBLIC int
|
||||
SI_SaveSignonData();
|
||||
|
||||
PRIVATE int
|
||||
si_LoadSignonData(PRBool fullLoad);
|
||||
PUBLIC int
|
||||
SI_LoadSignonData(PRBool fullLoad);
|
||||
|
||||
PRIVATE void
|
||||
si_RemoveAllSignonData();
|
||||
|
@ -441,7 +441,7 @@ si_SetSignonRememberingPref(PRBool x)
|
|||
|
||||
/* if pref is being turned on, load the signon file into memory */
|
||||
if (x == 1) {
|
||||
si_LoadSignonData(FALSE);
|
||||
SI_LoadSignonData(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -482,7 +482,7 @@ si_GetSignonRememberingPref(void)
|
|||
* calls si_GetSignonRememberingPref
|
||||
*/
|
||||
si_list_invalid = PR_FALSE;
|
||||
si_LoadSignonData(FALSE);
|
||||
SI_LoadSignonData(FALSE);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -808,7 +808,7 @@ si_GetUser(char* URLName, PRBool pickFirstUser, char* userText) {
|
|||
user_count++;
|
||||
}
|
||||
if (user_count > 1) {
|
||||
si_LoadSignonData(TRUE);
|
||||
SI_LoadSignonData(TRUE);
|
||||
url = si_GetURL(URLName);
|
||||
}
|
||||
user_ptr = url->signonUser_list;
|
||||
|
@ -1031,11 +1031,11 @@ si_PutReject(char * URLName, char * userName, PRBool save) {
|
|||
if (reject) {
|
||||
/*
|
||||
* lock the signon list
|
||||
* Note that, for efficiency, si_LoadSignonData already sets the lock
|
||||
* Note that, for efficiency, SI_LoadSignonData already sets the lock
|
||||
* before calling this routine whereas none of the other callers do.
|
||||
* So we need to determine whether or not we were called from
|
||||
* si_LoadSignonData before setting or clearing the lock. We can
|
||||
* determine this by testing "save" since only si_LoadSignonData
|
||||
* SI_LoadSignonData before setting or clearing the lock. We can
|
||||
* determine this by testing "save" since only SI_LoadSignonData
|
||||
* passes in a value of PR_FALSE for "save".
|
||||
*/
|
||||
XP_List * list_ptr;
|
||||
|
@ -1084,7 +1084,7 @@ si_PutReject(char * URLName, char * userName, PRBool save) {
|
|||
|
||||
if (save) {
|
||||
si_signon_list_changed = PR_TRUE;
|
||||
si_SaveSignonData();
|
||||
SI_SaveSignonData();
|
||||
}
|
||||
if (save) {
|
||||
si_unlock_signon_list();
|
||||
|
@ -1178,11 +1178,11 @@ si_PutData(char * URLName, LO_FormSubmitData * submit, PRBool save) {
|
|||
|
||||
/*
|
||||
* lock the signon list
|
||||
* Note that, for efficiency, si_LoadSignonData already sets the lock
|
||||
* Note that, for efficiency, SI_LoadSignonData already sets the lock
|
||||
* before calling this routine whereas none of the other callers do.
|
||||
* So we need to determine whether or not we were called from
|
||||
* si_LoadSignonData before setting or clearing the lock. We can
|
||||
* determine this by testing "save" since only si_LoadSignonData passes
|
||||
* SI_LoadSignonData before setting or clearing the lock. We can
|
||||
* determine this by testing "save" since only SI_LoadSignonData passes
|
||||
* in a value of PR_FALSE for "save".
|
||||
*/
|
||||
if (save) {
|
||||
|
@ -1691,8 +1691,8 @@ si_ReadLine
|
|||
/*
|
||||
* Load signon data from disk file
|
||||
*/
|
||||
PRIVATE int
|
||||
si_LoadSignonData(PRBool fullLoad) {
|
||||
PUBLIC int
|
||||
SI_LoadSignonData(PRBool fullLoad) {
|
||||
/*
|
||||
* This routine is called initially with fullLoad set to FALSE. That will cause
|
||||
* the main file (consisting of URLs and usernames but having dummy passwords) to
|
||||
|
@ -2163,8 +2163,8 @@ si_SaveSignonDataLocked() {
|
|||
* The parameter passed in on entry is ignored
|
||||
*/
|
||||
|
||||
PRIVATE int
|
||||
si_SaveSignonData() {
|
||||
PUBLIC int
|
||||
SI_SaveSignonData() {
|
||||
int retval;
|
||||
|
||||
/* do nothing if signon preference is not enabled */
|
||||
|
@ -2239,7 +2239,7 @@ SINGSIGN_RememberSignonData
|
|||
|
||||
if ((j<submit.value_cnt) && si_OkToSave(URLName, /* urlname */
|
||||
((char **)submit.value_array)[j] /* username */)) {
|
||||
si_LoadSignonData(TRUE);
|
||||
SI_LoadSignonData(TRUE);
|
||||
si_PutData(URLName, &submit, PR_TRUE);
|
||||
}
|
||||
} else if (passwordCount == 2) {
|
||||
|
@ -2272,7 +2272,7 @@ SINGSIGN_RememberSignonData
|
|||
}
|
||||
|
||||
/* get to password being saved */
|
||||
si_LoadSignonData(TRUE); /* this destroys "user" so we need to recalculate it */
|
||||
SI_LoadSignonData(TRUE); /* this destroys "user" so we need to recalculate it */
|
||||
user = si_GetURLAndUserForChangeForm
|
||||
(((char **)submit.value_array)[pswd[0]]);
|
||||
if (!user) { /* this should never happen but just in case */
|
||||
|
@ -2331,7 +2331,7 @@ SINGSIGN_RestoreSignonData
|
|||
/* get first saved user just so we can see the name of the first item on the form */
|
||||
user = si_GetUser(URLName, PR_TRUE, NULL); /* this is the first saved user */
|
||||
if (user) {
|
||||
si_LoadSignonData(PR_TRUE); /* this destroys "user" so need to recalculate it */
|
||||
SI_LoadSignonData(PR_TRUE); /* this destroys "user" so need to recalculate it */
|
||||
user = si_GetUser(URLName, PR_TRUE, NULL);
|
||||
data_ptr = user->signonData_list; /* this is first item on form */
|
||||
data = (si_SignonDataStruct *) XP_ListNextObject(data_ptr);
|
||||
|
@ -2357,7 +2357,7 @@ SINGSIGN_RestoreSignonData
|
|||
/* restore the data from previous time this URL was visited */
|
||||
user = si_GetUser(URLName, PR_FALSE, name);
|
||||
if (user) {
|
||||
si_LoadSignonData(TRUE); /* this destroys user so need to recaculate it */
|
||||
SI_LoadSignonData(TRUE); /* this destroys user so need to recaculate it */
|
||||
user = si_GetUser(URLName, PR_TRUE, name);
|
||||
if (user) { /* this should alwlays be true but just in case */
|
||||
data_ptr = user->signonData_list;
|
||||
|
@ -2408,7 +2408,7 @@ si_RememberSignonDataFromBrowser(char* URLName, char* username, char* password)
|
|||
type_array[1] = FORM_TYPE_PASSWORD;
|
||||
|
||||
/* Save the signon data */
|
||||
si_LoadSignonData(TRUE);
|
||||
SI_LoadSignonData(TRUE);
|
||||
si_PutData(URLName, &submit, PR_TRUE);
|
||||
|
||||
/* Free up the data memory just allocated */
|
||||
|
@ -2448,7 +2448,7 @@ si_RestoreOldSignonDataFromBrowser
|
|||
si_unlock_signon_list();
|
||||
return;
|
||||
}
|
||||
si_LoadSignonData(TRUE); /* this destroys "user" so need to recalculate it */
|
||||
SI_LoadSignonData(TRUE); /* this destroys "user" so need to recalculate it */
|
||||
user = si_GetUser(URLName, pickFirstUser, "username");
|
||||
|
||||
/* restore the data from previous time this URL was visited */
|
||||
|
@ -2882,7 +2882,7 @@ SINGSIGN_DisplaySignonInfoAsHTML()
|
|||
calls si_GetSignonRememberingPref */
|
||||
si_list_invalid = PR_FALSE;
|
||||
si_RemoveAllSignonData();
|
||||
si_LoadSignonData(TRUE);
|
||||
SI_LoadSignonData(TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
|
||||
static NS_DEFINE_IID(kIDOMHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMHTMLFormElementIID, NS_IDOMHTMLFORMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMHTMLInputElementIID, NS_IDOMHTMLINPUTELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMHTMLSelectElementIID, NS_IDOMHTMLSELECTELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMHTMLOptionElementIID, NS_IDOMHTMLOPTIONELEMENT_IID);
|
||||
|
@ -356,11 +357,10 @@ wallet_GetUsingDialogsPref(void)
|
|||
/* The following routines are used for accessing strings to be localized */
|
||||
/*************************************************************************/
|
||||
|
||||
#define TEST_URL "resource:/res/wallet.properties"
|
||||
|
||||
#ifdef xxx
|
||||
/* temporary until I can get the real routine below to work */
|
||||
PUBLIC char*
|
||||
Wallet_Localize(char* genericString) {
|
||||
Wallet_Localize1(char* genericString) {
|
||||
nsAutoString v("***NO LOCALIZED STRING FOUND***");
|
||||
if (!PL_strcmp(genericString,"IncorrectKey_TryAgain?")) {
|
||||
v = nsAutoString("Incorrect key. Do you want to try again?");
|
||||
|
@ -372,6 +372,8 @@ Wallet_Localize(char* genericString) {
|
|||
v = nsAutoString("Following items can be pre-filled for you.");
|
||||
} else if (!PL_strcmp(genericString,"password")){
|
||||
v = nsAutoString("database password: ");
|
||||
} else if (!PL_strcmp(genericString,"newPassword")){
|
||||
v = nsAutoString("new password: ");
|
||||
} else if (!PL_strcmp(genericString,"SelectUser")){
|
||||
v = nsAutoString("Select a username to be entered on this form");
|
||||
} else if (!PL_strcmp(genericString,"SelectUserWhosePasswordIsBeingChanged")){
|
||||
|
@ -395,9 +397,12 @@ Wallet_Localize(char* genericString) {
|
|||
}
|
||||
return v.ToNewCString();
|
||||
}
|
||||
#endif
|
||||
|
||||
#define TEST_URL "resource:/res/wallet.properties"
|
||||
|
||||
PUBLIC char*
|
||||
Wallet_Localize2(char* genericString) {
|
||||
Wallet_Localize(char* genericString) {
|
||||
nsresult ret;
|
||||
nsAutoString v("");
|
||||
|
||||
|
@ -711,7 +716,6 @@ Wallet_GetKey() {
|
|||
if (keyPosition >= PL_strlen(key)) {
|
||||
keyPosition = 0;
|
||||
}
|
||||
char c = key[keyPosition];
|
||||
return key[keyPosition++];
|
||||
}
|
||||
|
||||
|
@ -720,9 +724,25 @@ Wallet_BadKey() {
|
|||
return keyFailure;
|
||||
}
|
||||
|
||||
PRIVATE PRBool
|
||||
wallet_KeyExists() {
|
||||
nsSpecialSystemDirectory keyFile(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
|
||||
keyFile += "res";
|
||||
// keyFile += "wallet";
|
||||
keyFile += "key";
|
||||
nsInputFileStream strm(keyFile);
|
||||
|
||||
if (!strm.is_open()) {
|
||||
return PR_FALSE;
|
||||
} else {
|
||||
strm.close();
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
PUBLIC PRBool
|
||||
Wallet_SetKey() {
|
||||
if (keySet) {
|
||||
Wallet_SetKey(PRBool newkey) {
|
||||
if (keySet && !newkey) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -732,7 +752,12 @@ Wallet_SetKey() {
|
|||
if (!wallet_GetUsingDialogsPref()) {
|
||||
key[keyPosition++] = '~';
|
||||
} else {
|
||||
char * password = Wallet_Localize("password");
|
||||
char * password;
|
||||
if (newkey) {
|
||||
password = Wallet_Localize("newPassword");
|
||||
} else {
|
||||
password = Wallet_Localize("password");
|
||||
}
|
||||
char * newkey = FE_GetString(password);
|
||||
PR_FREEIF(password);
|
||||
for (; (keyPosition < PL_strlen(newkey) && keyPosition < maxKeySize); keyPosition++) {
|
||||
|
@ -743,16 +768,19 @@ Wallet_SetKey() {
|
|||
}
|
||||
Wallet_RestartKey();
|
||||
|
||||
/* verify this with the saved key */
|
||||
nsSpecialSystemDirectory keyFile(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
|
||||
keyFile += "res";
|
||||
// keyFile += "wallet";
|
||||
keyFile += "key";
|
||||
nsInputFileStream strm(keyFile);
|
||||
|
||||
if (!strm.is_open()) {
|
||||
/* verify this with the saved key */
|
||||
if (newkey || !wallet_KeyExists()) {
|
||||
|
||||
/*
|
||||
* Either key is to be changed or the file containing the saved key doesn' exist.
|
||||
* In either case we need to (re)create and re(write) the file.
|
||||
*/
|
||||
|
||||
/* file of saved key doesn't exist, so create it */
|
||||
nsOutputFileStream strm2(keyFile);
|
||||
if (!strm2.is_open()) {
|
||||
keyFailure = TRUE;
|
||||
|
@ -785,6 +813,7 @@ Wallet_SetKey() {
|
|||
* is why the following code reads a character and immediately after the read
|
||||
* checks for eof()
|
||||
*/
|
||||
nsInputFileStream strm(keyFile);
|
||||
Wallet_RestartKey();
|
||||
char* p = key+1;
|
||||
while (*p) {
|
||||
|
@ -1190,7 +1219,7 @@ PRInt32 FieldToValue(
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* fetch schema name from field/schema tables */
|
||||
/* if no schema name is given, fetch schema name from field/schema tables */
|
||||
XP_List* FieldToSchema_list = wallet_FieldToSchema_list;
|
||||
XP_List* URLFieldToSchema_list = wallet_specificURLFieldToSchema_list;
|
||||
XP_List* SchemaToValue_list;
|
||||
|
@ -1198,8 +1227,9 @@ PRInt32 FieldToValue(
|
|||
if (nsnull == resume) {
|
||||
resume = wallet_SchemaToValue_list;
|
||||
}
|
||||
if ((wallet_ReadFromList(field, schema, dummy, URLFieldToSchema_list) != -1) ||
|
||||
(wallet_ReadFromList(field, schema, dummy, FieldToSchema_list) != -1)) {
|
||||
if ((schema.Length() > 0) ||
|
||||
(wallet_ReadFromList(field, schema, dummy, URLFieldToSchema_list) != -1) ||
|
||||
(wallet_ReadFromList(field, schema, dummy, FieldToSchema_list) != -1)) {
|
||||
/* schema name found, now fetch value from schema/value table */
|
||||
SchemaToValue_list = resume;
|
||||
if (wallet_ReadFromList(schema, value, itemList, SchemaToValue_list) != -1) {
|
||||
|
@ -1307,9 +1337,23 @@ wallet_GetPrefills(
|
|||
nsAutoString field;
|
||||
result = inputElement->GetName(field);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
nsAutoString schema;
|
||||
nsAutoString schema("");
|
||||
nsAutoString value;
|
||||
XP_List* itemList;
|
||||
|
||||
/* get schema name from vcard attribute if it exists */
|
||||
nsIDOMElement * element;
|
||||
result = elementNode->QueryInterface(kIDOMElementIID, (void**)&element);
|
||||
if ((NS_SUCCEEDED(result)) && (nsnull != element)) {
|
||||
nsAutoString vcard("VCARD_NAME");
|
||||
result = element->GetAttribute(vcard, schema);
|
||||
NS_RELEASE(element);
|
||||
}
|
||||
|
||||
/*
|
||||
* if schema name was specified in vcard attribute the get value from schema name,
|
||||
* otherwise get value from field name by using mapping tables to get schema name
|
||||
*/
|
||||
if (FieldToValue(field, schema, value, itemList, resume) == 0) {
|
||||
if (value == "" && nsnull != itemList) {
|
||||
/* pick first of a set of synonymous values */
|
||||
|
@ -1333,7 +1377,7 @@ wallet_GetPrefills(
|
|||
nsAutoString field;
|
||||
result = selectElement->GetName(field);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
nsAutoString schema;
|
||||
nsAutoString schema("");
|
||||
nsAutoString value;
|
||||
XP_List* itemList;
|
||||
if (FieldToValue(field, schema, value, itemList, resume) == 0) {
|
||||
|
@ -1387,7 +1431,7 @@ wallet_Initialize() {
|
|||
Wallet_RestartKey();
|
||||
char * message = Wallet_Localize("IncorrectKey_TryAgain?");
|
||||
char * failed = Wallet_Localize("KeyFailure");
|
||||
while (!Wallet_SetKey()) {
|
||||
while (!Wallet_SetKey(PR_FALSE)) {
|
||||
if (!FE_Confirm(message)) {
|
||||
FE_Confirm(failed);
|
||||
PR_FREEIF(message);
|
||||
|
@ -1426,6 +1470,39 @@ wallet_Initialize() {
|
|||
|
||||
}
|
||||
|
||||
#ifdef SingleSignon
|
||||
extern int SI_SaveSignonData();
|
||||
extern int SI_LoadSignonData(PRBool fullLoad);
|
||||
#endif
|
||||
|
||||
PUBLIC
|
||||
void WLLT_ChangePassword() {
|
||||
|
||||
/* do nothing if password was never set */
|
||||
if (!wallet_KeyExists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* read in user data using old key */
|
||||
|
||||
wallet_Initialize();
|
||||
#ifdef SingleSignon
|
||||
SI_LoadSignonData(PR_TRUE);
|
||||
#endif
|
||||
if (Wallet_BadKey()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* establish new key */
|
||||
Wallet_SetKey(PR_TRUE);
|
||||
|
||||
/* write out user data using new key */
|
||||
wallet_WriteToFile("SchemaValue.tbl", wallet_SchemaToValue_list, TRUE);
|
||||
#ifdef SingleSignon
|
||||
SI_SaveSignonData();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* initialization for current URL
|
||||
*/
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
|
||||
XP_BEGIN_PROTOS
|
||||
|
||||
extern void
|
||||
WLLT_ChangePassword();
|
||||
|
||||
extern void
|
||||
WLLT_PreEdit(nsIURL* url);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче