1 var selectedSecurityChoice_ =
"";
2 var IDs_ = [
'NoSecurity',
'DigestAccessAuthentication'];
5 state_ = document.getElementById(
"state");
11 var nonSelectedTargetRed;
12 var nonSelectedTargetGreen;
13 var nonSelectedtargetBlue;
19 var selectedTargetRed;
20 var selectedTargetGreen;
21 var selectedtargetBlue;
29 var windowTooltip =
"This is an introduction into the Wiz-Mode Security!" +
31 "There are currently two options for otsdaq Security:" +
32 "\n\t- <b>No Security:</b>\n<INDENT>" +
33 "Just as it sounds, there will be no login required, and all requests " +
34 "will be treated as though they come from fully priveleged administrators. " +
35 "The only security is afforded by keeping your URL unknown (like on a private network)." +
37 "This mode is usually convenient during development when no hardware is at stake." +
39 "\n\t- <b>Digest Access Authentication:</b>\n<INDENT>" +
40 "This is a straightforward username and password approach to security. " +
41 "Included in this selection, when using a HTTPS gateway, is CILOGON certificate access if users associate and email " +
42 "address with their accounts." +
43 "Users can be assigned different levels of access individually." +
45 "This mode, behind the ots HTTPS nodejs gateway, is the recommended <i>otsdaq</i> security approach." +
47 console.log(
"init()");
48 DesktopContent.tooltip(
"Security in the Wiz-Mode",
51 DesktopContent.setWindowTooltip(windowTooltip);
53 for(var index = 0; index < IDs_.length; index++)
54 selection_[index] = IDs_[index];
57 colorFade(
'orange',
"all");
58 state_= document.getElementById(
"state");
59 state_.innerHTML =
"Loading...";
61 var setSelection=setTimeout(makeServerRequest, 1000);
66 function colorFade(secondColor, which)
72 if(which ==
"selected" || which ==
"all")
75 if(secondColor ==
'orange')
77 selectedTargetRed = 255;
78 selectedTargetGreen = 188;
79 selectedTargetBlue = 18;
81 else if(secondColor ==
'red')
83 selectedTargetRed = 242;
84 selectedTargetGreen = 5;
85 selectedTargetBlue = 5;
87 else if(secondColor ==
'green')
89 selectedTargetRed = 56;
90 selectedTargetGreen = 224;
91 selectedTargetBlue = 56;
93 else if(secondColor ==
'current')
101 if(which ==
"notSelected" || which ==
"all")
104 if(secondColor ==
'orange')
106 nonSelectedTargetRed = 255;
107 nonSelectedTargetGreen = 188;
108 nonSelectedTargetBlue = 18;
110 else if(secondColor ==
'red')
112 nonSelectedTargetRed = 242;
113 nonSelectedTargetGreen = 5;
114 nonSelectedTargetBlue = 5;
116 else if(secondColor ==
'green')
118 nonSelectedTargetRed = 56;
119 nonSelectedTargetGreen = 224;
120 nonSelectedTargetBlue = 56;
122 else if(secondColor ==
'current')
130 var colorChanger=setTimeout(decreaseColor, INTERVAL_);
137 function decreaseColor()
141 if(selectedGreen > 0)
145 if(nonSelectedRed > 0)
147 if(nonSelectedGreen > 0)
149 if(nonSelectedBlue > 0)
154 if((selectedRed + selectedGreen + selectedBlue +
155 nonSelectedRed + nonSelectedGreen + nonSelectedBlue) > 0)
156 colorChanger = setTimeout(decreaseColor, INTERVAL_);
160 colorChanger = setTimeout(increaseColor, INTERVAL_);
167 function increaseColor()
169 if(selectedRed < selectedTargetRed)
171 if(selectedGreen < selectedTargetGreen)
173 if(selectedBlue < selectedTargetBlue)
175 if(nonSelectedRed < nonSelectedTargetRed)
177 if(nonSelectedGreen < nonSelectedTargetGreen)
179 if(nonSelectedBlue < nonSelectedTargetBlue)
183 if((selectedRed + selectedGreen + selectedBlue +
184 nonSelectedRed + nonSelectedGreen + nonSelectedBlue) <
185 (selectedTargetRed + selectedTargetGreen + selectedTargetBlue +
186 nonSelectedTargetRed + nonSelectedTargetGreen + nonSelectedTargetBlue))
187 colorChanger = setTimeout(increaseColor, INTERVAL_);
193 function setDivGlow()
195 for(var index = 0; index < (selection_.length); index++)
197 var div = document.getElementById(selection_[index]);
198 if(index < (selection_.length-1))
200 div.style.boxShadow =
"0px 0px 64px 20px rgba(" + nonSelectedRed +
201 "," + nonSelectedGreen +
"," + nonSelectedBlue +
",1)";
202 div.style.webkitBoxShadow =
"0px 0px 64px 20px rgba(" + nonSelectedRed +
203 "," + nonSelectedGreen +
"," + nonSelectedBlue +
",1)";
204 div.style.mozBoxShadow =
"0px 0px 64px 20px rgba(" + nonSelectedRed +
205 "," + nonSelectedGreen +
"," + nonSelectedBlue +
",1)";
209 div.style.boxShadow =
"0px 0px 64px 20px rgba(" + selectedRed +
210 "," + selectedGreen +
"," + selectedBlue +
",1)";
211 div.style.webkitBoxShadow =
"0px 0px 64px 20px rgba(" + selectedRed +
212 "," + selectedGreen +
"," + selectedBlue +
",1)";
213 div.style.mozBoxShadow =
"0px 0px 64px 20px rgba(" + selectedRed +
214 "," + selectedGreen +
"," + selectedBlue +
",1)";
222 function showVisualSelection()
226 state_.innerHTML =
" ";
229 colorFade(
'green',
'selected');
231 colorFade(
'red',
'notSelected');
237 function confirm(description)
239 var randomNumber = Math.floor(Math.random() * 99999999);
240 if(prompt(
"Are you sure? "+ description +
" Type " +
241 randomNumber +
" to continue:") == randomNumber)
243 if(prompt(
"I know exactly what I'm doing. Type 'I Do':") ==
"I Do")
245 setSecurity(
'ResetSecurityUserData');
248 alert(
"You did not type 'I Do.' Mission aborted!");
251 alert(
"You did not type the correct number. Mission aborted!");
255 function setSecurity(
id)
258 if(
id ==
'NoSecurity')
260 console.log(
"No Security selected.")
261 selectedSecurityChoice_ =
'NoSecurity';
263 else if(
id ==
'DigestAccessAuthentication')
265 console.log(
"Digest Access Authentication selcted.")
266 selectedSecurityChoice_=
'DigestAccessAuthentication';
268 else if(
id ==
'Kerberos')
270 console.log(
"Kerberos selected.")
271 selectedSecurityChoice_=
'Kerberos';
273 else if(
id ==
'ResetSecurityUserData')
275 console.log(
"Reset Data selected.")
276 selectedSecurityChoice_=
'ResetSecurityUserData';
279 console.log(
"Selection not recognized!");
284 var serverRequest =
"selection=" + selectedSecurityChoice_;
285 console.log(serverRequest);
286 makeServerRequest(serverRequest);
291 function makeServerRequest(data)
293 DesktopContent.XMLHttpRequest(
"editSecurity", data, editSecurityHandler,
302 function restructure()
305 for(var index = 0; index < IDs_.length; index++)
307 if(selectedSecurityChoice_ !=
"")
309 if(selectedSecurityChoice_ != IDs_[index])
310 selection_[index] = IDs_[index];
313 if(selectedSecurityChoice_ !=
"")
314 selection_[selection_.length] = selectedSecurityChoice_;
321 function editSecurityHandler(req)
324 if(!req || !req.responseText.length ||
325 req.responseText.indexOf(
"Error") >= 0)
327 Debug.log(
"Action Failed. Invalid Verify Code!", Debug.HIGH_PRIORITY);
328 selectedSecurityChoice_ =
"NoSecurity";
329 showVisualSelection();
333 console.log(
"req.responseText",req.responseText);
335 if(selectedSecurityChoice_ ==
"DigestAccessAuthentication")
336 Debug.log(
"Digest Access Authentication was enabled successfully!" +
337 "\n\n NOTE: If this is the first time you are enabling users and passwords, " +
338 "then you must get the New Account Code for the admin account from " +
339 "the printouts in normal mode. In verbose mode ('ots -v'), the admin New Account Code will be in the linux console; " +
340 "otherwise ('ots'), the admin New Account Code can be retrieved in the Gateway log file. " +
341 "\n\nAfter the admin account has been setup, new accounts can be made and " +
342 "the admin account will have access to the New Account Codes in the settings " +
344 Debug.INFO_PRIORITY);
345 else if(selectedSecurityChoice_ ==
"NoSecurity")
346 Debug.log(
"Security was disabled successfully! " +
347 "\n\nNow anyone with the ots normal mode URL will have admin privileges.",
348 Debug.INFO_PRIORITY);
350 selectedSecurityChoice_ = req.responseText;
351 console.log(selectedSecurityChoice_);
352 showVisualSelection();