Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <HTML> <!-- -*- Mode: Java; tab-width: 8 -*- --> |
michael@0 | 2 | <!-- This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | - License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> |
michael@0 | 5 | <HEAD> |
michael@0 | 6 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
michael@0 | 7 | <SCRIPT LANGUAGE="JavaScript1.2"> |
michael@0 | 8 | |
michael@0 | 9 | script_url = 'http://interzone.mcom.com/cgi-bin/certomatic/bin/certcgi.cgi' |
michael@0 | 10 | |
michael@0 | 11 | ext_page_ver1 = |
michael@0 | 12 | make_page_intro('Version 1 extensions', "#FFFFFF") + |
michael@0 | 13 | '<IFRAME WIDTH="100%" HEIGHT="100%" FRAMEBORDER=0 ID="ext1">' + |
michael@0 | 14 | 'Version 1 X.509 certs do not support extensions' + |
michael@0 | 15 | '</IFRAME>' + |
michael@0 | 16 | '</body></html>'; |
michael@0 | 17 | |
michael@0 | 18 | num_ca = 0; |
michael@0 | 19 | |
michael@0 | 20 | your_certificate_index_label = 'Your Certificate'; |
michael@0 | 21 | netscape_extensions_index_label = 'Netscape X.509 Extensions'; |
michael@0 | 22 | standard_extensions_index_label = 'Standard X.509 Extensions'; |
michael@0 | 23 | certifying_authorities_index_label = 'Certifying Authorities'; |
michael@0 | 24 | add_sub_alt_name_index_label = 'Add Subject Alternative Name'; |
michael@0 | 25 | |
michael@0 | 26 | index_list = |
michael@0 | 27 | '0, your_certificate_index_label,' + |
michael@0 | 28 | '0, netscape_extensions_index_label,' + |
michael@0 | 29 | '0, standard_extensions_index_label,' + |
michael@0 | 30 | '0, certifying_authorities_index_label'; |
michael@0 | 31 | |
michael@0 | 32 | add_index_list = ''; |
michael@0 | 33 | |
michael@0 | 34 | ver = 3 |
michael@0 | 35 | |
michael@0 | 36 | max_pages = 13; |
michael@0 | 37 | cur_page = 1; |
michael@0 | 38 | |
michael@0 | 39 | ext_page_array = new Array(max_pages); |
michael@0 | 40 | |
michael@0 | 41 | index_label = 'Options'; |
michael@0 | 42 | |
michael@0 | 43 | var main_page = |
michael@0 | 44 | make_page_intro('Your Key', "#FFFFFF") + |
michael@0 | 45 | '<IFRAME WIDTH="100%" HEIGHT="100%" FRAMEBORDER=0 ID="main" SRC="main.html">' + |
michael@0 | 46 | '</IFRAME>' + |
michael@0 | 47 | '</body></html>' ; |
michael@0 | 48 | |
michael@0 | 49 | function setSubAltNameType(form) |
michael@0 | 50 | { |
michael@0 | 51 | with(form) { |
michael@0 | 52 | if (SubAltNameRadio[0].checked) { |
michael@0 | 53 | return true; |
michael@0 | 54 | } |
michael@0 | 55 | if (SubAltNameRadio[3].checked || SubAltNameRadio[5].checked) { |
michael@0 | 56 | SubAltNameDataType.checked = true; |
michael@0 | 57 | return true; |
michael@0 | 58 | } |
michael@0 | 59 | if (SubAltNameRadio[1].checked || SubAltNameRadio[2].checked || |
michael@0 | 60 | SubAltNameRadio[4].checked || SubAltNameRadio[6].checked || |
michael@0 | 61 | SubAltNameRadio[7].checked || SubAltNameRadio[8].checked) { |
michael@0 | 62 | SubAltNameDataType.checked = false; |
michael@0 | 63 | return true; |
michael@0 | 64 | } |
michael@0 | 65 | } |
michael@0 | 66 | return true; |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | function setIssuerAltNameType(form) |
michael@0 | 70 | { |
michael@0 | 71 | with(form) { |
michael@0 | 72 | if (IssuerAltNameRadio[0].checked) { |
michael@0 | 73 | return true; |
michael@0 | 74 | } |
michael@0 | 75 | if (IssuerAltNameRadio[3].checked || IssuerAltNameRadio[5].checked) { |
michael@0 | 76 | IssuerAltNameDataType.checked = true; |
michael@0 | 77 | return true; |
michael@0 | 78 | } |
michael@0 | 79 | if (IssuerAltNameRadio[1].checked || IssuerAltNameRadio[2].checked || |
michael@0 | 80 | IssuerAltNameRadio[4].checked || IssuerAltNameRadio[6].checked || |
michael@0 | 81 | IssuerAltNameRadio[7].checked || IssuerAltNameRadio[8].checked) { |
michael@0 | 82 | IssuerAltNameDataType.checked = false; |
michael@0 | 83 | return true; |
michael@0 | 84 | } |
michael@0 | 85 | } |
michael@0 | 86 | return true; |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | |
michael@0 | 90 | function setNameConstraintNameType(form) |
michael@0 | 91 | { |
michael@0 | 92 | with(form) { |
michael@0 | 93 | if (NameConstraintRadio[0].checked) { |
michael@0 | 94 | return true; |
michael@0 | 95 | } |
michael@0 | 96 | if (NameConstraintRadio[3].checked || NameConstraintRadio[5].checked) { |
michael@0 | 97 | NameConstraintNameDataType.checked = true; |
michael@0 | 98 | return true; |
michael@0 | 99 | } |
michael@0 | 100 | if (NameConstraintRadio[1].checked || NameConstraintRadio[2].checked || |
michael@0 | 101 | NameConstraintRadio[4].checked || NameConstraintRadio[6].checked || |
michael@0 | 102 | NameConstraintRadio[7].checked || NameConstraintRadio[8].checked) { |
michael@0 | 103 | NameConstraintNameDataType.checked = false; |
michael@0 | 104 | return true; |
michael@0 | 105 | } |
michael@0 | 106 | } |
michael@0 | 107 | return true; |
michael@0 | 108 | } |
michael@0 | 109 | |
michael@0 | 110 | |
michael@0 | 111 | function addSubAltName(form) |
michael@0 | 112 | { |
michael@0 | 113 | with(form) { |
michael@0 | 114 | var len = SubAltNameSelect.length; |
michael@0 | 115 | var value; |
michael@0 | 116 | var i = 0; |
michael@0 | 117 | while(!(i == (SubAltNameRadio.length - 1)) & |
michael@0 | 118 | !(SubAltNameRadio[i].checked == true)) { |
michael@0 | 119 | i++; |
michael@0 | 120 | } |
michael@0 | 121 | if (i != 0) { |
michael@0 | 122 | value = SubAltNameText.value + " - " + (i + 1); |
michael@0 | 123 | } else { |
michael@0 | 124 | value = SubAltNameText.value + " - " + |
michael@0 | 125 | SubAltNameOtherNameOID.value + " - "; |
michael@0 | 126 | if (SubAltNameDataType.checked) { |
michael@0 | 127 | value += "1 - "; |
michael@0 | 128 | } else { |
michael@0 | 129 | value += "0 - "; |
michael@0 | 130 | } |
michael@0 | 131 | value += (i + 1); |
michael@0 | 132 | if (SubAltNameOtherNameOID.value == "") { |
michael@0 | 133 | alert("Other names must include an OID"); |
michael@0 | 134 | return false; |
michael@0 | 135 | } |
michael@0 | 136 | } |
michael@0 | 137 | |
michael@0 | 138 | if ((SubAltNameText.value == "") | (SubAltNameRadio[i].checked != true)) { |
michael@0 | 139 | alert("Alternative Names must include values for name and name type."); |
michael@0 | 140 | } else { |
michael@0 | 141 | SubAltNameSelect.options[len] = new Option(value, value); |
michael@0 | 142 | } |
michael@0 | 143 | } |
michael@0 | 144 | return true; |
michael@0 | 145 | } |
michael@0 | 146 | |
michael@0 | 147 | function deleteSubAltName(form) |
michael@0 | 148 | { |
michael@0 | 149 | with(form) { |
michael@0 | 150 | while (SubAltNameSelect.selectedIndex >= 0) { |
michael@0 | 151 | SubAltNameSelect[SubAltNameSelect.selectedIndex] = null; |
michael@0 | 152 | } |
michael@0 | 153 | } |
michael@0 | 154 | } |
michael@0 | 155 | |
michael@0 | 156 | function addIssuerAltName(form) |
michael@0 | 157 | { |
michael@0 | 158 | with(form) |
michael@0 | 159 | { |
michael@0 | 160 | var len = IssuerAltNameSelect.length; |
michael@0 | 161 | var value; |
michael@0 | 162 | var i = 0; |
michael@0 | 163 | |
michael@0 | 164 | while(!(i == (IssuerAltNameRadio.length -1)) & |
michael@0 | 165 | !(IssuerAltNameRadio[i].checked == true)) { |
michael@0 | 166 | i++; |
michael@0 | 167 | } |
michael@0 | 168 | if (i != 0) { |
michael@0 | 169 | value = IssuerAltNameText.value + " - " + (i + 1); |
michael@0 | 170 | } else { |
michael@0 | 171 | value = IssuerAltNameText.value + " - " + |
michael@0 | 172 | IssuerAltNameOtherNameOID.value + " - "; |
michael@0 | 173 | if (IssuerAltNameDataType.checked) { |
michael@0 | 174 | value += "1 - "; |
michael@0 | 175 | } else { |
michael@0 | 176 | value += "0 - "; |
michael@0 | 177 | } |
michael@0 | 178 | value += (i + 1); |
michael@0 | 179 | if (IssuerAltNameOtherNameOID.value == "") { |
michael@0 | 180 | alert("Other names must include an OID"); |
michael@0 | 181 | return false; |
michael@0 | 182 | } |
michael@0 | 183 | } |
michael@0 | 184 | if ((IssuerAltNameText.value == "") | |
michael@0 | 185 | (IssuerAltNameRadio[i].checked != true)) { |
michael@0 | 186 | alert("Alternative Names must include values for name and name type.") |
michael@0 | 187 | } else { |
michael@0 | 188 | IssuerAltNameSelect.options[len] = new Option(value, value); |
michael@0 | 189 | } |
michael@0 | 190 | } |
michael@0 | 191 | return true; |
michael@0 | 192 | } |
michael@0 | 193 | |
michael@0 | 194 | function deleteIssuerAltName(form) |
michael@0 | 195 | { |
michael@0 | 196 | with(form) { |
michael@0 | 197 | while (IssuerAltNameSelect.selectedIndex >= 0) { |
michael@0 | 198 | IssuerAltNameSelect[IssuerAltNameSelect.selectedIndex] = null; |
michael@0 | 199 | } |
michael@0 | 200 | } |
michael@0 | 201 | } |
michael@0 | 202 | |
michael@0 | 203 | |
michael@0 | 204 | |
michael@0 | 205 | function addNameConstraint(form) |
michael@0 | 206 | { |
michael@0 | 207 | with(form) { |
michael@0 | 208 | var len = NameConstraintSelect.length; |
michael@0 | 209 | var value; |
michael@0 | 210 | var i = 0; |
michael@0 | 211 | var min = NameConstraintMin.value; |
michael@0 | 212 | var max = NameConstraintMax.value; |
michael@0 | 213 | |
michael@0 | 214 | while(!(i == (NameConstraintRadio.length - 1) ) & |
michael@0 | 215 | !(NameConstraintRadio[i].checked == true)) { |
michael@0 | 216 | i++; |
michael@0 | 217 | } |
michael@0 | 218 | value = NameConstraintText.value + " - "; |
michael@0 | 219 | if (i == 0) { |
michael@0 | 220 | value += NameConstraintOtherNameOID.value + " - "; |
michael@0 | 221 | if (NameConstraintNameDataType.checked) { |
michael@0 | 222 | value += "1 - "; |
michael@0 | 223 | } else { |
michael@0 | 224 | value += "0 - "; |
michael@0 | 225 | } |
michael@0 | 226 | if (NameConstraintOtherNameOID.value == "") { |
michael@0 | 227 | alert("Other names must include an OID"); |
michael@0 | 228 | return false; |
michael@0 | 229 | } |
michael@0 | 230 | } |
michael@0 | 231 | value += (i + 1) + " - "; |
michael@0 | 232 | if (NameConstraintTypeRadio[0].checked == true) { |
michael@0 | 233 | value += "p - "; |
michael@0 | 234 | } else { |
michael@0 | 235 | value += "e - "; |
michael@0 | 236 | } |
michael@0 | 237 | value += min + " - " + max; |
michael@0 | 238 | if ((min == "") | (NameConstraintText.value == "") | |
michael@0 | 239 | (NameConstraintRadio[i].checked != true)) { |
michael@0 | 240 | alert("Name Constraints must include values for minimum, name, and name type.") |
michael@0 | 241 | } else { |
michael@0 | 242 | NameConstraintSelect.options[len] = new Option(value, value); |
michael@0 | 243 | } |
michael@0 | 244 | } |
michael@0 | 245 | return true; |
michael@0 | 246 | } |
michael@0 | 247 | |
michael@0 | 248 | function deleteNameConstraint(form) |
michael@0 | 249 | { |
michael@0 | 250 | with(form) { |
michael@0 | 251 | while (NameConstraintSelect.selectedIndex >= 0) { |
michael@0 | 252 | NameConstraintSelect[NameConstraintSelect.selectedIndex] = null; |
michael@0 | 253 | } |
michael@0 | 254 | } |
michael@0 | 255 | } |
michael@0 | 256 | |
michael@0 | 257 | |
michael@0 | 258 | function submit_it() |
michael@0 | 259 | { |
michael@0 | 260 | save_cur_page(cur_page); |
michael@0 | 261 | |
michael@0 | 262 | var ver1 = (ver == 1); |
michael@0 | 263 | var ver3 = (ver == 3); |
michael@0 | 264 | var array_string; |
michael@0 | 265 | var serial = ext_page_array[0][10][0]; |
michael@0 | 266 | var serial_number = ext_page_array[0][12][0]; |
michael@0 | 267 | var manValidity = ext_page_array[0][19][0]; |
michael@0 | 268 | var notBefore = ext_page_array[0][20][0]; |
michael@0 | 269 | var notAfter = ext_page_array[0][21][0]; |
michael@0 | 270 | var subject = ext_page_array[0][22][0]; |
michael@0 | 271 | |
michael@0 | 272 | if (subject == "") { |
michael@0 | 273 | alert("The DN field must contain some data"); |
michael@0 | 274 | return false; |
michael@0 | 275 | } |
michael@0 | 276 | if (!serial & serial_number == "") { |
michael@0 | 277 | alert("No serial number specified"); |
michael@0 | 278 | return false; |
michael@0 | 279 | } |
michael@0 | 280 | if (ext_page_array[0][15][0]) { |
michael@0 | 281 | var keygen = "<keygen name=\"key\" challenge=\"foo\">"; |
michael@0 | 282 | } else { |
michael@0 | 283 | switch (ext_page_array[0][17][0]) { |
michael@0 | 284 | case 2: |
michael@0 | 285 | var keygen = "<keygen keytype=\"dsa\" pqg=\"MIGdAkEAjfKklEkidqo9JXWbsGhpy+rA2Dr7jQz3y7gyTw14guXQdi/FtyEOr8Lprawyq3qsSWk9+/g3JMLsBzbuMcgCkQIVAMdzIYxzfsjumTtPLe0w9I7azpFfAkEAYm0CeDnqChNBMWOlW0y1ACmdVSKVbO/LO/8Q85nOLC5xy53l+iS6v1jlt5UhklycxC6fb0ZLCIzFcq9T5teIAg==\" name=\"key\" challenge=\"foo\">"; |
michael@0 | 286 | break; |
michael@0 | 287 | case 1: |
michael@0 | 288 | var keygen = "<keygen keytype=\"dsa\" pqg=\"MIHaAmDCboVgX0+6pEeMlbwsasWDVBcJNHPKMzkq9kbCRK2U3k+tE15n+Dc2g3ZjDYr1um51e2iLC34/BwAAAAAAAAAAAAAAAAAAAAAAAAABbBhnlFN5Djmt0Mk8cdEBY5H8iPMCFMhUnFtbpjn3EyfH2DjVg3ALh7FtAmA2zWzhpeCwvOTjYnQorlXiv0WcnSiWmaC79CRYkFt5i+UEfRxwP1eNGJBVB1T+CPW6JGd4WhgsqtSf53pn5DEtv++O7lNfXyOhWhb3KaWHYIx8fuAXtioIWkWmpfEIVZA=\" name=\"key\" challenge=\"foo\">"; |
michael@0 | 289 | break; |
michael@0 | 290 | case 0: |
michael@0 | 291 | var keygen = "<keygen keytype=\"dsa\" pqg=\"MIIBHAKBgId8SiiWrcdua5zbsBhPkKfFcnHBG7T/bQla7c6OixGjjmSSuq2fJLvMKa579CaxHxLZzZZXIHmAk9poRgWl2GUUkCJ68XSum8OQzDPXPsofcEdeANjw3mIAAAAAAAAAAAAAAAAAAAAAAAAIE+MkW5hguLIQqWvEVi9dMpbNu6OZAhTIA+y3TgyiwA0D8pt686ofaL1IOQKBgAiZQC6UCXztr2iXxJrAC+51gN5oX/R9Thilln9RGegsWnHrdxUOpcm5vAWp1LU8TOXtujE8kqkm3UxIRhUWQORe9IxLANAXmZJqkw9FEVHkxj6Cy9detwT2MyBzSwS6avsf7aLisgHmI/IHSeapJsQ3NQa3rikb6zRiqIV+TVa6\" name=\"key\" challenge=\"foo\">"; |
michael@0 | 292 | break; |
michael@0 | 293 | } |
michael@0 | 294 | } |
michael@0 | 295 | array_string = build_array_string(); |
michael@0 | 296 | hiddens = "<input type=\"hidden\" name=\"subject\" value=\'" + subject + "\'> \n" + |
michael@0 | 297 | "<input type=\"hidden\" name=\"serial-auto\" value=\"" + serial + "\"> \n" + |
michael@0 | 298 | "<input type=\"hidden\" name=\"serial_value\" value=\"" + serial_number + "\"> \n" + |
michael@0 | 299 | "<input type=\"hidden\" name=\"ver-1\" value=\"" + ver1 + "\"> \n" + |
michael@0 | 300 | "<input type=\"hidden\" name=\"ver-3\" value=\"" + ver3 + "\"> \n" + |
michael@0 | 301 | "<input type=\"hidden\" name=\"notBefore\" value=\"" + notBefore + "\"> \n" + |
michael@0 | 302 | "<input type=\"hidden\" name=\"notAfter\" value=\"" + notAfter + "\"> \n" + |
michael@0 | 303 | "<input type=\"hidden\" name=\"manValidity\" value=\"" + manValidity + "\"> \n" + |
michael@0 | 304 | array_string; |
michael@0 | 305 | |
michael@0 | 306 | var good_submit_page = |
michael@0 | 307 | '<html>' + |
michael@0 | 308 | '<BODY TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#FF0000" BGCOLOR="#FFFFFF">' + |
michael@0 | 309 | '<form method="post" action="' + script_url + '">' + |
michael@0 | 310 | 'Select size for your key:' + keygen + '</p>' + |
michael@0 | 311 | '<input type="submit"></p>' + |
michael@0 | 312 | hiddens + |
michael@0 | 313 | '</form>\n' + |
michael@0 | 314 | '</body>\n' + |
michael@0 | 315 | '</html>\n'; |
michael@0 | 316 | |
michael@0 | 317 | window.frames['right'].document.write(good_submit_page); |
michael@0 | 318 | window.frames['right'].document.close(); |
michael@0 | 319 | cur_page = max_pages + 1; |
michael@0 | 320 | make_left_frame(window); |
michael@0 | 321 | return false; |
michael@0 | 322 | } |
michael@0 | 323 | |
michael@0 | 324 | |
michael@0 | 325 | |
michael@0 | 326 | function build_array_string() |
michael@0 | 327 | { |
michael@0 | 328 | var pg; |
michael@0 | 329 | var array_string = ''; |
michael@0 | 330 | var pages; |
michael@0 | 331 | |
michael@0 | 332 | if ((ext_page_array[3][4][0] > 0) && ext_page_array[3][3][0]) { |
michael@0 | 333 | pages = 4 + parseInt(ext_page_array[3][4][0]); |
michael@0 | 334 | } else { |
michael@0 | 335 | pages = 4; |
michael@0 | 336 | } |
michael@0 | 337 | for (pg = 1; pg < pages; pg++) { |
michael@0 | 338 | if ((pg > 1 || (ver == 3)) && (ext_page_array[pg].length > 1)) { |
michael@0 | 339 | if (pg < 4) { |
michael@0 | 340 | for (i = 0; i < ext_page_array[pg].length; i++) { |
michael@0 | 341 | if (ext_page_array[pg][i][3].indexOf("radio") == -1) { |
michael@0 | 342 | if (ext_page_array[pg][i][3].indexOf("multiple") == -1) { |
michael@0 | 343 | array_string += '<input type=\"hidden\" name=\"' + |
michael@0 | 344 | ext_page_array[pg][i][1] + '\" value=\'' + |
michael@0 | 345 | ext_page_array[pg][i][0] + '\'> \n'; |
michael@0 | 346 | } else { |
michael@0 | 347 | for (k = 0; k < ext_page_array[pg][i][0].length; k++) { |
michael@0 | 348 | array_string += '<input type=\"hidden\" name=\"' + |
michael@0 | 349 | ext_page_array[pg][i][1] + k + '\" value=\'' + |
michael@0 | 350 | ext_page_array[pg][i][0][k] + '\'> \n'; |
michael@0 | 351 | } |
michael@0 | 352 | } |
michael@0 | 353 | } else { |
michael@0 | 354 | array_string += '<input type=\"hidden\" name=\"' + |
michael@0 | 355 | ext_page_array[pg][i][1] + '-' + |
michael@0 | 356 | ext_page_array[pg][i][2] + '\" value=\'' + |
michael@0 | 357 | ext_page_array[pg][i][0] + '\'> \n'; |
michael@0 | 358 | } |
michael@0 | 359 | } |
michael@0 | 360 | } else { |
michael@0 | 361 | for (i = 0; i < ext_page_array[pg].length; i++) { |
michael@0 | 362 | if (ext_page_array[pg][i][3].indexOf("radio") == -1) { |
michael@0 | 363 | if (ext_page_array[pg][i][3].indexOf("multiple") == -1) { |
michael@0 | 364 | array_string += '<input type=\"hidden\" name=\"' + |
michael@0 | 365 | 'CA#' + (pg - 3) + '-' + |
michael@0 | 366 | ext_page_array[pg][i][1] + '\" value=\'' + |
michael@0 | 367 | ext_page_array[pg][i][0] +'\'> \n'; |
michael@0 | 368 | } else { |
michael@0 | 369 | for (k = 0; k < ext_page_array[pg][i][0].length; k++) { |
michael@0 | 370 | array_string += '<input type=\"hidden\" name=\"' + |
michael@0 | 371 | 'CA#' + (pg - 3) + '-' + |
michael@0 | 372 | ext_page_array[pg][i][1] + k + '\" value=\'' + |
michael@0 | 373 | ext_page_array[pg][i][0][k] + '\'> \n'; |
michael@0 | 374 | } |
michael@0 | 375 | } |
michael@0 | 376 | } else { |
michael@0 | 377 | array_string += '<input type=\"hidden\" name=\"' + |
michael@0 | 378 | 'CA#' + (pg - 3) + '-' + |
michael@0 | 379 | ext_page_array[pg][i][1] + '-' + |
michael@0 | 380 | ext_page_array[pg][i][2] + '\" value=\'' + |
michael@0 | 381 | ext_page_array[pg][i][0] + '\'> \n'; |
michael@0 | 382 | } |
michael@0 | 383 | } |
michael@0 | 384 | } |
michael@0 | 385 | } |
michael@0 | 386 | } |
michael@0 | 387 | return array_string; |
michael@0 | 388 | } |
michael@0 | 389 | |
michael@0 | 390 | |
michael@0 | 391 | |
michael@0 | 392 | function init_ext_page_array() |
michael@0 | 393 | { |
michael@0 | 394 | for (i = 0; i < max_pages; i++) { |
michael@0 | 395 | ext_page_array[i] = ''; |
michael@0 | 396 | } |
michael@0 | 397 | } |
michael@0 | 398 | |
michael@0 | 399 | function ca_num_change(n,ca_form) |
michael@0 | 400 | { |
michael@0 | 401 | with(ca_form) { |
michael@0 | 402 | n = parseInt(n,10); |
michael@0 | 403 | if (caChoiceradio[2].checked) { |
michael@0 | 404 | if (n) { |
michael@0 | 405 | update_left_frame(n); |
michael@0 | 406 | } else { |
michael@0 | 407 | update_left_frame(0); |
michael@0 | 408 | } |
michael@0 | 409 | } |
michael@0 | 410 | } |
michael@0 | 411 | } |
michael@0 | 412 | |
michael@0 | 413 | function choice_change(ca_form) |
michael@0 | 414 | { |
michael@0 | 415 | with(ca_form) { |
michael@0 | 416 | if (caChoiceradio[2].checked) { |
michael@0 | 417 | ca_num_change(manCAs.value,ca_form); |
michael@0 | 418 | } else { |
michael@0 | 419 | update_left_frame(0); |
michael@0 | 420 | } |
michael@0 | 421 | } |
michael@0 | 422 | } |
michael@0 | 423 | |
michael@0 | 424 | function update_left_frame(n) |
michael@0 | 425 | { |
michael@0 | 426 | var add_string = ''; |
michael@0 | 427 | for (var i = 0; i < n; i++) { |
michael@0 | 428 | var j = i + 1; |
michael@0 | 429 | add_string = add_string + ',1, \'CA #' + j + '\''; |
michael@0 | 430 | } |
michael@0 | 431 | top.add_index_list = add_string; |
michael@0 | 432 | num_ca = n; |
michael@0 | 433 | make_left_frame(window); |
michael@0 | 434 | } |
michael@0 | 435 | |
michael@0 | 436 | function set_ver1() |
michael@0 | 437 | // redraws the extensions page for version 1 certificates |
michael@0 | 438 | { |
michael@0 | 439 | ver = 1 |
michael@0 | 440 | if (cur_page == 2 || cur_page == 3) { |
michael@0 | 441 | switch_right_frame(window, cur_page, cur_page); |
michael@0 | 442 | } |
michael@0 | 443 | } |
michael@0 | 444 | |
michael@0 | 445 | |
michael@0 | 446 | function set_ver3() |
michael@0 | 447 | // redraws the extensions page for version 3 certificates |
michael@0 | 448 | { |
michael@0 | 449 | ver = 3 |
michael@0 | 450 | if (cur_page == 2) { |
michael@0 | 451 | switch_right_frame(window, 0, 2); |
michael@0 | 452 | } else if (cur_page == 3) { |
michael@0 | 453 | switch_right_frame(window, 0, 3); |
michael@0 | 454 | } |
michael@0 | 455 | } |
michael@0 | 456 | |
michael@0 | 457 | function reset_subject(marker, value, form) |
michael@0 | 458 | // Updates the subject field from a subordinate field |
michael@0 | 459 | { |
michael@0 | 460 | with(form) { |
michael@0 | 461 | var field_sep = '", '; |
michael@0 | 462 | var begin_index = subject.value.indexOf(marker); |
michael@0 | 463 | if (begin_index != 0 && subject.value[begin_index - 1] != ' ') { |
michael@0 | 464 | begin_index = subject.value.indexOf(marker, begin_index +1); |
michael@0 | 465 | } |
michael@0 | 466 | var end_index = subject.value.indexOf(field_sep, begin_index); |
michael@0 | 467 | if (begin_index > -1) { // is it a delete/change? |
michael@0 | 468 | if (end_index == -1) { // is it the last one (includes only one)? |
michael@0 | 469 | if (value.length > 0) { // do I have to change it? |
michael@0 | 470 | if (begin_index == 0) { // is is the only one? |
michael@0 | 471 | subject.value = marker + '"' + value + '"'; |
michael@0 | 472 | } else { // it is the last of many |
michael@0 | 473 | subject.value = subject.value.substring(0,begin_index) + |
michael@0 | 474 | marker + '"' + value + '"'; |
michael@0 | 475 | } |
michael@0 | 476 | } else { // must be a delete |
michael@0 | 477 | if (begin_index == 0) { // is it the only one? |
michael@0 | 478 | begin_index += 2; |
michael@0 | 479 | } |
michael@0 | 480 | subject.value = subject.value.substring(0,(begin_index - 2)); |
michael@0 | 481 | } |
michael@0 | 482 | } else { // it is the first of many or a middle one |
michael@0 | 483 | if (value.length >0) { // do I have to change it? |
michael@0 | 484 | subject.value = |
michael@0 | 485 | subject.value.substring(0,(begin_index + marker.length + 1)) + |
michael@0 | 486 | value + subject.value.substring(end_index,subject.length); |
michael@0 | 487 | } else { // it is a delete |
michael@0 | 488 | subject.value = subject.value.substring(0,begin_index) + |
michael@0 | 489 | subject.value.substring((end_index + 3),subject.length); |
michael@0 | 490 | } |
michael@0 | 491 | } |
michael@0 | 492 | } else { // It is either an insert or a do nothing |
michael@0 | 493 | if (value.length > 0) { // is it an insert? |
michael@0 | 494 | if (subject.value.length == 0) { // is subject currently empty? |
michael@0 | 495 | subject.value = marker + '"' + value + '"'; |
michael@0 | 496 | } else { |
michael@0 | 497 | subject.value = subject.value + ', ' + marker + '"' + value + '"'; |
michael@0 | 498 | } |
michael@0 | 499 | } |
michael@0 | 500 | } |
michael@0 | 501 | } |
michael@0 | 502 | } |
michael@0 | 503 | |
michael@0 | 504 | |
michael@0 | 505 | |
michael@0 | 506 | function reset_subjectFields(form) |
michael@0 | 507 | // updates all the subordinate fields from the subject field of a form |
michael@0 | 508 | // **** move the strings to global variables, to make maintentance easier **** |
michael@0 | 509 | { |
michael@0 | 510 | |
michael@0 | 511 | update_subject_Field(form, 'CN=\"', form.name); |
michael@0 | 512 | update_subject_Field(form, 'MAIL=\"', form.email); |
michael@0 | 513 | update_subject_Field(form, 'O=\"', form.org); |
michael@0 | 514 | update_subject_Field(form, 'C=\"', form.country); |
michael@0 | 515 | update_subject_Field(form, ' L=\"', form.loc); |
michael@0 | 516 | update_subject_Field(form, 'ST=\"', form.state); |
michael@0 | 517 | update_subject_Field(form, 'E=\"', form.email); |
michael@0 | 518 | update_subject_Field(form, 'OU=\"', form.org_unit); |
michael@0 | 519 | update_subject_Field(form, 'UID=\"', form.uid); |
michael@0 | 520 | } |
michael@0 | 521 | |
michael@0 | 522 | function update_subject_Field(form, marker, update_field) |
michael@0 | 523 | //updates a single subordinate field from the subject field of a form |
michael@0 | 524 | // *** need to deal with the two types of e-mail addresses ************** |
michael@0 | 525 | { |
michael@0 | 526 | with(form) { |
michael@0 | 527 | var field_sep = '", '; |
michael@0 | 528 | var begin_index = subject.value.indexOf(marker) + marker.length; |
michael@0 | 529 | var end_index = subject.value.indexOf(field_sep, begin_index); |
michael@0 | 530 | if (end_index == -1) { |
michael@0 | 531 | end_index = subject.value.indexOf('"',begin_index); |
michael@0 | 532 | } |
michael@0 | 533 | if (begin_index != (-1 + marker.length) ) { |
michael@0 | 534 | update_field.value = subject.value.substring(begin_index, end_index); |
michael@0 | 535 | } else { |
michael@0 | 536 | update_field.value = ''; |
michael@0 | 537 | } |
michael@0 | 538 | } |
michael@0 | 539 | } |
michael@0 | 540 | |
michael@0 | 541 | |
michael@0 | 542 | function switch_mail(form) |
michael@0 | 543 | // **** Do I want to delete the other type of e-mail address ? ************ |
michael@0 | 544 | { |
michael@0 | 545 | if (form.email_type[0].checked) { |
michael@0 | 546 | var del = 'E='; |
michael@0 | 547 | var ins = 'MAIL='; |
michael@0 | 548 | } else { |
michael@0 | 549 | var del = 'MAIL='; |
michael@0 | 550 | var ins = 'E='; |
michael@0 | 551 | } |
michael@0 | 552 | reset_subject(del, '', form); |
michael@0 | 553 | reset_subject(ins, form.email.value, form); |
michael@0 | 554 | } |
michael@0 | 555 | |
michael@0 | 556 | function make_page_intro(title, bgcolor) |
michael@0 | 557 | { |
michael@0 | 558 | var style = '<STYLE TYPE="text/css">BODY{' + |
michael@0 | 559 | 'font-family: Geneva,MS Sans Serif,Arial,Lucida,Helvetica,sans-serif;' + |
michael@0 | 560 | 'font-size: 10pt;' + |
michael@0 | 561 | '}' + |
michael@0 | 562 | 'TD{' + |
michael@0 | 563 | 'font-family: Geneva,MS Sans Serif,Arial,Lucida,Helvetica,sans-serif;' + |
michael@0 | 564 | 'font-size: 10pt;}' + |
michael@0 | 565 | '</STYLE>'; |
michael@0 | 566 | |
michael@0 | 567 | if (bgcolor == null) { bgcolor = "#C0C0C0"; } |
michael@0 | 568 | return '<HTML><HEAD>' + |
michael@0 | 569 | '<TITLE>' + title + '</TITLE>' + |
michael@0 | 570 | '</HEAD>' + |
michael@0 | 571 | '<BODY TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#FF0000" ' + |
michael@0 | 572 | 'BGCOLOR="' + bgcolor + '">'; |
michael@0 | 573 | } |
michael@0 | 574 | |
michael@0 | 575 | |
michael@0 | 576 | function make_left_frame(window) |
michael@0 | 577 | { |
michael@0 | 578 | with (window.frames['index']) { |
michael@0 | 579 | eval ('index_string = make_left_frame_page(cur_page, ' |
michael@0 | 580 | + index_list + add_index_list + ' )'); |
michael@0 | 581 | fool1 = make_page_intro(index_label, "#FFFFFF") + |
michael@0 | 582 | index_string + '</BODY></HTML>'; |
michael@0 | 583 | document.write(fool1); |
michael@0 | 584 | document.close(); |
michael@0 | 585 | } |
michael@0 | 586 | } |
michael@0 | 587 | |
michael@0 | 588 | |
michael@0 | 589 | function save_cur_page(page_number) |
michael@0 | 590 | { |
michael@0 | 591 | var len; |
michael@0 | 592 | var pg = page_number - 1; |
michael@0 | 593 | if (window.frames['right'].document.forms.length != 0) { |
michael@0 | 594 | with (window.frames['right'].document) { |
michael@0 | 595 | if ((page_number != 2 && page_number != 3 && page_number <= max_pages) || |
michael@0 | 596 | ver == 3) { |
michael@0 | 597 | ext_page_array[pg] = new Array(forms[0].elements.length); |
michael@0 | 598 | for (i = 0; i < forms[0].elements.length; i++) { |
michael@0 | 599 | ext_page_array[pg][i] = new Array(4); |
michael@0 | 600 | switch (forms[0].elements[i].type) { |
michael@0 | 601 | case 'radio': |
michael@0 | 602 | case 'checkbox': |
michael@0 | 603 | ext_page_array[pg][i][0] = forms[0].elements[i].checked; |
michael@0 | 604 | break; |
michael@0 | 605 | case 'select-one': |
michael@0 | 606 | ext_page_array[pg][i][0] = forms[0].elements[i].selectedIndex; |
michael@0 | 607 | break; |
michael@0 | 608 | case 'select-multiple': |
michael@0 | 609 | len = forms[0].elements[i].options.length; |
michael@0 | 610 | ext_page_array[pg][i][0] = new Array(len); |
michael@0 | 611 | for(k = 0; k < len; k++) { |
michael@0 | 612 | ext_page_array[pg][i][0][k] = forms[0].elements[i].options[k].value; |
michael@0 | 613 | } |
michael@0 | 614 | break; |
michael@0 | 615 | default: |
michael@0 | 616 | ext_page_array[pg][i][0] = forms[0].elements[i].value; |
michael@0 | 617 | } |
michael@0 | 618 | ext_page_array[pg][i][1] = forms[0].elements[i].name; |
michael@0 | 619 | ext_page_array[pg][i][2] = forms[0].elements[i].value; |
michael@0 | 620 | ext_page_array[pg][i][3] = forms[0].elements[i].type; |
michael@0 | 621 | } |
michael@0 | 622 | } |
michael@0 | 623 | } |
michael@0 | 624 | } |
michael@0 | 625 | } |
michael@0 | 626 | |
michael@0 | 627 | function reload_form(page_number) |
michael@0 | 628 | { |
michael@0 | 629 | var j = page_number - 1; |
michael@0 | 630 | with (window.frames['right'].document) { |
michael@0 | 631 | if (((page_number < 2 || page_number > 3) || ver == 3) |
michael@0 | 632 | && page_number != 0 && (ext_page_array[j].length > 1)) { |
michael@0 | 633 | for (i = 0; i < ext_page_array[j].length; i++) { |
michael@0 | 634 | switch (forms[0].elements[i].type) { |
michael@0 | 635 | case 'radio': case 'checkbox': |
michael@0 | 636 | forms[0].elements[i].checked = ext_page_array[j][i][0]; |
michael@0 | 637 | break; |
michael@0 | 638 | case 'select-one': |
michael@0 | 639 | forms[0].elements[i].selectedIndex = ext_page_array[j][i][0]; |
michael@0 | 640 | break; |
michael@0 | 641 | case 'select-multiple': |
michael@0 | 642 | for (k = 0; k < ext_page_array[j][i][0].length; k++) { |
michael@0 | 643 | forms[0].elements[i].options[k] = |
michael@0 | 644 | new Option(ext_page_array[j][i][0][k], |
michael@0 | 645 | ext_page_array[j][i][0][k]); |
michael@0 | 646 | } |
michael@0 | 647 | break; |
michael@0 | 648 | default: |
michael@0 | 649 | forms[0].elements[i].value = ext_page_array[j][i][0]; |
michael@0 | 650 | } |
michael@0 | 651 | } |
michael@0 | 652 | } |
michael@0 | 653 | } |
michael@0 | 654 | } |
michael@0 | 655 | |
michael@0 | 656 | function switch_right_frame(top_window, old_pane, new_pane) |
michael@0 | 657 | { |
michael@0 | 658 | var ext_page_stnd = |
michael@0 | 659 | make_page_intro(standard_extensions_index_label, "#FFFFFF") + |
michael@0 | 660 | '<IFRAME WIDTH="100%" HEIGHT="100%" FRAMEBORDER=0 ID="ext" ' + |
michael@0 | 661 | 'SRC="stnd_ext_form.html">' + |
michael@0 | 662 | '</IFRAME></body></html>'; |
michael@0 | 663 | |
michael@0 | 664 | var ext_page_nscp = |
michael@0 | 665 | make_page_intro(netscape_extensions_index_label, "#FFFFFF") + |
michael@0 | 666 | '<IFRAME WIDTH="100%" HEIGHT="100%" FRAMEBORDER=0 ID="ext" ' + |
michael@0 | 667 | 'SRC="nscp_ext_form.html">' + |
michael@0 | 668 | '</IFRAME></body></html>'; |
michael@0 | 669 | |
michael@0 | 670 | var ext_page_ca = |
michael@0 | 671 | make_page_intro(certifying_authorities_index_label, "#FFFFFF") + |
michael@0 | 672 | '<IFRAME WIDTH="100%" HEIGHT="100%" FRAMEBORDER=0 ID="ext" ' + |
michael@0 | 673 | 'SRC="ca.html">' + |
michael@0 | 674 | '</IFRAME></body</html>'; |
michael@0 | 675 | |
michael@0 | 676 | var ext_page_ca_exp = |
michael@0 | 677 | make_page_intro('Certifying Authority Details', "#FFFFFF") + |
michael@0 | 678 | '<IFRAME WIDTH="100%" HEIGHT="100%" FRAMEBORDER=0 ID="ext" ' + |
michael@0 | 679 | 'SRC="ca_form.html">' + |
michael@0 | 680 | '</IFRAME></body></html>'; |
michael@0 | 681 | |
michael@0 | 682 | |
michael@0 | 683 | if (old_pane > 0 && cur_page <= max_pages) { |
michael@0 | 684 | save_cur_page(old_pane); |
michael@0 | 685 | } |
michael@0 | 686 | cur_page = new_pane; |
michael@0 | 687 | make_left_frame(top_window); |
michael@0 | 688 | if (new_pane == 2 || new_pane == 3) { |
michael@0 | 689 | if (ver == 1) { |
michael@0 | 690 | frames['right'].document.write(ext_page_ver1); |
michael@0 | 691 | frames['right'].document.close(); |
michael@0 | 692 | } else if (new_pane == 2) { |
michael@0 | 693 | frames['right'].document.write(ext_page_nscp); |
michael@0 | 694 | frames['right'].document.close(); |
michael@0 | 695 | reload_form(new_pane); |
michael@0 | 696 | } else { |
michael@0 | 697 | frames['right'].document.write(ext_page_stnd); |
michael@0 | 698 | frames['right'].document.close(); |
michael@0 | 699 | reload_form(new_pane); |
michael@0 | 700 | } |
michael@0 | 701 | } else if (new_pane == 4) { |
michael@0 | 702 | frames['right'].document.write(ext_page_ca); |
michael@0 | 703 | frames['right'].document.close(); |
michael@0 | 704 | reload_form(new_pane); |
michael@0 | 705 | } else if (new_pane == 1) { |
michael@0 | 706 | frames['right'].document.write(main_page); |
michael@0 | 707 | frames['right'].document.close(); |
michael@0 | 708 | reload_form(new_pane); |
michael@0 | 709 | } else { |
michael@0 | 710 | frames['right'].document.write(ext_page_ca_exp); |
michael@0 | 711 | frames['right'].document.close(); |
michael@0 | 712 | reload_form(new_pane); |
michael@0 | 713 | } |
michael@0 | 714 | } |
michael@0 | 715 | |
michael@0 | 716 | function make_left_frame_page(selected) |
michael@0 | 717 | { |
michael@0 | 718 | var n_strings = ( make_left_frame_page.arguments.length - 1 ) / 2; |
michael@0 | 719 | var table_background; |
michael@0 | 720 | var command; |
michael@0 | 721 | var indent; |
michael@0 | 722 | var label; |
michael@0 | 723 | var ret_string = ""; |
michael@0 | 724 | |
michael@0 | 725 | ret_string += '<TABLE CELLSPACING=4>'; |
michael@0 | 726 | for ( var i = 1; i <= n_strings; i++ ) { |
michael@0 | 727 | if ( i == selected ) { |
michael@0 | 728 | table_background = 'BGCOLOR=#BBCCBB'; |
michael@0 | 729 | } else { |
michael@0 | 730 | table_background = ''; |
michael@0 | 731 | } |
michael@0 | 732 | |
michael@0 | 733 | indent = make_left_frame_page.arguments[(i*2) - 1]; |
michael@0 | 734 | label = make_left_frame_page.arguments[(i*2)]; |
michael@0 | 735 | |
michael@0 | 736 | if ( indent == 0 ) { |
michael@0 | 737 | ret_string += ('<TR><TD COLSPAN=2 ' + table_background + '>'); |
michael@0 | 738 | } else { |
michael@0 | 739 | ret_string += ('<TR><TD> </TD><TD ' + table_background + '>'); |
michael@0 | 740 | } |
michael@0 | 741 | |
michael@0 | 742 | command = "'parent.switch_right_frame(parent," + selected + "," + i + ")'"; |
michael@0 | 743 | ret_string += ('<A HREF="javascript:void setTimeout(' + command + ',0)">'); |
michael@0 | 744 | if ( indent == 0 ) { ret_string += "<B>"; } |
michael@0 | 745 | ret_string += label; |
michael@0 | 746 | if ( indent == 0 ) { ret_string += "</B>"; } |
michael@0 | 747 | ret_string += '</A></TD></TR>'; |
michael@0 | 748 | } |
michael@0 | 749 | if (selected == (max_pages + 1)) { |
michael@0 | 750 | table_background = 'BGCOLOR=#BBCCBB'; |
michael@0 | 751 | } else { |
michael@0 | 752 | table_background = ''; |
michael@0 | 753 | } |
michael@0 | 754 | ret_string += |
michael@0 | 755 | '<TR><TD COLSPAN=2 ' + table_background + |
michael@0 | 756 | '><b><A HREF="javascript:void setTimeout(\'top.submit_it()\', 0)">Finish</A></b>' + |
michael@0 | 757 | '</TD></TR>' + |
michael@0 | 758 | '<input type="submit"></form>' + |
michael@0 | 759 | '</TABLE>'; |
michael@0 | 760 | return(ret_string); |
michael@0 | 761 | } |
michael@0 | 762 | |
michael@0 | 763 | |
michael@0 | 764 | function make_page(window) |
michael@0 | 765 | // Draws the initial page setup |
michael@0 | 766 | { |
michael@0 | 767 | selected = cur_page |
michael@0 | 768 | init_ext_page_array() |
michael@0 | 769 | |
michael@0 | 770 | with (window.frames['right']) { |
michael@0 | 771 | location="main.html"; |
michael@0 | 772 | // document.write(main_page); |
michael@0 | 773 | // document.close(); |
michael@0 | 774 | } |
michael@0 | 775 | |
michael@0 | 776 | make_left_frame(window); |
michael@0 | 777 | |
michael@0 | 778 | } |
michael@0 | 779 | </script> |
michael@0 | 780 | |
michael@0 | 781 | </HEAD> |
michael@0 | 782 | <title>Cert-O-Matic</title> |
michael@0 | 783 | <FRAMESET cols="150,*" BORDER=3 ONLOAD="make_page(window)"> |
michael@0 | 784 | <FRAME SRC="about:blank" ID="index" NAME="index" |
michael@0 | 785 | MARGINWIDTH=15 MARGINHEIGHT=10 BORDER=3> |
michael@0 | 786 | <FRAME SRC="about:blank" ID="right" NAME="right" |
michael@0 | 787 | MARGINWIDTH=15 MARGINHEIGHT=10 BORDER=3> |
michael@0 | 788 | </FRAMESET> |
michael@0 | 789 | </HTML> |