3
* ***** BEGIN LICENSE BLOCK *****
4
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
6
* The contents of this file are subject to the Mozilla Public
7
* License Version 1.1 (the "MPL"); you may not use this file
8
* except in compliance with the MPL. You may obtain a copy of
9
* the MPL at http://www.mozilla.org/MPL/
11
* Software distributed under the MPL is distributed on an "AS
12
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
13
* implied. See the MPL for the specific language governing
14
* rights and limitations under the MPL.
16
* The Original Code is Enigmail.
18
* The Initial Developer of the Original Code is Patrick Brunschwig.
19
* Portions created by Patrick Brunschwig <patrick@mozilla-enigmail.org> are
20
* Copyright (C) 2005 Patrick Brunschwig. All Rights Reserved.
24
* Alternatively, the contents of this file may be used under the terms of
25
* either the GNU General Public License Version 2 or later (the "GPL"), or
26
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
* in which case the provisions of the GPL or the LGPL are applicable instead
28
* of those above. If you wish to allow use of your version of this file only
29
* under the terms of either the GPL or the LGPL, and not to allow others to
30
* use your version of this file under the terms of the MPL, indicate your
31
* decision by deleting the provisions above and replace them with the notice
32
* and other provisions required by the GPL or the LGPL. If you do not delete
33
* the provisions above, a recipient may use your version of this file under
34
* the terms of any one of the MPL, the GPL or the LGPL.
35
* ***** END LICENSE BLOCK ***** *
39
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
40
<?xml-stylesheet href="chrome://enigmail/skin/enigmail.css" type="text/css"?>
43
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
45
<!ENTITY % enigMailDTD SYSTEM "chrome://enigmail/locale/enigmail.dtd" >
49
<window id="enigmailGenCardKeyDlg"
50
title="&enigmail.genCardKey.title;"
51
windowtype="enigmail:genCardKey"
52
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
54
buttons="accept,cancel"
58
<script type="application/x-javascript" src="chrome://enigmail/content/enigmailCommon.js"/>
59
<script type="application/x-javascript" src="chrome://enigmail/content/enigmailKeygen.js"/>
62
<broadcaster id="bcBackupKey"/>
63
<broadcaster id="bcNoExpiry"/>
66
<popupset id="aTooltipSet"/>
68
<groupbox id="userIdBox" orient="vertical">
70
<hbox orient="horizontal" align="center">
71
<label value="&enigmail.keyUserId.label;" control="userIdentity"/>
72
<menulist id="userIdentity" label="..." flex="1">
73
<menupopup id="userIdentityPopup"/>
77
<checkbox id="useForSigning"
78
label="&enigmail.useForSigning.label;"
83
<checkbox id="createBackup"
84
label="&enigmail.genCardKey.backupKey.label;"
86
oncommand="enableDisable('createBackup','bcBackupKey', false)"/>
95
<hbox id="passphraseBox" align="center">
96
<label control="passphrase" value="&enigmail.keyPassphrase.label;" />
99
<textbox id="passphrase" type="password" observes="bcBackupKey"/>
100
<label control="passphraseRepeat" value="&enigmail.keyPassphraseRepeat.label;" />
101
<textbox id="passphraseRepeat" type="password" observes="bcBackupKey"/>
106
<hbox align="center">
107
<label control="keyComment" value="&enigmail.keyComment.label;" />
109
<textbox id="keyComment" />
113
<hbox align="center">
114
<label value="&enigmail.keyGen.expire.label;" control="expireInput"/>
116
<hbox align="center">
117
<textbox id="expireInput" size="5" maxlength="5" value="5" observes="bcNoExpiry"/>
118
<menulist id="timeScale" label="&enigmail.keyGen.years.label;" value="365" observes="bcNoExpiry">
119
<menupopup id="timeScalePopup" value="5">
120
<menuitem id="years" value="y" label="&enigmail.keyGen.years.label;" selected="true"/>
121
<menuitem id="months" value="m" label="&enigmail.keyGen.months.label;"/>
122
<menuitem id="days" value="d" label="&enigmail.keyGen.days.label;"/>
125
<checkbox label="&enigmail.keyGen.noExpiry.label;"
127
oncommand="enableDisable('noExpiry','bcNoExpiry', true)"/>
136
<hbox autostretch="never">
137
<button label="&enigmail.generateKey.label;"
140
tooltiptext="&enigmail.generateKey.tooltip;"
141
oncommand="startKeyGen();" />
143
<button label="&enigmail.cancelKey.label;"
146
tooltiptext="&enigmail.cancelKey.tooltip;"
147
oncommand="onClose();" />
150
<groupbox id="keygenConsoleBox" orient="vertical">
152
<caption label="&enigmail.keyGen.console.label;"/>
154
<description>&enigmail.genCardKey.desc;</description>
156
<iframe id="keygenConsole" type="content" name="keygenConsole"
157
src="chrome://enigmail/content/enigmailKeygenConsole.htm"
158
height="200" flex="1"/>
163
<script type="application/x-javascript">
165
Components.utils.import("resource://enigmail/commonFuncs.jsm");
166
Components.utils.import("resource://enigmail/enigmailCommon.jsm");
167
Components.utils.import("resource://enigmail/keyManagement.jsm");
169
// Ec is predefined by enigmailCommon.js
172
var gIdentityListPopup;
177
gIdentityList = document.getElementById("userIdentity");
178
gIdentityListPopup = document.getElementById("userIdentityPopup");
179
gUseForSigning = document.getElementById("useForSigning");
180
//document.getElementById("bcNoExpiry")
181
if (gIdentityListPopup) {
182
fillIdentityListPopup();
190
function enableDisable(watchElement, bcElement, inverted) {
191
var bcBackupKey = document.getElementById(bcElement);
193
if (document.getElementById(watchElement).checked) {
195
bcBackupKey.setAttribute("disabled", "true");
198
bcBackupKey.removeAttribute("disabled");
203
bcBackupKey.removeAttribute("disabled");
206
bcBackupKey.setAttribute("disabled", "true");
211
function enigGenKeyObserver() {
215
enigGenKeyObserver.prototype =
218
backupLocation: null,
221
QueryInterface : function(iid)
223
//DEBUG_LOG("enigmailGenCardKey: EnigMimeReadCallback.QI: "+iid+"\n");
224
if (iid.equals(Components.interfaces.nsIEnigMimeReadCallback) ||
225
iid.equals(Components.interfaces.nsISupports) )
228
throw Components.results.NS_NOINTERFACE;
231
onDataAvailable: function (data) {
233
var aLine = data.split(/ +/);
234
if (aLine[0] == "[GNUPG:]") {
235
if (aLine[1]=="GET_LINE" && aLine[2]=="keygen.comment") {
236
txt=Ec.getString("keygen.started")+"\n";
239
else if (aLine[1]=="PROGRESS" && aLine[2]=="primegen") {
242
else if (aLine[1] == "BACKUP_KEY_CREATED") {
243
this.backupLocation = data.replace(/^.*BACKUP_KEY_CREATED [A-Z0-9]+ +/, "");
245
else if (aLine[1] == "KEY_CREATED") {
246
this.keyId = aLine[3].substr(-16);
249
else if (this._state>0) {
253
var contentFrame = Ec.getFrame(window, "keygenConsole");
255
var consoleElement = contentFrame.document.getElementById('console');
256
consoleElement.firstChild.data += txt;
257
if (!contentFrame.mouseDownState)
258
contentFrame.scrollTo(0,9999);
265
function startKeyGen() {
266
DEBUG_LOG("enigmailGenCardKey: startKeyGen(): Start\n");
268
var enigmailSvc = Ec.getService(window);
270
Ec.alert(window,Ec.getString("accessError"));
274
var passphraseElement = document.getElementById("passphrase");
275
var passphrase2Element = document.getElementById("passphraseRepeat");
276
var createBackupElement = document.getElementById("createBackup");
278
var passphrase = passphraseElement.value;
280
if (!createBackupElement.checked) {
284
if (passphrase != passphrase2Element.value) {
285
Ec.alert(window,Ec.getString("passNoMatch"));
289
if (passphrase.search(/[\x80-\xFF]/)>=0) {
290
Ec.alert(window,Ec.getString("passCharProblem"));
295
Ec.alert(window,Ec.getString("keygen.passRequired"));
300
var commentElement = document.getElementById("keyComment");
301
var comment = commentElement.value;
303
var noExpiry = document.getElementById("noExpiry");
304
var expireInput = document.getElementById("expireInput");
305
var timeScale = document.getElementById("timeScale");
309
if (! noExpiry.checked) {
310
expiryTime = Number(expireInput.value) * (timeScale.value == "y" ? 365 : (timeScale.value == "m" ? 30 : 1));
311
if (expiryTime > 36500) {
312
Ec.alert(window,Ec.getString("expiryTooLong"));
315
if (! (expiryTime > 0)) {
316
Ec.alert(window,Ec.getString("expiryTooShort"));
319
valid = String(Number(expireInput.value));
320
if (timeScale.value != "d") valid += timeScale.value;
322
var curId = getCurrentIdentity();
325
var userName = curId.fullName;
326
var userEmail = curId.email;
329
Ec.alert(window,Ec.getString("passUserName"));
333
var idString = userName;
336
idString += " (" + comment + ")";
338
idString += " <" + userEmail + ">";
340
var confirmMsg = Ec.getString("keyConfirm",idString);
342
if (!EnigConfirm(confirmMsg, Ec.getString("keyMan.button.generateKey"))) {
345
var contentFrame = Ec.getFrame(window, "keygenConsole");
347
var consoleElement = contentFrame.document.getElementById('console');
348
consoleElement.firstChild.data = "";
351
var generateObserver = new enigGenKeyObserver();
352
EnigmailKeyMgmt.genCardKey(window,
359
function _keyGenCb(exitCode, errorMsg) {
360
if (exitCode == 0 && generateObserver.keyId) {
361
if (document.getElementById("useForSigning").checked && generateObserver.keyId) {
362
gUsedId.setBoolAttribute("enablePgp", true);
363
gUsedId.setIntAttribute("pgpKeyMode", 1);
364
gUsedId.setCharAttribute("pgpkeyId", "0x"+generateObserver.keyId.substr(-8,8));
366
var msg=Ec.getString("keygen.completed", generateObserver.keyId);
367
if (generateObserver.backupLocation) {
368
msg += "\n"+Ec.getString("keygen.keyBackup", generateObserver.backupLocation);
370
if (Ec.confirmDlg(window, msg+"\n\n"+Ec.getString("revokeCertRecommended"), Ec.getString("keyMan.button.generateCert"))) {
371
EnigCreateRevokeCert(generateObserver.keyId, curId.email, closeWin);
377
Ec.alert(window, errorMsg);
382
function closeWin() {