otsdaq_utilities  v2_02_00
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 function init(){
27  console.log("init()");
28  DesktopContent.tooltip("Security in the Wiz-Mode",
29  "This is an introduction into the Wiz-Mode Security!" +
30  "\n\n" +
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)." +
36  "\n\n" +
37  "This mode is usually convenient during development when no hardware is at stake." +
38  "</INDENT>" +
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." +
44  "\n\n" +
45  "This mode, behind the ots HTTPS nodejs gateway, is the recommended <i>otsdaq</i> security approach." +
46  "</INDENT>"
47  );
48 
49 
50  for(var index = 0; index < IDs_.length; index++)
51  selection_[index] = IDs_[index];
52  //Added all of the IDs into the selection_ array and position the selection at the end
53 
54  colorFade('orange', "all");
55  state_= document.getElementById("state");
56  state_.innerHTML = "Loading...";
57 
58  var setSelection=setTimeout(makeServerRequest, 1000);
59 }
60 
61 
62 function colorFade(secondColor, which){
63 
64 
65  //Added all of the IDs into the selection_ array and position the selection at the end
66 
67  if(which == "selected" || which == "all"){
68 
69  if(secondColor == 'orange'){
70  selectedTargetRed = 255;
71  selectedTargetGreen = 188;
72  selectedTargetBlue = 18;
73  }else if(secondColor == 'red'){
74  selectedTargetRed = 242;
75  selectedTargetGreen = 5;
76  selectedTargetBlue = 5;
77  }else if(secondColor == 'green'){
78  selectedTargetRed = 56;
79  selectedTargetGreen = 224;
80  selectedTargetBlue = 56;
81  }else if(secondColor == 'current'){
82 
83  }
84 
85  }
86  if(which == "notSelected" || which == "all"){
87 
88  if(secondColor == 'orange'){
89  nonSelectedTargetRed = 255;
90  nonSelectedTargetGreen = 188;
91  nonSelectedTargetBlue = 18;
92  }else if(secondColor == 'red'){
93  nonSelectedTargetRed = 242;
94  nonSelectedTargetGreen = 5;
95  nonSelectedTargetBlue = 5;
96  }else if(secondColor == 'green'){
97  nonSelectedTargetRed = 56;
98  nonSelectedTargetGreen = 224;
99  nonSelectedTargetBlue = 56;
100  }else if(secondColor == 'current'){
101 
102  }
103  }
104 
105  //console.log(selectedRed, selectedGreen, selectedBlue, nonSelectedRed, nonSelectedGreen, nonSelectedBlue);
106 
107  var colorChanger=setTimeout(decreaseColor, INTERVAL_);
108 
109 
110 }
111 
112 function decreaseColor(){
113  if(selectedRed > 0)
114  --selectedRed;
115  if(selectedGreen > 0)
116  --selectedGreen;
117  if(selectedBlue > 0)
118  --selectedBlue;
119  if(nonSelectedRed > 0)
120  --nonSelectedRed;
121  if(nonSelectedGreen > 0)
122  --nonSelectedGreen;
123  if(nonSelectedBlue > 0)
124  --nonSelectedBlue;
125  //console.log("Called");
126  setDivGlow();
127 
128  if((selectedRed + selectedGreen + selectedBlue + nonSelectedRed + nonSelectedGreen + nonSelectedBlue) > 0)
129  colorChanger = setTimeout(decreaseColor, INTERVAL_);
130  else{
131  restructure();
132  colorChanger = setTimeout(increaseColor, INTERVAL_);
133 
134  }
135 }
136 
137 function increaseColor(){
138  if(selectedRed < selectedTargetRed)
139  ++selectedRed;
140  if(selectedGreen < selectedTargetGreen)
141  ++selectedGreen;
142  if(selectedBlue < selectedTargetBlue)
143  ++selectedBlue;
144  if(nonSelectedRed < nonSelectedTargetRed)
145  ++nonSelectedRed;
146  if(nonSelectedGreen < nonSelectedTargetGreen)
147  ++nonSelectedGreen;
148  if(nonSelectedBlue < nonSelectedTargetBlue)
149  ++nonSelectedBlue;
150  setDivGlow();
151 
152  if((selectedRed + selectedGreen + selectedBlue + nonSelectedRed + nonSelectedGreen + nonSelectedBlue) < (selectedTargetRed + selectedTargetGreen + selectedTargetBlue + nonSelectedTargetRed + nonSelectedTargetGreen + nonSelectedTargetBlue))
153  colorChanger = setTimeout(increaseColor, INTERVAL_);
154 
155 }
156 
157 function setDivGlow(){
158 
159 
160  for(var index = 0; index < (selection_.length); index++)
161  {
162  var div = document.getElementById(selection_[index]);
163  if(index < (selection_.length-1)){
164  div.style.boxShadow = "0px 0px 64px 20px rgba(" + nonSelectedRed + "," + nonSelectedGreen + "," + nonSelectedBlue + ",1)";
165  div.style.webkitBoxShadow = "0px 0px 64px 20px rgba(" + nonSelectedRed + "," + nonSelectedGreen + "," + nonSelectedBlue + ",1)";
166  div.style.mozBoxShadow = "0px 0px 64px 20px rgba(" + nonSelectedRed + "," + nonSelectedGreen + "," + nonSelectedBlue + ",1)";
167  }else{
168  div.style.boxShadow = "0px 0px 64px 20px rgba(" + selectedRed + "," + selectedGreen + "," + selectedBlue + ",1)";
169  div.style.webkitBoxShadow = "0px 0px 64px 20px rgba(" + selectedRed + "," + selectedGreen + "," + selectedBlue + ",1)";
170  div.style.mozBoxShadow = "0px 0px 64px 20px rgba(" + selectedRed + "," + selectedGreen + "," + selectedBlue + ",1)";
171  }
172  }
173 
174 }
175 
176 
177 function showVisualSelection(){
178 
179 
180  state_.innerHTML = "&nbsp";
181 
182  //set selected to green
183  colorFade('green', 'selected');
184  //set selected to green
185  colorFade('red', 'notSelected');
186 
187 }
188 
189 function confirm(description){
190  var randomNumber = Math.floor(Math.random() * 99999999)
191  if(prompt("Are you sure? "+ description + " Type " + randomNumber + " to continue:") == randomNumber)
192  if(prompt("I know exactly what I'm doing. Type 'I Do':") == "I Do"){
193  setSecurity('ResetSecurityUserData');
194  }
195  else
196  alert("You did not type 'I Do.' Mission aborted!");
197 
198  else
199  alert("You did not type the correct number. Mission aborted!");
200 }
201 
202 function setSecurity(id){
203 
204  if(id == 'NoSecurity'){
205  console.log("No Security selected.")
206  selectedSecurityChoice_ = 'NoSecurity';
207  }else if(id == 'DigestAccessAuthentication'){
208  console.log("Digest Access Authentication selcted.")
209  selectedSecurityChoice_= 'DigestAccessAuthentication';
210  }else if(id == 'Kerberos'){
211  console.log("Kerberos selected.")
212  selectedSecurityChoice_= 'Kerberos';
213  }else if(id == 'ResetSecurityUserData'){
214  console.log("Reset Data selected.")
215  selectedSecurityChoice_= 'ResetSecurityUserData';
216  }else{
217  console.log("Selection not recognized!");
218  return;
219  }
220 
221 
222  var serverRequest = "selection=" + selectedSecurityChoice_;
223  console.log(serverRequest);
224  makeServerRequest(serverRequest);
225 }
226 
227 function makeServerRequest(data){
228 
229  DesktopContent.XMLHttpRequest("editSecurity", data, editSecurityHandler, undefined, undefined);
230 }
231 
232 function restructure(){
233 
234  for(var index = 0; index < IDs_.length; index++)
235  {
236  if(selectedSecurityChoice_ != "")
237  {
238  if(selectedSecurityChoice_ != IDs_[index])
239  selection_[index] = IDs_[index];
240  }
241  }
242  if(selectedSecurityChoice_ != "")
243  selection_[selection_.length] = selectedSecurityChoice_;
244 
245 }
246 
247 var editSecurityHandler = function(req){
248 
249  if(!req || !req.responseText.length)
250  {
251  Debug.log("Action Failed. Invalid Verify Code!", Debug.HIGH_PRIORITY);
252  selectedSecurityChoice_ = "";
253  showVisualSelection();
254  return;
255  }
256 
257  if(selectedSecurityChoice_ == "ResetSecurityUserData")
258  Debug.log("User Data was RESET successfully!", Debug.INFO_PRIORITY);
259 
260  selectedSecurityChoice_ = req.responseText;
261  console.log(selectedSecurityChoice_);
262  showVisualSelection();
263  return;
264 }