michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const nsPK11TokenDB = "@mozilla.org/security/pk11tokendb;1"; michael@0: const nsIPK11TokenDB = Components.interfaces.nsIPK11TokenDB; michael@0: const nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock; michael@0: michael@0: var tokenName; michael@0: michael@0: function onLoad() michael@0: { michael@0: if ("arguments" in window) { michael@0: var params = window.arguments[0].QueryInterface(nsIDialogParamBlock); michael@0: tokenName = params.GetString(1); michael@0: } else { michael@0: tokenName = self.name; michael@0: } michael@0: } michael@0: michael@0: function resetPassword() michael@0: { michael@0: var pk11db = Components.classes[nsPK11TokenDB].getService(nsIPK11TokenDB); michael@0: var token = pk11db.findTokenByName(tokenName); michael@0: token.reset(); michael@0: michael@0: try { michael@0: var loginManager = Components.classes["@mozilla.org/login-manager;1"]. michael@0: getService(Components.interfaces.nsILoginManager); michael@0: loginManager.removeAllLogins(); michael@0: } catch (e) { michael@0: } michael@0: michael@0: var pref = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefService); michael@0: if (pref) { michael@0: pref = pref.getBranch(null); michael@0: try { michael@0: if (pref.getBoolPref("wallet.crypto")) { michael@0: // data in wallet is encrypted, clear it michael@0: var wallet = Components.classes['@mozilla.org/wallet/wallet-service;1']; michael@0: if (wallet) { michael@0: wallet = wallet.getService(Components.interfaces.nsIWalletService); michael@0: wallet.WALLET_DeleteAll(); michael@0: } michael@0: } michael@0: } michael@0: catch(e) { michael@0: // wallet.crypto pref is missing michael@0: } michael@0: } michael@0: michael@0: var bundle = document.getElementById("pippki_bundle"); michael@0: var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(); michael@0: promptService = promptService.QueryInterface(Components.interfaces.nsIPromptService); michael@0: if (promptService && bundle) { michael@0: promptService.alert(window, michael@0: bundle.getString("resetPasswordConfirmationTitle"), michael@0: bundle.getString("resetPasswordConfirmationMessage")); michael@0: } michael@0: michael@0: return true; michael@0: } michael@0: