/usr/share/pki/ca/webapps/ca/agent/cms-funcs.js is in pki-ca 10.6.0-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 | // --- BEGIN COPYRIGHT BLOCK ---
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// Copyright (C) 2007 Red Hat, Inc.
// All rights reserved.
// --- END COPYRIGHT BLOCK ---
//<!--
function checkClientTime()
{
var speed;
var server_date = new Date(serverdate);
var client_date = new Date();
var zone = client_date.getTimezoneOffset();
var timediff = 0;
var serverutc = server_date.getTime();
var clientutc = client_date.getTime();
var offset = clientutc - serverutc;
if (offset >0) {
speed = 'fast';
} else {
speed = 'slow';
}
timediff = Math.round(Math.abs(offset/1000/60));
if (timediff > 10) {
msg = 'Your computer\'s clock is '+ timediff+ ' minutes '+ speed +
'\n\nYou may encounter problems using your certificate\n' +
'as your clock is set incorrectly.\n\n' +
'According to the server, the time is:\n ' + server_date +
'\n\nPlease correct your clock before proceeding with enrollment'+
'\n\nYour timezone is set to ' + (-zone/60) +' hours relative to GMT.\n' +
'If you change your timezone, you may need to restart your browser\n'+
'before continuing.';
alert(msg);
return false;
}
return true;
}
function doubleQuotes(componentName)
{
for (i=0; i < componentName.length; i++) {
if (componentName.charAt(i) == '"') {
return true;
}
}
return false;
}
function escapeDNComponent(str)
{
var outStr = "";
var escapeValue = false;
// Do we need to escape any characters
for (i=0; i < str.length; i++) {
c = str.charAt(i);
if (c == ',' || c == '=' || c == '+' || c == '<' ||
c == '>' || c == '#' || c == ';' || c == '\r' ||
c == '\n') {
escapeValue = true;
break;
}
}
if (escapeValue == true) {
outStr += '"';
outStr += str;
outStr += '"';
} else {
outStr += str;
}
return outStr;
}
function formulateDN(form, distinguishedName)
{
// Note: The alerts about double quotes are here to avoid
// problems with the code dealing with quoting and escaping in the
// Netscape Directory Server 1.0 implementation.
with (form) {
distinguishedName.value = '';
if (form.E != null) {
if (E.value != '') {
if (doubleQuotes(E.value) == true) {
alert('Double quotes are not allowed in the E-mail field');
E.value = '';
E.focus();
return;
}
if (distinguishedName.value != '') distinguishedName.value += ', ';
distinguishedName.value += 'E=' + escapeDNComponent(E.value);
}
}
if (form.CN!= null) {
if (CN.value != '') {
if (doubleQuotes(CN.value) == true) {
alert('Double quotes are not allowed in Common Name field');
CN.value = '';
CN.focus();
return;
}
if (distinguishedName.value != '') distinguishedName.value += ', ';
distinguishedName.value += 'CN=' + escapeDNComponent(CN.value);
}
}
if (form.UID1 != null) {
if (UID1.value != '') {
if (doubleQuotes(UID1.value) == true) {
alert('Double quotes are not allowed in the user id field');
UID1.value = '';
UID1.focus();
return;
}
if (distinguishedName.value != '') distinguishedName.value += ', ';
distinguishedName.value += 'UID=' + escapeDNComponent(UID1.value);
}
}
if (form.OU != null) {
if (OU.value != '') {
if (doubleQuotes(OU.value) == true) {
alert('Double quotes are not allowed in Org Unit field');
OU.value = '';
OU.focus();
return;
}
if (distinguishedName.value != '') distinguishedName.value += ', ';
distinguishedName.value += 'OU=' + escapeDNComponent(OU.value);
}
}
if (form.O != null) {
if (O.value != '') {
if (doubleQuotes(O.value) == true) {
alert('Double quotes are not allowed in Organization field.');
O.value = '';
O.focus();
return;
}
if (distinguishedName.value != '') distinguishedName.value += ', ';
distinguishedName.value += 'O=' + escapeDNComponent(O.value);
}
}
if (form.L != null) {
if (L.value != '') {
if (doubleQuotes(L.value) == true) {
alert('Double quotes are not allowed in Locality field.');
L.value = '';
L.focus();
return;
}
if (distinguishedName.value != '') distinguishedName.value += ', ';
distinguishedName.value += 'L=' + escapeDNComponent(L.value);
}
}
if (form.ST != null) {
if (ST.value != '') {
if (doubleQuotes(ST.value) == true) {
alert('Double quotes are not allowed in State field.');
ST.value = '';
ST.focus();
return;
}
if (distinguishedName.value != '') distinguishedName.value += ', ';
distinguishedName.value += 'ST=' + escapeDNComponent(ST.value);
}
}
if (form.C != null) {
if (C.value != '') {
if (doubleQuotes(C.value) == true) {
alert('Double quotes are not allowed in Country field.');
C.value = '';
C.focus();
return;
}
if (distinguishedName.value != '') distinguishedName.value += ', ';
distinguishedName.value += 'C=' + escapeDNComponent(C.value);
}
}
}
}
function isValidIssuerDN(form)
{
// Note: The check here is to avoid a bug in Netscape Navigator 3.0 and 3.01
// that are triggered on formation of the nickname on import of a CA cert if
// that cert does not contain an OU or O component.
if ((form.OU.value == '') && (form.O.value == '')) {
alert("You must enter an Organization Unit or an Organization.");
return false;
} else {
return true;
}
}
function isValidAdminDN(form)
{
// Note: The check here is to avoid a bug in Netscape Navigator 3.0 and 3.01
// that are triggered on formation of the nickname on import of a personal cert if
// that cert does not contain a common name.
if (form.CN.value == '') {
alert("You must enter a Common Name.");
return false;
} else {
return true;
}
}
function isValidCSR(form)
{
// Note: the checks here are of mixed origin. Some are required for Navigator
// and Communicator. The CSR field checks are to avoid server side rejection of the
// submission. These checks can be split up to be different for different types of
// certificates.
formulateDN(form, form.subject);
// DEBUG
//alert(form.subject);
with (form) {
if (email != null) {
if (E.value == "" && email.checked) {
alert("E-mail certificates must include an E-mail address.");
return false;
}
}
if (CN.value == "") {
alert("You must supply your name for the certificate.");
return false;
}
return true;
}
}
function isNumber(string, radix) {
var i = 0;
var legalDigits;
if (radix == null || radix == 10) {
legalDigits = "0123456789";
} else if (radix == 16) {
legalDigits = "0123456789abcdefABCDEF:";
} else {
return false;
}
for(; i < string.length; ++i) {
if (string.charAt(i) != ' ')
break;
}
if (string.charAt(i) == '+' || string.charAt(i) == '-' ) {
++i;
}
if (radix == 16 && i < string.length - 2 &&
string.charAt(i) == '0' &&
(string.charAt(i+1) == 'x' || string.charAt(i+1) == 'X') &&
legalDigits.indexOf(string.charAt(i+2)) != -1) {
i += 3;
}
for(; i < string.length; ++i) {
if (legalDigits.indexOf(string.charAt(i)) == -1)
break;
}
for(; i < string.length; ++i) {
if (string.charAt(i) != ' ')
return false;
}
return true;
}
function dateForm(name)
{
var i;
document.write('<FORM NAME=\"'+ name +'\">');
document.write('<SELECT NAME=\"day\"><OPTION VALUE=0> ');
for (i=1; i <=31; ++i)
document.write('<OPTION VALUE='+i+'>'+i);
document.write('</SELECT>');
document.write('<SELECT NAME=\"month\">'+
'<OPTION VALUE=13> '+
'<OPTION VALUE=0>January'+
'<OPTION VALUE=1>February'+
'<OPTION VALUE=2>March'+
'<OPTION VALUE=3>April'+
'<OPTION VALUE=4>May'+
'<OPTION VALUE=5>June'+
'<OPTION VALUE=6>July'+
'<OPTION VALUE=7>August'+
'<OPTION VALUE=8>September'+
'<OPTION VALUE=9>October'+
'<OPTION VALUE=10>November'+
'<OPTION VALUE=11>December'+
'</SELECT>'
);
document.write('<SELECT NAME=\"year\"><OPTION VALUE=0> ');
for (i=1996; i <=2006; ++i)
document.write('<OPTION VALUE='+i+'>'+i);
document.write('</SELECT>');
document.write('</FORM>');
}
function dateIsEmpty(form)
{
return form.day.selectedIndex == 0 &&
form.month.selectedIndex == 0 &&
form.year.selectedIndex == 0;
}
function convertDate(form, fieldName)
{
var date;
var day = form.day.options[form.day.selectedIndex].value;
var month = form.month.options[form.month.selectedIndex].value;
var year = form.year.options[form.year.selectedIndex].value;
date = new Date(year,month,day);
// see if normalization was required
if (date.getMonth() != month || date.getDate() != day ) {
alert(fieldName + " is invalid");
return null;
}
else
return Math.round(date.getTime() / 1000);
}
function daysToSeconds(days){
return 3600 * 24 * days;
}
// encloses value in double quotes preceding all embedded double quotes with \
function escapeValue(value)
{
var result;
var fromIndex = 0, toIndex = 0;
// kludgy work-around for indexOf JavaScript bug on empty string
if (value == "")
return '\"\"';
result = '\"';
while ((toIndex = value.indexOf('\"',fromIndex)) != -1) {
result += value.substring(fromIndex,toIndex);
result += '\\"';
fromIndex = toIndex + 1;
}
result += value.substring(fromIndex,value.length);
result += '\"';
return result;
}
// encloses value in double quotes preceding all embedded double quotes and
// backslashes with backslash
function escapeValueJSString(value)
{
var result = "";
// Do we need to escape any characters
for (i=0; i < value.length; i++) {
c = value.charAt(i);
if (c == '\\' | c == '"') {
result += '\\';
}
result += c;
}
return '\"' + result + '\"';
}
function escapeValueRfc1779(value)
{
var result = "";
// Do we need to escape any characters
for (i=0; i < value.length; i++) {
c = value.charAt(i);
if (c == ',' || c == '=' || c == '+' || c == '<' ||
c == '>' || c == '#' || c == ';' || c == '\r' ||
c == '\n' || c == '\\' | c == '"') {
result += '\\';
}
result += c;
}
return result;
}
// helper function to construct name component(pattern)
function makeComponent(list,tag,value,asPattern)
{
var last = list.length;
if (asPattern) {
list[last] = (value == "") ? "*" : (tag+"="+escapeValueRfc1779(value));
}
else if (value != "")
list[last] = tag+"="+escapeValueRfc1779(value);
}
// If asPattern is false formulates the RFC 1779 format subject name
// from the component parts skipping all components with blank values,
// otherwise builds RFC 1779-like matching pattern from components
function computeNameCriterion(form)
{
var asPattern = form.match[1].checked;
var result = new Array;
with (form) {
// The order of clauses here determines how components are ordered
// in the name sent in the client's request. A site may wish to
// re-order the clauses here if their conventions produce names
// with components in a different order.
makeComponent(result,"E",E.value,asPattern);
makeComponent(result,"CN",CN.value,asPattern);
makeComponent(result,"UID",UID.value,asPattern);
makeComponent(result,"OU",OU.value,asPattern);
makeComponent(result,"O",O.value,asPattern);
makeComponent(result,"L",L.value,asPattern);
makeComponent(result,"ST",ST.value,asPattern);
makeComponent(result,"C",C.value,asPattern);
}
if (result.length == 0)
return asPattern ? "0 == 0" : "0 == 1";
else
return "subject" + ( asPattern ? " ~= " : " == ") +
escapeValue(result.join(', '));
}
function booleanCrit(crit,radioArg)
{
for (var i = 0; i < radioArg.length; ++i ){
if( radioArg[i].checked ) {
if (radioArg[i].value.length != 0) {
crit[crit.length] = radioArg[i].name + " == " + radioArg[i].value;
}
return;
}
}
}
function isHTTPEscapeChar(c)
{
if (c == '%' || c == '#' || c == '+' || c == '=' || c == '\n' ||
c == '\r' || c == '\t' || c == ';' || c == '&' ||
c == '>') {
return true;
}
return false;
}
function produceHTTPEscapedString(inString)
{
table = new Object();
table["%"] = "25";
table["#"] = "23";
table["+"] = "2B";
table["="] = "3D";
table["\n"] = "0A";
table["\r"] = "0D";
table["\t"] = "09";
table[";"] = "3B";
table["&"] = "26";
table[">"] = "3E";
outString = "";
for (i=0; i < inString.length; i++) {
if (inString.charAt(i) == ' ') {
outString += '+';
} else {
if (isHTTPEscapeChar(inString.charAt(i))) {
outString += "%" + table[inString.substring(i, i+1)];
} else {
outString += inString.charAt(i);
}
}
}
return outString;
}
// strips (optional) spaces and 0[xX] prefix at the beginning of s
function stripPrefix(s)
{
var i;
for(i = 0; i < s.length - 1; ++i) {
if (s.charAt(i) != ' ' )
break;
}
if (s.charAt(i) == '0' && (s.charAt(i+1) == 'x' || s.charAt(i+1) == 'X')) {
return s.substring(i+2,s.length);
} else {
return s.substring(i,s.length);;
}
}
// removes colons from value and returns the result
// used as helper to convert colon-separated hexadecimal numbers
// to regular numbers
function removeColons(value)
{
var result = "";
for (i=0; i < value.length; i++) {
c = value.charAt(i);
if (c != ':' ){
result += c;
}
}
return result;
}
function navMajorVersion()
{
return parseInt(navigator.appVersion.substring(0, navigator.appVersion.indexOf(".")));
}
//-->
|