Diffstat (limited to 'frontend/beta/js/Clipperz/PM/DataModel/OneTimePasswordManager.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/OneTimePasswordManager.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/OneTimePasswordManager.js b/frontend/beta/js/Clipperz/PM/DataModel/OneTimePasswordManager.js index d90100a..aa40aba 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/OneTimePasswordManager.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/OneTimePasswordManager.js | |||
@@ -1,120 +1,117 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2011 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz's Javascript Crypto Library. | 5 | This file is part of Clipperz Community Edition. |
6 | Javascript Crypto Library provides web developers with an extensive | 6 | Clipperz Community Edition is an online password manager. |
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | 7 | For further information about its features and functionalities please |
11 | refer to http://www.clipperz.com | 8 | refer to http://www.clipperz.com. |
12 | 9 | ||
13 | * Javascript Crypto Library is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
14 | it and/or modify it under the terms of the GNU Affero General Public | 11 | it and/or modify it under the terms of the GNU Affero General Public |
15 | License as published by the Free Software Foundation, either version | 12 | License as published by the Free Software Foundation, either version |
16 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
17 | 14 | ||
18 | * Javascript Crypto Library is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
21 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
22 | 19 | ||
23 | * You should have received a copy of the GNU Affero General Public | 20 | * You should have received a copy of the GNU Affero General Public |
24 | License along with Javascript Crypto Library. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
25 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
26 | 23 | ||
27 | */ | 24 | */ |
28 | 25 | ||
29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
31 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | 28 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } |
32 | 29 | ||
33 | 30 | ||
34 | //############################################################################# | 31 | //############################################################################# |
35 | 32 | ||
36 | Clipperz.PM.DataModel.OneTimePasswordManager = function(anUser, args) { | 33 | Clipperz.PM.DataModel.OneTimePasswordManager = function(anUser, args) { |
37 | args = args || {}; | 34 | args = args || {}; |
38 | 35 | ||
39 | this._user = anUser; | 36 | this._user = anUser; |
40 | this._oneTimePasswords = {}; | 37 | this._oneTimePasswords = {}; |
41 | 38 | ||
42 | this.updateWithData(args); | 39 | this.updateWithData(args); |
43 | 40 | ||
44 | Clipperz.NotificationCenter.notify(null, 'oneTimePasswordAdded', null, true); | 41 | Clipperz.NotificationCenter.notify(null, 'oneTimePasswordAdded', null, true); |
45 | 42 | ||
46 | return this; | 43 | return this; |
47 | } | 44 | } |
48 | 45 | ||
49 | Clipperz.PM.DataModel.OneTimePasswordManager.prototype = MochiKit.Base.update(null, { | 46 | Clipperz.PM.DataModel.OneTimePasswordManager.prototype = MochiKit.Base.update(null, { |
50 | 47 | ||
51 | 'toString': function() { | 48 | 'toString': function() { |
52 | return "Clipperz.PM.DataModel.OneTimePasswordManager"; | 49 | return "Clipperz.PM.DataModel.OneTimePasswordManager"; |
53 | }, | 50 | }, |
54 | 51 | ||
55 | //------------------------------------------------------------------------- | 52 | //------------------------------------------------------------------------- |
56 | 53 | ||
57 | 'updateWithData': function(someValues) { | 54 | 'updateWithData': function(someValues) { |
58 | varotpReference; | 55 | varotpReference; |
59 | 56 | ||
60 | //console.log("OneTimePasswordManager.updateWithData", someValues); | 57 | //console.log("OneTimePasswordManager.updateWithData", someValues); |
61 | //MochiKit.Logging.logDebug("OneTimePasswordManager.updateWithData: " + Clipperz.Base.serializeJSON(someValues)); | 58 | //MochiKit.Logging.logDebug("OneTimePasswordManager.updateWithData: " + Clipperz.Base.serializeJSON(someValues)); |
62 | for (otpReference in someValues) { | 59 | for (otpReference in someValues) { |
63 | var otp; | 60 | var otp; |
64 | var otpConfiguration; | 61 | var otpConfiguration; |
65 | 62 | ||
66 | otpConfiguration = someValues[otpReference]; | 63 | otpConfiguration = someValues[otpReference]; |
67 | otpConfiguration['user'] = this.user(); | 64 | otpConfiguration['user'] = this.user(); |
68 | otpConfiguration['reference'] = otpReference; | 65 | otpConfiguration['reference'] = otpReference; |
69 | otp = new Clipperz.PM.DataModel.OneTimePassword(otpConfiguration); | 66 | otp = new Clipperz.PM.DataModel.OneTimePassword(otpConfiguration); |
70 | this._oneTimePasswords[otpReference] = otp; | 67 | this._oneTimePasswords[otpReference] = otp; |
71 | } | 68 | } |
72 | 69 | ||
73 | return this; | 70 | return this; |
74 | }, | 71 | }, |
75 | 72 | ||
76 | //------------------------------------------------------------------------- | 73 | //------------------------------------------------------------------------- |
77 | 74 | ||
78 | 'updateWithServerData': function(someValues) { | 75 | 'updateWithServerData': function(someValues) { |
79 | var deferredResult; | 76 | var deferredResult; |
80 | varoneTimePasswordReference; | 77 | varoneTimePasswordReference; |
81 | var wereChangesApplied; | 78 | var wereChangesApplied; |
82 | 79 | ||
83 | //MochiKit.Logging.logDebug(">>> OneTimePasswordManager.updateWithServerData"); | 80 | //MochiKit.Logging.logDebug(">>> OneTimePasswordManager.updateWithServerData"); |
84 | deferredResult = new MochiKit.Async.Deferred(); | 81 | deferredResult = new MochiKit.Async.Deferred(); |
85 | wereChangesApplied = false; | 82 | wereChangesApplied = false; |
86 | 83 | ||
87 | for (oneTimePasswordReference in someValues) { | 84 | for (oneTimePasswordReference in someValues) { |
88 | var oneTimePassword; | 85 | var oneTimePassword; |
89 | 86 | ||
90 | oneTimePassword = this.oneTimePasswordWithReference(oneTimePasswordReference); | 87 | oneTimePassword = this.oneTimePasswordWithReference(oneTimePasswordReference); |
91 | if (oneTimePassword != null) { | 88 | if (oneTimePassword != null) { |
92 | var oneTimePasswordHasBeenUpdated; | 89 | var oneTimePasswordHasBeenUpdated; |
93 | 90 | ||
94 | oneTimePasswordHasBeenUpdated = oneTimePassword.updateStatusWithValues(someValues[oneTimePasswordReference]); | 91 | oneTimePasswordHasBeenUpdated = oneTimePassword.updateStatusWithValues(someValues[oneTimePasswordReference]); |
95 | wereChangesApplied = oneTimePasswordHasBeenUpdated || wereChangesApplied; | 92 | wereChangesApplied = oneTimePasswordHasBeenUpdated || wereChangesApplied; |
96 | } else { | 93 | } else { |
97 | 94 | ||
98 | } | 95 | } |
99 | } | 96 | } |
100 | 97 | ||
101 | if (wereChangesApplied == true) { | 98 | if (wereChangesApplied == true) { |
102 | this.user().header().markSectionAsUpdated('oneTimePasswords'); | 99 | this.user().header().markSectionAsUpdated('oneTimePasswords'); |
103 | } | 100 | } |
104 | 101 | ||
105 | for (oneTimePasswordReference in this.oneTimePasswords()) { | 102 | for (oneTimePasswordReference in this.oneTimePasswords()) { |
106 | if (typeof(someValues[oneTimePasswordReference]) == 'undefind') { | 103 | if (typeof(someValues[oneTimePasswordReference]) == 'undefind') { |
107 | deferredResult.addCallback(MochiKit.Base.method(this.oneTimePasswordWithReference(oneTimePasswordReference), 'saveChanges')); | 104 | deferredResult.addCallback(MochiKit.Base.method(this.oneTimePasswordWithReference(oneTimePasswordReference), 'saveChanges')); |
108 | } | 105 | } |
109 | } | 106 | } |
110 | 107 | ||
111 | deferredResult.addCallback(MochiKit.Async.succeed, this); | 108 | deferredResult.addCallback(MochiKit.Async.succeed, this); |
112 | 109 | ||
113 | deferredResult.callback(); | 110 | deferredResult.callback(); |
114 | //MochiKit.Logging.logDebug("<<< OneTimePasswordManager.updateWithServerData"); | 111 | //MochiKit.Logging.logDebug("<<< OneTimePasswordManager.updateWithServerData"); |
115 | 112 | ||
116 | return deferredResult; | 113 | return deferredResult; |
117 | }, | 114 | }, |
118 | 115 | ||
119 | //------------------------------------------------------------------------- | 116 | //------------------------------------------------------------------------- |
120 | 117 | ||