security/manager/pki/resources/content/resetpassword.js

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 const nsPK11TokenDB = "@mozilla.org/security/pk11tokendb;1";
     6 const nsIPK11TokenDB = Components.interfaces.nsIPK11TokenDB;
     7 const nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock;
     9 var tokenName;
    11 function onLoad()
    12 {
    13   if ("arguments" in window) {
    14     var params = window.arguments[0].QueryInterface(nsIDialogParamBlock);
    15     tokenName = params.GetString(1);
    16   } else {
    17     tokenName = self.name;
    18   }
    19 }
    21 function resetPassword()
    22 {
    23   var pk11db = Components.classes[nsPK11TokenDB].getService(nsIPK11TokenDB);
    24   var token = pk11db.findTokenByName(tokenName);
    25   token.reset();
    27   try {
    28     var loginManager = Components.classes["@mozilla.org/login-manager;1"].
    29                        getService(Components.interfaces.nsILoginManager);
    30     loginManager.removeAllLogins();
    31   } catch (e) {
    32   }
    34   var pref = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefService);
    35   if (pref) {
    36     pref = pref.getBranch(null);
    37     try {
    38       if (pref.getBoolPref("wallet.crypto")) {
    39         // data in wallet is encrypted, clear it
    40         var wallet = Components.classes['@mozilla.org/wallet/wallet-service;1'];
    41         if (wallet) {
    42           wallet = wallet.getService(Components.interfaces.nsIWalletService);
    43           wallet.WALLET_DeleteAll();
    44         }
    45       }
    46     }
    47     catch(e) {
    48       // wallet.crypto pref is missing
    49     }
    50   }
    52   var bundle = document.getElementById("pippki_bundle");
    53   var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService();
    54   promptService = promptService.QueryInterface(Components.interfaces.nsIPromptService);
    55   if (promptService && bundle) {
    56     promptService.alert(window,
    57       bundle.getString("resetPasswordConfirmationTitle"), 
    58       bundle.getString("resetPasswordConfirmationMessage"));
    59   }
    61   return true;
    62 }

mercurial