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 console.log(
"init()");
30 DesktopContent.tooltip(
"Security in the Wiz-Mode",
31 "This is an introduction into the Wiz-Mode Security!" +
33 "There are currently two options for otsdaq Security:" +
34 "\n\t- <b>No Security:</b>\n<INDENT>" +
35 "Just as it sounds, there will be no login required, and all requests " +
36 "will be treated as though they come from fully priveleged administrators. " +
37 "The only security is afforded by keeping your URL unknown (like on a private network)." +
39 "This mode is usually convenient during development when no hardware is at stake." +
41 "\n\t- <b>Digest Access Authentication:</b>\n<INDENT>" +
42 "This is a straightforward username and password approach to security. " +
43 "Included in this selection, when using a HTTPS gateway, is CILOGON certificate access if users associate and email " +
44 "address with their accounts." +
45 "Users can be assigned different levels of access individually." +
47 "This mode, behind the ots HTTPS nodejs gateway, is the recommended <i>otsdaq</i> security approach." +
52 for(var index = 0; index < IDs_.length; index++)
53 selection_[index] = IDs_[index];
56 colorFade(
'orange',
"all");
57 state_= document.getElementById(
"state");
58 state_.innerHTML =
"Loading...";
60 var setSelection=setTimeout(makeServerRequest, 1000);
65 function colorFade(secondColor, which)
71 if(which ==
"selected" || which ==
"all")
74 if(secondColor ==
'orange')
76 selectedTargetRed = 255;
77 selectedTargetGreen = 188;
78 selectedTargetBlue = 18;
80 else if(secondColor ==
'red')
82 selectedTargetRed = 242;
83 selectedTargetGreen = 5;
84 selectedTargetBlue = 5;
86 else if(secondColor ==
'green')
88 selectedTargetRed = 56;
89 selectedTargetGreen = 224;
90 selectedTargetBlue = 56;
92 else if(secondColor ==
'current')
100 if(which ==
"notSelected" || which ==
"all")
103 if(secondColor ==
'orange')
105 nonSelectedTargetRed = 255;
106 nonSelectedTargetGreen = 188;
107 nonSelectedTargetBlue = 18;
109 else if(secondColor ==
'red')
111 nonSelectedTargetRed = 242;
112 nonSelectedTargetGreen = 5;
113 nonSelectedTargetBlue = 5;
115 else if(secondColor ==
'green')
117 nonSelectedTargetRed = 56;
118 nonSelectedTargetGreen = 224;
119 nonSelectedTargetBlue = 56;
121 else if(secondColor ==
'current')
129 var colorChanger=setTimeout(decreaseColor, INTERVAL_);
136 function decreaseColor()
140 if(selectedGreen > 0)
144 if(nonSelectedRed > 0)
146 if(nonSelectedGreen > 0)
148 if(nonSelectedBlue > 0)
153 if((selectedRed + selectedGreen + selectedBlue +
154 nonSelectedRed + nonSelectedGreen + nonSelectedBlue) > 0)
155 colorChanger = setTimeout(decreaseColor, INTERVAL_);
159 colorChanger = setTimeout(increaseColor, INTERVAL_);
166 function increaseColor()
168 if(selectedRed < selectedTargetRed)
170 if(selectedGreen < selectedTargetGreen)
172 if(selectedBlue < selectedTargetBlue)
174 if(nonSelectedRed < nonSelectedTargetRed)
176 if(nonSelectedGreen < nonSelectedTargetGreen)
178 if(nonSelectedBlue < nonSelectedTargetBlue)
182 if((selectedRed + selectedGreen + selectedBlue +
183 nonSelectedRed + nonSelectedGreen + nonSelectedBlue) <
184 (selectedTargetRed + selectedTargetGreen + selectedTargetBlue +
185 nonSelectedTargetRed + nonSelectedTargetGreen + nonSelectedTargetBlue))
186 colorChanger = setTimeout(increaseColor, INTERVAL_);
192 function setDivGlow()
194 for(var index = 0; index < (selection_.length); index++)
196 var div = document.getElementById(selection_[index]);
197 if(index < (selection_.length-1))
199 div.style.boxShadow =
"0px 0px 64px 20px rgba(" + nonSelectedRed +
200 "," + nonSelectedGreen +
"," + nonSelectedBlue +
",1)";
201 div.style.webkitBoxShadow =
"0px 0px 64px 20px rgba(" + nonSelectedRed +
202 "," + nonSelectedGreen +
"," + nonSelectedBlue +
",1)";
203 div.style.mozBoxShadow =
"0px 0px 64px 20px rgba(" + nonSelectedRed +
204 "," + nonSelectedGreen +
"," + nonSelectedBlue +
",1)";
208 div.style.boxShadow =
"0px 0px 64px 20px rgba(" + selectedRed +
209 "," + selectedGreen +
"," + selectedBlue +
",1)";
210 div.style.webkitBoxShadow =
"0px 0px 64px 20px rgba(" + selectedRed +
211 "," + selectedGreen +
"," + selectedBlue +
",1)";
212 div.style.mozBoxShadow =
"0px 0px 64px 20px rgba(" + selectedRed +
213 "," + selectedGreen +
"," + selectedBlue +
",1)";
221 function showVisualSelection()
225 state_.innerHTML =
" ";
228 colorFade(
'green',
'selected');
230 colorFade(
'red',
'notSelected');
236 function confirm(description)
238 var randomNumber = Math.floor(Math.random() * 99999999);
239 if(prompt(
"Are you sure? "+ description +
" Type " +
240 randomNumber +
" to continue:") == randomNumber)
242 if(prompt(
"I know exactly what I'm doing. Type 'I Do':") ==
"I Do")
244 setSecurity(
'ResetSecurityUserData');
247 alert(
"You did not type 'I Do.' Mission aborted!");
250 alert(
"You did not type the correct number. Mission aborted!");
254 function setSecurity(
id)
257 if(
id ==
'NoSecurity')
259 console.log(
"No Security selected.")
260 selectedSecurityChoice_ =
'NoSecurity';
262 else if(
id ==
'DigestAccessAuthentication')
264 console.log(
"Digest Access Authentication selcted.")
265 selectedSecurityChoice_=
'DigestAccessAuthentication';
267 else if(
id ==
'Kerberos')
269 console.log(
"Kerberos selected.")
270 selectedSecurityChoice_=
'Kerberos';
272 else if(
id ==
'ResetSecurityUserData')
274 console.log(
"Reset Data selected.")
275 selectedSecurityChoice_=
'ResetSecurityUserData';
278 console.log(
"Selection not recognized!");
283 var serverRequest =
"selection=" + selectedSecurityChoice_;
284 console.log(serverRequest);
285 makeServerRequest(serverRequest);
290 function makeServerRequest(data)
292 DesktopContent.XMLHttpRequest(
"editSecurity", data, editSecurityHandler,
301 function restructure()
304 for(var index = 0; index < IDs_.length; index++)
306 if(selectedSecurityChoice_ !=
"")
308 if(selectedSecurityChoice_ != IDs_[index])
309 selection_[index] = IDs_[index];
312 if(selectedSecurityChoice_ !=
"")
313 selection_[selection_.length] = selectedSecurityChoice_;
320 function editSecurityHandler(req)
323 if(!req || !req.responseText.length ||
324 req.responseText.indexOf(
"Error") >= 0)
326 Debug.log(
"Action Failed. Invalid Verify Code!", Debug.HIGH_PRIORITY);
327 selectedSecurityChoice_ =
"";
328 showVisualSelection();
332 console.log(
"req.responseText",req.responseText);
334 if(selectedSecurityChoice_ ==
"DigestAccessAuthentication")
335 Debug.log(
"Digest Access Authentication was enabled successfully!" +
336 "\n\nIf this is the first time you are enabling users and passwords, " +
337 "then you must get the New Account Code for the admin account from " +
338 "the printouts in the linux console when you start ots in normal mode." +
339 "\n\nAfter the admin account has been setup, new accounts can be made and " +
340 "the admin account will have access to the New Account Codes in the settings " +
342 Debug.INFO_PRIORITY);
343 else if(selectedSecurityChoice_ ==
"NoSecurity")
344 Debug.log(
"Security was disabled successfully! " +
345 "\n\nNow anyone with the ots normal mode URL will have admin privileges.",
346 Debug.INFO_PRIORITY);
348 selectedSecurityChoice_ = req.responseText;
349 console.log(selectedSecurityChoice_);
350 showVisualSelection();