1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* import-globals-from pippki.js */
"use strict";
/**
* @file Implements the functionality of downloadcert.xhtml: a dialog that allows
* a user to confirm whether to import a certificate, and if so what trust
* to give it.
* @argument {nsISupports} window.arguments[0]
* Certificate to confirm import of, queryable to nsIX509Cert.
* @argument {nsISupports} window.arguments[1]
* Object to set the return values of calling the dialog on, queryable
* to the underlying type of DownloadCertReturnValues.
*/
/**
* @typedef DownloadCertReturnValues
* @type nsIWritablePropertyBag2
* @property {Boolean} importConfirmed
* Set to true if the user confirmed import of the cert and accepted
* the dialog, false otherwise.
* @property {Boolean} trustForSSL
* Set to true if the cert should be trusted for SSL, false otherwise.
* Undefined value if |importConfirmed| is not true.
* @property {Boolean} trustForEmail
* Set to true if the cert should be trusted for e-mail, false
* otherwise. Undefined value if |importConfirmed| is not true.
*/
/**
* The cert to potentially import.
* @type nsIX509Cert
*/
var gCert;
/**
* onload() handler.
*/
function onLoad() {
gCert = window.arguments[0].QueryInterface(Ci.nsIX509Cert);
document.addEventListener("dialogaccept", onDialogAccept);
document.addEventListener("dialogcancel", onDialogCancel);
let bundle = document.getElementById("pippki_bundle");
let caName = gCert.commonName;
if (caName.length == 0) {
caName = bundle.getString("unnamedCA");
}
setText("trustHeader", bundle.getFormattedString("newCAMessage1", [caName]));
}
/**
* Handler for the "View Cert" button.
*/
function viewCert() {
viewCertHelper(window, gCert, "window");
}
/**
* ondialogaccept() handler.
*/
function onDialogAccept() {
let checkSSL = document.getElementById("trustSSL");
let checkEmail = document.getElementById("trustEmail");
let retVals = window.arguments[1].QueryInterface(Ci.nsIWritablePropertyBag2);
retVals.setPropertyAsBool("importConfirmed", true);
retVals.setPropertyAsBool("trustForSSL", checkSSL.checked);
retVals.setPropertyAsBool("trustForEmail", checkEmail.checked);
}
/**
* ondialogcancel() handler.
*/
function onDialogCancel() {
let retVals = window.arguments[1].QueryInterface(Ci.nsIWritablePropertyBag2);
retVals.setPropertyAsBool("importConfirmed", false);
}
|