home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / komunikace / kmeleon / K-Meleon1.1.3en-US.exe / chrome / embed.jar / kmprefs / content / pref-encryption.xul < prev    next >
Extensible Markup Language  |  2007-04-23  |  8KB  |  200 lines

  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type="text/css" href="chrome://global/skin/"?>
  3. <!DOCTYPE page SYSTEM "chrome://kmprefs/locale/pref-encryption.dtd">
  4. <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 
  5. id="prefEncryption" onload="init()" onunload="Masterpass.toggleTimeout(false)">
  6.  
  7. <stringbundle id="pref_bundle" src="chrome://kmprefs/locale/pref.properties"/>
  8.  
  9. <script type="application/x-javascript" src="chrome://kmprefs/content/pref.js"/>
  10. <script type="application/x-javascript">
  11. <![CDATA[
  12. var Masterpass = {
  13.  
  14. _isset: null,
  15. _isold: null,
  16. _times: null,
  17. _tmout: null,
  18. _token: null,
  19.  
  20. init: function() {
  21.     this._isset = this._isSet();
  22.     this._token = Components.classes["@mozilla.org/security/pk11tokendb;1"]
  23.                 .getService(Components.interfaces.nsIPK11TokenDB)
  24.                 .getInternalKeyToken();
  25.     this._initEncryption();
  26.     this._setControls();
  27.     this._initTimeout();
  28.  
  29.     document.getElementsByTagName("checkbox")[0].checked = this._isset;
  30. },
  31. change: function() {
  32.     var dpb = Components.classes["@mozilla.org/embedcomp/dialogparam;1"]
  33.                 .createInstance(Components.interfaces.nsIDialogParamBlock);
  34.  
  35.     dpb.SetString(1,"");
  36.     window.openDialog("chrome://pippki/content/changepassword.xul","","chrome,centerscreen,modal",dpb);
  37. },
  38. devices: function() {
  39.     window.openDialog("chrome://pippki/content/device_manager.xul","","chrome,centerscreen,modal");
  40.     this.init();
  41. },
  42. toggle: function(elem) {
  43.     if(elem.checked)
  44.         this.change();
  45.     else
  46.         this._reset();
  47.     this.init();
  48. },
  49. toggleTimeout: function(init) {
  50.     const nsIPK11Token = Components.interfaces.nsIPK11Token;
  51.  
  52.     var b=document.getElementById("security.password_lifetime"),t,x;
  53.     switch(document.getElementById("security.ask_for_password").value) {
  54.         case "0": t=nsIPK11Token.ASK_FIRST_TIME;  x=false; b.disabled=true; break;
  55.         case "1": t=nsIPK11Token.ASK_EVERY_TIME;  x=true;  b.disabled=true; break;
  56.         case "2": t=nsIPK11Token.ASK_EXPIRE_TIME; x=false; b.disabled=!this._isset; if(!init) b.focus(); this._tmout=b.value; var r=new RegExp("^[0-9]+$"); if(!r.test(this._tmout)) this._tmout="1"; break;
  57.     }
  58.     this._token.setAskPasswordDefaults(t,this._tmout);
  59.     pref.setBoolPref("signon.expireMasterPassword",x);
  60. },
  61. _initEncryption: function() {
  62.     if(this._isold==null)
  63.         this._isold = this._isset;
  64.     else {
  65.         if(this._isold!=this._isset) this._reencrypt();
  66.         this._isold = this._isset;
  67.         return;
  68.     }
  69.     if(this._isset && (getPrefValue("wallet.crypto")!="true"))
  70.         this._reencrypt();
  71. },
  72. _reencrypt: function() {
  73.     var ws = Components.classes["@mozilla.org/wallet/wallet-service;1"]
  74.                .getService()
  75.                .QueryInterface(Components.interfaces.nsIWalletService);
  76.  
  77.     ws.WALLET_InitReencryptCallback(window);
  78.     pref.setBoolPref("wallet.crypto",this._isset);
  79. },
  80. _initTimeout: function() {
  81.     this._times = this._token.getAskPasswordTimes();
  82.     this._tmout = this._token.getAskPasswordTimeout();
  83.  
  84.     const nsIPK11Token = Components.interfaces.nsIPK11Token;
  85.  
  86.     var i;
  87.     switch(this._times) {
  88.         case nsIPK11Token.ASK_FIRST_TIME : i=0; break;
  89.         case nsIPK11Token.ASK_EVERY_TIME : i=1; break;
  90.         case nsIPK11Token.ASK_EXPIRE_TIME: i=2; break;
  91.     }
  92.     document.getElementById("security.ask_for_password").selectedItem = document.getElementsByTagName("radio")[i];
  93.  
  94.     if(this._tmout)
  95.         document.getElementById("security.password_lifetime").value = this._tmout;
  96.     else
  97.         initTextbox("security.password_lifetime",false);
  98.  
  99.     this.toggleTimeout(true);
  100. },
  101. _isSet: function() {
  102.     var mdb = Components.classes["@mozilla.org/security/pkcs11moduledb;1"]
  103.                 .getService(Components.interfaces.nsIPKCS11ModuleDB);
  104.  
  105.     var slot = mdb.findSlotByName("");
  106.     if(slot) {
  107.         return ((slot.status!=Components.interfaces.nsIPKCS11Slot.SLOT_UNINITIALIZED) && 
  108.             (slot.status!=Components.interfaces.nsIPKCS11Slot.SLOT_READY));
  109.     } else    return false;
  110. },
  111. _reset: function() {
  112.     window.openDialog("chrome://pippki/content/resetpassword.xul",this._token.tokenName,"chrome,centerscreen,modal");
  113. },
  114. _setControls: function() {
  115.     document.getElementsByTagName("label")[0].disabled = !this._isset;
  116.     document.getElementsByTagName("button")[0].disabled = !this._isset;
  117.     document.getElementsByTagName("button")[1].disabled = false;
  118.     document.getElementsByTagName("radiogroup")[0].disabled = !this._isset;
  119. }
  120.  
  121. };
  122.  
  123. function init() {
  124.     Masterpass.init();
  125.     for(var j=1,b=document.getElementsByTagName("checkbox");j<b.length;j++) initCheckbox(b[j].id);
  126. }
  127. ]]>
  128. </script>
  129.  
  130. <vbox flex="1" style="overflow:auto">
  131.   <dialogheader title="&encryption.header;"/>
  132.   <separator class="thin"/>
  133.   <tabcontrol flex="1">
  134.     <tabbox flex="1">
  135.       <tabs>
  136.         <tab label="&encryption.storage;"/>
  137.         <tab label="&encryption.transmission;"/>
  138.       </tabs>
  139.       <tabpanels flex="1">
  140.         <tabpanel flex="1" orient="vertical" style="overflow:auto">
  141. <!-- Protected Storage -->
  142. <separator class="thin"/>
  143. <description>&masterpass.descr;</description>
  144. <separator class="thin"/>
  145. <checkbox oncommand="Masterpass.toggle(this)" label="&masterpass.enable;"/>
  146. <separator class="thin"/>
  147. <hbox>
  148.   <button label="&masterpass.change;" oncommand="Masterpass.change()" style="margin-left:2.25em"/>
  149.   <button label="&encryption.devices;" oncommand="Masterpass.devices()"/>
  150.   <hbox flex="1"/>
  151. </hbox>
  152. <separator class="thick"/>
  153. <description>&masterpass.warning;</description>
  154. <separator class="thick"/>
  155. <groupbox>
  156.   <caption label="&masterpass.timeout;"/>
  157.   <separator class="thin"/>
  158.   <description>&masterpass.ask;</description>
  159.   <radiogroup id="security.ask_for_password">
  160.     <radio value="0" label="&masterpass.askfirsttime;" oncommand="Masterpass.toggleTimeout(false)"/>
  161.     <radio value="1" label="&masterpass.askeverytime;" oncommand="Masterpass.toggleTimeout(false)"/>
  162.     <hbox align="center">
  163.       <radio value="2" label="&masterpass.askminutes.before;" oncommand="Masterpass.toggleTimeout(false)"/>
  164.       <textbox id="security.password_lifetime" size="4" class="uri-element" oninput="setIntPref(this.id,this.value)"/>
  165.       <label value="&masterpass.askminutes.after;"/>
  166.     </hbox>
  167.   </radiogroup>
  168.   <separator class="thin"/>
  169. </groupbox>
  170. <!-- Protected Storage -->
  171.     </tabpanel>
  172.         <tabpanel flex="1" orient="vertical" style="overflow:auto">
  173. <!-- Encrypted Transmission -->
  174. <separator class="thin"/>
  175. <groupbox>
  176.   <caption label="&ssl.protocols;"/>
  177.   <separator class="thin"/>
  178.   <checkbox id="security.enable_ssl3" label="&ssl.enable_ssl3;" oncommand="toggleCheckbox(this.id)"/>
  179.   <checkbox id="security.enable_tls" label="&ssl.enable_tls;" oncommand="toggleCheckbox(this.id)"/>
  180.   <separator class="thin"/>
  181. </groupbox>
  182. <groupbox>
  183.   <caption label="&ssl.warnings;"/>
  184.   <separator class="thin"/>
  185.   <description>&warn.description;</description>
  186.   <checkbox id="security.warn_entering_secure" label="&warn.enteringsecure;" oncommand="toggleCheckbox(this.id)"/>
  187.   <checkbox id="security.warn_entering_weak" label="&warn.enteringweak;" oncommand="toggleCheckbox(this.id)"/>
  188.   <checkbox id="security.warn_leaving_secure" label="&warn.leavingsecure;" oncommand="toggleCheckbox(this.id)"/>
  189.   <checkbox id="security.warn_submit_insecure" label="&warn.insecurepost;" oncommand="toggleCheckbox(this.id)"/>
  190.   <checkbox id="security.warn_viewing_mixed" label="&warn.viewmixed;" oncommand="toggleCheckbox(this.id)"/>
  191.   <separator class="thin"/>
  192. </groupbox>
  193. <!-- Encrypted Transmission -->
  194.     </tabpanel>
  195.       </tabpanels>
  196.     </tabbox>
  197.   </tabcontrol>
  198. </vbox>
  199.  
  200. </page>