otsdaq_utilities  v2_04_01
SecuritySettings.js
1 var selectedSecurityChoice_ = "";
2 var IDs_ = ['NoSecurity', 'DigestAccessAuthentication'];//, 'ResetSecurityUserData'];//'Kerberos','ResetSecurityUserData'];
3 var selection_ = [];
4 INTERVAL_ = 1;
5 state_ = document.getElementById("state");
7 nonSelectedRed = 2;
8 nonSelectedGreen = 2;
9 nonSelectedBlue = 2;
11 var nonSelectedTargetRed;
12 var nonSelectedTargetGreen;
13 var nonSelectedtargetBlue;
15 selectedRed = 2;
16 selectedGreen = 2;
17 selectedBlue = 2;
19 var selectedTargetRed;
20 var selectedTargetGreen;
21 var selectedtargetBlue;
23 
24 
25 
26 //=====================================================================================
27 function init()
28 {
29  console.log("init()");
30  DesktopContent.tooltip("Security in the Wiz-Mode",
31  "This is an introduction into the Wiz-Mode Security!" +
32  "\n\n" +
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)." +
38  "\n\n" +
39  "This mode is usually convenient during development when no hardware is at stake." +
40  "</INDENT>" +
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." +
46  "\n\n" +
47  "This mode, behind the ots HTTPS nodejs gateway, is the recommended <i>otsdaq</i> security approach." +
48  "</INDENT>"
49  );
50 
51 
52  for(var index = 0; index < IDs_.length; index++)
53  selection_[index] = IDs_[index];
54  //Added all of the IDs into the selection_ array and position the selection at the end
55 
56  colorFade('orange', "all");
57  state_= document.getElementById("state");
58  state_.innerHTML = "Loading...";
59 
60  var setSelection=setTimeout(makeServerRequest, 1000);
61 } //end init()
62 
63 
64 //=====================================================================================
65 function colorFade(secondColor, which)
66 {
67 
68 
69  //Added all of the IDs into the selection_ array and position the selection at the end
70 
71  if(which == "selected" || which == "all")
72  {
73 
74  if(secondColor == 'orange')
75  {
76  selectedTargetRed = 255;
77  selectedTargetGreen = 188;
78  selectedTargetBlue = 18;
79  }
80  else if(secondColor == 'red')
81  {
82  selectedTargetRed = 242;
83  selectedTargetGreen = 5;
84  selectedTargetBlue = 5;
85  }
86  else if(secondColor == 'green')
87  {
88  selectedTargetRed = 56;
89  selectedTargetGreen = 224;
90  selectedTargetBlue = 56;
91  }
92  else if(secondColor == 'current')
93  {
94 
95  }
96 
97  }
98 
99 
100  if(which == "notSelected" || which == "all")
101  {
102 
103  if(secondColor == 'orange')
104  {
105  nonSelectedTargetRed = 255;
106  nonSelectedTargetGreen = 188;
107  nonSelectedTargetBlue = 18;
108  }
109  else if(secondColor == 'red')
110  {
111  nonSelectedTargetRed = 242;
112  nonSelectedTargetGreen = 5;
113  nonSelectedTargetBlue = 5;
114  }
115  else if(secondColor == 'green')
116  {
117  nonSelectedTargetRed = 56;
118  nonSelectedTargetGreen = 224;
119  nonSelectedTargetBlue = 56;
120  }
121  else if(secondColor == 'current')
122  {
123 
124  }
125  }
126 
127  //console.log(selectedRed, selectedGreen, selectedBlue, nonSelectedRed, nonSelectedGreen, nonSelectedBlue);
128 
129  var colorChanger=setTimeout(decreaseColor, INTERVAL_);
130 
131 
132 } //end colorFade()
133 
134 
135 //=====================================================================================
136 function decreaseColor()
137 {
138  if(selectedRed > 0)
139  --selectedRed;
140  if(selectedGreen > 0)
141  --selectedGreen;
142  if(selectedBlue > 0)
143  --selectedBlue;
144  if(nonSelectedRed > 0)
145  --nonSelectedRed;
146  if(nonSelectedGreen > 0)
147  --nonSelectedGreen;
148  if(nonSelectedBlue > 0)
149  --nonSelectedBlue;
150  //console.log("Called");
151  setDivGlow();
152 
153  if((selectedRed + selectedGreen + selectedBlue +
154  nonSelectedRed + nonSelectedGreen + nonSelectedBlue) > 0)
155  colorChanger = setTimeout(decreaseColor, INTERVAL_);
156  else
157  {
158  restructure();
159  colorChanger = setTimeout(increaseColor, INTERVAL_);
160 
161  }
162 } //end decreaseColor()
163 
164 
165 //=====================================================================================
166 function increaseColor()
167 {
168  if(selectedRed < selectedTargetRed)
169  ++selectedRed;
170  if(selectedGreen < selectedTargetGreen)
171  ++selectedGreen;
172  if(selectedBlue < selectedTargetBlue)
173  ++selectedBlue;
174  if(nonSelectedRed < nonSelectedTargetRed)
175  ++nonSelectedRed;
176  if(nonSelectedGreen < nonSelectedTargetGreen)
177  ++nonSelectedGreen;
178  if(nonSelectedBlue < nonSelectedTargetBlue)
179  ++nonSelectedBlue;
180  setDivGlow();
181 
182  if((selectedRed + selectedGreen + selectedBlue +
183  nonSelectedRed + nonSelectedGreen + nonSelectedBlue) <
184  (selectedTargetRed + selectedTargetGreen + selectedTargetBlue +
185  nonSelectedTargetRed + nonSelectedTargetGreen + nonSelectedTargetBlue))
186  colorChanger = setTimeout(increaseColor, INTERVAL_);
187 
188 } //end increaseColor()
189 
190 
191 //=====================================================================================
192 function setDivGlow()
193 {
194  for(var index = 0; index < (selection_.length); index++)
195  {
196  var div = document.getElementById(selection_[index]);
197  if(index < (selection_.length-1))
198  {
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)";
205  }
206  else
207  {
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)";
214  }
215  }
216 
217 } //end setDivGlow()
218 
219 
220 //=====================================================================================
221 function showVisualSelection()
222 {
223 
224 
225  state_.innerHTML = "&nbsp";
226 
227  //set selected to green
228  colorFade('green', 'selected');
229  //set selected to green
230  colorFade('red', 'notSelected');
231 
232 } //end showVisualSelection()
233 
234 
235 //=====================================================================================
236 function confirm(description)
237 {
238  var randomNumber = Math.floor(Math.random() * 99999999);
239  if(prompt("Are you sure? "+ description + " Type " +
240  randomNumber + " to continue:") == randomNumber)
241  {
242  if(prompt("I know exactly what I'm doing. Type 'I Do':") == "I Do")
243  {
244  setSecurity('ResetSecurityUserData');
245  }
246  else
247  alert("You did not type 'I Do.' Mission aborted!");
248  }
249  else
250  alert("You did not type the correct number. Mission aborted!");
251 } //end confirm()
252 
253 //=====================================================================================
254 function setSecurity(id)
255 {
256 
257  if(id == 'NoSecurity')
258  {
259  console.log("No Security selected.")
260  selectedSecurityChoice_ = 'NoSecurity';
261  }
262  else if(id == 'DigestAccessAuthentication')
263  {
264  console.log("Digest Access Authentication selcted.")
265  selectedSecurityChoice_= 'DigestAccessAuthentication';
266  }
267  else if(id == 'Kerberos')
268  {
269  console.log("Kerberos selected.")
270  selectedSecurityChoice_= 'Kerberos';
271  }
272  else if(id == 'ResetSecurityUserData')
273  {
274  console.log("Reset Data selected.")
275  selectedSecurityChoice_= 'ResetSecurityUserData';
276  }
277  else{
278  console.log("Selection not recognized!");
279  return;
280  }
281 
282 
283  var serverRequest = "selection=" + selectedSecurityChoice_;
284  console.log(serverRequest);
285  makeServerRequest(serverRequest);
286 } //end setSecurity()
287 
288 
289 //=====================================================================================
290 function makeServerRequest(data)
291 {
292  DesktopContent.XMLHttpRequest("editSecurity", data, editSecurityHandler,
293  undefined /*reqParam*/,
294  undefined /*progressHandler*/,
295  true /*callHandlerOnErr*/);
296 
297 } //end makeServerRequest()
298 
299 
300 //=====================================================================================
301 function restructure()
302 {
303 
304  for(var index = 0; index < IDs_.length; index++)
305  {
306  if(selectedSecurityChoice_ != "")
307  {
308  if(selectedSecurityChoice_ != IDs_[index])
309  selection_[index] = IDs_[index];
310  }
311  }
312  if(selectedSecurityChoice_ != "")
313  selection_[selection_.length] = selectedSecurityChoice_;
314 
315 } //end restructure()
316 
317 
318 //=====================================================================================
319 //Note: not an xml response, just text
320 function editSecurityHandler(req)
321 {
322 
323  if(!req || !req.responseText.length ||
324  req.responseText.indexOf("Error") >= 0)
325  {
326  Debug.log("Action Failed. Invalid Verify Code!", Debug.HIGH_PRIORITY);
327  selectedSecurityChoice_ = "";
328  showVisualSelection();
329  return;
330  }
331 
332  console.log("req.responseText",req.responseText);
333 
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 " +
341  "web GUI.",
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);
347 
348  selectedSecurityChoice_ = req.responseText;
349  console.log(selectedSecurityChoice_);
350  showVisualSelection();
351 
352 } //end editSecurityHandler()
353 
354 
355