summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/DataModel/DirectLogin.js
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/DataModel/DirectLogin.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/DataModel/DirectLogin.js22
1 files changed, 15 insertions, 7 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/DirectLogin.js b/frontend/beta/js/Clipperz/PM/DataModel/DirectLogin.js
index c0cfa3c..56d9d59 100644
--- a/frontend/beta/js/Clipperz/PM/DataModel/DirectLogin.js
+++ b/frontend/beta/js/Clipperz/PM/DataModel/DirectLogin.js
@@ -1,235 +1,243 @@
1/* 1/*
2 2
3Copyright 2008-2013 Clipperz Srl 3Copyright 2008-2013 Clipperz Srl
4 4
5This file is part of Clipperz, the online password manager. 5This file is part of Clipperz, the online password manager.
6For further information about its features and functionalities please 6For further information about its features and functionalities please
7refer to http://www.clipperz.com. 7refer to http://www.clipperz.com.
8 8
9* Clipperz is free software: you can redistribute it and/or modify it 9* Clipperz is free software: you can redistribute it and/or modify it
10 under the terms of the GNU Affero General Public License as published 10 under the terms of the GNU Affero General Public License as published
11 by the Free Software Foundation, either version 3 of the License, or 11 by the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version. 12 (at your option) any later version.
13 13
14* Clipperz is distributed in the hope that it will be useful, but 14* Clipperz is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of 15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 See the GNU Affero General Public License for more details. 17 See the GNU Affero General Public License for more details.
18 18
19* You should have received a copy of the GNU Affero General Public 19* You should have received a copy of the GNU Affero General Public
20 License along with Clipperz. If not, see http://www.gnu.org/licenses/. 20 License along with Clipperz. If not, see http://www.gnu.org/licenses/.
21 21
22*/ 22*/
23 23
24if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } 24if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
25if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } 25if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
26if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } 26if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; }
27 27
28 28
29//############################################################################# 29//#############################################################################
30 30
31Clipperz.PM.DataModel.DirectLogin = function(args) { 31Clipperz.PM.DataModel.DirectLogin = function(args) {
32//MochiKit.Logging.logDebug(">>> new Clipperz.PM.DataModel.DirectLogin"); 32//MochiKit.Logging.logDebug(">>> new Clipperz.PM.DataModel.DirectLogin");
33//console.log(">>> new Clipperz.PM.DataModel.DirectLogin - args: %o", args); 33//console.log(">>> new Clipperz.PM.DataModel.DirectLogin - args: %o", args);
34//console.log("--- formData: %s", Clipperz.Base.serializeJSON(args.formData)); 34//console.log("--- formData: %s", Clipperz.Base.serializeJSON(args.formData));
35 args = args || {}; 35 args = args || {};
36 36
37//MochiKit.Logging.logDebug("--- new Clipperz.PM.DataModel.DirectLogin - args: " + Clipperz.Base.serializeJSON(MochiKit.Base.keys(args))); 37//MochiKit.Logging.logDebug("--- new Clipperz.PM.DataModel.DirectLogin - args: " + Clipperz.Base.serializeJSON(MochiKit.Base.keys(args)));
38 this._record = args.record || null; 38 this._record = args.record || null;
39 this._label = args.label || "unnamed record" 39 this._label = args.label || "unnamed record"
40 this._reference = args.reference || Clipperz.PM.Crypto.randomKey(); 40 this._reference = args.reference || Clipperz.PM.Crypto.randomKey();
41 this._favicon = args.favicon || null; 41 this._favicon = Clipperz.Base.sanitizeFavicon(args.favicon) || null;
42 this._bookmarkletVersion = args.bookmarkletVersion || "0.1"; 42 this._bookmarkletVersion = args.bookmarkletVersion || "0.1";
43 43
44 this._directLoginInputs = null; 44 this._directLoginInputs = null;
45 45
46 this._formValues = args.formValues || {}; 46 this._formValues = args.formValues || {};
47 this.setFormData(args.formData || null); 47 this.setFormData(args.formData || null);
48//console.log("=== formData: %o", this.formData()); 48//console.log("=== formData: %o", this.formData());
49 49
50 if (args.legacyBindingData == null) { 50 if (args.legacyBindingData == null) {
51 this.setBindingData(args.bindingData || null); 51 this.setBindingData(args.bindingData || null);
52 } else { 52 } else {
53 this.setLegacyBindingData(args.legacyBindingData); 53 this.setLegacyBindingData(args.legacyBindingData);
54 } 54 }
55 55
56 this._fixedFavicon = null; 56 this._fixedFavicon = null;
57 57
58 //this._formValues = args.formValues || (this.hasValuesToSet() ? {} : null); 58 //this._formValues = args.formValues || (this.hasValuesToSet() ? {} : null);
59//MochiKit.Logging.logDebug("<<< new Clipperz.PM.DataModel.DirectLogin"); 59//MochiKit.Logging.logDebug("<<< new Clipperz.PM.DataModel.DirectLogin");
60 60
61 return this; 61 return this;
62} 62}
63 63
64Clipperz.PM.DataModel.DirectLogin.prototype = MochiKit.Base.update(null, { 64Clipperz.PM.DataModel.DirectLogin.prototype = MochiKit.Base.update(null, {
65 65
66 'remove': function() { 66 'remove': function() {
67 this.record().removeDirectLogin(this); 67 this.record().removeDirectLogin(this);
68 }, 68 },
69 69
70 //------------------------------------------------------------------------- 70 //-------------------------------------------------------------------------
71 71
72 'record': function() { 72 'record': function() {
73 return this._record; 73 return this._record;
74 }, 74 },
75 75
76 //------------------------------------------------------------------------- 76 //-------------------------------------------------------------------------
77 77
78 'user': function() { 78 'user': function() {
79 return this.record().user(); 79 return this.record().user();
80 }, 80 },
81 81
82 //------------------------------------------------------------------------- 82 //-------------------------------------------------------------------------
83 83
84 'reference': function() { 84 'reference': function() {
85 return this._reference; 85 return this._reference;
86 }, 86 },
87 87
88 //------------------------------------------------------------------------- 88 //-------------------------------------------------------------------------
89 89
90 'label': function() { 90 'label': function() {
91 return this._label; 91 return this._label;
92 }, 92 },
93 93
94 'setLabel': function(aValue) { 94 'setLabel': function(aValue) {
95 this._label = aValue; 95 this._label = aValue;
96 }, 96 },
97 97
98 //------------------------------------------------------------------------- 98 //-------------------------------------------------------------------------
99 99
100 'favicon': function() { 100 'favicon': function() {
101 if (this._favicon == null) { 101 if (this._favicon == null) {
102 varactionUrl; 102 varactionUrl;
103 var hostname; 103 var hostname;
104 104
105 actionUrl = this.formData()['attributes']['action']; 105 actionUrl = this.action();
106 hostname = actionUrl.replace(/^https?:\/\/([^\/]*)\/.*/, '$1'); 106 hostname = actionUrl.replace(/^https?:\/\/([^\/]*)\/.*/, '$1');
107 this._favicon = "http://" + hostname + "/favicon.ico"; 107 this._favicon = Clipperz.Base.sanitizeFavicon("http://" + hostname + "/favicon.ico");
108 } 108 }
109 109
110 return this._favicon; 110 return this._favicon;
111 }, 111 },
112 112
113 //------------------------------------------------------------------------- 113 //-------------------------------------------------------------------------
114 114
115 'fixedFavicon': function() { 115 'fixedFavicon': function() {
116 var result; 116 var result;
117 117
118 if (this._fixedFavicon == null) { 118 if (this._fixedFavicon == null) {
119 result = this.favicon(); 119 result = this.favicon();
120 120
121 if (Clipperz_IEisBroken) { 121 if (Clipperz_IEisBroken) {
122 if (this.user().preferences().disableUnsecureFaviconLoadingForIE()) { 122 if (this.user().preferences().disableUnsecureFaviconLoadingForIE()) {
123 if (result.indexOf('https://') != 0) { 123 if (result.indexOf('https://') != 0) {
124 result = Clipperz.PM.Strings['defaultFaviconUrl_IE']; 124 result = Clipperz.PM.Strings['defaultFaviconUrl_IE'];
125 this.setFixedFavicon(result); 125 this.setFixedFavicon(result);
126 } 126 }
127 } 127 }
128 } 128 }
129 } else { 129 } else {
130 result = this._fixedFavicon; 130 result = this._fixedFavicon;
131 } 131 }
132 132
133 return result; 133 return result;
134 }, 134 },
135 135
136 'setFixedFavicon': function(aValue) { 136 'setFixedFavicon': function(aValue) {
137 this._fixedFavicon = aValue; 137 this._fixedFavicon = aValue;
138 }, 138 },
139 139
140 'action': function () {
141 varresult;
142
143 result = Clipperz.Base.sanitizeUrl(this.formData()['attributes']['action']);
144
145 return result;
146 },
147
140 //------------------------------------------------------------------------- 148 //-------------------------------------------------------------------------
141 149
142 'bookmarkletVersion': function() { 150 'bookmarkletVersion': function() {
143 return this._bookmarkletVersion; 151 return this._bookmarkletVersion;
144 }, 152 },
145 153
146 'setBookmarkletVersion': function(aValue) { 154 'setBookmarkletVersion': function(aValue) {
147 this._bookmarkletVersion = aValue; 155 this._bookmarkletVersion = aValue;
148 }, 156 },
149 157
150 //------------------------------------------------------------------------- 158 //-------------------------------------------------------------------------
151 159
152 'formData': function() { 160 'formData': function() {
153 return this._formData; 161 return this._formData;
154 }, 162 },
155 163
156 'setFormData': function(aValue) { 164 'setFormData': function(aValue) {
157 var formData; 165 var formData;
158 166
159//MochiKit.Logging.logDebug(">>> DirectLogin.setFormData - " + Clipperz.Base.serializeJSON(aValue)); 167//MochiKit.Logging.logDebug(">>> DirectLogin.setFormData - " + Clipperz.Base.serializeJSON(aValue));
160 switch (this.bookmarkletVersion()) { 168 switch (this.bookmarkletVersion()) {
161 case "0.2": 169 case "0.2":
162 formData = aValue; 170 formData = aValue;
163 break; 171 break;
164 case "0.1": 172 case "0.1":
165//MochiKit.Logging.logDebug("--- DirectLogin.setFormData - fixing form data from bookmarklet version 0.1"); 173//MochiKit.Logging.logDebug("--- DirectLogin.setFormData - fixing form data from bookmarklet version 0.1");
166 formData = this.fixFormDataFromBookmarkletVersion_0_1(aValue); 174 formData = this.fixFormDataFromBookmarkletVersion_0_1(aValue);
167 break; 175 break;
168 } 176 }
169 177
170 this._formData = aValue; 178 this._formData = aValue;
171 this.setBookmarkletVersion("0.2"); 179 this.setBookmarkletVersion("0.2");
172 180
173//MochiKit.Logging.logDebug("--- DirectLogin.setFormData - formData: " + Clipperz.Base.serializeJSON(formData)); 181//MochiKit.Logging.logDebug("--- DirectLogin.setFormData - formData: " + Clipperz.Base.serializeJSON(formData));
174 if (formData != null) { 182 if (formData != null) {
175 var i,c; 183 var i,c;
176 184
177 this._directLoginInputs = []; 185 this._directLoginInputs = [];
178 c = formData['inputs'].length; 186 c = formData['inputs'].length;
179 for (i=0; i<c; i++) { 187 for (i=0; i<c; i++) {
180 var directLoginInput; 188 var directLoginInput;
181 189
182 directLoginInput = new Clipperz.PM.DataModel.DirectLoginInput(this, formData['inputs'][i]); 190 directLoginInput = new Clipperz.PM.DataModel.DirectLoginInput(this, formData['inputs'][i]);
183 this._directLoginInputs.push(directLoginInput); 191 this._directLoginInputs.push(directLoginInput);
184 } 192 }
185 } 193 }
186//MochiKit.Logging.logDebug("<<< DirectLogin.setFormData"); 194//MochiKit.Logging.logDebug("<<< DirectLogin.setFormData");
187 }, 195 },
188 196
189 'fixFormDataFromBookmarkletVersion_0_1': function(aValue) { 197 'fixFormDataFromBookmarkletVersion_0_1': function(aValue) {
190//{"type":"radio", "name":"action", "value":"new-user", "checked":false }, { "type":"radio", "name":"action", "value":"sign-in", "checked":true } 198//{"type":"radio", "name":"action", "value":"new-user", "checked":false }, { "type":"radio", "name":"action", "value":"sign-in", "checked":true }
191 // || 199 // ||
192 // \ / 200 // \ /
193 // \/ 201 // \/
194//{"name":"dominio", "type":"radio", "options":[{"value":"@alice.it", "checked":true}, {"value":"@tin.it", "checked":false}, {"value":"@virgilio.it", "checked":false}, {"value":"@tim.it", "checked":false}]} 202//{"name":"dominio", "type":"radio", "options":[{"value":"@alice.it", "checked":true}, {"value":"@tin.it", "checked":false}, {"value":"@virgilio.it", "checked":false}, {"value":"@tim.it", "checked":false}]}
195 var result; 203 var result;
196 var inputs; 204 var inputs;
197 var updatedInputs; 205 var updatedInputs;
198 var radios; 206 var radios;
199 207
200//MochiKit.Logging.logDebug(">>> DirectLogin.fixFormDataFromBookmarkletVersion_0_1"); 208//MochiKit.Logging.logDebug(">>> DirectLogin.fixFormDataFromBookmarkletVersion_0_1");
201 result = aValue; 209 result = aValue;
202 inputs = aValue['inputs']; 210 inputs = aValue['inputs'];
203 211
204 updatedInputs = MochiKit.Base.filter(function(anInput) { 212 updatedInputs = MochiKit.Base.filter(function(anInput) {
205 varresult; 213 varresult;
206 var type; 214 var type;
207 215
208 type = anInput['type'] || 'text'; 216 type = anInput['type'] || 'text';
209 result = type.toLowerCase() != 'radio'; 217 result = type.toLowerCase() != 'radio';
210 218
211 return result; 219 return result;
212 }, inputs); 220 }, inputs);
213 radios = MochiKit.Base.filter(function(anInput) { 221 radios = MochiKit.Base.filter(function(anInput) {
214 varresult; 222 varresult;
215 var type; 223 var type;
216 224
217 type = anInput['type'] || 'text'; 225 type = anInput['type'] || 'text';
218 result = type.toLowerCase() == 'radio'; 226 result = type.toLowerCase() == 'radio';
219 227
220 return result; 228 return result;
221 }, inputs); 229 }, inputs);
222 230
223 if (radios.length > 0) { 231 if (radios.length > 0) {
224 var updatedRadios; 232 var updatedRadios;
225 233
226 updatedRadios = {}; 234 updatedRadios = {};
227 MochiKit.Iter.forEach(radios, MochiKit.Base.bind(function(aRadio) { 235 MochiKit.Iter.forEach(radios, MochiKit.Base.bind(function(aRadio) {
228 varradioConfiguration; 236 varradioConfiguration;
229 237
230 radioConfiguration = updatedRadios[aRadio['name']]; 238 radioConfiguration = updatedRadios[aRadio['name']];
231 if (radioConfiguration == null) { 239 if (radioConfiguration == null) {
232 radioConfiguration = {type:'radio', name:aRadio['name'], options:[]}; 240 radioConfiguration = {type:'radio', name:aRadio['name'], options:[]};
233 updatedRadios[aRadio['name']] = radioConfiguration; 241 updatedRadios[aRadio['name']] = radioConfiguration;
234 } 242 }
235 243
@@ -349,183 +357,183 @@ Clipperz.PM.DataModel.DirectLogin.prototype = MochiKit.Base.update(null, {
349 this._bindings = {}; 357 this._bindings = {};
350 358
351 for (bindingKey in aValue) { 359 for (bindingKey in aValue) {
352 var directLoginBinding; 360 var directLoginBinding;
353 361
354 directLoginBinding = new Clipperz.PM.DataModel.DirectLoginBinding(this, bindingKey, {fieldName:aValue[bindingKey]}); 362 directLoginBinding = new Clipperz.PM.DataModel.DirectLoginBinding(this, bindingKey, {fieldName:aValue[bindingKey]});
355 this._bindings[bindingKey] = directLoginBinding; 363 this._bindings[bindingKey] = directLoginBinding;
356 } 364 }
357//MochiKit.Logging.logDebug("<<< DirectLogin.setLegacyBindingData"); 365//MochiKit.Logging.logDebug("<<< DirectLogin.setLegacyBindingData");
358 }, 366 },
359 367
360 //......................................................................... 368 //.........................................................................
361 369
362 'bindings': function() { 370 'bindings': function() {
363 return this._bindings; 371 return this._bindings;
364 }, 372 },
365 373
366 //------------------------------------------------------------------------- 374 //-------------------------------------------------------------------------
367 375
368 'serializedData': function() { 376 'serializedData': function() {
369 var result; 377 var result;
370 varbindingKey; 378 varbindingKey;
371 379
372 result = {}; 380 result = {};
373 // result.reference = this.reference(); 381 // result.reference = this.reference();
374 result.label = this.label(); 382 result.label = this.label();
375 result.favicon = this.favicon() || ""; 383 result.favicon = this.favicon() || "";
376 result.bookmarkletVersion = this.bookmarkletVersion(); 384 result.bookmarkletVersion = this.bookmarkletVersion();
377 result.formData = this.formData(); 385 result.formData = this.formData();
378 if (this.hasValuesToSet) { 386 if (this.hasValuesToSet) {
379 result.formValues = this.formValues(); 387 result.formValues = this.formValues();
380 } 388 }
381 result.bindingData = {}; 389 result.bindingData = {};
382 390
383 for (bindingKey in this.bindings()) { 391 for (bindingKey in this.bindings()) {
384 result.bindingData[bindingKey] = this.bindings()[bindingKey].serializedData(); 392 result.bindingData[bindingKey] = this.bindings()[bindingKey].serializedData();
385 } 393 }
386 394
387 return result; 395 return result;
388 }, 396 },
389 397
390 //------------------------------------------------------------------------- 398 //-------------------------------------------------------------------------
391 399
392 'handleMissingFaviconImage': function(anEvent) { 400 'handleMissingFaviconImage': function(anEvent) {
393 anEvent.stop(); 401 anEvent.stop();
394 MochiKit.Signal.disconnectAll(anEvent.src()); 402 MochiKit.Signal.disconnectAll(anEvent.src());
395 this.setFixedFavicon(Clipperz.PM.Strings['defaultFaviconUrl']); 403 this.setFixedFavicon(Clipperz.PM.Strings['defaultFaviconUrl']);
396 anEvent.src().src = this.fixedFavicon(); 404 anEvent.src().src = this.fixedFavicon();
397 }, 405 },
398 406
399 //========================================================================= 407 //=========================================================================
400 408
401 'runHttpAuthDirectLogin': function(aWindow) { 409 'runHttpAuthDirectLogin': function(aWindow) {
402 MochiKit.DOM.withWindow(aWindow, MochiKit.Base.bind(function() { 410 MochiKit.DOM.withWindow(aWindow, MochiKit.Base.bind(function() {
403 var completeUrl; 411 var completeUrl;
404 var url; 412 var url;
405 413
406 url = this.bindings()['url'].field().value(); 414 url = this.bindings()['url'].field().value();
407 415
408 if (/^https?\:\/\//.test(url) == false) { 416 if (/^https?\:\/\//.test(url) == false) {
409 url = 'http://' + url; 417 url = 'http://' + url;
410 } 418 }
411 419
412 if (Clipperz_IEisBroken === true) { 420 if (Clipperz_IEisBroken === true) {
413 completeUrl = url; 421 completeUrl = url;
414 } else { 422 } else {
415 var username; 423 var username;
416 var password; 424 var password;
417 425
418 username = this.bindings()['username'].field().value(); 426 username = this.bindings()['username'].field().value();
419 password = this.bindings()['password'].field().value(); 427 password = this.bindings()['password'].field().value();
420 428
421 /(^https?\:\/\/)?(.*)/.test(url); 429 /(^https?\:\/\/)?(.*)/.test(url);
422 430
423 completeUrl = RegExp.$1 + username + ':' + password + '@' + RegExp.$2; 431 completeUrl = RegExp.$1 + username + ':' + password + '@' + RegExp.$2;
424 } 432 }
425 433
426 MochiKit.DOM.currentWindow().location.href = completeUrl; 434 MochiKit.DOM.currentWindow().location.href = completeUrl;
427 }, this)); 435 }, this));
428 }, 436 },
429 437
430 //------------------------------------------------------------------------- 438 //-------------------------------------------------------------------------
431 439
432 'runSubmitFormDirectLogin': function(aWindow) { 440 'runSubmitFormDirectLogin': function(aWindow) {
433 MochiKit.DOM.withWindow(aWindow, MochiKit.Base.bind(function() { 441 MochiKit.DOM.withWindow(aWindow, MochiKit.Base.bind(function() {
434 var formElement; 442 var formElement;
435 varformSubmitFunction; 443 varformSubmitFunction;
436 var submitButtons; 444 var submitButtons;
437 445
438//MochiKit.Logging.logDebug("### runDirectLogin - 3"); 446//MochiKit.Logging.logDebug("### runDirectLogin - 3");
439 // MochiKit.DOM.currentDocument().write('<html><head><title>' + this.label() + '</title><META http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body></body></html>') 447 // MochiKit.DOM.currentDocument().write('<html><head><title>' + this.label() + '</title><META http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body></body></html>')
440//MochiKit.Logging.logDebug("### runDirectLogin - 3.1"); 448//MochiKit.Logging.logDebug("### runDirectLogin - 3.1");
441 MochiKit.DOM.appendChildNodes(MochiKit.DOM.currentDocument().body, MochiKit.DOM.H3(null, "Loading " + this.label() + " ...")); 449 MochiKit.DOM.appendChildNodes(MochiKit.DOM.currentDocument().body, MochiKit.DOM.H3(null, "Loading " + this.label() + " ..."));
442//MochiKit.Logging.logDebug("### runDirectLogin - 4"); 450//MochiKit.Logging.logDebug("### runDirectLogin - 4");
443//console.log(this.formData()['attributes']); 451//console.log(this.formData()['attributes']);
444 formElement = MochiKit.DOM.FORM(MochiKit.Base.update({id:'directLoginForm'}, {'method':this.formData()['attributes']['method'], 452 formElement = MochiKit.DOM.FORM(MochiKit.Base.update({id:'directLoginForm'}, {'method':this.formData()['attributes']['method'],
445 'action':this.formData()['attributes']['action']})); 453 'action': this.action()}));
446//MochiKit.Logging.logDebug("### runDirectLogin - 5"); 454//MochiKit.Logging.logDebug("### runDirectLogin - 5");
447 formSubmitFunction = MochiKit.Base.method(formElement, 'submit'); 455 formSubmitFunction = MochiKit.Base.method(formElement, 'submit');
448//MochiKit.Logging.logDebug("### runDirectLogin - 6"); 456//MochiKit.Logging.logDebug("### runDirectLogin - 6");
449 457
450 MochiKit.DOM.appendChildNodes(MochiKit.DOM.currentDocument().body, 458 MochiKit.DOM.appendChildNodes(MochiKit.DOM.currentDocument().body,
451 MochiKit.DOM.DIV({style:'display:none; visibility:hidden;'}, formElement) 459 MochiKit.DOM.DIV({style:'display:none; visibility:hidden;'}, formElement)
452 ); 460 );
453//MochiKit.Logging.logDebug("### runDirectLogin - 7"); 461//MochiKit.Logging.logDebug("### runDirectLogin - 7");
454 MochiKit.DOM.appendChildNodes(formElement, MochiKit.Base.map(MochiKit.Base.methodcaller("formConfiguration"), 462 MochiKit.DOM.appendChildNodes(formElement, MochiKit.Base.map(MochiKit.Base.methodcaller("formConfiguration"),
455 this.directLoginInputs())); 463 this.directLoginInputs()));
456//MochiKit.Logging.logDebug("### runDirectLogin - 8"); 464//MochiKit.Logging.logDebug("### runDirectLogin - 8");
457 465
458 submitButtons = MochiKit.Base.filter(function(anInputElement) { 466 submitButtons = MochiKit.Base.filter(function(anInputElement) {
459//MochiKit.Logging.logDebug("### runDirectLogin - 8.1 - " + anInputElement); 467//MochiKit.Logging.logDebug("### runDirectLogin - 8.1 - " + anInputElement);
460//MochiKit.Logging.logDebug("### runDirectLogin - 8.2 - " + anInputElement.tagName); 468//MochiKit.Logging.logDebug("### runDirectLogin - 8.2 - " + anInputElement.tagName);
461//MochiKit.Logging.logDebug("### runDirectLogin - 8.3 - " + anInputElement.getAttribute('type')); 469//MochiKit.Logging.logDebug("### runDirectLogin - 8.3 - " + anInputElement.getAttribute('type'));
462 return ((anInputElement.tagName.toLowerCase() == 'input') && (anInputElement.getAttribute('type').toLowerCase() == 'submit')); 470 return ((anInputElement.tagName.toLowerCase() == 'input') && (anInputElement.getAttribute('type').toLowerCase() == 'submit'));
463 }, formElement.elements) 471 }, formElement.elements)
464//MochiKit.Logging.logDebug("### runDirectLogin - 9"); 472//MochiKit.Logging.logDebug("### runDirectLogin - 9");
465 473
466 if (submitButtons.length == 0) { 474 if (submitButtons.length == 0) {
467//MochiKit.Logging.logDebug("### OLD submit") 475//MochiKit.Logging.logDebug("### OLD submit")
468 if (Clipperz_IEisBroken == true) { 476 if (Clipperz_IEisBroken == true) {
469//MochiKit.Logging.logDebug("### runDirectLogin - 10"); 477//MochiKit.Logging.logDebug("### runDirectLogin - 10");
470 formElement.submit(); 478 formElement.submit();
471 } else { 479 } else {
472//MochiKit.Logging.logDebug("### runDirectLogin - 11"); 480//MochiKit.Logging.logDebug("### runDirectLogin - 11");
473 formSubmitFunction(); 481 formSubmitFunction();
474 } 482 }
475 } else { 483 } else {
476//MochiKit.Logging.logDebug("### NEW submit") 484//MochiKit.Logging.logDebug("### NEW submit")
477 submitButtons[0].click(); 485 submitButtons[0].click();
478 } 486 }
479 487
480 }, this)); 488 }, this));
481 }, 489 },
482 490
483 //------------------------------------------------------------------------- 491 //-------------------------------------------------------------------------
484 492
485 'runDirectLogin': function(aNewWindow) { 493 'runDirectLogin': function(aNewWindow) {
486 varnewWindow; 494 varnewWindow;
487 495
488//console.log("formData.attributes", this.formData()['attributes']); 496//console.log("formData.attributes", this.formData()['attributes']);
489 // if (/^javascript/.test(this.formData()['attributes']['action'])) { 497 // if (/^javascript/.test(this.formData()['attributes']['action'])) {
490 if ((/^(https?|webdav|ftp)\:/.test(this.formData()['attributes']['action']) == false) && 498 if ((/^(https?|webdav|ftp)\:/.test(this.action()) == false) &&
491 (this.formData()['attributes']['type'] != 'http_auth')) 499 (this.formData()['attributes']['type'] != 'http_auth')
492 { 500 ) {
493 var messageBoxConfiguration; 501 var messageBoxConfiguration;
494 502
495 if (typeof(aNewWindow) != 'undefined') { 503 if (typeof(aNewWindow) != 'undefined') {
496 aNewWindow.close(); 504 aNewWindow.close();
497 } 505 }
498 506
499 messageBoxConfiguration = {}; 507 messageBoxConfiguration = {};
500 messageBoxConfiguration.title = Clipperz.PM.Strings['VulnerabilityWarning_Panel_title']; 508 messageBoxConfiguration.title = Clipperz.PM.Strings['VulnerabilityWarning_Panel_title'];
501 messageBoxConfiguration.msg = Clipperz.PM.Strings['VulnerabilityWarning_Panel_message']; 509 messageBoxConfiguration.msg = Clipperz.PM.Strings['VulnerabilityWarning_Panel_message'];
502 messageBoxConfiguration.animEl = YAHOO.ext.Element.get("mainDiv"); 510 messageBoxConfiguration.animEl = YAHOO.ext.Element.get("mainDiv");
503 messageBoxConfiguration.progress = false; 511 messageBoxConfiguration.progress = false;
504 messageBoxConfiguration.closable = false; 512 messageBoxConfiguration.closable = false;
505 messageBoxConfiguration.buttons = {'cancel': Clipperz.PM.Strings['VulnerabilityWarning_Panel_buttonLabel']}; 513 messageBoxConfiguration.buttons = {'cancel': Clipperz.PM.Strings['VulnerabilityWarning_Panel_buttonLabel']};
506 514
507 Clipperz.YUI.MessageBox.show(messageBoxConfiguration); 515 Clipperz.YUI.MessageBox.show(messageBoxConfiguration);
508 516
509 throw Clipperz.Base.exception.VulnerabilityIssue; 517 throw Clipperz.Base.exception.VulnerabilityIssue;
510 } 518 }
511 519
512//MochiKit.Logging.logDebug("### runDirectLogin - 1 : " + Clipperz.Base.serializeJSON(this.serializedData())); 520//MochiKit.Logging.logDebug("### runDirectLogin - 1 : " + Clipperz.Base.serializeJSON(this.serializedData()));
513 if (typeof(aNewWindow) == 'undefined') { 521 if (typeof(aNewWindow) == 'undefined') {
514 newWindow = window.open(Clipperz.PM.Strings['directLoginJumpPageUrl'], ""); 522 newWindow = window.open(Clipperz.PM.Strings['directLoginJumpPageUrl'], "");
515 } else { 523 } else {
516 newWindow = aNewWindow; 524 newWindow = aNewWindow;
517 } 525 }
518//MochiKit.Logging.logDebug("### runDirectLogin - 2"); 526//MochiKit.Logging.logDebug("### runDirectLogin - 2");
519 527
520 if (this.formData()['attributes']['type'] == 'http_auth') { 528 if (this.formData()['attributes']['type'] == 'http_auth') {
521 this.runHttpAuthDirectLogin(newWindow); 529 this.runHttpAuthDirectLogin(newWindow);
522 } else { 530 } else {
523 this.runSubmitFormDirectLogin(newWindow) 531 this.runSubmitFormDirectLogin(newWindow)
524 } 532 }
525 }, 533 },
526 534
527 //------------------------------------------------------------------------- 535 //-------------------------------------------------------------------------
528 __syntaxFix__: "syntax fix" 536 __syntaxFix__: "syntax fix"
529 537
530}); 538});
531 539