summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/DataModel/OneTimePassword.js
Unidiff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/DataModel/OneTimePassword.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/DataModel/OneTimePassword.js66
1 files changed, 31 insertions, 35 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/OneTimePassword.js b/frontend/gamma/js/Clipperz/PM/DataModel/OneTimePassword.js
index 834e21b..fbca1ff 100644
--- a/frontend/gamma/js/Clipperz/PM/DataModel/OneTimePassword.js
+++ b/frontend/gamma/js/Clipperz/PM/DataModel/OneTimePassword.js
@@ -1,25 +1,23 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2013 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz, the online password manager.
6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 6For further information about its features and functionalities please
8refer to http://www.clipperz.com. 7refer 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
@@ -143,12 +141,12 @@ Clipperz.PM.DataModel.OneTimePassword.prototype = MochiKit.Base.update(null, {
143 getRandomBytes = MochiKit.Base.method(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'getRandomBytes'); 141 getRandomBytes = MochiKit.Base.method(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'getRandomBytes');
144 142
145 encodedPassphrase = new Clipperz.ByteArray(this.user().passphrase()).toBase64String(); 143 encodedPassphrase = new Clipperz.ByteArray(this.user().passphrase()).toBase64String();
146//MochiKit.Logging.logDebug("--- encodedPassphrase.length: " + encodedPassphrase.length); 144//Clipperz.logDebug("--- encodedPassphrase.length: " + encodedPassphrase.length);
147 prefixPadding = getRandomBytes(getRandomBytes(1).byteAtIndex(0)).toBase64String(); 145 prefixPadding = getRandomBytes(getRandomBytes(1).byteAtIndex(0)).toBase64String();
148//MochiKit.Logging.logDebug("--- prefixPadding.length: " + prefixPadding.length); 146//Clipperz.logDebug("--- prefixPadding.length: " + prefixPadding.length);
149 suffixPadding = getRandomBytes((500 - prefixPadding.length - encodedPassphrase.length) * 6 / 8).toBase64String(); 147 suffixPadding = getRandomBytes((500 - prefixPadding.length - encodedPassphrase.length) * 6 / 8).toBase64String();
150//MochiKit.Logging.logDebug("--- suffixPadding.length: " + suffixPadding.length); 148//Clipperz.logDebug("--- suffixPadding.length: " + suffixPadding.length);
151//MochiKit.Logging.logDebug("--- total.length: " + (prefixPadding.length + encodedPassphrase.length + suffixPadding.length)); 149//Clipperz.logDebug("--- total.length: " + (prefixPadding.length + encodedPassphrase.length + suffixPadding.length));
152 150
153 packedPassphrase = { 151 packedPassphrase = {
154 'prefix': prefixPadding, 152 'prefix': prefixPadding,
@@ -158,8 +156,8 @@ Clipperz.PM.DataModel.OneTimePassword.prototype = MochiKit.Base.update(null, {
158 156
159 // result = Clipperz.Base.serializeJSON(packedPassphrase); 157 // result = Clipperz.Base.serializeJSON(packedPassphrase);
160 result = packedPassphrase; 158 result = packedPassphrase;
161//MochiKit.Logging.logDebug("===== OTP packedPassprase: [" + result.length + "]" + result); 159//Clipperz.logDebug("===== OTP packedPassprase: [" + result.length + "]" + result);
162//MochiKit.Logging.logDebug("<<< OneTimePassword.packedPassphrase"); 160//Clipperz.logDebug("<<< OneTimePassword.packedPassphrase");
163 161
164 return result; 162 return result;
165 }, 163 },
@@ -176,8 +174,8 @@ Clipperz.PM.DataModel.OneTimePassword.prototype = MochiKit.Base.update(null, {
176 var deferredResult; 174 var deferredResult;
177 varresult; 175 varresult;
178 176
179//MochiKit.Logging.logDebug(">>> OneTimePassword.encryptedData"); 177//Clipperz.logDebug(">>> OneTimePassword.encryptedData");
180//MochiKit.Logging.logDebug("--- OneTimePassword.encryptedData - id: " + this.reference()); 178//Clipperz.logDebug("--- OneTimePassword.encryptedData - id: " + this.reference());
181 result = { 179 result = {
182 'reference': this.reference(), 180 'reference': this.reference(),
183 'key': this.key(), 181 'key': this.key(),
@@ -185,22 +183,22 @@ Clipperz.PM.DataModel.OneTimePassword.prototype = MochiKit.Base.update(null, {
185 'data': "", 183 'data': "",
186 'version': Clipperz.PM.Crypto.encryptingFunctions.currentVersion 184 'version': Clipperz.PM.Crypto.encryptingFunctions.currentVersion
187 } 185 }
188//MochiKit.Logging.logDebug("--- OneTimePassword.encryptedData - 2: " + Clipperz.Base.serializeJSON(result)); 186//Clipperz.logDebug("--- OneTimePassword.encryptedData - 2: " + Clipperz.Base.serializeJSON(result));
189 deferredResult = new MochiKit.Async.Deferred(); 187 deferredResult = new MochiKit.Async.Deferred();
190//MochiKit.Logging.logDebug("--- OneTimePassword.encryptedData - 3"); 188//Clipperz.logDebug("--- OneTimePassword.encryptedData - 3");
191//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OneTimePassword.encryptedData - 1: " + res); return res;}); 189//deferredResult.addBoth(function(res) {Clipperz.logDebug("OneTimePassword.encryptedData - 1: " + res); return res;});
192 //# deferredResult.addCallback(Clipperz.PM.Crypto.deferredEncryptWithCurrentVersion, this.passwordValue(), this.packedPassphrase()); 190 //# deferredResult.addCallback(Clipperz.PM.Crypto.deferredEncryptWithCurrentVersion, this.passwordValue(), this.packedPassphrase());
193 deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedPackedPassphrase')); 191 deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedPackedPassphrase'));
194//MochiKit.Logging.logDebug("--- OneTimePassword.encryptedData - 4"); 192//Clipperz.logDebug("--- OneTimePassword.encryptedData - 4");
195//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OneTimePassword.encryptedData - 2: [" + res.length + "]" + res); return res;}); 193//deferredResult.addBoth(function(res) {Clipperz.logDebug("OneTimePassword.encryptedData - 2: [" + res.length + "]" + res); return res;});
196 deferredResult.addCallback(function(aResult, res) { 194 deferredResult.addCallback(function(aResult, res) {
197 aResult['data'] = res; 195 aResult['data'] = res;
198 return aResult; 196 return aResult;
199 }, result); 197 }, result);
200//MochiKit.Logging.logDebug("--- OneTimePassword.encryptedData - 5"); 198//Clipperz.logDebug("--- OneTimePassword.encryptedData - 5");
201//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OneTimePassword.encryptedData - 3: " + Clipperz.Base.serializeJSON(res)); return res;}); 199//deferredResult.addBoth(function(res) {Clipperz.logDebug("OneTimePassword.encryptedData - 3: " + Clipperz.Base.serializeJSON(res)); return res;});
202 deferredResult.callback(); 200 deferredResult.callback();
203//MochiKit.Logging.logDebug("--- OneTimePassword.encryptedData - 6"); 201//Clipperz.logDebug("--- OneTimePassword.encryptedData - 6");
204 202
205 return deferredResult; 203 return deferredResult;
206 }, 204 },
@@ -211,7 +209,7 @@ Clipperz.PM.DataModel.OneTimePassword.prototype = MochiKit.Base.update(null, {
211 var deferredResult; 209 var deferredResult;
212 varresult; 210 varresult;
213 211
214//MochiKit.Logging.logDebug(">>> OneTimePassword.saveChanges"); 212//Clipperz.logDebug(">>> OneTimePassword.saveChanges");
215 result = {}; 213 result = {};
216 deferredResult = new MochiKit.Async.Deferred(); 214 deferredResult = new MochiKit.Async.Deferred();
217 215
@@ -230,16 +228,16 @@ Clipperz.PM.DataModel.OneTimePassword.prototype = MochiKit.Base.update(null, {
230 }, result); 228 }, result);
231 229
232 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveOTP_sendingData'); 230 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveOTP_sendingData');
233//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OneTimePassword.saveChanges - 1: " + Clipperz.Base.serializeJSON(res)); return res;}); 231//deferredResult.addBoth(function(res) {Clipperz.logDebug("OneTimePassword.saveChanges - 1: " + Clipperz.Base.serializeJSON(res)); return res;});
234 deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'addNewOneTimePassword'); 232 deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'addNewOneTimePassword');
235 233
236 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveOTP_updatingInterface'); 234 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveOTP_updatingInterface');
237//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OneTimePassword.saveChanges - 2: " + res); return res;}); 235//deferredResult.addBoth(function(res) {Clipperz.logDebug("OneTimePassword.saveChanges - 2: " + res); return res;});
238 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'OTPUpdated'); 236 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'OTPUpdated');
239 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'oneTimePassword_saveChanges_done', null); 237 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'oneTimePassword_saveChanges_done', null);
240//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OneTimePassword.saveChanges - 2: " + res); return res;}); 238//deferredResult.addBoth(function(res) {Clipperz.logDebug("OneTimePassword.saveChanges - 2: " + res); return res;});
241 deferredResult.callback(); 239 deferredResult.callback();
242//MochiKit.Logging.logDebug("<<< OneTimePassword.saveChanges"); 240//Clipperz.logDebug("<<< OneTimePassword.saveChanges");
243 241
244 return deferredResult; 242 return deferredResult;
245 }, 243 },
@@ -308,7 +306,6 @@ Clipperz.PM.DataModel.OneTimePassword.isValidOneTimePasswordValue = function(aPa
308 var result; 306 var result;
309 307
310 //"yaxx k7ww - f8y6 tqz5 - 58b6 th44 - 9cwv q0fg" 308 //"yaxx k7ww - f8y6 tqz5 - 58b6 th44 - 9cwv q0fg"
311//console.log("Clipperz.PM.DataModel.OneTimePassword.isValidOneTimePasswordValue", aPassword);
312 if (aPassword.replace(/[\s\-]/g, '').length == 32) { 309 if (aPassword.replace(/[\s\-]/g, '').length == 32) {
313 try { 310 try {
314 var passwordByteArray; 311 var passwordByteArray;
@@ -347,7 +344,6 @@ Clipperz.PM.DataModel.OneTimePassword.normalizedOneTimePassword = function(aPass
347 result = aPassword; 344 result = aPassword;
348 } 345 }
349 346
350//console.log("Clipperz.PM.DataModel.OneTimePassword.normalizedOneTimePassword", aPassword, result);
351 return result; 347 return result;
352} 348}
353 349