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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 *
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7
michael@0 8 const nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock;
michael@0 9
michael@0 10 var dialogParams;
michael@0 11 var itemCount = 0;
michael@0 12 var rememberBox;
michael@0 13
michael@0 14 function onLoad()
michael@0 15 {
michael@0 16 var cn;
michael@0 17 var org;
michael@0 18 var issuer;
michael@0 19
michael@0 20 dialogParams = window.arguments[0].QueryInterface(nsIDialogParamBlock);
michael@0 21 cn = dialogParams.GetString(0);
michael@0 22 org = dialogParams.GetString(1);
michael@0 23 issuer = dialogParams.GetString(2);
michael@0 24
michael@0 25 // added with bug 431819. reuse string from caps in order to avoid string changes
michael@0 26 var capsBundle = document.getElementById("caps_bundle");
michael@0 27 var rememberString = capsBundle.getString("CheckMessage");
michael@0 28 var rememberSetting = true;
michael@0 29
michael@0 30 var pref = Components.classes['@mozilla.org/preferences-service;1']
michael@0 31 .getService(Components.interfaces.nsIPrefService);
michael@0 32 if (pref) {
michael@0 33 pref = pref.getBranch(null);
michael@0 34 try {
michael@0 35 rememberSetting =
michael@0 36 pref.getBoolPref("security.remember_cert_checkbox_default_setting");
michael@0 37 }
michael@0 38 catch(e) {
michael@0 39 // pref is missing
michael@0 40 }
michael@0 41 }
michael@0 42
michael@0 43 rememberBox = document.getElementById("rememberBox");
michael@0 44 rememberBox.label = rememberString;
michael@0 45 rememberBox.checked = rememberSetting;
michael@0 46
michael@0 47 var bundle = document.getElementById("pippki_bundle");
michael@0 48 var message1 = bundle.getFormattedString("clientAuthMessage1", [org]);
michael@0 49 var message2 = bundle.getFormattedString("clientAuthMessage2", [issuer]);
michael@0 50 setText("hostname", cn);
michael@0 51 setText("organization", message1);
michael@0 52 setText("issuer", message2);
michael@0 53
michael@0 54 var selectElement = document.getElementById("nicknames");
michael@0 55 itemCount = dialogParams.GetInt(0);
michael@0 56 for (var i=0; i < itemCount; i++) {
michael@0 57 var menuItemNode = document.createElement("menuitem");
michael@0 58 var nick = dialogParams.GetString(i+3);
michael@0 59 menuItemNode.setAttribute("value", i);
michael@0 60 menuItemNode.setAttribute("label", nick); // this is displayed
michael@0 61 selectElement.firstChild.appendChild(menuItemNode);
michael@0 62 if (i == 0) {
michael@0 63 selectElement.selectedItem = menuItemNode;
michael@0 64 }
michael@0 65 }
michael@0 66
michael@0 67 setDetails();
michael@0 68 }
michael@0 69
michael@0 70 function setDetails()
michael@0 71 {
michael@0 72 var index = parseInt(document.getElementById("nicknames").value);
michael@0 73 var details = dialogParams.GetString(index+itemCount+3);
michael@0 74 document.getElementById("details").value = details;
michael@0 75 }
michael@0 76
michael@0 77 function onCertSelected()
michael@0 78 {
michael@0 79 setDetails();
michael@0 80 }
michael@0 81
michael@0 82 function doOK()
michael@0 83 {
michael@0 84 dialogParams.SetInt(0,1);
michael@0 85 var index = parseInt(document.getElementById("nicknames").value);
michael@0 86 dialogParams.SetInt(1, index);
michael@0 87 dialogParams.SetInt(2, rememberBox.checked);
michael@0 88 return true;
michael@0 89 }
michael@0 90
michael@0 91 function doCancel()
michael@0 92 {
michael@0 93 dialogParams.SetInt(0,0);
michael@0 94 dialogParams.SetInt(1, -1); // invalid value
michael@0 95 dialogParams.SetInt(2, rememberBox.checked);
michael@0 96 return true;
michael@0 97 }

mercurial