Bug 667327 - Require Master Pasword before allowing password to be copied. r=kairo, sr=neil
--- a/suite/common/dataman/dataman.js
+++ b/suite/common/dataman/dataman.js
@@ -2028,23 +2028,41 @@ var gPasswords = {
document.getElementById("pwd-context-remove").disabled =
this.removeButton.disabled;
document.getElementById("pwd-context-copypassword").disabled =
this.tree.view.selection.count != 1;
document.getElementById("pwd-context-selectall").disabled =
this.tree.view.selection.count >= this.tree.view.rowCount;
},
- copyPassword: function passwords_copyPassword() {
+ copySelPassword: function passwords_copySelPassword() {
// Copy selected signon's password to clipboard.
let row = this.tree.currentIndex;
let password = gPasswords.displayedSignons[row].password;
gLocSvc.clipboard.copyString(password);
},
+ copyPassword: function passwords_copyPassword() {
+ // Prompt for the master password upfront.
+ let token = Components.classes["@mozilla.org/security/pk11tokendb;1"]
+ .getService(Components.interfaces.nsIPK11TokenDB)
+ .getInternalKeyToken();
+
+ if (this.showPasswords || token.checkPassword(""))
+ this.copySelPassword();
+ else {
+ try {
+ token.login(true);
+ this.copySelPassword();
+ } catch (ex) {
+ // If user cancels an exception is expected.
+ }
+ }
+ },
+
reactToChange: function passwords_reactToChange(aSubject, aData) {
// aData: addLogin, modifyLogin, removeLogin, removeAllLogins
if (aData == "removeAllLogins") {
// Go for re-parsing the whole thing.
if (this.displayedSignons.length) {
this.tree.treeBoxObject.beginUpdateBatch();
this.tree.view.selection.clearSelection();
this.displayedSignons = [];