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