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