Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/Connection.js') (more/less context) (show whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/Connection.js | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/Connection.js b/frontend/gamma/js/Clipperz/PM/Connection.js index b4e8aaa..a05a310 100644 --- a/frontend/gamma/js/Clipperz/PM/Connection.js +++ b/frontend/gamma/js/Clipperz/PM/Connection.js | |||
@@ -41,6 +41,7 @@ Clipperz.PM.Connection = function (args) { | |||
41 | this._clipperz_pm_crypto_version = null; | 41 | this._clipperz_pm_crypto_version = null; |
42 | this._connectionId = null; | 42 | this._connectionId = null; |
43 | this._sharedSecret = null; | 43 | this._sharedSecret = null; |
44 | this._serverLockValue = null; | ||
44 | 45 | ||
45 | return this; | 46 | return this; |
46 | } | 47 | } |
@@ -146,6 +147,16 @@ MochiKit.Logging.logError("### Connection.defaultErrorHandler: " + anErrorString | |||
146 | this._connectionId = aValue; | 147 | this._connectionId = aValue; |
147 | }, | 148 | }, |
148 | 149 | ||
150 | //------------------------------------------------------------------------- | ||
151 | |||
152 | 'serverLockValue': function () { | ||
153 | return this._serverLockValue; | ||
154 | }, | ||
155 | |||
156 | 'setServerLockValue': function (aValue) { | ||
157 | this._serverLockValue = aValue; | ||
158 | }, | ||
159 | |||
149 | //========================================================================= | 160 | //========================================================================= |
150 | /* | 161 | /* |
151 | //TODO: ????? | 162 | //TODO: ????? |
@@ -320,13 +331,12 @@ Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz. | |||
320 | ], {trace:false}) | 331 | ], {trace:false}) |
321 | }, | 332 | }, |
322 | 333 | ||
323 | 'login': function(/*anUsername, aPassphrase*/) { | 334 | 'login': function(isReconnecting) { |
324 | vardeferredResult; | 335 | vardeferredResult; |
325 | var cryptoVersion; | 336 | var cryptoVersion; |
326 | var srpConnection; | 337 | var srpConnection; |
327 | 338 | ||
328 | cryptoVersion = this.clipperz_pm_crypto_version(); | 339 | cryptoVersion = this.clipperz_pm_crypto_version(); |
329 | |||
330 | deferredResult = new Clipperz.Async.Deferred("Connection.login", {trace:false}); | 340 | deferredResult = new Clipperz.Async.Deferred("Connection.login", {trace:false}); |
331 | deferredResult.addCallback(this.getCredentialsFunction()); | 341 | deferredResult.addCallback(this.getCredentialsFunction()); |
332 | deferredResult.addMethod(this, 'normalizedCredentials'); | 342 | deferredResult.addMethod(this, 'normalizedCredentials'); |
@@ -399,6 +409,13 @@ Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz. | |||
399 | // if (this.oneTimePassword() != null) { | 409 | // if (this.oneTimePassword() != null) { |
400 | /// ?? result = this.user().oneTimePasswordManager().archiveOneTimePassword(this.oneTimePassword())); | 410 | /// ?? result = this.user().oneTimePasswordManager().archiveOneTimePassword(this.oneTimePassword())); |
401 | // } | 411 | // } |
412 | |||
413 | if ((isReconnecting == true) && (this.serverLockValue() != someParameters['lock'])) { | ||
414 | throw Clipperz.PM.Connection.exception.StaleData; | ||
415 | } else { | ||
416 | this.setServerLockValue(someParameters['lock']); | ||
417 | } | ||
418 | |||
402 | return someParameters; | 419 | return someParameters; |
403 | }, this)); | 420 | }, this)); |
404 | // deferredResult.addCallbackPass(MochiKit.Signal.signal, this, 'updatedProgressState', 'connection_loggedIn'); | 421 | // deferredResult.addCallbackPass(MochiKit.Signal.signal, this, 'updatedProgressState', 'connection_loggedIn'); |
@@ -429,12 +446,19 @@ Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz. | |||
429 | 446 | ||
430 | 'message': function(aMessageName, someParameters) { | 447 | 'message': function(aMessageName, someParameters) { |
431 | var args; | 448 | var args; |
449 | var parameters; | ||
450 | |||
451 | parameters = someParameters || {}; | ||
452 | if (typeof(parameters['user']) != 'undefined') { | ||
453 | parameters['user']['lock'] = this.serverLockValue(); | ||
454 | } | ||
432 | 455 | ||
433 | //console.log(">>> Connection.message", aMessageName, someParameters); | 456 | //console.log(">>> Connection.message", aMessageName, someParameters); |
434 | args = { | 457 | args = { |
435 | message: aMessageName, | 458 | message: aMessageName, |
436 | srpSharedSecret: this.sharedSecret(), | 459 | srpSharedSecret: this.sharedSecret(), |
437 | parameters: (someParameters || {}) | 460 | // parameters: (someParameters || {}) |
461 | parameters: parameters | ||
438 | } | 462 | } |
439 | 463 | ||
440 | return this.sendMessage(args); | 464 | return this.sendMessage(args); |
@@ -449,8 +473,7 @@ Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz. | |||
449 | deferredResult.addMethod(this.proxy(), 'message', someArguments); | 473 | deferredResult.addMethod(this.proxy(), 'message', someArguments); |
450 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | 474 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { |
451 | if (typeof(res['lock']) != 'undefined') { | 475 | if (typeof(res['lock']) != 'undefined') { |
452 | //TODO: ????? | 476 | this.setServerLockValue(res['lock']); |
453 | // ?? this.user().setLock(res['lock']); | ||
454 | } | 477 | } |
455 | return res; | 478 | return res; |
456 | }, this)); | 479 | }, this)); |
@@ -587,6 +610,7 @@ Clipperz.PM.Connection.SRP['1.1'].prototype = MochiKit.Base.update(new Clipperz. | |||
587 | 610 | ||
588 | Clipperz.PM.Connection.exception = { | 611 | Clipperz.PM.Connection.exception = { |
589 | WrongChecksum: new MochiKit.Base.NamedError("Clipperz.ByteArray.exception.InvalidValue"), | 612 | WrongChecksum: new MochiKit.Base.NamedError("Clipperz.ByteArray.exception.InvalidValue"), |
613 | StaleData: new MochiKit.Base.NamedError("Stale data"), | ||
590 | UnexpectedRequest:new MochiKit.Base.NamedError("Clipperz.ByteArray.exception.UnexpectedRequest") | 614 | UnexpectedRequest:new MochiKit.Base.NamedError("Clipperz.ByteArray.exception.UnexpectedRequest") |
591 | }; | 615 | }; |
592 | 616 | ||