Diffstat (limited to 'frontend/beta/js/Clipperz/PM/DataModel/OneTimePassword.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/OneTimePassword.js | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/OneTimePassword.js b/frontend/beta/js/Clipperz/PM/DataModel/OneTimePassword.js index 88f383a..3f611b4 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/OneTimePassword.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/OneTimePassword.js | |||
@@ -1,118 +1,116 @@ | |||
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.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | 26 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } |
29 | 27 | ||
30 | 28 | ||
31 | //############################################################################# | 29 | //############################################################################# |
32 | 30 | ||
33 | Clipperz.PM.DataModel.OneTimePassword = function(args) { | 31 | Clipperz.PM.DataModel.OneTimePassword = function(args) { |
34 | args = args || {}; | 32 | args = args || {}; |
35 | 33 | ||
36 | //console.log("new OneTimePassword", args); | 34 | //console.log("new OneTimePassword", args); |
37 | //MochiKit.Logging.logDebug("---"); | 35 | //MochiKit.Logging.logDebug("---"); |
38 | this._user = args['user']; | 36 | this._user = args['user']; |
39 | this._password = args['password']; | 37 | this._password = args['password']; |
40 | this._passwordValue = Clipperz.PM.DataModel.OneTimePassword.normalizedOneTimePassword(args['password']); | 38 | this._passwordValue = Clipperz.PM.DataModel.OneTimePassword.normalizedOneTimePassword(args['password']); |
41 | this._reference = args['reference'] || Clipperz.PM.Crypto.randomKey(); | 39 | this._reference = args['reference'] || Clipperz.PM.Crypto.randomKey(); |
42 | this._creationDate = args['created'] ? Clipperz.PM.Date.parseDateWithUTCFormat(args['created']) : new Date(); | 40 | this._creationDate = args['created'] ? Clipperz.PM.Date.parseDateWithUTCFormat(args['created']) : new Date(); |
43 | this._usageDate = args['used'] ? Clipperz.PM.Date.parseDateWithUTCFormat(args['used']) : null; | 41 | this._usageDate = args['used'] ? Clipperz.PM.Date.parseDateWithUTCFormat(args['used']) : null; |
44 | 42 | ||
45 | this._status = args['status'] || 'ACTIVE'; | 43 | this._status = args['status'] || 'ACTIVE'; |
46 | this._connectionInfo = null; | 44 | this._connectionInfo = null; |
47 | 45 | ||
48 | this._key = null; | 46 | this._key = null; |
49 | this._keyChecksum = null; | 47 | this._keyChecksum = null; |
50 | 48 | ||
51 | return this; | 49 | return this; |
52 | } | 50 | } |
53 | 51 | ||
54 | Clipperz.PM.DataModel.OneTimePassword.prototype = MochiKit.Base.update(null, { | 52 | Clipperz.PM.DataModel.OneTimePassword.prototype = MochiKit.Base.update(null, { |
55 | 53 | ||
56 | 'toString': function() { | 54 | 'toString': function() { |
57 | return "Clipperz.PM.DataModel.OneTimePassword"; | 55 | return "Clipperz.PM.DataModel.OneTimePassword"; |
58 | }, | 56 | }, |
59 | 57 | ||
60 | //------------------------------------------------------------------------- | 58 | //------------------------------------------------------------------------- |
61 | 59 | ||
62 | 'user': function() { | 60 | 'user': function() { |
63 | return this._user; | 61 | return this._user; |
64 | }, | 62 | }, |
65 | 63 | ||
66 | //------------------------------------------------------------------------- | 64 | //------------------------------------------------------------------------- |
67 | 65 | ||
68 | 'password': function() { | 66 | 'password': function() { |
69 | return this._password; | 67 | return this._password; |
70 | }, | 68 | }, |
71 | 69 | ||
72 | //------------------------------------------------------------------------- | 70 | //------------------------------------------------------------------------- |
73 | 71 | ||
74 | 'passwordValue': function() { | 72 | 'passwordValue': function() { |
75 | return this._passwordValue; | 73 | return this._passwordValue; |
76 | }, | 74 | }, |
77 | 75 | ||
78 | //------------------------------------------------------------------------- | 76 | //------------------------------------------------------------------------- |
79 | 77 | ||
80 | 'creationDate': function() { | 78 | 'creationDate': function() { |
81 | return this._creationDate; | 79 | return this._creationDate; |
82 | }, | 80 | }, |
83 | 81 | ||
84 | //------------------------------------------------------------------------- | 82 | //------------------------------------------------------------------------- |
85 | 83 | ||
86 | 'reference': function() { | 84 | 'reference': function() { |
87 | return this._reference; | 85 | return this._reference; |
88 | }, | 86 | }, |
89 | 87 | ||
90 | //------------------------------------------------------------------------- | 88 | //------------------------------------------------------------------------- |
91 | 89 | ||
92 | 'key': function() { | 90 | 'key': function() { |
93 | if (this._key == null) { | 91 | if (this._key == null) { |
94 | this._key = Clipperz.PM.DataModel.OneTimePassword.computeKeyWithUsernameAndPassword(this.user().username(), this.passwordValue()); | 92 | this._key = Clipperz.PM.DataModel.OneTimePassword.computeKeyWithUsernameAndPassword(this.user().username(), this.passwordValue()); |
95 | } | 93 | } |
96 | 94 | ||
97 | return this._key; | 95 | return this._key; |
98 | }, | 96 | }, |
99 | 97 | ||
100 | //------------------------------------------------------------------------- | 98 | //------------------------------------------------------------------------- |
101 | 99 | ||
102 | 'keyChecksum': function() { | 100 | 'keyChecksum': function() { |
103 | if (this._keyChecksum == null) { | 101 | if (this._keyChecksum == null) { |
104 | this._keyChecksum = Clipperz.PM.DataModel.OneTimePassword.computeKeyChecksumWithUsernameAndPassword(this.user().username(), this.passwordValue()); | 102 | this._keyChecksum = Clipperz.PM.DataModel.OneTimePassword.computeKeyChecksumWithUsernameAndPassword(this.user().username(), this.passwordValue()); |
105 | } | 103 | } |
106 | 104 | ||
107 | return this._keyChecksum; | 105 | return this._keyChecksum; |
108 | }, | 106 | }, |
109 | 107 | ||
110 | //------------------------------------------------------------------------- | 108 | //------------------------------------------------------------------------- |
111 | 109 | ||
112 | 'status': function() { | 110 | 'status': function() { |
113 | return this._status; | 111 | return this._status; |
114 | }, | 112 | }, |
115 | 113 | ||
116 | 'setStatus': function(aValue) { | 114 | 'setStatus': function(aValue) { |
117 | this._status = aValue; | 115 | this._status = aValue; |
118 | }, | 116 | }, |