allow conversion of database between encrypted and obscurred

This commit is contained in:
morse%netscape.com 2000-05-08 06:32:46 +00:00
parent a14f8defd7
commit 1efefd23d3
9 changed files with 128 additions and 4 deletions

View File

@ -50,6 +50,7 @@ interface nsIWalletService : nsISupports {
[noscript]void WALLET_PreEdit(in nsAutoStringRef walletList);
[noscript]void WALLET_PostEdit(in nsAutoString walletList);
void WALLET_ChangePassword();
void WALLET_ReencryptAll();
void WALLET_RequestToCapture(in nsIPresShell shell);
void WALLET_Prefill(in nsIPresShell shell, in boolean quick);
[noscript]void WALLET_PrefillReturn(in nsAutoString results);

View File

@ -80,6 +80,11 @@ NS_IMETHODIMP nsWalletlibService::WALLET_ChangePassword() {
return NS_OK;
}
NS_IMETHODIMP nsWalletlibService::WALLET_ReencryptAll() {
::WLLT_ReencryptAll();
return NS_OK;
}
NS_IMETHODIMP nsWalletlibService::WALLET_RequestToCapture(nsIPresShell* shell) {
::WLLT_RequestToCapture(shell);
return NS_OK;

View File

@ -48,6 +48,7 @@ public:
NS_IMETHOD WALLET_PreEdit(nsAutoString& walletList);
NS_IMETHOD WALLET_PostEdit(nsAutoString walletList);
NS_IMETHOD WALLET_ChangePassword();
NS_IMETHOD WALLET_ReencryptAll();
NS_IMETHOD WALLET_RequestToCapture(nsIPresShell* shell);
NS_IMETHOD WALLET_Prefill(nsIPresShell* shell, PRBool quick);
NS_IMETHOD WALLET_PrefillReturn(nsAutoString results);

View File

@ -2689,6 +2689,44 @@ SINGSIGN_GetSignonListForViewer(nsAutoString& aSignonList)
aSignonList = buffer;
}
PUBLIC void
SINGSIGN_ReencryptAll()
{
/* force loading of the signons file */
si_RegisterSignonPrefCallbacks();
nsAutoString buffer;
int signonNum = 0;
si_SignonURLStruct *url;
si_SignonUserStruct * user;
si_SignonDataStruct* data = nsnull;
si_lock_signon_list();
PRInt32 urlCount = LIST_COUNT(si_signon_list);
for (PRInt32 i=0; i<urlCount; i++) {
url = NS_STATIC_CAST(si_SignonURLStruct*, si_signon_list->ElementAt(i));
PRInt32 userCount = LIST_COUNT(url->signonUser_list);
for (PRInt32 j=0; j<userCount; j++) {
user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list->ElementAt(j));
PRInt32 dataCount = LIST_COUNT(user->signonData_list);
for (PRInt32 k=0; k<dataCount; k++) {
data = (si_SignonDataStruct *) (user->signonData_list->ElementAt(k));
nsAutoString userName;
if (NS_FAILED(si_Decrypt(data->value, userName))) {
return;
}
if (NS_FAILED(si_Encrypt(userName, data->value))) {
return;
}
}
}
}
si_signon_list_changed = PR_TRUE;
si_SaveSignonDataLocked();
si_unlock_signon_list();
}
PUBLIC void
SINGSIGN_GetRejectListForViewer(nsAutoString& aRejectList)
{

View File

@ -2938,6 +2938,45 @@ WLLT_PreEdit(nsAutoString& walletList) {
}
}
extern void
SINGSIGN_ReencryptAll();
PUBLIC void
WLLT_ReencryptAll() {
wallet_Initialize(PR_FALSE);
wallet_MapElement * ptr;
nsAutoString value;
PRInt32 count = LIST_COUNT(wallet_SchemaToValue_list);
for (PRInt32 i=0; i<count; i++) {
ptr = NS_STATIC_CAST(wallet_MapElement*, wallet_SchemaToValue_list->ElementAt(i));
if (!ptr->item2.IsEmpty()) {
if (NS_FAILED(Wallet_Decrypt(ptr->item2, value))) {
return;
}
if (NS_FAILED(Wallet_Encrypt(value, ptr->item2))) {
return;
}
} else {
wallet_Sublist * ptr1;
PRInt32 count2 = LIST_COUNT(ptr->itemList);
for (PRInt32 i2=0; i2<count2; i2++) {
ptr1 = NS_STATIC_CAST(wallet_Sublist*, ptr->itemList->ElementAt(i2));
if (NS_FAILED(Wallet_Decrypt(ptr1->item, value))) {
return;
}
if (NS_FAILED(Wallet_Encrypt(value, ptr1->item))) {
return;
}
}
}
}
wallet_WriteToFile(schemaValueFileName, wallet_SchemaToValue_list);
SINGSIGN_ReencryptAll();
PRUnichar * message = Wallet_Localize("Converted");
Wallet_Alert(message);
Recycle(message);
}
/*
* return after previewing a set of prefills
*/

View File

@ -40,6 +40,9 @@ XP_BEGIN_PROTOS
extern void
WLLT_ChangePassword();
extern void
WLLT_ReencryptAll();
extern void
WLLT_PreEdit(nsAutoString& walletList);

View File

@ -48,3 +48,4 @@ NoPasswordsEverSaved = No passwords have ever been saved.
Captured = Data has been captured.
NotCaptured = There is nothing to capture.
UnableToCapture = Unable to capture data.
Converted = Stored data has been converted.

View File

@ -59,6 +59,29 @@
wallet = wallet.QueryInterface(Components.interfaces.nsIWalletService);
wallet.WALLET_ChangePassword();
}
function convertStoredValues(encrypt)
{
try {
this.pref = Components.classes["component://netscape/preferences"].getService();
if(this.pref)
this.pref = this.pref.QueryInterface( Components.interfaces.nsIPref );
}
catch(e) {
dump("*** Failed to create prefs object\n");
return;
}
var oldpref = this.pref.GetBoolPref("wallet.crypto");
this.pref.SetBoolPref("wallet.crypto", encrypt);
dump("\n##### pref="+ this.pref.GetBoolPref("wallet.crypto")+"\n");
wallet = Components.classes['component://netscape/wallet'];
wallet = wallet.getService();
wallet = wallet.QueryInterface(Components.interfaces.nsIWalletService);
wallet.WALLET_ReencryptAll();
this.pref.SetBoolPref("wallet.crypto", oldpref);
}
]]>
</script>
@ -107,6 +130,14 @@
pref="true" preftype="bool" prefstring="wallet.crypto"
prefattribute="checked"/>
<separator/>
<box autostretch="never" halign="center">
<button class="dialog" value="&convertEncrypted.label;" accesskey="&convertEncrypted.accesskey;"
oncommand="convertStoredValues(true);"/>
<button class="dialog" value="&convertObscurred.label;" accesskey="&convertObscurred.accesskey;"
oncommand="convertStoredValues(false);"/>
</box>
</titledbox>
</window>

View File

@ -21,7 +21,12 @@
<!ENTITY changePasswords.label "Change Forms Manager Password...">
<!ENTITY changePasswords.accesskey "c">
<!ENTITY encryptHeader.label "Encrypting versus Obscurring">
<!ENTITY encryptDescription.label "Sensitive data that is stored on your hard disk can be either encrypted or obscurred. Encryption prevents the data from being read by an intruder but requires you to enter a password to access the data.">
<!ENTITY encryptEnabled.label "Use encryption when storing sensitive data.">
<!ENTITY encryptEnabled.accesskey "n">
<!ENTITY encryptHeader.label "Encrypting versus Obscurring">
<!ENTITY encryptDescription.label "Sensitive data that is stored on your hard disk can be either encrypted or obscurred. Encryption prevents the data from being read by an intruder but requires you to enter a password to access the data.">
<!ENTITY encryptEnabled.label "Use encryption when storing sensitive data in the future.">
<!ENTITY encryptEnabled.accesskey "n">
<!ENTITY convertEncrypted.label "Encrypt existing stored data">
<!ENTITY convertObscurred.label "Obscur existing stored data">
<!ENTITY convertEncrypted.accesskey "p">
<!ENTITY convertObscurred.accesskey "o">