~ubuntu-branches/ubuntu/quantal/enigmail/quantal-security

« back to all changes in this revision

Viewing changes to extensions/enigmail/ui/content/enigmailSetCardPin.xul

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2013-09-13 16:02:15 UTC
  • mfrom: (0.12.16)
  • Revision ID: package-import@ubuntu.com-20130913160215-u3g8nmwa0pdwagwc
Tags: 2:1.5.2-0ubuntu0.12.10.1
* New upstream release v1.5.2 for Thunderbird 24

* Build enigmail using a stripped down Thunderbird 17 build system, as it's
  now quite difficult to build the way we were doing previously, with the
  latest Firefox build system
* Add debian/patches/no_libxpcom.patch - Don't link against libxpcom, as it
  doesn't exist anymore (but exists in the build system)
* Add debian/patches/use_sdk.patch - Use the SDK version of xpt.py and
  friends
* Drop debian/patches/ipc-pipe_rename.diff (not needed anymore)
* Drop debian/patches/makefile_depth.diff (not needed anymore)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0"?>
2
 
<!--
3
 
 * ***** BEGIN LICENSE BLOCK *****
4
 
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
 
 *
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/
10
 
 *
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.
15
 
 *
16
 
 * The Original Code is Enigmail.
17
 
 *
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.
21
 
 *
22
 
 * Contributor(s):
23
 
 *
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 ***** *
36
 
-->
37
 
 
38
 
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
39
 
<?xml-stylesheet href="chrome://enigmail/skin/enigmail.css" type="text/css"?>
40
 
 
41
 
<!DOCTYPE window [
42
 
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
43
 
%brandDTD;
44
 
<!ENTITY % enigMailDTD SYSTEM "chrome://enigmail/locale/enigmail.dtd" >
45
 
%enigMailDTD;
46
 
]>
47
 
 
48
 
<dialog id="enigmailSetCardPingDlg"
49
 
        title="&enigmail.cardPin.title;"
50
 
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
51
 
        onload="onLoad();"
52
 
        ondialogaccept="return onAccept();"
53
 
        >
54
 
 
55
 
 
56
 
  <vbox>
57
 
    <hbox align="center">
58
 
      <label value="&enigmail.cardPin.action.label;" control="actionMenu"/>
59
 
      <menulist id="actionMenu" label="&enigmail.cardPin.changePin.label;" value="P">
60
 
        <menupopup id="actionMenuPopup">
61
 
          <menuitem id="changePin"
62
 
                    label="&enigmail.cardPin.changePin.label;"
63
 
                    selected="true"
64
 
                    oncommand="setDlgContent('P')"/>
65
 
          <menuitem id="changeAPin"
66
 
                    label="&enigmail.cardPin.changeAdmPin.label;"
67
 
                    oncommand="setDlgContent('A')"/>
68
 
          <menuitem id="unblockPin"
69
 
                    label="&enigmail.cardPin.unblockPin.label;"
70
 
                    oncommand="setDlgContent('U')"/>
71
 
        </menupopup>
72
 
      </menulist>
73
 
    </hbox>
74
 
    <separator/>
75
 
    <grid>
76
 
      <columns>
77
 
        <column/>
78
 
        <column flex="1"/>
79
 
      </columns>
80
 
      <rows>
81
 
        <row align="center" id="currAdminPinRow" collapsed="true">
82
 
          <label value="&enigmail.cardPin.currAdmPin.label; :" type="password" control="currAdmPinTxt"/>
83
 
          <textbox id="currAdmPinTxt" value="" type="password"/>
84
 
        </row>
85
 
        <row align="center" id="adminPinRow" collapsed="true">
86
 
          <label value="&enigmail.cardPin.newAdminPin.label; :" control="adminPinTxt"/>
87
 
          <textbox id="adminPinTxt" value="" type="password"/>
88
 
        </row>
89
 
        <row align="center" id="adminPinRepeatRow" collapsed="true">
90
 
          <label value="&enigmail.cardPin.adminPinRepeat.label; :" control="adminPinRepeatTxt"/>
91
 
          <textbox id="adminPinRepeatTxt" value="" type="password"/>
92
 
        </row>
93
 
        <row align="center" id="currPinRow">
94
 
          <label value="&enigmail.cardPin.currPin.label; :" control="currPinTxt"/>
95
 
          <textbox id="currPinTxt" value="" type="password"/>
96
 
        </row>
97
 
        <row align="center" id="pinRow">
98
 
          <label value="&enigmail.cardPin.newPin.label; :" control="pinTxt"/>
99
 
          <textbox id="pinTxt" value="" type="password"/>
100
 
        </row>
101
 
        <row align="center" id="pinRepeatRow">
102
 
          <label value="&enigmail.cardPin.pinRepeat.label; :" control="pinRepeatTxt"/>
103
 
          <textbox id="pinRepeatTxt" value="" type="password"/>
104
 
        </row>
105
 
      </rows>
106
 
    </grid>
107
 
  </vbox>
108
 
 
109
 
  <script type="application/x-javascript">
110
 
  <![CDATA[
111
 
 
112
 
  Components.utils.import("resource://enigmail/enigmailCommon.jsm");
113
 
  Components.utils.import("resource://enigmail/keyManagement.jsm");
114
 
 
115
 
  const Ec = EnigmailCommon;
116
 
  const nsIEnigmail = Components.interfaces.nsIEnigmail;
117
 
  const Ci = Components.interfaces;
118
 
 
119
 
  const CHANGE_PIN  = 'P';
120
 
  const ADMIN_PIN   = 'A';
121
 
  const UNBLOCK_PIN = 'U';
122
 
 
123
 
  var gAction = null;
124
 
 
125
 
  function onLoad() {
126
 
    setDlgContent(CHANGE_PIN);
127
 
  }
128
 
 
129
 
  function onAccept() {
130
 
    var enigmailSvc = Ec.getService(window);
131
 
    if (!enigmailSvc)
132
 
      return false;
133
 
 
134
 
    var pinItem1;
135
 
    var pinItem2;
136
 
    var minLen=0;
137
 
    var action;
138
 
 
139
 
    switch(gAction) {
140
 
      case CHANGE_PIN:
141
 
        pinItem1="pinTxt";
142
 
        pinItem2="pinRepeatTxt";
143
 
        minLen=6;
144
 
        action = nsIEnigmail.CARD_PIN_CHANGE;
145
 
        break;
146
 
      case UNBLOCK_PIN:
147
 
        pinItem1="pinTxt";
148
 
        pinItem2="pinRepeatTxt";
149
 
        minLen=6;
150
 
        action = nsIEnigmail.CARD_PIN_UNBLOCK;
151
 
        break;
152
 
      case ADMIN_PIN:
153
 
        pinItem1="adminPinTxt";
154
 
        pinItem2="adminPinRepeatTxt";
155
 
        minLen=8;
156
 
        action = nsIEnigmail.CARD_ADMIN_PIN_CHANGE;
157
 
        break;
158
 
    }
159
 
    var adminPin = "";
160
 
    var oldPin = "";
161
 
    var newPin = "";
162
 
 
163
 
    if (! enigmailSvc.useGpgAgent()) {
164
 
      adminPin = document.getElementById("currAdmPinTxt").value;
165
 
      oldPin = document.getElementById("currPinTxt").value;
166
 
      newPin = document.getElementById(pinItem1).value;
167
 
 
168
 
      if (newPin.length < minLen) {
169
 
        Ec.alert(window, Ec.getString("cardPin.minLength", minLen));
170
 
        return false;
171
 
      }
172
 
      if (newPin != document.getElementById(pinItem2).value) {
173
 
        Ec.alert(window, Ec.getString("cardPin.dontMatch"));
174
 
        return false;
175
 
      }
176
 
    }
177
 
 
178
 
    var pinObserver = new changePinObserver();
179
 
 
180
 
    EnigmailKeyMgmt.cardChangePin(window,
181
 
                                 action,
182
 
                                 oldPin,
183
 
                                 newPin,
184
 
                                 adminPin,
185
 
                                 pinObserver,
186
 
      function _ChangePinCb(exitCode, errorMsg) {
187
 
        if (exitCode != 0) {
188
 
          Ec.alert(window, Ec.getString("cardPin.processFailed")+"\n"+pinObserver.result);
189
 
        }
190
 
        else
191
 
          window.close();
192
 
      });
193
 
 
194
 
    return false;
195
 
  }
196
 
 
197
 
  function dlgEnable(item) {
198
 
    document.getElementById(item).removeAttribute("collapsed");
199
 
  }
200
 
 
201
 
  function dlgDisable(item) {
202
 
    document.getElementById(item).setAttribute("collapsed", "true");
203
 
  }
204
 
 
205
 
  function setDlgContent(sel) {
206
 
    var enigmailSvc = Ec.getService(window);
207
 
    if (!enigmailSvc)
208
 
      return false;
209
 
 
210
 
    gAction = sel;
211
 
 
212
 
    if (enigmailSvc.useGpgAgent()) {
213
 
      dlgDisable("currAdminPinRow");
214
 
      dlgDisable("adminPinRow");
215
 
      dlgDisable("adminPinRepeatRow");
216
 
      dlgDisable("currPinRow");
217
 
      dlgDisable("pinRow");
218
 
      dlgDisable("pinRepeatRow");
219
 
      return;
220
 
    }
221
 
 
222
 
    switch(sel) {
223
 
    case 'P':
224
 
      dlgDisable("currAdminPinRow");
225
 
      dlgDisable("adminPinRow");
226
 
      dlgDisable("adminPinRepeatRow");
227
 
      dlgEnable("currPinRow");
228
 
      dlgEnable("pinRow");
229
 
      dlgEnable("pinRepeatRow");
230
 
      break;
231
 
    case 'A':
232
 
      dlgEnable("currAdminPinRow");
233
 
      dlgEnable("adminPinRow");
234
 
      dlgEnable("adminPinRepeatRow");
235
 
      dlgDisable("currPinRow");
236
 
      dlgDisable("pinRow");
237
 
      dlgDisable("pinRepeatRow");
238
 
      break;
239
 
    case 'U':
240
 
      dlgEnable("currAdminPinRow");
241
 
      dlgDisable("adminPinRow");
242
 
      dlgDisable("adminPinRepeatRow");
243
 
      dlgDisable("currPinRow");
244
 
      dlgEnable("pinRow");
245
 
      dlgEnable("pinRepeatRow");
246
 
      break;
247
 
    }
248
 
  }
249
 
 
250
 
  function changePinObserver() {
251
 
  }
252
 
 
253
 
  changePinObserver.prototype =
254
 
  {
255
 
    _data: "",
256
 
    result: "",
257
 
 
258
 
    QueryInterface : function(iid)
259
 
    {
260
 
      if (iid.equals(Ci.nsIEnigMimeReadCallback) ||
261
 
          iid.equals(Ci.nsISupports) )
262
 
        return this;
263
 
 
264
 
      throw Components.results.NS_NOINTERFACE;
265
 
    },
266
 
 
267
 
    onDataAvailable: function (data) {
268
 
      var ret="";
269
 
      Ec.DEBUG_LOG("enigmailSetCardPin: changePinObserver.onDataAvailable: data="+data+"\n");
270
 
      if (data.indexOf("[GNUPG:] SC_OP_FAILURE")>=0) {
271
 
        this.result = this._data;
272
 
      }
273
 
      else if (data.indexOf("[GNUPG:] BAD_PASSPHRASE")>=0) {
274
 
        this.result = Ec.getString("badPhrase");
275
 
        return data;
276
 
      }
277
 
      else {
278
 
        this._data = data
279
 
      }
280
 
      return "";
281
 
    }
282
 
  }
283
 
 
284
 
  ]]>
285
 
  </script>
286
 
</dialog>
287
 
 
288