1
/* ***** BEGIN LICENSE BLOCK *****
2
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
* The contents of this file are subject to the Mozilla Public
5
* License Version 1.1 (the "MPL"); you may not use this file
6
* except in compliance with the MPL. You may obtain a copy of
7
* the MPL at http://www.mozilla.org/MPL/
9
* Software distributed under the MPL is distributed on an "AS
10
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11
* implied. See the MPL for the specific language governing
12
* rights and limitations under the MPL.
14
* The Original Code is Enigmail.
16
* The Initial Developer of the Original Code is Patrick Brunschwig.
17
* Portions created by Patrick Brunschwig <patrick@mozilla-enigmail.org> are
18
* Copyright (C) 2007 Patrick Brunschwig. All Rights Reserved.
22
* Alternatively, the contents of this file may be used under the terms of
23
* either the GNU General Public License Version 2 or later (the "GPL"), or
24
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
25
* in which case the provisions of the GPL or the LGPL are applicable instead
26
* of those above. If you wish to allow use of your version of this file only
27
* under the terms of either the GPL or the LGPL, and not to allow others to
28
* use your version of this file under the terms of the MPL, indicate your
29
* decision by deleting the provisions above and replace them with the notice
30
* and other provisions required by the GPL or the LGPL. If you do not delete
31
* the provisions above, a recipient may use your version of this file under
32
* the terms of any one of the MPL, the GPL or the LGPL.
33
* ***** END LICENSE BLOCK ***** */
36
EnigInitCommon("enigmailKeyDetailsDlg");
43
window.arguments[1].refresh = false;
45
gKeyId = window.arguments[0].keyId;
46
gKeyList = window.arguments[0].keyListArr;
50
if (window.arguments[0].secKey) {
51
setAttr("keyType", EnigGetString("keyTypePair"));
52
document.getElementById("ownKeyCommands").removeAttribute("hidden");
55
setAttr("keyType", EnigGetString("keyTypePublic"));
59
function reloadData() {
60
var enigmailSvc = GetEnigmailSvc();
62
EnigAlert(EnigGetString("accessError"));
66
var exitCodeObj = new Object();
67
var statusFlagsObj = new Object();
68
var errorMsgObj = new Object();
75
var treeChildren = document.getElementById("keyListChildren");
76
var uidList = document.getElementById("uidListChildren");
79
while (treeChildren.firstChild) {
80
treeChildren.removeChild(treeChildren.firstChild);
82
while (uidList.firstChild) {
83
uidList.removeChild(uidList.firstChild);
86
var sigListStr = enigmailSvc.getKeySig("0x"+gKeyId, exitCodeObj, errorMsgObj);
87
if (exitCodeObj.value == 0) {
88
var sigList = sigListStr.split(/[\n\r]+/);
89
for (var i=0; i < sigList.length; i++) {
90
var aLine=sigList[i].split(/:/);
93
gUserId=EnigConvertGpgToUnicode(aLine[9]);
94
var calcTrust=aLine[1];
95
if (aLine[11].indexOf("D")>=0) calcTrust="d";
96
calcTrust=getTrustLabel(calcTrust);
97
var ownerTrust=getTrustLabel(aLine[8]);
98
addSubkey(treeChildren, aLine);
101
gUserId=EnigConvertGpgToUnicode(aLine[9]);
104
uidList.appendChild(createUidRow(aLine));
108
if (aLine[9].search("1 ") == 0) {
109
document.getElementById("showPhoto").removeAttribute("disabled");
113
addSubkey(treeChildren, aLine);
116
fingerprint = aLine[9];
122
setAttr("userId", gUserId);
123
setAttr("keyId", "0x"+ gKeyId.substr(-8,8));
124
setAttr("calcTrust", calcTrust);
125
setAttr("ownerTrust", ownerTrust);
127
setAttr("fingerprint", EnigFormatFpr(fingerprint));
131
function createUidRow(aLine) {
132
var treeItem = document.createElement("treeitem");
133
var treeRow = document.createElement("treerow");
134
var uidCol = createCell(EnigConvertGpgToUnicode(aLine[9]));
135
var validCol = createCell(getTrustLabel(aLine[1]));
136
if ("dre".search(aLine[1]) >= 0) {
137
uidCol.setAttribute("properties", "enigKeyInactive");
138
validCol.setAttribute("properties", "enigKeyInactive");
140
treeRow.appendChild(uidCol);
141
treeRow.appendChild(validCol);
142
treeItem.appendChild(treeRow);
146
function addSubkey(treeChildren, aLine) {
147
var aRow=document.createElement("treerow");
148
var treeItem=document.createElement("treeitem");
149
var subkey=EnigGetString(aLine[0]=="sub" ? "keyTypeSubkey" : "keyTypePrimary");
150
aRow.appendChild(createCell(subkey)); // subkey type
151
aRow.appendChild(createCell("0x"+aLine[4].substr(-8,8))); // key id
152
aRow.appendChild(createCell(EnigGetString("keyAlgorithm_"+aLine[3]))); // algorithm
153
aRow.appendChild(createCell(aLine[2])); // size
154
aRow.appendChild(createCell(EnigGetDateTime(aLine[5], true, false))); // created
155
var expire=(aLine[6].length==0 ? EnigGetString("keyExpiryNever") : EnigGetDateTime(aLine[6], true, false));
157
expire = EnigGetString("keyValid.revoked");
159
aRow.appendChild(createCell(expire)); // expiry
160
var usagecodes=aLine[11];
166
Capital Letters are ignored, as these reflect summary properties of a key
169
for (i=0; i < aLine[11].length; i++)
171
singlecode = aLine[11].substr(i, 1);
175
if (usagetext.length>0)
177
usagetext = usagetext + ", ";
179
usagetext = usagetext + EnigGetString("keyUsageEncrypt");
182
if (usagetext.length>0)
184
usagetext = usagetext + ", ";
186
usagetext = usagetext + EnigGetString("keyUsageSign");
189
if (usagetext.length>0)
191
usagetext = usagetext + ", ";
193
usagetext = usagetext + EnigGetString("keyUsageCertify");
196
if (usagetext.length>0)
198
usagetext = usagetext + ", ";
200
usagetext = usagetext + EnigGetString("keyUsageAuthentication");
205
aRow.appendChild(createCell(usagetext)); // usage
206
treeItem.appendChild(aRow);
207
treeChildren.appendChild(treeItem);
210
function createCell(label) {
211
var cell = document.createElement("treecell");
212
cell.setAttribute("label", label);
216
function getTrustLabel(trustCode) {
217
var trustTxt=EnigGetTrustLabel(trustCode);
218
if (trustTxt=="-" || trustTxt.length==0) {
219
trustTxt=EnigGetString("keyValid.unknown");
224
function setAttr(attribute, value) {
225
var elem = document.getElementById(attribute);
231
function enableRefresh() {
232
window.arguments[1].refresh = true;
235
// ------------------ onCommand Functions -----------------
237
function showPhoto() {
238
EnigShowPhoto(gKeyId, gUserId, 0);
241
function viewSignatures() {
246
var resultObj = {refresh: false};
248
window.openDialog("chrome://enigmail/content/enigmailViewKeySigDlg.xul",
249
"", "dialog,modal,centerscreen,resizable=yes", inputObj, resultObj);
251
if (resultObj.refresh) {
258
function keyDetailsAddPhoto() {
259
keyMgrAddPhoto(gUserId, gKeyId);
263
if (EnigSignKey(gUserId, gKeyId, null)) {
269
function setOwnerTrust() {
271
if (EnigEditKeyTrust([gUserId], [gKeyId])) {
277
function manageUids() {
280
ownKey: window.arguments[0].secKey
283
var resultObj = {refresh: false};
284
window.openDialog("chrome://enigmail/content/enigmailManageUidDlg.xul",
285
"", "dialog,modal,centerscreen,resizable=yes", inputObj, resultObj);
286
if (resultObj.refresh) {
292
function changePassword() {
293
EnigChangeKeyPwd(gKeyId, gUserId);
296
function revokeKey() {
297
EnigRevokeKey(gKeyId, gUserId, function _revokeKeyCb(success) {
305
function genRevocationCert() {
306
EnigCreateRevokeCert(gKeyId, gUserId);