| 76 | | var howNoneVal = "none"; |
|---|
| | 79 | // How denied accesses appear |
|---|
| | 80 | var howDenyAllVal = "none"; |
|---|
| | 81 | |
|---|
| | 82 | var howDenyReadVal = "not-read"; |
|---|
| | 83 | var howDenyReadAclVal = "not-read-acl"; |
|---|
| | 84 | var howDenyReadCurPrivSetVal = "not-read-curprivset"; |
|---|
| | 85 | var howDenyReadFreebusyVal = "not-read-freebusy "; |
|---|
| | 86 | |
|---|
| | 87 | var howDenyWriteVal = "not-write"; |
|---|
| | 88 | var howDenyWriteAclVal = "not-write-acl"; |
|---|
| | 89 | var howDenyWritePropertiesVal = "not-write-properties"; |
|---|
| | 90 | var howDenyWriteContentVal = "not-write-content"; |
|---|
| | 91 | |
|---|
| | 92 | var howDenyBindVal = "not-create"; |
|---|
| | 93 | var howDenyScheduleVal = "not-schedule"; |
|---|
| | 94 | var howDenyScheduleRequestVal = "not-schedule-request"; |
|---|
| | 95 | var howDenyScheduleReplyVal = "not-schedule-reply"; |
|---|
| | 96 | var howDenyScheduleFreebusyVal = "not-schedule-freebusy"; |
|---|
| | 97 | |
|---|
| | 98 | var howDenyUnbindVal = "not-delete"; |
|---|
| | 99 | |
|---|
| | 100 | var howDenyUnlockVal = "not-unlock"; |
|---|
| | 101 | |
|---|
| | 102 | //var howNoneVal = "none"; |
|---|
| | 103 | |
|---|
| | 104 | /* We shouldn't use the word local - it probably doesn't mean too much and it might actually be |
|---|
| | 105 | inherited from something called /local for example */ |
|---|
| | 106 | var inheritedStr = "Not inherited"; |
|---|
| | 107 | |
|---|
| | 108 | // ************************** |
|---|
| | 109 | // The prefixes come from the directory code so should be emitted by the jsp. |
|---|
| | 110 | // We may have problems here as convertng from a user id to a principal might be |
|---|
| | 111 | // awkward |
|---|
| | 112 | |
|---|
| | 113 | var principalPrefix = "/principals/"; |
|---|
| | 114 | var userPrincipalPrefix = "/principals/users/"; |
|---|
| | 115 | var groupPrincipalPrefix = "/principals/groups/"; |
|---|
| | 116 | var resourcePrincipalPrefix = "/principals/resources/"; |
|---|
| 102 | | hv.push(new howVals("A", "RrPFWapcbStysuN", howAllVal)); |
|---|
| 103 | | |
|---|
| 104 | | hv.push(new howVals("R", "rPF", howReadVal)); |
|---|
| 105 | | hv.push(new howVals("r", "", howReadAclVal)); |
|---|
| 106 | | hv.push(new howVals("P", "", howReadCurPrivSetVal)); |
|---|
| 107 | | hv.push(new howVals("F", "", howReadFreebusyVal)); |
|---|
| 108 | | |
|---|
| 109 | | hv.push(new howVals("W", "apcbStysuN", howWriteVal)); |
|---|
| 110 | | hv.push(new howVals("a", "", howWriteAclVal)); |
|---|
| 111 | | hv.push(new howVals("p", "", howWritePropertiesVal)); |
|---|
| 112 | | hv.push(new howVals("c", "", howWriteContentVal)); |
|---|
| 113 | | |
|---|
| 114 | | hv.push(new howVals("b", "Stys", howBindVal)); |
|---|
| 115 | | hv.push(new howVals("S", "tys", howScheduleVal)); |
|---|
| 116 | | hv.push(new howVals("t", "", howScheduleRequestVal)); |
|---|
| 117 | | hv.push(new howVals("y", "", howScheduleReplyVal)); |
|---|
| 118 | | hv.push(new howVals("s", "", howScheduleFreebusyVal)); |
|---|
| 119 | | |
|---|
| 120 | | hv.push(new howVals("u", "", howUnbindVal)); |
|---|
| 121 | | |
|---|
| 122 | | hv.push(new howVals("U", "", howUnlockVal)); |
|---|
| 123 | | |
|---|
| 124 | | hv.push(new howVals("N", "rPFapcbStysu", howNoneVal)); |
|---|
| | 167 | hv.push(new howVals("A", "RrPFWapcbStysuN", "<D:all/>", howAllVal, howDenyAllVal)); |
|---|
| | 168 | |
|---|
| | 169 | hv.push(new howVals("R", "rPF", "<D:read/>", howReadVal, howDenyReadVal)); |
|---|
| | 170 | hv.push(new howVals("r", "", "<D:read-acl/>", howReadAclVal, howDenyReadAclVal)); |
|---|
| | 171 | hv.push(new howVals("P", "", "<D:read-current-user-privilege-set/>", howReadCurPrivSetVal, howDenyReadCurPrivSetVal)); |
|---|
| | 172 | hv.push(new howVals("F", "", "<C:read-free-busy/>", howReadFreebusyVal, howDenyReadFreebusyVal)); |
|---|
| | 173 | |
|---|
| | 174 | hv.push(new howVals("W", "apcbStysuN", "<D:write/>", howWriteVal, howDenyWriteVal)); |
|---|
| | 175 | hv.push(new howVals("a", "", "<D:write-acl/>", howWriteAclVal, howDenyWriteAclVal)); |
|---|
| | 176 | hv.push(new howVals("p", "", "<D: write-properties/>", howWritePropertiesVal, howDenyWritePropertiesVal)); |
|---|
| | 177 | hv.push(new howVals("c", "", "<D:write-content/>", howWriteContentVal, howDenyWriteContentVal)); |
|---|
| | 178 | |
|---|
| | 179 | hv.push(new howVals("b", "Stys", "<D:bind/>", howBindVal, howDenyBindVal)); |
|---|
| | 180 | hv.push(new howVals("S", "tys", "<C:schedule/>", howScheduleVal, howDenyScheduleVal)); |
|---|
| | 181 | hv.push(new howVals("t", "", "<C:schedule-request/>", howScheduleRequestVal, howDenyScheduleRequestVal)); |
|---|
| | 182 | hv.push(new howVals("y", "", "<C:schedule-reply/>", howScheduleReplyVal, howDenyScheduleReplyVal)); |
|---|
| | 183 | hv.push(new howVals("s", "", "<C:schedule-free-busy/>", howScheduleFreebusyVal, howDenyScheduleFreebusyVal)); |
|---|
| | 184 | |
|---|
| | 185 | hv.push(new howVals("u", "", "<D:unbind/>", howUnbindVal, howDenyUnbindVal)); |
|---|
| | 186 | |
|---|
| | 187 | hv.push(new howVals("U", "", "<D:unlock/>", howUnlockVal, howDenyUnlockVal)); |
|---|
| | 188 | |
|---|
| | 189 | //hv.push(new howVals("N", "rPFapcbStysu", "", howNoneVal)); // None is -A |
|---|
| | 294 | |
|---|
| | 295 | // Don't touch email like addresses |
|---|
| | 296 | if (who.indexOf("@") < 0) { |
|---|
| | 297 | // Normalize the who |
|---|
| | 298 | if (whoType == "user") { |
|---|
| | 299 | if (who.indexOf(principalPrefix) != "0") { |
|---|
| | 300 | who = userPrincipalPrefix + who; |
|---|
| | 301 | } |
|---|
| | 302 | } else if (whoType == "group") { |
|---|
| | 303 | if (who.indexOf(principalPrefix) != "0") { |
|---|
| | 304 | who = groupPrincipalPrefix + who; |
|---|
| | 305 | } |
|---|
| | 306 | } else if (whoType == "resource") { |
|---|
| | 307 | if (who.indexOf(principalPrefix) != "0") { |
|---|
| | 308 | who = resourcePrincipalPrefix + who; |
|---|
| | 309 | } |
|---|
| | 310 | } |
|---|
| | 311 | } |
|---|
| | 312 | |
|---|
| | 313 | // format the who string for on-screen display |
|---|
| | 314 | this.format = function() { |
|---|
| | 315 | if (whoType == "user") { |
|---|
| | 316 | return who; |
|---|
| | 317 | } |
|---|
| | 318 | |
|---|
| | 319 | if (whoType == "group") { |
|---|
| | 320 | return who; |
|---|
| | 321 | } |
|---|
| | 322 | |
|---|
| | 323 | if (whoType == "resource") { |
|---|
| | 324 | return who; |
|---|
| | 325 | } |
|---|
| | 326 | |
|---|
| | 327 | if (whoType == "auth") { |
|---|
| | 328 | return authenticatedStr; |
|---|
| | 329 | } |
|---|
| | 330 | |
|---|
| | 331 | if (whoType == "unauth") { |
|---|
| | 332 | return unauthenticatedStr; |
|---|
| | 333 | } |
|---|
| | 334 | |
|---|
| | 335 | if (whoType == "owner") { |
|---|
| | 336 | return ownerStr; |
|---|
| | 337 | } |
|---|
| | 338 | |
|---|
| | 339 | if (whoType == "other") { |
|---|
| | 340 | return otherStr; |
|---|
| | 341 | } |
|---|
| | 342 | |
|---|
| | 343 | return "***************" + whoType; |
|---|
| | 344 | } |
|---|
| | 345 | |
|---|
| | 346 | this.toXml = function() { |
|---|
| | 347 | var w = this.format(); |
|---|
| | 348 | |
|---|
| | 349 | if (whoType == "other") { |
|---|
| | 350 | return " <D:invert>\n <D:principal><D:owner/></D:principal>\n </D:invert>"; |
|---|
| | 351 | } |
|---|
| | 352 | |
|---|
| | 353 | var res = " <D:principal>\n"; |
|---|
| | 354 | |
|---|
| | 355 | if (w.indexOf(principalPrefix) == "0") { |
|---|
| | 356 | res += " <D:href>" + w + "</D:href>\n"; |
|---|
| | 357 | } else if (whoType == "auth") { |
|---|
| | 358 | res += " <D:authenticated/>\n"; |
|---|
| | 359 | } else if (whoType == "unauth") { |
|---|
| | 360 | res += " <D:unauthenticated/>\n"; |
|---|
| | 361 | } else if (whoType == "owner") { |
|---|
| | 362 | res += " <D:property><D:owner/></D:property>\n"; |
|---|
| | 363 | } else { |
|---|
| | 364 | res += "************??????" + whoType; |
|---|
| | 365 | } |
|---|
| | 366 | |
|---|
| | 367 | return res + " </D:principal>\n"; |
|---|
| | 368 | } |
|---|
| | 369 | |
|---|
| | 370 | this.equals = function(pr) { |
|---|
| | 371 | if (this.whoType != pr.whoType) { |
|---|
| | 372 | return false; |
|---|
| | 373 | } |
|---|
| | 374 | |
|---|
| | 375 | return this.who == pr.who; |
|---|
| | 376 | } |
|---|
| | 377 | } |
|---|
| | 378 | |
|---|
| | 379 | /* METHOD TWO FUNCTIONS*/ |
|---|
| | 380 | // Access Control Entry (ACE) object |
|---|
| | 381 | |
|---|
| | 382 | function bwAce(who, whoType, how, inherited, invert) { |
|---|
| | 383 | this.principal = new bwPrincipal(who, whoType); |
|---|
| 243 | | if (whoType == "user" || whoType == "group") { |
|---|
| 244 | | return who; |
|---|
| 245 | | } |
|---|
| 246 | | |
|---|
| 247 | | if (whoType == "auth") { |
|---|
| 248 | | return authenticatedStr; |
|---|
| 249 | | } |
|---|
| 250 | | |
|---|
| 251 | | if (whoType == "unauth") { |
|---|
| 252 | | return unauthenticatedStr; |
|---|
| 253 | | } |
|---|
| 254 | | |
|---|
| 255 | | if (whoType == "owner") { |
|---|
| 256 | | return ownerStr; |
|---|
| 257 | | } |
|---|
| 258 | | |
|---|
| 259 | | if (whoType == "other") { |
|---|
| 260 | | return otherStr; |
|---|
| 261 | | } |
|---|
| 262 | | |
|---|
| 263 | | return "***************" + whoType; |
|---|
| 264 | | } |
|---|
| 265 | | |
|---|
| 266 | | this.toXml = function() { |
|---|
| 267 | | var res = "<ace><principal>\n"; |
|---|
| 268 | | |
|---|
| 269 | | if (whoType == "user" || whoType == "group") { |
|---|
| 270 | | res += "<href>" + who + "</href>"; |
|---|
| 271 | | } else if (whoType == "auth") { |
|---|
| 272 | | res += "<property>" + who + "</property>"; |
|---|
| 273 | | }else if (whoType == "unauth") { |
|---|
| 274 | | res += "<property>" + who + "</property>"; |
|---|
| 275 | | } if (whoType == "owner") { |
|---|
| 276 | | res += "<property>" + who + "</property>"; |
|---|
| 277 | | } if (whoType == "other") { |
|---|
| 278 | | res += "<invert><principal>" + who + "</principal></invert>"; |
|---|
| 279 | | } |
|---|
| 280 | | res += "</principal>"; |
|---|
| 281 | | res += "<grant>"; |
|---|
| 282 | | res += "<read/>"; |
|---|
| 283 | | res += "</grant>"; |
|---|
| 284 | | |
|---|
| 285 | | if (this.inherited != '') { |
|---|
| 286 | | res += "<inherited><href>" + this.inherited + "</href></inherited>"; |
|---|
| 287 | | } |
|---|
| 288 | | |
|---|
| 289 | | return res + "</ace>"; |
|---|
| | 394 | return this.principal.format(); |
|---|
| 303 | | formattedHow += hvs.dispVal + " "; |
|---|
| 304 | | } |
|---|
| 305 | | } |
|---|
| 306 | | |
|---|
| 307 | | return formattedHow; |
|---|
| | 444 | if (!open) { |
|---|
| | 445 | if (doGrants) { |
|---|
| | 446 | res += " <D:grant>\n"; |
|---|
| | 447 | } else { |
|---|
| | 448 | res += " <D:deny>\n"; |
|---|
| | 449 | } |
|---|
| | 450 | |
|---|
| | 451 | open = true; |
|---|
| | 452 | } |
|---|
| | 453 | |
|---|
| | 454 | res += " <D:privilege>" + hvs.davEl + "</D:privilege>\n"; |
|---|
| | 455 | } |
|---|
| | 456 | } |
|---|
| | 457 | |
|---|
| | 458 | if (open) { |
|---|
| | 459 | if (doGrants) { |
|---|
| | 460 | res += " </D:grant>\n"; |
|---|
| | 461 | } else { |
|---|
| | 462 | res += " </D:deny>\n"; |
|---|
| | 463 | } |
|---|
| | 464 | } |
|---|
| | 465 | |
|---|
| | 466 | return res; |
|---|
| | 467 | } |
|---|
| | 468 | |
|---|
| | 469 | this.toXml = function() { |
|---|
| | 470 | var res = " <D:ace>\n" + this.principal.toXml(); |
|---|
| | 471 | |
|---|
| | 472 | res += this.howsToXml(true); |
|---|
| | 473 | res += this.howsToXml(false); |
|---|
| | 474 | |
|---|
| | 475 | if (this.inherited != "") { |
|---|
| | 476 | res += " <D:inherited><D:href>" + this.inherited + "</D:href></D:inherited>"; |
|---|
| | 477 | } |
|---|
| | 478 | |
|---|
| | 479 | return res + " </D:ace>\n"; |
|---|
| | 480 | } |
|---|
| | 481 | |
|---|
| | 482 | this.toFormRow = function(row) { |
|---|
| | 483 | row.insertCell(0).appendChild(document.createTextNode(this.principal.format())); |
|---|
| | 484 | row.insertCell(1).appendChild(document.createTextNode(this.formatHow())); |
|---|
| | 485 | row.insertCell(2).appendChild(document.createTextNode(this.formatInherited())); |
|---|
| | 486 | var td_3 = row.insertCell(3); |
|---|
| | 487 | td_3.appendChild(document.createTextNode('')); |
|---|
| | 488 | //<a href="javascript:bwAcl.delete(' + j +')">' + deleteStr + '</a> |
|---|
| 352 | | // return the how string from the form |
|---|
| 353 | | var how = setAccessHow(formObj,2); |
|---|
| 354 | | // update the bwAcl |
|---|
| 355 | | bwAcl.addAce(new bwAce(formObj.who.value,type,how,"local",false)); |
|---|
| | 534 | |
|---|
| | 535 | // get the how string from the form |
|---|
| | 536 | var how = setAccessHow(formObj, 2); |
|---|
| | 537 | |
|---|
| | 538 | //alert("About to update who=" + formObj.who.value + |
|---|
| | 539 | // "\ntype= " + type + "\nhow=" + how); |
|---|
| | 540 | |
|---|
| | 541 | bwAcl.addAce(new bwAce(formObj.who.value, type, how, "" , false)); |
|---|
| | 542 | formObj.who.value = ""; |
|---|
| | 543 | |
|---|
| | 544 | // update the acl form field |
|---|
| | 545 | formObj.acl.value = this.toXml(); |
|---|
| | 546 | |
|---|
| | 547 | // redraw the display |
|---|
| | 548 | this.display(); |
|---|
| | 549 | } |
|---|
| | 550 | |
|---|
| | 551 | this.deleteAce = function(index) { |
|---|
| | 552 | bwAcl.aces.splice(index, 1); |
|---|