Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/Proxy') (more/less context) (ignore whitespace changes)
5 files changed, 54 insertions, 88 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.JSON.js b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.JSON.js index 5b39b4a..7d10dd4 100755 --- a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.JSON.js +++ b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.JSON.js | |||
@@ -1,91 +1,89 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * 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 |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 25 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
28 | 26 | ||
29 | //============================================================================= | 27 | //============================================================================= |
30 | 28 | ||
31 | Clipperz.PM.Proxy.JSON = function(args) { | 29 | Clipperz.PM.Proxy.JSON = function(args) { |
32 | Clipperz.PM.Proxy.JSON.superclass.constructor.call(this, args); | 30 | Clipperz.PM.Proxy.JSON.superclass.constructor.call(this, args); |
33 | 31 | ||
34 | this._url = args.url || Clipperz.Base.exception.raise('MandatoryParameter'); | 32 | this._url = args.url || Clipperz.Base.exception.raise('MandatoryParameter'); |
35 | 33 | ||
36 | return this; | 34 | return this; |
37 | } | 35 | } |
38 | 36 | ||
39 | Clipperz.Base.extend(Clipperz.PM.Proxy.JSON, Clipperz.PM.Proxy, { | 37 | Clipperz.Base.extend(Clipperz.PM.Proxy.JSON, Clipperz.PM.Proxy, { |
40 | 38 | ||
41 | 'toString': function() { | 39 | 'toString': function() { |
42 | return "Clipperz.PM.Proxy.JSON"; | 40 | return "Clipperz.PM.Proxy.JSON"; |
43 | }, | 41 | }, |
44 | 42 | ||
45 | //========================================================================= | 43 | //========================================================================= |
46 | 44 | ||
47 | 'url': function () { | 45 | 'url': function () { |
48 | return this._url; | 46 | return this._url; |
49 | }, | 47 | }, |
50 | 48 | ||
51 | //========================================================================= | 49 | //========================================================================= |
52 | 50 | ||
53 | 'sendMessage': function(aFunctionName, someParameters) { | 51 | 'sendMessage': function(aFunctionName, someParameters) { |
54 | vardeferredResult; | 52 | vardeferredResult; |
55 | var parameters; | 53 | var parameters; |
56 | 54 | ||
57 | parameters = { | 55 | parameters = { |
58 | method: aFunctionName, | 56 | method: aFunctionName, |
59 | // version: someParameters['version'], | 57 | // version: someParameters['version'], |
60 | // message: someParameters['message'], | 58 | // message: someParameters['message'], |
61 | parameters: Clipperz.Base.serializeJSON(someParameters) | 59 | parameters: Clipperz.Base.serializeJSON(someParameters) |
62 | }; | 60 | }; |
63 | 61 | ||
64 | deferredResult = new Clipperz.Async.Deferred("Proxy.JSON.sendMessage", {trace:false}); | 62 | deferredResult = new Clipperz.Async.Deferred("Proxy.JSON.sendMessage", {trace:false}); |
65 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'remoteRequestSent'); | 63 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'remoteRequestSent'); |
66 | deferredResult.addCallback(MochiKit.Async.doXHR, this.url(), { | 64 | deferredResult.addCallback(MochiKit.Async.doXHR, this.url(), { |
67 | method:'POST', | 65 | method:'POST', |
68 | sendContent:MochiKit.Base.queryString(parameters), | 66 | sendContent:MochiKit.Base.queryString(parameters), |
69 | headers:{"Content-Type":"application/x-www-form-urlencoded"} | 67 | headers:{"Content-Type":"application/x-www-form-urlencoded"} |
70 | }); | 68 | }); |
71 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'remoteRequestReceived'); | 69 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'remoteRequestReceived'); |
72 | // deferredResult.addCallback(MochiKit.Async.evalJSONRequest); | 70 | // deferredResult.addCallback(MochiKit.Async.evalJSONRequest); |
73 | deferredResult.addCallback(MochiKit.Base.itemgetter('responseText')); | 71 | deferredResult.addCallback(MochiKit.Base.itemgetter('responseText')); |
74 | deferredResult.addCallback(Clipperz.Base.evalJSON); | 72 | deferredResult.addCallback(Clipperz.Base.evalJSON); |
75 | deferredResult.addCallback(function (someValues) { | 73 | deferredResult.addCallback(function (someValues) { |
76 | if (someValues['result'] == 'EXCEPTION') { | 74 | if (someValues['result'] == 'EXCEPTION') { |
77 | throw someValues['message']; | 75 | throw someValues['message']; |
78 | } | 76 | } |
79 | 77 | ||
80 | return someValues; | 78 | return someValues; |
81 | }) | 79 | }) |
82 | // return MochiKit.Base.evalJSON(req.responseText); | 80 | // return MochiKit.Base.evalJSON(req.responseText); |
83 | deferredResult.callback(); | 81 | deferredResult.callback(); |
84 | 82 | ||
85 | return deferredResult; | 83 | return deferredResult; |
86 | }, | 84 | }, |
87 | 85 | ||
88 | //========================================================================= | 86 | //========================================================================= |
89 | __syntaxFix__: "syntax fix" | 87 | __syntaxFix__: "syntax fix" |
90 | 88 | ||
91 | }); | 89 | }); |
diff --git a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js index 01ba122..326022c 100644 --- a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js +++ b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js | |||
@@ -1,808 +1,788 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * 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 |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | try { if (typeof(Clipperz.PM.Proxy.Offline) == 'undefined') { throw ""; }} catch (e) { | 24 | try { if (typeof(Clipperz.PM.Proxy.Offline) == 'undefined') { throw ""; }} catch (e) { |
27 | throw "Clipperz.PM.Proxy.Offline.DataStore depends on Clipperz.PM.Proxy.Offline!"; | 25 | throw "Clipperz.PM.Proxy.Offline.DataStore depends on Clipperz.PM.Proxy.Offline!"; |
28 | } | 26 | } |
29 | 27 | ||
30 | //============================================================================= | 28 | //============================================================================= |
31 | 29 | ||
32 | Clipperz.PM.Proxy.Offline.DataStore = function(args) { | 30 | Clipperz.PM.Proxy.Offline.DataStore = function(args) { |
33 | args = args || {}; | 31 | args = args || {}; |
34 | 32 | ||
35 | this._data = args.data || (typeof(_clipperz_dump_data_) != 'undefined' ? _clipperz_dump_data_ : null); | 33 | this._data = args.data || (typeof(_clipperz_dump_data_) != 'undefined' ? _clipperz_dump_data_ : null); |
36 | this._isReadOnly = (typeof(args.readOnly) == 'undefined' ? true : args.readOnly); | 34 | this._isReadOnly = (typeof(args.readOnly) == 'undefined' ? true : args.readOnly); |
37 | this._shouldPayTolls = args.shouldPayTolls || false; | 35 | this._shouldPayTolls = args.shouldPayTolls || false; |
38 | 36 | ||
39 | this._tolls = {}; | 37 | this._tolls = {}; |
40 | this._currentStaticConnection = null; | 38 | this._currentStaticConnection = null; |
41 | 39 | ||
42 | return this; | 40 | return this; |
43 | } | 41 | } |
44 | 42 | ||
45 | Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, { | 43 | Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, { |
46 | 44 | ||
47 | //------------------------------------------------------------------------- | 45 | //------------------------------------------------------------------------- |
48 | 46 | ||
49 | 'isReadOnly': function () { | 47 | 'isReadOnly': function () { |
50 | return this._isReadOnly; | 48 | return this._isReadOnly; |
51 | }, | 49 | }, |
52 | 50 | ||
53 | //------------------------------------------------------------------------- | 51 | //------------------------------------------------------------------------- |
54 | 52 | ||
55 | 'shouldPayTolls': function() { | 53 | 'shouldPayTolls': function() { |
56 | return this._shouldPayTolls; | 54 | return this._shouldPayTolls; |
57 | }, | 55 | }, |
58 | 56 | ||
59 | //------------------------------------------------------------------------- | 57 | //------------------------------------------------------------------------- |
60 | 58 | ||
61 | 'data': function () { | 59 | 'data': function () { |
62 | return this._data; | 60 | return this._data; |
63 | }, | 61 | }, |
64 | 62 | ||
65 | //------------------------------------------------------------------------- | 63 | //------------------------------------------------------------------------- |
66 | 64 | ||
67 | 'tolls': function () { | 65 | 'tolls': function () { |
68 | return this._tolls; | 66 | return this._tolls; |
69 | }, | 67 | }, |
70 | 68 | ||
71 | //========================================================================= | 69 | //========================================================================= |
72 | 70 | ||
73 | 'resetData': function() { | 71 | 'resetData': function() { |
74 | this._data = { | 72 | this._data = { |
75 | 'users': { | 73 | 'users': { |
76 | 'catchAllUser': { | 74 | 'catchAllUser': { |
77 | __masterkey_test_value__: 'masterkey', | 75 | __masterkey_test_value__: 'masterkey', |
78 | s: '112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00', | 76 | s: '112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00', |
79 | v: '112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00' | 77 | v: '112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00' |
80 | } | 78 | } |
81 | } | 79 | } |
82 | }; | 80 | }; |
83 | }, | 81 | }, |
84 | 82 | ||
85 | //------------------------------------------------------------------------- | 83 | //------------------------------------------------------------------------- |
86 | 84 | ||
87 | 'setupWithEncryptedData': function(someData) { | 85 | 'setupWithEncryptedData': function(someData) { |
88 | this._data = Clipperz.Base.deepClone(someData); | 86 | this._data = Clipperz.Base.deepClone(someData); |
89 | }, | 87 | }, |
90 | 88 | ||
91 | //------------------------------------------------------------------------- | 89 | //------------------------------------------------------------------------- |
92 | 90 | ||
93 | 'setupWithData': function(someData) { | 91 | 'setupWithData': function(someData) { |
94 | var deferredResult; | 92 | var deferredResult; |
95 | var resultData; | 93 | var resultData; |
96 | var i, c; | 94 | var i, c; |
97 | 95 | ||
98 | //Clipperz.log(">>> Proxy.Test.setupWithData"); | 96 | //Clipperz.log(">>> Proxy.Test.setupWithData"); |
99 | resultData = this._data; | 97 | resultData = this._data; |
100 | 98 | ||
101 | deferredResult = new Clipperz.Async.Deferred("Proxy.Test.seupWithData", {trace:false}); | 99 | deferredResult = new Clipperz.Async.Deferred("Proxy.Test.seupWithData", {trace:false}); |
102 | c = someData['users'].length; | 100 | c = someData['users'].length; |
103 | 101 | ||
104 | for (i=0; i<c; i++) { | 102 | for (i=0; i<c; i++) { |
105 | varnewConnection; | 103 | varnewConnection; |
106 | varrecordConfiguration; | 104 | varrecordConfiguration; |
107 | 105 | ||
108 | deferredResult.addMethod(this, 'userSerializedEncryptedData', someData['users'][i]); | 106 | deferredResult.addMethod(this, 'userSerializedEncryptedData', someData['users'][i]); |
109 | deferredResult.addCallback(MochiKit.Base.bind(function(aUserSerializationContext) { | 107 | deferredResult.addCallback(MochiKit.Base.bind(function(aUserSerializationContext) { |
110 | //console.log("SERIALIZED USER", aUserSerializationContext); | ||
111 | resultData['users'][aUserSerializationContext['credentials']['C']] = { | 108 | resultData['users'][aUserSerializationContext['credentials']['C']] = { |
112 | 's': aUserSerializationContext['credentials']['s'], | 109 | 's': aUserSerializationContext['credentials']['s'], |
113 | 'v': aUserSerializationContext['credentials']['v'], | 110 | 'v': aUserSerializationContext['credentials']['v'], |
114 | 'version': aUserSerializationContext['data']['connectionVersion'], | 111 | 'version': aUserSerializationContext['data']['connectionVersion'], |
115 | 'userDetails': aUserSerializationContext['encryptedData']['user']['header'], | 112 | 'userDetails': aUserSerializationContext['encryptedData']['user']['header'], |
116 | 'userDetailsVersion':aUserSerializationContext['encryptedData']['user']['version'], | 113 | 'userDetailsVersion':aUserSerializationContext['encryptedData']['user']['version'], |
117 | 'statistics': aUserSerializationContext['encryptedData']['user']['statistics'], | 114 | 'statistics': aUserSerializationContext['encryptedData']['user']['statistics'], |
118 | 'lock': aUserSerializationContext['encryptedData']['user']['lock'], | 115 | 'lock': aUserSerializationContext['encryptedData']['user']['lock'], |
119 | 'records': this.rearrangeRecordsData(aUserSerializationContext['encryptedData']['records']) | 116 | 'records': this.rearrangeRecordsData(aUserSerializationContext['encryptedData']['records']) |
120 | } | 117 | } |
121 | }, this)); | 118 | }, this)); |
122 | } | 119 | } |
123 | 120 | ||
124 | deferredResult.addCallback(MochiKit.Base.bind(function() { | 121 | deferredResult.addCallback(MochiKit.Base.bind(function() { |
125 | //console.log("this._data", resultData); | ||
126 | this._data = resultData; | 122 | this._data = resultData; |
127 | }, this)); | 123 | }, this)); |
128 | 124 | ||
129 | deferredResult.callback(); | 125 | deferredResult.callback(); |
130 | //Clipperz.log("<<< Proxy.Test.setupWithData"); | 126 | //Clipperz.log("<<< Proxy.Test.setupWithData"); |
131 | 127 | ||
132 | return deferredResult; | 128 | return deferredResult; |
133 | }, | 129 | }, |
134 | 130 | ||
135 | //========================================================================= | 131 | //========================================================================= |
136 | 132 | ||
137 | 'getTollForRequestType': function (aRequestType) { | 133 | 'getTollForRequestType': function (aRequestType) { |
138 | varresult; | 134 | varresult; |
139 | vartargetValue; | 135 | vartargetValue; |
140 | var cost; | 136 | var cost; |
141 | 137 | ||
142 | targetValue = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2); | 138 | targetValue = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2); |
143 | switch (aRequestType) { | 139 | switch (aRequestType) { |
144 | case 'REGISTER': | 140 | case 'REGISTER': |
145 | cost = 5; | 141 | cost = 5; |
146 | break; | 142 | break; |
147 | case 'CONNECT': | 143 | case 'CONNECT': |
148 | cost = 5; | 144 | cost = 5; |
149 | break; | 145 | break; |
150 | case 'MESSAGE': | 146 | case 'MESSAGE': |
151 | cost = 2; | 147 | cost = 2; |
152 | break; | 148 | break; |
153 | } | 149 | } |
154 | 150 | ||
155 | result = { | 151 | result = { |
156 | requestType: aRequestType, | 152 | requestType: aRequestType, |
157 | targetValue: targetValue, | 153 | targetValue: targetValue, |
158 | cost: cost | 154 | cost: cost |
159 | } | 155 | } |
160 | 156 | ||
161 | if (this.shouldPayTolls()) { | 157 | if (this.shouldPayTolls()) { |
162 | this.tolls()[targetValue] = result; | 158 | this.tolls()[targetValue] = result; |
163 | } | 159 | } |
164 | 160 | ||
165 | return result; | 161 | return result; |
166 | }, | 162 | }, |
167 | 163 | ||
168 | //------------------------------------------------------------------------- | 164 | //------------------------------------------------------------------------- |
169 | 165 | ||
170 | 'checkToll': function (aFunctionName, someParameters) { | 166 | 'checkToll': function (aFunctionName, someParameters) { |
171 | if (this.shouldPayTolls()) { | 167 | if (this.shouldPayTolls()) { |
172 | var localToll; | 168 | var localToll; |
173 | vartollParameters; | 169 | vartollParameters; |
174 | 170 | ||
175 | tollParameters = someParameters['toll']; | 171 | tollParameters = someParameters['toll']; |
176 | localToll = this.tolls()[tollParameters['targetValue']]; | 172 | localToll = this.tolls()[tollParameters['targetValue']]; |
177 | 173 | ||
178 | if (localToll != null) { | 174 | if (localToll != null) { |
179 | if (! Clipperz.PM.Toll.validate(tollParameters['targetValue'], tollParameters['toll'], localToll['cost'])) { | 175 | if (! Clipperz.PM.Toll.validate(tollParameters['targetValue'], tollParameters['toll'], localToll['cost'])) { |
180 | throw "Toll value too low."; | 176 | throw "Toll value too low."; |
181 | }; | 177 | }; |
182 | } else { | 178 | } else { |
183 | throw "Missing toll"; | 179 | throw "Missing toll"; |
184 | } | 180 | } |
185 | } | 181 | } |
186 | }, | 182 | }, |
187 | 183 | ||
188 | //========================================================================= | 184 | //========================================================================= |
189 | 185 | ||
190 | 'currentStaticConnection': function () { | 186 | 'currentStaticConnection': function () { |
191 | if (this._currentStaticConnection == null) { | 187 | if (this._currentStaticConnection == null) { |
192 | this._currentStaticConnection = {}; | 188 | this._currentStaticConnection = {}; |
193 | } | 189 | } |
194 | 190 | ||
195 | return this._currentStaticConnection; | 191 | return this._currentStaticConnection; |
196 | }, | 192 | }, |
197 | 193 | ||
198 | //------------------------------------------------------------------------- | 194 | //------------------------------------------------------------------------- |
199 | 195 | ||
200 | 'getConnectionForRequest': function (aFunctionName, someParameters) { | 196 | 'getConnectionForRequest': function (aFunctionName, someParameters) { |
201 | varresult; | 197 | varresult; |
202 | 198 | ||
203 | if (this.shouldPayTolls()) { | 199 | if (this.shouldPayTolls()) { |
204 | if ((typeof(someParameters['toll']) != 'undefined') && (typeof(someParameters['toll']['targetValue']) != 'undefined')) { | 200 | if ((typeof(someParameters['toll']) != 'undefined') && (typeof(someParameters['toll']['targetValue']) != 'undefined')) { |
205 | result = this.tolls()[someParameters['toll']['targetValue']]['connection']; | 201 | result = this.tolls()[someParameters['toll']['targetValue']]['connection']; |
206 | if (typeof(result) == 'undefined') { | 202 | if (typeof(result) == 'undefined') { |
207 | result = {}; | 203 | result = {}; |
208 | } | 204 | } |
209 | } else { | 205 | } else { |
210 | result = {}; | 206 | result = {}; |
211 | } | 207 | } |
212 | } else { | 208 | } else { |
213 | result = this.currentStaticConnection(); | 209 | result = this.currentStaticConnection(); |
214 | } | 210 | } |
215 | 211 | ||
216 | return result; | 212 | return result; |
217 | }, | 213 | }, |
218 | 214 | ||
219 | //------------------------------------------------------------------------- | 215 | //------------------------------------------------------------------------- |
220 | 216 | ||
221 | 'storeConnectionForRequestWithConnectionAndResponse': function (aFunctionName, someParameters, aConnection, aResponse) { | 217 | 'storeConnectionForRequestWithConnectionAndResponse': function (aFunctionName, someParameters, aConnection, aResponse) { |
222 | if (this.shouldPayTolls()) { | 218 | if (this.shouldPayTolls()) { |
223 | if ((typeof(aResponse['toll']) != 'undefined') | 219 | if ((typeof(aResponse['toll']) != 'undefined') |
224 | &&(typeof(aResponse['toll']['targetValue']) != 'undefined') | 220 | &&(typeof(aResponse['toll']['targetValue']) != 'undefined') |
225 | &&(typeof(this.tolls()[aResponse['toll']['targetValue']]) != 'undefined') | 221 | &&(typeof(this.tolls()[aResponse['toll']['targetValue']]) != 'undefined') |
226 | ) { | 222 | ) { |
227 | this.tolls()[aResponse['toll']['targetValue']]['connection'] = aConnection; | 223 | this.tolls()[aResponse['toll']['targetValue']]['connection'] = aConnection; |
228 | } | 224 | } |
229 | } | 225 | } |
230 | }, | 226 | }, |
231 | 227 | ||
232 | //========================================================================= | 228 | //========================================================================= |
233 | 229 | ||
234 | 'processMessage': function (aFunctionName, someParameters) { | 230 | 'processMessage': function (aFunctionName, someParameters) { |
235 | var result; | 231 | var result; |
236 | varconnection; | 232 | varconnection; |
237 | 233 | ||
238 | connection = this.getConnectionForRequest(aFunctionName, someParameters); | 234 | connection = this.getConnectionForRequest(aFunctionName, someParameters); |
239 | 235 | ||
240 | switch(aFunctionName) { | 236 | switch(aFunctionName) { |
241 | case 'knock': | 237 | case 'knock': |
242 | result = this._knock(connection, someParameters); | 238 | result = this._knock(connection, someParameters); |
243 | break; | 239 | break; |
244 | case 'registration': | 240 | case 'registration': |
245 | this.checkToll(aFunctionName, someParameters); | 241 | this.checkToll(aFunctionName, someParameters); |
246 | result = this._registration(connection, someParameters.parameters); | 242 | result = this._registration(connection, someParameters.parameters); |
247 | break; | 243 | break; |
248 | case 'handshake': | 244 | case 'handshake': |
249 | this.checkToll(aFunctionName, someParameters); | 245 | this.checkToll(aFunctionName, someParameters); |
250 | result = this._handshake(connection, someParameters.parameters); | 246 | result = this._handshake(connection, someParameters.parameters); |
251 | break; | 247 | break; |
252 | case 'message': | 248 | case 'message': |
253 | this.checkToll(aFunctionName, someParameters); | 249 | this.checkToll(aFunctionName, someParameters); |
254 | result = this._message(connection, someParameters.parameters); | 250 | result = this._message(connection, someParameters.parameters); |
255 | break; | 251 | break; |
256 | case 'logout': | 252 | case 'logout': |
257 | this._currentStaticConnection = null; | 253 | this._currentStaticConnection = null; |
258 | result = this._logout(connection, someParameters.parameters); | 254 | result = this._logout(connection, someParameters.parameters); |
259 | break; | 255 | break; |
260 | } | 256 | } |
261 | 257 | ||
262 | this.storeConnectionForRequestWithConnectionAndResponse(aFunctionName, someParameters, connection, result); | 258 | this.storeConnectionForRequestWithConnectionAndResponse(aFunctionName, someParameters, connection, result); |
263 | 259 | ||
264 | return MochiKit.Async.succeed(result); | 260 | return MochiKit.Async.succeed(result); |
265 | }, | 261 | }, |
266 | 262 | ||
267 | //========================================================================= | 263 | //========================================================================= |
268 | 264 | ||
269 | '_knock': function(aConnection, someParameters) { | 265 | '_knock': function(aConnection, someParameters) { |
270 | var result; | 266 | var result; |
271 | 267 | ||
272 | result = { | 268 | result = { |
273 | toll: this.getTollForRequestType(someParameters['requestType']) | 269 | toll: this.getTollForRequestType(someParameters['requestType']) |
274 | } | 270 | } |
275 | 271 | ||
276 | return result; | 272 | return result; |
277 | }, | 273 | }, |
278 | 274 | ||
279 | //------------------------------------------------------------------------- | 275 | //------------------------------------------------------------------------- |
280 | 276 | ||
281 | '_registration': function(aConnection, someParameters) { | 277 | '_registration': function(aConnection, someParameters) { |
282 | if (this.isReadOnly() == false) { | 278 | if (this.isReadOnly() == false) { |
283 | if (typeof(this.data()['users'][someParameters['credentials']['C']]) == 'undefined') { | 279 | if (typeof(this.data()['users'][someParameters['credentials']['C']]) == 'undefined') { |
284 | this.data()['users'][someParameters['credentials']['C']] = { | 280 | this.data()['users'][someParameters['credentials']['C']] = { |
285 | 's': someParameters['credentials']['s'], | 281 | 's': someParameters['credentials']['s'], |
286 | 'v': someParameters['credentials']['v'], | 282 | 'v': someParameters['credentials']['v'], |
287 | 'version':someParameters['credentials']['version'], | 283 | 'version':someParameters['credentials']['version'], |
288 | 'lock': Clipperz.Crypto.Base.generateRandomSeed(), | 284 | 'lock': Clipperz.Crypto.Base.generateRandomSeed(), |
289 | 'userDetails': someParameters['user']['header'], | 285 | 'userDetails': someParameters['user']['header'], |
290 | 'statistics': someParameters['user']['statistics'], | 286 | 'statistics': someParameters['user']['statistics'], |
291 | 'userDetailsVersion':someParameters['user']['version'], | 287 | 'userDetailsVersion':someParameters['user']['version'], |
292 | 'records':{} | 288 | 'records':{} |
293 | } | 289 | } |
294 | } else { | 290 | } else { |
295 | throw "user already exists"; | 291 | throw "user already exists"; |
296 | } | 292 | } |
297 | } else { | 293 | } else { |
298 | throw Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly; | 294 | throw Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly; |
299 | } | 295 | } |
300 | 296 | ||
301 | result = { | 297 | result = { |
302 | result: { | 298 | result: { |
303 | 'lock': this.data()['users'][someParameters['credentials']['C']]['lock'], | 299 | 'lock': this.data()['users'][someParameters['credentials']['C']]['lock'], |
304 | 'result':'done' | 300 | 'result':'done' |
305 | }, | 301 | }, |
306 | toll: this.getTollForRequestType('CONNECT') | 302 | toll: this.getTollForRequestType('CONNECT') |
307 | } | 303 | } |
308 | 304 | ||
309 | return result; | 305 | return result; |
310 | }, | 306 | }, |
311 | 307 | ||
312 | //------------------------------------------------------------------------- | 308 | //------------------------------------------------------------------------- |
313 | 309 | ||
314 | '_handshake': function(aConnection, someParameters) { | 310 | '_handshake': function(aConnection, someParameters) { |
315 | var result; | 311 | var result; |
316 | varnextTollRequestType; | 312 | varnextTollRequestType; |
317 | 313 | ||
318 | result = {}; | 314 | result = {}; |
319 | if (someParameters.message == "connect") { | 315 | if (someParameters.message == "connect") { |
320 | var userData; | 316 | var userData; |
321 | var randomBytes; | 317 | var randomBytes; |
322 | var v; | 318 | var v; |
323 | 319 | ||
324 | userData = this.data()['users'][someParameters.parameters.C]; | 320 | userData = this.data()['users'][someParameters.parameters.C]; |
325 | 321 | ||
326 | if ((typeof(userData) != 'undefined') && (userData['version'] == someParameters.version)) { | 322 | if ((typeof(userData) != 'undefined') && (userData['version'] == someParameters.version)) { |
327 | aConnection['userData'] = userData; | 323 | aConnection['userData'] = userData; |
328 | aConnection['C'] = someParameters.parameters.C; | 324 | aConnection['C'] = someParameters.parameters.C; |
329 | } else { | 325 | } else { |
330 | aConnection['userData'] = this.data()['users']['catchAllUser']; | 326 | aConnection['userData'] = this.data()['users']['catchAllUser']; |
331 | } | 327 | } |
332 | 328 | ||
333 | randomBytes = Clipperz.Crypto.Base.generateRandomSeed(); | 329 | randomBytes = Clipperz.Crypto.Base.generateRandomSeed(); |
334 | aConnection['b'] = new Clipperz.Crypto.BigInt(randomBytes, 16); | 330 | aConnection['b'] = new Clipperz.Crypto.BigInt(randomBytes, 16); |
335 | v = new Clipperz.Crypto.BigInt(aConnection['userData']['v'], 16); | 331 | v = new Clipperz.Crypto.BigInt(aConnection['userData']['v'], 16); |
336 | aConnection['B'] = v.add(Clipperz.Crypto.SRP.g().powerModule(aConnection['b'], Clipperz.Crypto.SRP.n())); | 332 | aConnection['B'] = v.add(Clipperz.Crypto.SRP.g().powerModule(aConnection['b'], Clipperz.Crypto.SRP.n())); |
337 | 333 | ||
338 | aConnection['A'] = someParameters.parameters.A; | 334 | aConnection['A'] = someParameters.parameters.A; |
339 | 335 | ||
340 | result['s'] = aConnection['userData']['s']; | 336 | result['s'] = aConnection['userData']['s']; |
341 | result['B'] = aConnection['B'].asString(16); | 337 | result['B'] = aConnection['B'].asString(16); |
342 | 338 | ||
343 | nextTollRequestType = 'CONNECT'; | 339 | nextTollRequestType = 'CONNECT'; |
344 | } else if (someParameters.message == "credentialCheck") { | 340 | } else if (someParameters.message == "credentialCheck") { |
345 | var v, u, S, A, K, M1; | 341 | var v, u, S, A, K, M1; |
346 | 342 | ||
347 | v = new Clipperz.Crypto.BigInt(aConnection['userData']['v'], 16); | 343 | v = new Clipperz.Crypto.BigInt(aConnection['userData']['v'], 16); |
348 | u = new Clipperz.Crypto.BigInt(Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(aConnection['B'].asString(10))).toHexString(), 16); | 344 | u = new Clipperz.Crypto.BigInt(Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(aConnection['B'].asString(10))).toHexString(), 16); |
349 | A = new Clipperz.Crypto.BigInt(aConnection['A'], 16); | 345 | A = new Clipperz.Crypto.BigInt(aConnection['A'], 16); |
350 | S = (A.multiply(v.powerModule(u, Clipperz.Crypto.SRP.n()))).powerModule(aConnection['b'], Clipperz.Crypto.SRP.n()); | 346 | S = (A.multiply(v.powerModule(u, Clipperz.Crypto.SRP.n()))).powerModule(aConnection['b'], Clipperz.Crypto.SRP.n()); |
351 | 347 | ||
352 | K = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(S.asString(10))).toHexString().slice(2); | 348 | K = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(S.asString(10))).toHexString().slice(2); |
353 | 349 | ||
354 | M1 = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(A.asString(10) + aConnection['B'].asString(10) + K)).toHexString().slice(2); | 350 | M1 = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(A.asString(10) + aConnection['B'].asString(10) + K)).toHexString().slice(2); |
355 | if (someParameters.parameters.M1 == M1) { | 351 | if (someParameters.parameters.M1 == M1) { |
356 | var M2; | 352 | var M2; |
357 | 353 | ||
358 | M2 = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(A.asString(10) + someParameters.parameters.M1 + K)).toHexString().slice(2); | 354 | M2 = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(A.asString(10) + someParameters.parameters.M1 + K)).toHexString().slice(2); |
359 | result['M2'] = M2; | 355 | result['M2'] = M2; |
360 | } else { | 356 | } else { |
361 | throw new Error("Client checksum verification failed! Expected <" + M1 + ">, received <" + someParameters.parameters.M1 + ">.", "Error"); | 357 | throw new Error("Client checksum verification failed! Expected <" + M1 + ">, received <" + someParameters.parameters.M1 + ">.", "Error"); |
362 | } | 358 | } |
363 | 359 | ||
364 | nextTollRequestType = 'MESSAGE'; | 360 | nextTollRequestType = 'MESSAGE'; |
365 | } else if (someParameters.message == "oneTimePassword") { | 361 | } else if (someParameters.message == "oneTimePassword") { |
366 | var otpData; | 362 | var otpData; |
367 | 363 | ||
368 | otpData = this.data()['onetimePasswords'][someParameters.parameters.oneTimePasswordKey]; | 364 | otpData = this.data()['onetimePasswords'][someParameters.parameters.oneTimePasswordKey]; |
369 | 365 | ||
370 | try { | 366 | try { |
371 | if (typeof(otpData) != 'undefined') { | 367 | if (typeof(otpData) != 'undefined') { |
372 | if (otpData['status'] == 'ACTIVE') { | 368 | if (otpData['status'] == 'ACTIVE') { |
373 | if (otpData['key_checksum'] == someParameters.parameters.oneTimePasswordKeyChecksum) { | 369 | if (otpData['key_checksum'] == someParameters.parameters.oneTimePasswordKeyChecksum) { |
374 | result = { | 370 | result = { |
375 | 'data': otpData['data'], | 371 | 'data': otpData['data'], |
376 | 'version':otpData['version'] | 372 | 'version':otpData['version'] |
377 | } | 373 | } |
378 | 374 | ||
379 | otpData['status'] = 'REQUESTED'; | 375 | otpData['status'] = 'REQUESTED'; |
380 | } else { | 376 | } else { |
381 | otpData['status'] = 'DISABLED'; | 377 | otpData['status'] = 'DISABLED'; |
382 | throw "The requested One Time Password has been disabled, due to a wrong keyChecksum"; | 378 | throw "The requested One Time Password has been disabled, due to a wrong keyChecksum"; |
383 | } | 379 | } |
384 | } else { | 380 | } else { |
385 | throw "The requested One Time Password was not active"; | 381 | throw "The requested One Time Password was not active"; |
386 | } | 382 | } |
387 | } else { | 383 | } else { |
388 | throw "The requested One Time Password has not been found" | 384 | throw "The requested One Time Password has not been found" |
389 | } | 385 | } |
390 | } catch (exception) { | 386 | } catch (exception) { |
391 | result = { | 387 | result = { |
392 | 'data': Clipperz.PM.Crypto.randomKey(), | 388 | 'data': Clipperz.PM.Crypto.randomKey(), |
393 | 'version':Clipperz.PM.Connection.communicationProtocol.currentVersion | 389 | 'version':Clipperz.PM.Connection.communicationProtocol.currentVersion |
394 | } | 390 | } |
395 | } | 391 | } |
396 | nextTollRequestType = 'CONNECT'; | 392 | nextTollRequestType = 'CONNECT'; |
397 | } else { | 393 | } else { |
398 | MochiKit.Logging.logError("Clipperz.PM.Proxy.Test.handshake - unhandled message: " + someParameters.message); | 394 | Clipperz.logError("Clipperz.PM.Proxy.Test.handshake - unhandled message: " + someParameters.message); |
399 | } | 395 | } |
400 | 396 | ||
401 | result = { | 397 | result = { |
402 | result: result, | 398 | result: result, |
403 | toll: this.getTollForRequestType(nextTollRequestType) | 399 | toll: this.getTollForRequestType(nextTollRequestType) |
404 | } | 400 | } |
405 | 401 | ||
406 | return result; | 402 | return result; |
407 | }, | 403 | }, |
408 | 404 | ||
409 | //------------------------------------------------------------------------- | 405 | //------------------------------------------------------------------------- |
410 | 406 | ||
411 | '_message': function(aConnection, someParameters) { | 407 | '_message': function(aConnection, someParameters) { |
412 | var result; | 408 | var result; |
413 | 409 | ||
414 | result = {}; | 410 | result = {}; |
415 | 411 | ||
416 | //===================================================================== | 412 | //===================================================================== |
417 | // | 413 | // |
418 | // R E A D - O N L Y M e t h o d s | 414 | // R E A D - O N L Y M e t h o d s |
419 | // | 415 | // |
420 | //===================================================================== | 416 | //===================================================================== |
421 | if (someParameters.message == 'getUserDetails') { | 417 | if (someParameters.message == 'getUserDetails') { |
422 | var recordsStats; | 418 | var recordsStats; |
423 | var recordReference; | 419 | var recordReference; |
424 | 420 | ||
425 | recordsStats = {}; | 421 | recordsStats = {}; |
426 | for (recordReference in aConnection['userData']['records']) { | 422 | for (recordReference in aConnection['userData']['records']) { |
427 | recordsStats[recordReference] = { | 423 | recordsStats[recordReference] = { |
428 | 'updateDate': aConnection['userData']['records'][recordReference]['updateDate'] | 424 | 'updateDate': aConnection['userData']['records'][recordReference]['updateDate'] |
429 | } | 425 | } |
430 | } | 426 | } |
431 | 427 | ||
432 | result['header'] = this.userDetails(aConnection); | 428 | result['header'] = this.userDetails(aConnection); |
433 | result['statistics'] = this.statistics(aConnection); | 429 | result['statistics'] = this.statistics(aConnection); |
434 | result['maxNumberOfRecords'] = aConnection['userData']['maxNumberOfRecords']; | 430 | result['maxNumberOfRecords'] = aConnection['userData']['maxNumberOfRecords']; |
435 | result['version'] = aConnection['userData']['userDetailsVersion']; | 431 | result['version'] = aConnection['userData']['userDetailsVersion']; |
436 | result['recordsStats'] = recordsStats; | 432 | result['recordsStats'] = recordsStats; |
437 | 433 | ||
438 | if (this.isReadOnly() == false) { | 434 | if (this.isReadOnly() == false) { |
439 | varlock; | 435 | varlock; |
440 | 436 | ||
441 | if (typeof(aConnection['userData']['lock']) == 'undefined') { | 437 | if (typeof(aConnection['userData']['lock']) == 'undefined') { |
442 | aConnection['userData']['lock'] = "<<LOCK>>"; | 438 | aConnection['userData']['lock'] = "<<LOCK>>"; |
443 | } | 439 | } |
444 | 440 | ||
445 | result['lock'] = aConnection['userData']['lock']; | 441 | result['lock'] = aConnection['userData']['lock']; |
446 | } | 442 | } |
447 | 443 | ||
448 | //===================================================================== | 444 | //===================================================================== |
449 | } else if (someParameters.message == 'getRecordDetail') { | 445 | } else if (someParameters.message == 'getRecordDetail') { |
450 | /* | 446 | /* |
451 | varrecordData; | 447 | varrecordData; |
452 | var currentVersionData; | 448 | var currentVersionData; |
453 | 449 | ||
454 | recordData = this.userData()['records'][someParameters['parameters']['reference']]; | 450 | recordData = this.userData()['records'][someParameters['parameters']['reference']]; |
455 | result['reference'] = someParameters['parameters']['reference']; | 451 | result['reference'] = someParameters['parameters']['reference']; |
456 | result['data'] = recordData['data']; | 452 | result['data'] = recordData['data']; |
457 | result['version'] = recordData['version']; | 453 | result['version'] = recordData['version']; |
458 | result['creationData'] = recordData['creationDate']; | 454 | result['creationData'] = recordData['creationDate']; |
459 | result['updateDate'] = recordData['updateDate']; | 455 | result['updateDate'] = recordData['updateDate']; |
460 | result['accessDate'] = recordData['accessDate']; | 456 | result['accessDate'] = recordData['accessDate']; |
461 | 457 | ||
462 | currentVersionData = recordData['versions'][recordData['currentVersion']]; | 458 | currentVersionData = recordData['versions'][recordData['currentVersion']]; |
463 | 459 | ||
464 | result['currentVersion'] = {}; | 460 | result['currentVersion'] = {}; |
465 | result['currentVersion']['reference'] = recordData['currentVersion']; | 461 | result['currentVersion']['reference'] = recordData['currentVersion']; |
466 | result['currentVersion']['version'] = currentVersionData['version']; | 462 | result['currentVersion']['version'] = currentVersionData['version']; |
467 | result['currentVersion']['header'] = currentVersionData['header']; | 463 | result['currentVersion']['header'] = currentVersionData['header']; |
468 | result['currentVersion']['data'] = currentVersionData['data']; | 464 | result['currentVersion']['data'] = currentVersionData['data']; |
469 | result['currentVersion']['creationData'] = currentVersionData['creationDate']; | 465 | result['currentVersion']['creationData'] = currentVersionData['creationDate']; |
470 | result['currentVersion']['updateDate'] = currentVersionData['updateDate']; | 466 | result['currentVersion']['updateDate'] = currentVersionData['updateDate']; |
471 | result['currentVersion']['accessDate'] = currentVersionData['accessDate']; | 467 | result['currentVersion']['accessDate'] = currentVersionData['accessDate']; |
472 | if (typeof(currentVersionData['previousVersion']) != 'undefined') { | 468 | if (typeof(currentVersionData['previousVersion']) != 'undefined') { |
473 | result['currentVersion']['previousVersionKey'] = currentVersionData['previousVersionKey']; | 469 | result['currentVersion']['previousVersionKey'] = currentVersionData['previousVersionKey']; |
474 | result['currentVersion']['previousVersion'] = currentVersionData['previousVersion']; | 470 | result['currentVersion']['previousVersion'] = currentVersionData['previousVersion']; |
475 | } | 471 | } |
476 | */ | 472 | */ |
477 | MochiKit.Base.update(result, aConnection['userData']['records'][someParameters['parameters']['reference']]); | 473 | MochiKit.Base.update(result, aConnection['userData']['records'][someParameters['parameters']['reference']]); |
478 | result['reference'] = someParameters['parameters']['reference']; | 474 | result['reference'] = someParameters['parameters']['reference']; |
479 | 475 | ||
480 | //===================================================================== | 476 | //===================================================================== |
481 | // | 477 | // |
482 | // R E A D - W R I T E M e t h o d s | 478 | // R E A D - W R I T E M e t h o d s |
483 | // | 479 | // |
484 | //===================================================================== | 480 | //===================================================================== |
485 | } else if (someParameters.message == 'upgradeUserCredentials') { | 481 | } else if (someParameters.message == 'upgradeUserCredentials') { |
486 | if (this.isReadOnly() == false) { | 482 | if (this.isReadOnly() == false) { |
487 | var parameters; | 483 | var parameters; |
488 | var credentials; | 484 | var credentials; |
489 | 485 | ||
490 | parameters = someParameters['parameters']; | 486 | parameters = someParameters['parameters']; |
491 | credentials = parameters['credentials']; | 487 | credentials = parameters['credentials']; |
492 | 488 | ||
493 | if ((credentials['C'] == null) | 489 | if ((credentials['C'] == null) |
494 | ||(credentials['s'] == null) | 490 | ||(credentials['s'] == null) |
495 | ||(credentials['v'] == null) | 491 | ||(credentials['v'] == null) |
496 | ||(credentials['version'] != Clipperz.PM.Connection.communicationProtocol.currentVersion) | 492 | ||(credentials['version'] != Clipperz.PM.Connection.communicationProtocol.currentVersion) |
497 | ) { | 493 | ) { |
498 | result = Clipperz.PM.DataModel.User.exception.CredentialUpgradeFailed; | 494 | result = Clipperz.PM.DataModel.User.exception.CredentialUpgradeFailed; |
499 | } else { | 495 | } else { |
500 | varoldCValue; | 496 | varoldCValue; |
501 | oldCValue = aConnection['C']; | 497 | oldCValue = aConnection['C']; |
502 | 498 | ||
503 | this.data()['users'][credentials['C']] = aConnection['userData']; | 499 | this.data()['users'][credentials['C']] = aConnection['userData']; |
504 | aConnection['C'] = credentials['C']; | 500 | aConnection['C'] = credentials['C']; |
505 | 501 | ||
506 | aConnection['userData']['s'] = credentials['s']; | 502 | aConnection['userData']['s'] = credentials['s']; |
507 | aConnection['userData']['v'] = credentials['v']; | 503 | aConnection['userData']['v'] = credentials['v']; |
508 | aConnection['userData']['version'] = credentials['version']; | 504 | aConnection['userData']['version'] = credentials['version']; |
509 | 505 | ||
510 | aConnection['userData']['userDetails'] = parameters['user']['header']; | 506 | aConnection['userData']['userDetails'] = parameters['user']['header']; |
511 | aConnection['userData']['userDetailsVersion'] = parameters['user']['version']; | 507 | aConnection['userData']['userDetailsVersion'] = parameters['user']['version']; |
512 | aConnection['userData']['statistics'] = parameters['user']['statistics']; | 508 | aConnection['userData']['statistics'] = parameters['user']['statistics']; |
513 | 509 | ||
514 | aConnection['userData']['lock'] = parameters['user']['lock']; | 510 | aConnection['userData']['lock'] = parameters['user']['lock']; |
515 | 511 | ||
516 | delete this.data()['users'][oldCValue]; | 512 | delete this.data()['users'][oldCValue]; |
517 | 513 | ||
518 | result = {result:"done", parameters:parameters}; | 514 | result = {result:"done", parameters:parameters}; |
519 | } | 515 | } |
520 | } else { | 516 | } else { |
521 | throw Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly; | 517 | throw Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly; |
522 | } | 518 | } |
523 | //===================================================================== | 519 | //===================================================================== |
524 | /* } else if (someParameters.message == 'updateData') { | 520 | /* } else if (someParameters.message == 'updateData') { |
525 | if (this.isReadOnly() == false) { | 521 | if (this.isReadOnly() == false) { |
526 | var i, c; | 522 | var i, c; |
527 | 523 | ||
528 | //console.log("###==============================================================="); | ||
529 | //console.log("###>>>", Clipperz.Base.serializeJSON(someParameters)); | ||
530 | //console.log("###--- userData", Clipperz.Base.serializeJSON(this.userData())); | ||
531 | if (this.userData()['lock']!= someParameters['parameters']['user']['lock']) { | 524 | if (this.userData()['lock']!= someParameters['parameters']['user']['lock']) { |
532 | throw "the lock attribute is not processed correctly" | 525 | throw "the lock attribute is not processed correctly" |
533 | } | 526 | } |
534 | 527 | ||
535 | this.userData()['userDetails'] = someParameters['parameters']['user']['header']; | 528 | this.userData()['userDetails'] = someParameters['parameters']['user']['header']; |
536 | this.userData()['statistics'] = someParameters['parameters']['user']['statistics']; | 529 | this.userData()['statistics'] = someParameters['parameters']['user']['statistics']; |
537 | this.userData()['userDetailsVersions']= someParameters['parameters']['user']['version']; | 530 | this.userData()['userDetailsVersions']= someParameters['parameters']['user']['version']; |
538 | 531 | ||
539 | c = someParameters['parameters']['records'].length; | 532 | c = someParameters['parameters']['records'].length; |
540 | for (i=0; i<c; i++) { | 533 | for (i=0; i<c; i++) { |
541 | var currentRecord; | 534 | var currentRecord; |
542 | var currentRecordData; | 535 | var currentRecordData; |
543 | 536 | ||
544 | currentRecordData = someParameters['parameters']['records'][i]; | 537 | currentRecordData = someParameters['parameters']['records'][i]; |
545 | currentRecord = this.userData()['records'][currentRecordData['record']['reference']]; | 538 | currentRecord = this.userData()['records'][currentRecordData['record']['reference']]; |
546 | 539 | ||
547 | if (currentRecord == null) { | 540 | if (currentRecord == null) { |
548 | } | 541 | } |
549 | 542 | ||
550 | currentRecord['data'] = currentRecordData['record']['data']; | 543 | currentRecord['data'] = currentRecordData['record']['data']; |
551 | currentRecord['version'] = currentRecordData['record']['version']; | 544 | currentRecord['version'] = currentRecordData['record']['version']; |
552 | currentRecord['currentVersion'] = currentRecordData['currentRecordVersion']['reference']; | 545 | currentRecord['currentVersion'] = currentRecordData['currentRecordVersion']['reference']; |
553 | 546 | ||
554 | currentRecord['versions'][currentRecordData['currentRecordVersion']['reference']] = { | 547 | currentRecord['versions'][currentRecordData['currentRecordVersion']['reference']] = { |
555 | 'data': currentRecordData['currentRecordVersion']['data'], | 548 | 'data': currentRecordData['currentRecordVersion']['data'], |
556 | 'version': currentRecordData['currentRecordVersion']['version'], | 549 | 'version': currentRecordData['currentRecordVersion']['version'], |
557 | 'previousVersion': currentRecordData['currentRecordVersion']['previousVersion'], | 550 | 'previousVersion': currentRecordData['currentRecordVersion']['previousVersion'], |
558 | 'previousVersionKey':currentRecordData['currentRecordVersion']['previousVersionKey'] | 551 | 'previousVersionKey':currentRecordData['currentRecordVersion']['previousVersionKey'] |
559 | } | 552 | } |
560 | } | 553 | } |
561 | 554 | ||
562 | this.userData()['lock'] = Clipperz.PM.Crypto.randomKey(); | 555 | this.userData()['lock'] = Clipperz.PM.Crypto.randomKey(); |
563 | result['lock'] = this.userData()['lock']; | 556 | result['lock'] = this.userData()['lock']; |
564 | result['result'] = 'done'; | 557 | result['result'] = 'done'; |
565 | //console.log("###<<< userData", Clipperz.Base.serializeJSON(this.userData())); | ||
566 | } else { | 558 | } else { |
567 | throw Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly; | 559 | throw Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly; |
568 | } | 560 | } |
569 | */ //===================================================================== | 561 | */ //===================================================================== |
570 | } else if (someParameters.message == 'saveChanges') { | 562 | } else if (someParameters.message == 'saveChanges') { |
571 | if (this.isReadOnly() == false) { | 563 | if (this.isReadOnly() == false) { |
572 | var i, c; | 564 | var i, c; |
573 | 565 | ||
574 | //console.log("###==============================================================="); | ||
575 | //console.log("###>>>", someParameters); | ||
576 | //console.log("###>>>", Clipperz.Base.serializeJSON(someParameters)); | ||
577 | //console.log("###--- userData", Clipperz.Base.serializeJSON(this.userData())); | ||
578 | //console.log("###==============================================================="); | ||
579 | //console.log("--- userData.lock ", this.userData()['lock']); | ||
580 | //console.log("--- parameters.lock", someParameters['parameters']['user']['lock']); | ||
581 | if (aConnection['userData']['lock']!= someParameters['parameters']['user']['lock']) { | 566 | if (aConnection['userData']['lock']!= someParameters['parameters']['user']['lock']) { |
582 | throw "the lock attribute is not processed correctly" | 567 | throw "the lock attribute is not processed correctly" |
583 | } | 568 | } |
584 | 569 | ||
585 | aConnection['userData']['userDetails'] = someParameters['parameters']['user']['header']; | 570 | aConnection['userData']['userDetails'] = someParameters['parameters']['user']['header']; |
586 | aConnection['userData']['statistics'] = someParameters['parameters']['user']['statistics']; | 571 | aConnection['userData']['statistics'] = someParameters['parameters']['user']['statistics']; |
587 | aConnection['userData']['userDetailsVersions']= someParameters['parameters']['user']['version']; | 572 | aConnection['userData']['userDetailsVersions']= someParameters['parameters']['user']['version']; |
588 | 573 | ||
589 | c = someParameters['parameters']['records']['updated'].length; | 574 | c = someParameters['parameters']['records']['updated'].length; |
590 | for (i=0; i<c; i++) { | 575 | for (i=0; i<c; i++) { |
591 | var currentRecord; | 576 | var currentRecord; |
592 | var currentRecordData; | 577 | var currentRecordData; |
593 | 578 | ||
594 | currentRecordData = someParameters['parameters']['records']['updated'][i]; | 579 | currentRecordData = someParameters['parameters']['records']['updated'][i]; |
595 | currentRecord = aConnection['userData']['records'][currentRecordData['record']['reference']]; | 580 | currentRecord = aConnection['userData']['records'][currentRecordData['record']['reference']]; |
596 | 581 | ||
597 | if ( | 582 | if ( |
598 | (typeof(aConnection['userData']['records'][currentRecordData['record']['reference']]) == 'undefined') | 583 | (typeof(aConnection['userData']['records'][currentRecordData['record']['reference']]) == 'undefined') |
599 | && | 584 | && |
600 | (typeof(currentRecordData['currentRecordVersion']) == 'undefined') | 585 | (typeof(currentRecordData['currentRecordVersion']) == 'undefined') |
601 | ) { | 586 | ) { |
602 | //console.log("######## SHIT HAPPENS"); | ||
603 | throw "Record added without a recordVersion"; | 587 | throw "Record added without a recordVersion"; |
604 | } | 588 | } |
605 | 589 | ||
606 | if (currentRecord == null) { | 590 | if (currentRecord == null) { |
607 | currentRecord = {}; | 591 | currentRecord = {}; |
608 | currentRecord['versions'] = {}; | 592 | currentRecord['versions'] = {}; |
609 | currentRecord['creationDate']= Clipperz.PM.Date.formatDateWithUTCFormat(new Date()); | 593 | currentRecord['creationDate']= Clipperz.PM.Date.formatDateWithUTCFormat(new Date()); |
610 | currentRecord['accessDate'] = Clipperz.PM.Date.formatDateWithUTCFormat(new Date()); | 594 | currentRecord['accessDate'] = Clipperz.PM.Date.formatDateWithUTCFormat(new Date()); |
611 | 595 | ||
612 | aConnection['userData']['records'][currentRecordData['record']['reference']] = currentRecord; | 596 | aConnection['userData']['records'][currentRecordData['record']['reference']] = currentRecord; |
613 | } | 597 | } |
614 | 598 | ||
615 | currentRecord['data'] = currentRecordData['record']['data']; | 599 | currentRecord['data'] = currentRecordData['record']['data']; |
616 | currentRecord['version']= currentRecordData['record']['version']; | 600 | currentRecord['version']= currentRecordData['record']['version']; |
617 | currentRecord['updateDate']= Clipperz.PM.Date.formatDateWithUTCFormat(new Date()); | 601 | currentRecord['updateDate']= Clipperz.PM.Date.formatDateWithUTCFormat(new Date()); |
618 | 602 | ||
619 | if (typeof(currentRecordData['currentRecordVersion']) != 'undefined') { | 603 | if (typeof(currentRecordData['currentRecordVersion']) != 'undefined') { |
620 | currentRecord['currentVersion'] = currentRecordData['currentRecordVersion']['reference']; | 604 | currentRecord['currentVersion'] = currentRecordData['currentRecordVersion']['reference']; |
621 | currentRecord['versions'][currentRecordData['currentRecordVersion']['reference']] = { | 605 | currentRecord['versions'][currentRecordData['currentRecordVersion']['reference']] = { |
622 | 'data': currentRecordData['currentRecordVersion']['data'], | 606 | 'data': currentRecordData['currentRecordVersion']['data'], |
623 | 'version': currentRecordData['currentRecordVersion']['version'], | 607 | 'version': currentRecordData['currentRecordVersion']['version'], |
624 | 'previousVersion': currentRecordData['currentRecordVersion']['previousVersion'], | 608 | 'previousVersion': currentRecordData['currentRecordVersion']['previousVersion'], |
625 | 'previousVersionKey':currentRecordData['currentRecordVersion']['previousVersionKey'], | 609 | 'previousVersionKey':currentRecordData['currentRecordVersion']['previousVersionKey'], |
626 | 'creationDate':Clipperz.PM.Date.formatDateWithUTCFormat(new Date()), | 610 | 'creationDate':Clipperz.PM.Date.formatDateWithUTCFormat(new Date()), |
627 | 'updateDate':Clipperz.PM.Date.formatDateWithUTCFormat(new Date()), | 611 | 'updateDate':Clipperz.PM.Date.formatDateWithUTCFormat(new Date()), |
628 | 'accessDate':Clipperz.PM.Date.formatDateWithUTCFormat(new Date()) | 612 | 'accessDate':Clipperz.PM.Date.formatDateWithUTCFormat(new Date()) |
629 | } | 613 | } |
630 | } | 614 | } |
631 | } | 615 | } |
632 | 616 | ||
633 | c = someParameters['parameters']['records']['deleted'].length; | 617 | c = someParameters['parameters']['records']['deleted'].length; |
634 | for (i=0; i<c; i++) { | 618 | for (i=0; i<c; i++) { |
635 | var currentRecordReference; | 619 | var currentRecordReference; |
636 | 620 | ||
637 | currentRecordReference = someParameters['parameters']['records']['deleted'][i]; | 621 | currentRecordReference = someParameters['parameters']['records']['deleted'][i]; |
638 | //console.log("DELETING records", currentRecordReference); | ||
639 | delete aConnection['userData']['records'][currentRecordReference]; | 622 | delete aConnection['userData']['records'][currentRecordReference]; |
640 | } | 623 | } |
641 | 624 | ||
642 | aConnection['userData']['lock'] = Clipperz.PM.Crypto.randomKey(); | 625 | aConnection['userData']['lock'] = Clipperz.PM.Crypto.randomKey(); |
643 | result['lock'] = aConnection['userData']['lock']; | 626 | result['lock'] = aConnection['userData']['lock']; |
644 | result['result'] = 'done'; | 627 | result['result'] = 'done'; |
645 | //console.log("###<<< userData", Clipperz.Base.serializeJSON(this.userData())); | ||
646 | } else { | 628 | } else { |
647 | throw Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly; | 629 | throw Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly; |
648 | } | 630 | } |
649 | 631 | ||
650 | //===================================================================== | 632 | //===================================================================== |
651 | // | 633 | // |
652 | // U N H A N D L E D M e t h o d | 634 | // U N H A N D L E D M e t h o d |
653 | // | 635 | // |
654 | //===================================================================== | 636 | //===================================================================== |
655 | } else { | 637 | } else { |
656 | MochiKit.Logging.logError("Clipperz.PM.Proxy.Test.message - unhandled message: " + someParameters.message); | 638 | Clipperz.logError("Clipperz.PM.Proxy.Test.message - unhandled message: " + someParameters.message); |
657 | } | 639 | } |
658 | 640 | ||
659 | result = { | 641 | result = { |
660 | result: result, | 642 | result: result, |
661 | toll: this.getTollForRequestType('MESSAGE') | 643 | toll: this.getTollForRequestType('MESSAGE') |
662 | } | 644 | } |
663 | 645 | ||
664 | // return MochiKit.Async.succeed(result); | 646 | // return MochiKit.Async.succeed(result); |
665 | return result; | 647 | return result; |
666 | }, | 648 | }, |
667 | 649 | ||
668 | //------------------------------------------------------------------------- | 650 | //------------------------------------------------------------------------- |
669 | 651 | ||
670 | '_logout': function(someParameters) { | 652 | '_logout': function(someParameters) { |
671 | // return MochiKit.Async.succeed({result: 'done'}); | 653 | // return MochiKit.Async.succeed({result: 'done'}); |
672 | return {result: 'done'}; | 654 | return {result: 'done'}; |
673 | }, | 655 | }, |
674 | 656 | ||
675 | //========================================================================= | 657 | //========================================================================= |
676 | //######################################################################### | 658 | //######################################################################### |
677 | 659 | ||
678 | 'isTestData': function(aConnection) { | 660 | 'isTestData': function(aConnection) { |
679 | return (typeof(aConnection['userData']['__masterkey_test_value__']) != 'undefined'); | 661 | return (typeof(aConnection['userData']['__masterkey_test_value__']) != 'undefined'); |
680 | }, | 662 | }, |
681 | 663 | ||
682 | 'userDetails': function(aConnection) { | 664 | 'userDetails': function(aConnection) { |
683 | var result; | 665 | var result; |
684 | 666 | ||
685 | if (this.isTestData(aConnection)) { | 667 | if (this.isTestData(aConnection)) { |
686 | var serializedHeader; | 668 | var serializedHeader; |
687 | var version; | 669 | var version; |
688 | 670 | ||
689 | //MochiKit.Logging.logDebug("### test data"); | 671 | //Clipperz.logDebug("### test data"); |
690 | version = aConnection['userData']['userDetailsVersion']; | 672 | version = aConnection['userData']['userDetailsVersion']; |
691 | serializedHeader = Clipperz.Base.serializeJSON(aConnection['userData']['userDetails']); | 673 | serializedHeader = Clipperz.Base.serializeJSON(aConnection['userData']['userDetails']); |
692 | result = Clipperz.PM.Crypto.encryptingFunctions.versions[version].encrypt(aConnection['userData']['__masterkey_test_value__'], serializedHeader); | 674 | result = Clipperz.PM.Crypto.encryptingFunctions.versions[version].encrypt(aConnection['userData']['__masterkey_test_value__'], serializedHeader); |
693 | } else { | 675 | } else { |
694 | //MochiKit.Logging.logDebug("### NOT test data"); | 676 | //Clipperz.logDebug("### NOT test data"); |
695 | result = aConnection['userData']['userDetails']; | 677 | result = aConnection['userData']['userDetails']; |
696 | } | 678 | } |
697 | 679 | ||
698 | return result; | 680 | return result; |
699 | }, | 681 | }, |
700 | 682 | ||
701 | 'statistics': function(aConnection) { | 683 | 'statistics': function(aConnection) { |
702 | var result; | 684 | var result; |
703 | 685 | ||
704 | if (aConnection['userData']['statistics'] != null) { | 686 | if (aConnection['userData']['statistics'] != null) { |
705 | if (this.isTestData(aConnection)) { | 687 | if (this.isTestData(aConnection)) { |
706 | var serializedStatistics; | 688 | var serializedStatistics; |
707 | var version; | 689 | var version; |
708 | 690 | ||
709 | version = aConnection['userData']['userDetailsVersion']; | 691 | version = aConnection['userData']['userDetailsVersion']; |
710 | serializedStatistics = Clipperz.Base.serializeJSON(aConnection['userData']['statistics']); | 692 | serializedStatistics = Clipperz.Base.serializeJSON(aConnection['userData']['statistics']); |
711 | result = Clipperz.PM.Crypto.encryptingFunctions.versions[version].encrypt(aConnection['userData']['__masterkey_test_value__'], serializedStatistics); | 693 | result = Clipperz.PM.Crypto.encryptingFunctions.versions[version].encrypt(aConnection['userData']['__masterkey_test_value__'], serializedStatistics); |
712 | } else { | 694 | } else { |
713 | result = aConnection['userData']['statistics']; | 695 | result = aConnection['userData']['statistics']; |
714 | } | 696 | } |
715 | } else { | 697 | } else { |
716 | result = null; | 698 | result = null; |
717 | } | 699 | } |
718 | 700 | ||
719 | return result; | 701 | return result; |
720 | }, | 702 | }, |
721 | 703 | ||
722 | /* | 704 | /* |
723 | 'userSerializedEncryptedData': function(someData) { | 705 | 'userSerializedEncryptedData': function(someData) { |
724 | var deferredResult; | 706 | var deferredResult; |
725 | var deferredContext; | 707 | var deferredContext; |
726 | 708 | ||
727 | deferredContext = { 'data': someData }; | 709 | deferredContext = { 'data': someData }; |
728 | 710 | ||
729 | deferredResult = new Clipperz.Async.Deferred('Proxy.Test.serializeUserEncryptedData', {trace:false}); | 711 | deferredResult = new Clipperz.Async.Deferred('Proxy.Test.serializeUserEncryptedData', {trace:false}); |
730 | deferredResult.addCallback(MochiKit.Base.bind(function(aDeferredContext) { | 712 | deferredResult.addCallback(MochiKit.Base.bind(function(aDeferredContext) { |
731 | aDeferredContext['user'] = this.createUserUsingConfigurationData(aDeferredContext['data']); | 713 | aDeferredContext['user'] = this.createUserUsingConfigurationData(aDeferredContext['data']); |
732 | return aDeferredContext; | 714 | return aDeferredContext; |
733 | }, this)); | 715 | }, this)); |
734 | deferredResult.addCallback(function(aDeferredContext) { | 716 | deferredResult.addCallback(function(aDeferredContext) { |
735 | // return aDeferredContext['user'].encryptedDataUsingVersion(aDeferredContext['data']['version']); | 717 | // return aDeferredContext['user'].encryptedDataUsingVersion(aDeferredContext['data']['version']); |
736 | return aDeferredContext['user'].serializedDataUsingVersion(MochiKit.Base.values(aDeferredContext['user'].records()), aDeferredContext['data']['version']); | 718 | return aDeferredContext['user'].serializedDataUsingVersion(MochiKit.Base.values(aDeferredContext['user'].records()), aDeferredContext['data']['version']); |
737 | }); | 719 | }); |
738 | deferredResult.addCallback(function(aUserEncryptedData) { | 720 | deferredResult.addCallback(function(aUserEncryptedData) { |
739 | deferredContext['encryptedData'] = aUserEncryptedData; | 721 | deferredContext['encryptedData'] = aUserEncryptedData; |
740 | return deferredContext; | 722 | return deferredContext; |
741 | }); | 723 | }); |
742 | deferredResult.addCallback(function(aDeferredContext) { | 724 | deferredResult.addCallback(function(aDeferredContext) { |
743 | var connection; | 725 | var connection; |
744 | 726 | ||
745 | connection = new Clipperz.PM.Connection.communicationProtocol.versions[aDeferredContext['data']['connectionVersion']]() | 727 | connection = new Clipperz.PM.Connection.communicationProtocol.versions[aDeferredContext['data']['connectionVersion']]() |
746 | aDeferredContext['credentials'] = connection.serverSideUserCredentials(aDeferredContext['user'].username(),aDeferredContext['user'].passphrase()); | 728 | aDeferredContext['credentials'] = connection.serverSideUserCredentials(aDeferredContext['user'].username(),aDeferredContext['user'].passphrase()); |
747 | 729 | ||
748 | return aDeferredContext; | 730 | return aDeferredContext; |
749 | }); | 731 | }); |
750 | 732 | ||
751 | // deferredResult.addCallback(function(aDeferredContext) { | 733 | // deferredResult.addCallback(function(aDeferredContext) { |
752 | //console.log("#-#-#-#-#", aDeferredContext); | ||
753 | // return aDeferredContext['user'].serializedDataUsingVersion(MochiKit.Base.values(aDeferredContext['user'].records()), aDeferredContext['data']['version']); | 734 | // return aDeferredContext['user'].serializedDataUsingVersion(MochiKit.Base.values(aDeferredContext['user'].records()), aDeferredContext['data']['version']); |
754 | // }, deferredContext); | 735 | // }, deferredContext); |
755 | // deferredResult.addCallback(function(aUserSerializedData) { | 736 | // deferredResult.addCallback(function(aUserSerializedData) { |
756 | //console.log("USER SERIALIZED DATA", aUserSerializedData); | ||
757 | // }); | 737 | // }); |
758 | // | 738 | // |
759 | // deferredResult.addCallback(MochiKit.Async.succeed, deferredContext); | 739 | // deferredResult.addCallback(MochiKit.Async.succeed, deferredContext); |
760 | deferredResult.callback(deferredContext); | 740 | deferredResult.callback(deferredContext); |
761 | 741 | ||
762 | return deferredResult; | 742 | return deferredResult; |
763 | }, | 743 | }, |
764 | 744 | ||
765 | 'createUserUsingConfigurationData': function(someData) { | 745 | 'createUserUsingConfigurationData': function(someData) { |
766 | var result; | 746 | var result; |
767 | var user; | 747 | var user; |
768 | var recordLabel; | 748 | var recordLabel; |
769 | 749 | ||
770 | user = new Clipperz.PM.DataModel.User(); | 750 | user = new Clipperz.PM.DataModel.User(); |
771 | user.initForTests(); | 751 | user.initForTests(); |
772 | user.setUsername(someData['username']); | 752 | user.setUsername(someData['username']); |
773 | user.setPassphrase(someData['passphrase']); | 753 | user.setPassphrase(someData['passphrase']); |
774 | 754 | ||
775 | for (recordLabel in someData['records']) { | 755 | for (recordLabel in someData['records']) { |
776 | var recordData; | 756 | var recordData; |
777 | var record; | 757 | var record; |
778 | var i, c; | 758 | var i, c; |
779 | 759 | ||
780 | recordData = someData['records'][recordLabel]; | 760 | recordData = someData['records'][recordLabel]; |
781 | record = new Clipperz.PM.DataModel.Record({user:user, label:recordLabel}); | 761 | record = new Clipperz.PM.DataModel.Record({user:user, label:recordLabel}); |
782 | record.setNotes(recordData['notes']); | 762 | record.setNotes(recordData['notes']); |
783 | 763 | ||
784 | c = recordData['fields'].length; | 764 | c = recordData['fields'].length; |
785 | for (i=0; i<c; i++) { | 765 | for (i=0; i<c; i++) { |
786 | var recordField; | 766 | var recordField; |
787 | 767 | ||
788 | recordField = new Clipperz.PM.DataModel.RecordField(); | 768 | recordField = new Clipperz.PM.DataModel.RecordField(); |
789 | recordField.setLabel(recordData['fields'][i]['name']); | 769 | recordField.setLabel(recordData['fields'][i]['name']); |
790 | recordField.setValue(recordData['fields'][i]['value']); | 770 | recordField.setValue(recordData['fields'][i]['value']); |
791 | recordField.setType(recordData['fields'][i]['type']); | 771 | recordField.setType(recordData['fields'][i]['type']); |
792 | record.addField(recordField); | 772 | record.addField(recordField); |
793 | } | 773 | } |
794 | user.addRecord(record, true); | 774 | user.addRecord(record, true); |
795 | } | 775 | } |
796 | 776 | ||
797 | result = user; | 777 | result = user; |
798 | 778 | ||
799 | return result; | 779 | return result; |
800 | }, | 780 | }, |
801 | */ | 781 | */ |
802 | //========================================================================= | 782 | //========================================================================= |
803 | __syntaxFix__: "syntax fix" | 783 | __syntaxFix__: "syntax fix" |
804 | }); | 784 | }); |
805 | 785 | ||
806 | Clipperz.PM.Proxy.Offline.DataStore['exception'] = { | 786 | Clipperz.PM.Proxy.Offline.DataStore['exception'] = { |
807 | 'ReadOnly': new MochiKit.Base.NamedError("Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly") | 787 | 'ReadOnly': new MochiKit.Base.NamedError("Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly") |
808 | }; \ No newline at end of file | 788 | }; \ No newline at end of file |
diff --git a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.js b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.js index a86ac4f..5764bda 100644 --- a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.js +++ b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.js | |||
@@ -1,64 +1,62 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * 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 |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 25 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
28 | 26 | ||
29 | //============================================================================= | 27 | //============================================================================= |
30 | 28 | ||
31 | Clipperz.PM.Proxy.Offline = function(args) { | 29 | Clipperz.PM.Proxy.Offline = function(args) { |
32 | args = args || {}; | 30 | args = args || {}; |
33 | 31 | ||
34 | Clipperz.PM.Proxy.Offline.superclass.constructor.call(this, args); | 32 | Clipperz.PM.Proxy.Offline.superclass.constructor.call(this, args); |
35 | 33 | ||
36 | this._dataStore = args.dataStore || new Clipperz.PM.Proxy.Offline.DataStore(args); | 34 | this._dataStore = args.dataStore || new Clipperz.PM.Proxy.Offline.DataStore(args); |
37 | 35 | ||
38 | return this; | 36 | return this; |
39 | } | 37 | } |
40 | 38 | ||
41 | Clipperz.Base.extend(Clipperz.PM.Proxy.Offline, Clipperz.PM.Proxy, { | 39 | Clipperz.Base.extend(Clipperz.PM.Proxy.Offline, Clipperz.PM.Proxy, { |
42 | 40 | ||
43 | 'toString': function () { | 41 | 'toString': function () { |
44 | return "Clipperz.PM.Proxy.Offline"; | 42 | return "Clipperz.PM.Proxy.Offline"; |
45 | }, | 43 | }, |
46 | 44 | ||
47 | //------------------------------------------------------------------------- | 45 | //------------------------------------------------------------------------- |
48 | 46 | ||
49 | 'dataStore': function () { | 47 | 'dataStore': function () { |
50 | return this._dataStore; | 48 | return this._dataStore; |
51 | }, | 49 | }, |
52 | 50 | ||
53 | //------------------------------------------------------------------------- | 51 | //------------------------------------------------------------------------- |
54 | 52 | ||
55 | 'sendMessage': function(aFunctionName, someParameters) { | 53 | 'sendMessage': function(aFunctionName, someParameters) { |
56 | return this.dataStore().processMessage(aFunctionName, someParameters); | 54 | return this.dataStore().processMessage(aFunctionName, someParameters); |
57 | }, | 55 | }, |
58 | 56 | ||
59 | //------------------------------------------------------------------------- | 57 | //------------------------------------------------------------------------- |
60 | 58 | ||
61 | __syntaxFix__: "syntax fix" | 59 | __syntaxFix__: "syntax fix" |
62 | 60 | ||
63 | }); | 61 | }); |
64 | 62 | ||
diff --git a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.OfflineCache.js b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.OfflineCache.js index 803c590..f628975 100644 --- a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.OfflineCache.js +++ b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.OfflineCache.js | |||
@@ -1,65 +1,63 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * 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 |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 25 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
28 | 26 | ||
29 | //============================================================================= | 27 | //============================================================================= |
30 | 28 | ||
31 | Clipperz.PM.Proxy.OfflineCache = function(args) { | 29 | Clipperz.PM.Proxy.OfflineCache = function(args) { |
32 | args = args || {}; | 30 | args = args || {}; |
33 | 31 | ||
34 | Clipperz.PM.Proxy.Offline.superclass.constructor.call(this, args); | 32 | Clipperz.PM.Proxy.Offline.superclass.constructor.call(this, args); |
35 | 33 | ||
36 | //this._dataStore = args.dataStore || new Clipperz.PM.Proxy.Offline.DataStore(args); | 34 | //this._dataStore = args.dataStore || new Clipperz.PM.Proxy.Offline.DataStore(args); |
37 | 35 | ||
38 | return this; | 36 | return this; |
39 | } | 37 | } |
40 | 38 | ||
41 | Clipperz.Base.extend(Clipperz.PM.Proxy.OfflineCache, Clipperz.PM.Proxy, { | 39 | Clipperz.Base.extend(Clipperz.PM.Proxy.OfflineCache, Clipperz.PM.Proxy, { |
42 | 40 | ||
43 | 'toString': function () { | 41 | 'toString': function () { |
44 | return "Clipperz.PM.Proxy.OfflineCache"; | 42 | return "Clipperz.PM.Proxy.OfflineCache"; |
45 | }, | 43 | }, |
46 | 44 | ||
47 | //------------------------------------------------------------------------- | 45 | //------------------------------------------------------------------------- |
48 | 46 | ||
49 | //'dataStore': function () { | 47 | //'dataStore': function () { |
50 | // return this._dataStore; | 48 | // return this._dataStore; |
51 | //}, | 49 | //}, |
52 | 50 | ||
53 | //------------------------------------------------------------------------- | 51 | //------------------------------------------------------------------------- |
54 | 52 | ||
55 | 'sendMessage': function(aFunctionName, someParameters) { | 53 | 'sendMessage': function(aFunctionName, someParameters) { |
56 | throw Clipperz.Base.exception.MethodNotImplementedYet; | 54 | throw Clipperz.Base.exception.MethodNotImplementedYet; |
57 | // return this.dataStore().processMessage(aFunctionName, someParameters); | 55 | // return this.dataStore().processMessage(aFunctionName, someParameters); |
58 | }, | 56 | }, |
59 | 57 | ||
60 | //------------------------------------------------------------------------- | 58 | //------------------------------------------------------------------------- |
61 | 59 | ||
62 | __syntaxFix__: "syntax fix" | 60 | __syntaxFix__: "syntax fix" |
63 | 61 | ||
64 | }); | 62 | }); |
65 | 63 | ||
diff --git a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Test.js b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Test.js index d554c6a..d459726 100644 --- a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Test.js +++ b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Test.js | |||
@@ -1,164 +1,156 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * 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 |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 25 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
28 | if (typeof(Clipperz.PM.Proxy) == 'undefined') { Clipperz.PM.Proxy = {}; } | 26 | if (typeof(Clipperz.PM.Proxy) == 'undefined') { Clipperz.PM.Proxy = {}; } |
29 | 27 | ||
30 | //============================================================================= | 28 | //============================================================================= |
31 | 29 | ||
32 | Clipperz.PM.Proxy.Test = function(args) { | 30 | Clipperz.PM.Proxy.Test = function(args) { |
33 | Clipperz.PM.Proxy.Test.superclass.constructor.call(this, args); | 31 | Clipperz.PM.Proxy.Test.superclass.constructor.call(this, args); |
34 | 32 | ||
35 | args = args || {}; | 33 | args = args || {}; |
36 | 34 | ||
37 | this._expectedRequests = (args.shouldCheckExpectedRequests === true) ? [] : null; | 35 | this._expectedRequests = (args.shouldCheckExpectedRequests === true) ? [] : null; |
38 | this._isExpectingRequests = true; | 36 | this._isExpectingRequests = true; |
39 | this._unexpectedRequests = []; | 37 | this._unexpectedRequests = []; |
40 | 38 | ||
41 | this.dataStore().resetData(); | 39 | this.dataStore().resetData(); |
42 | 40 | ||
43 | return this; | 41 | return this; |
44 | } | 42 | } |
45 | 43 | ||
46 | Clipperz.Base.extend(Clipperz.PM.Proxy.Test, Clipperz.PM.Proxy.Offline, { | 44 | Clipperz.Base.extend(Clipperz.PM.Proxy.Test, Clipperz.PM.Proxy.Offline, { |
47 | 45 | ||
48 | 'toString': function() { | 46 | 'toString': function() { |
49 | return "Clipperz.PM.Proxy.Test"; | 47 | return "Clipperz.PM.Proxy.Test"; |
50 | }, | 48 | }, |
51 | 49 | ||
52 | //========================================================================= | 50 | //========================================================================= |
53 | 51 | ||
54 | 'expectedRequests': function () { | 52 | 'expectedRequests': function () { |
55 | return this._expectedRequests; | 53 | return this._expectedRequests; |
56 | }, | 54 | }, |
57 | 55 | ||
58 | //------------------------------------------------------------------------- | 56 | //------------------------------------------------------------------------- |
59 | 57 | ||
60 | 'shouldCheckExpectedRequests': function () { | 58 | 'shouldCheckExpectedRequests': function () { |
61 | return (this._expectedRequests != null); | 59 | return (this._expectedRequests != null); |
62 | }, | 60 | }, |
63 | 61 | ||
64 | 'setShouldCheckExpectedRequests': function(aValue) { | 62 | 'setShouldCheckExpectedRequests': function(aValue) { |
65 | if (aValue) { | 63 | if (aValue) { |
66 | this._expectedRequests = aValue; | 64 | this._expectedRequests = aValue; |
67 | } else { | 65 | } else { |
68 | this._expectedRequests = null; | 66 | this._expectedRequests = null; |
69 | } | 67 | } |
70 | }, | 68 | }, |
71 | 69 | ||
72 | //------------------------------------------------------------------------- | 70 | //------------------------------------------------------------------------- |
73 | 71 | ||
74 | 'shouldNotReceiveAnyFurtherRequest': function () { | 72 | 'shouldNotReceiveAnyFurtherRequest': function () { |
75 | this._isExpectingRequests = false; | 73 | this._isExpectingRequests = false; |
76 | }, | 74 | }, |
77 | 75 | ||
78 | 'mayReceiveMoreRequests': function () { | 76 | 'mayReceiveMoreRequests': function () { |
79 | this._isExpectingRequests = true; | 77 | this._isExpectingRequests = true; |
80 | this.resetUnexpectedRequests(); | 78 | this.resetUnexpectedRequests(); |
81 | }, | 79 | }, |
82 | 80 | ||
83 | 'isExpectingRequests': function () { | 81 | 'isExpectingRequests': function () { |
84 | return this._isExpectingRequests; | 82 | return this._isExpectingRequests; |
85 | }, | 83 | }, |
86 | 84 | ||
87 | //------------------------------------------------------------------------- | 85 | //------------------------------------------------------------------------- |
88 | 86 | ||
89 | 'unexpectedRequests': function () { | 87 | 'unexpectedRequests': function () { |
90 | return this._unexpectedRequests; | 88 | return this._unexpectedRequests; |
91 | }, | 89 | }, |
92 | 90 | ||
93 | 'resetUnexpectedRequests': function () { | 91 | 'resetUnexpectedRequests': function () { |
94 | this._unexpectedRequests = []; | 92 | this._unexpectedRequests = []; |
95 | }, | 93 | }, |
96 | 94 | ||
97 | //------------------------------------------------------------------------- | 95 | //------------------------------------------------------------------------- |
98 | 96 | ||
99 | 'testExpectedRequestParameters': function (aPath, anActualRequest, anExpectedRequest) { | 97 | 'testExpectedRequestParameters': function (aPath, anActualRequest, anExpectedRequest) { |
100 | var aKey; | 98 | var aKey; |
101 | //console.log(">>> Proxy.testExpectedRequestParameters [" + aPath + "]", anActualRequest, anExpectedRequest); | ||
102 | for (aKey in anExpectedRequest) { | 99 | for (aKey in anExpectedRequest) { |
103 | if (typeof(anActualRequest[aKey]) == 'undefined') { | 100 | if (typeof(anActualRequest[aKey]) == 'undefined') { |
104 | throw "the expected paramter [" + aKey + "] is missing from the actual request"; | 101 | throw "the expected paramter [" + aKey + "] is missing from the actual request"; |
105 | } | 102 | } |
106 | if (typeof(anExpectedRequest[aKey]) == 'object') { | 103 | if (typeof(anExpectedRequest[aKey]) == 'object') { |
107 | this.testExpectedRequestParameters(aPath + "." + aKey, anActualRequest[aKey], anExpectedRequest[aKey]) | 104 | this.testExpectedRequestParameters(aPath + "." + aKey, anActualRequest[aKey], anExpectedRequest[aKey]) |
108 | } else { | 105 | } else { |
109 | if (! anExpectedRequest[aKey](anActualRequest[aKey])) { | 106 | if (! anExpectedRequest[aKey](anActualRequest[aKey])) { |
110 | throw "wrong value for paramter [" + aKey + "]; got '" + anActualRequest[aKey] + "'"; | 107 | throw "wrong value for paramter [" + aKey + "]; got '" + anActualRequest[aKey] + "'"; |
111 | } | 108 | } |
112 | } | 109 | } |
113 | } | 110 | } |
114 | //console.log("<<< Proxy.testExpectedRequestParameters"); | ||
115 | }, | 111 | }, |
116 | 112 | ||
117 | //------------------------------------------------------------------------- | 113 | //------------------------------------------------------------------------- |
118 | 114 | ||
119 | 'checkRequest': function(aFunctionName, someParameters) { | 115 | 'checkRequest': function(aFunctionName, someParameters) { |
120 | if (this.shouldCheckExpectedRequests()) { | 116 | if (this.shouldCheckExpectedRequests()) { |
121 | var expectedRequest; | 117 | var expectedRequest; |
122 | 118 | ||
123 | //console.log(">>> Proxy.Test.checkRequest - " + aFunctionName, someParameters); | ||
124 | expectedRequest = this.expectedRequests().pop(); | 119 | expectedRequest = this.expectedRequests().pop(); |
125 | //console.log("--- Proxy.Test.checkRequest - expectedRequest", expectedRequest); | ||
126 | if (expectedRequest == null) { | 120 | if (expectedRequest == null) { |
127 | throw "Proxy.Test.sentMessage: no expected result specified. Got request '" + aFunctionName + "': " + someParameters; | 121 | throw "Proxy.Test.sentMessage: no expected result specified. Got request '" + aFunctionName + "': " + someParameters; |
128 | } | 122 | } |
129 | 123 | ||
130 | try { | 124 | try { |
131 | if (aFunctionName != expectedRequest.functionName) { | 125 | if (aFunctionName != expectedRequest.functionName) { |
132 | throw "wrong function name. Got '" + aFunctionName + "', expected '" + expectedRequest.request.functionName + "'"; | 126 | throw "wrong function name. Got '" + aFunctionName + "', expected '" + expectedRequest.request.functionName + "'"; |
133 | } | 127 | } |
134 | 128 | ||
135 | this.testExpectedRequestParameters("parameters", someParameters, expectedRequest.parameters); | 129 | this.testExpectedRequestParameters("parameters", someParameters, expectedRequest.parameters); |
136 | } catch(exception) { | 130 | } catch(exception) { |
137 | //console.log("EXCEPTION: Proxy.Test.sentMessage[" + expectedRequest.name + "]", exception) | ||
138 | throw "Proxy.Test.sentMessage[" + expectedRequest.name + "]: " + exception; | 131 | throw "Proxy.Test.sentMessage[" + expectedRequest.name + "]: " + exception; |
139 | } | 132 | } |
140 | } | 133 | } |
141 | //console.log("<<< Proxy.Test.checkRequest"); | ||
142 | }, | 134 | }, |
143 | 135 | ||
144 | //========================================================================= | 136 | //========================================================================= |
145 | 137 | ||
146 | 'sendMessage': function(aFunctionName, someParameters) { | 138 | 'sendMessage': function(aFunctionName, someParameters) { |
147 | var result; | 139 | var result; |
148 | 140 | ||
149 | if (this.isExpectingRequests() == false) { | 141 | if (this.isExpectingRequests() == false) { |
150 | // throw Clipperz.PM.Connection.exception.UnexpectedRequest; | 142 | // throw Clipperz.PM.Connection.exception.UnexpectedRequest; |
151 | Clipperz.log("UNEXPECTED REQUEST " + aFunctionName /* + ": " + Clipperz.Base.serializeJSON(someParameters) */); | 143 | Clipperz.log("UNEXPECTED REQUEST " + aFunctionName /* + ": " + Clipperz.Base.serializeJSON(someParameters) */); |
152 | this.unexpectedRequests().push({'functionName':aFunctionName, 'someParameters': someParameters}); | 144 | this.unexpectedRequests().push({'functionName':aFunctionName, 'someParameters': someParameters}); |
153 | }; | 145 | }; |
154 | this.checkRequest(aFunctionName, someParameters); | 146 | this.checkRequest(aFunctionName, someParameters); |
155 | result = Clipperz.PM.Proxy.Test.superclass.sendMessage.call(this, aFunctionName, someParameters); | 147 | result = Clipperz.PM.Proxy.Test.superclass.sendMessage.call(this, aFunctionName, someParameters); |
156 | 148 | ||
157 | return result; | 149 | return result; |
158 | }, | 150 | }, |
159 | 151 | ||
160 | //========================================================================= | 152 | //========================================================================= |
161 | __syntaxFix__: "syntax fix" | 153 | __syntaxFix__: "syntax fix" |
162 | 154 | ||
163 | }); | 155 | }); |
164 | 156 | ||