Diffstat (limited to 'frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js b/frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js index d2b3e12..fc4a45c 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.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.RecordVersion = function(aRecord, args) { | 33 | Clipperz.PM.DataModel.RecordVersion = function(aRecord, args) { |
37 | args = args || {}; | 34 | args = args || {}; |
38 | 35 | ||
39 | this._record = aRecord; | 36 | this._record = aRecord; |
40 | 37 | ||
41 | this._reference = args.reference || Clipperz.PM.Crypto.randomKey(); | 38 | this._reference = args.reference || Clipperz.PM.Crypto.randomKey(); |
42 | this._version = args.version || Clipperz.PM.Crypto.encryptingFunctions.currentVersion; | 39 | this._version = args.version || Clipperz.PM.Crypto.encryptingFunctions.currentVersion; |
43 | this._key = args.key || Clipperz.PM.Crypto.randomKey();; | 40 | this._key = args.key || Clipperz.PM.Crypto.randomKey();; |
44 | 41 | ||
45 | this._previousVersion = args.previousVersion || null; | 42 | this._previousVersion = args.previousVersion || null; |
46 | this._previousVersionKey = args.previousVersionKey || null; | 43 | this._previousVersionKey = args.previousVersionKey || null; |
47 | 44 | ||
48 | this.setIsBrandNew(args.reference == null); | 45 | this.setIsBrandNew(args.reference == null); |
49 | 46 | ||
50 | if (this.isBrandNew()) { | 47 | if (this.isBrandNew()) { |
51 | this._fields = {}; | 48 | this._fields = {}; |
52 | 49 | ||
53 | this.setShouldLoadData(false); | 50 | this.setShouldLoadData(false); |
54 | this.setShouldDecryptData(false); | 51 | this.setShouldDecryptData(false); |
55 | this.setShouldProcessData(false); | 52 | this.setShouldProcessData(false); |
56 | } else { | 53 | } else { |
57 | if (typeof(args.fields) != 'undefined') { | 54 | if (typeof(args.fields) != 'undefined') { |
58 | this.processFieldData(args.fields); | 55 | this.processFieldData(args.fields); |
59 | 56 | ||
60 | this.setShouldLoadData(false); | 57 | this.setShouldLoadData(false); |
61 | this.setShouldDecryptData(false); | 58 | this.setShouldDecryptData(false); |
62 | this.setShouldProcessData(false); | 59 | this.setShouldProcessData(false); |
63 | } else { | 60 | } else { |
64 | if (typeof(args.data) != 'undefined') { | 61 | if (typeof(args.data) != 'undefined') { |
65 | this.setShouldLoadData(false); | 62 | this.setShouldLoadData(false); |
66 | } else { | 63 | } else { |
67 | this.setShouldLoadData(true); | 64 | this.setShouldLoadData(true); |
68 | } | 65 | } |
69 | this.setShouldDecryptData(true); | 66 | this.setShouldDecryptData(true); |
70 | this.setShouldProcessData(true); | 67 | this.setShouldProcessData(true); |
71 | } | 68 | } |
72 | } | 69 | } |
73 | 70 | ||
74 | this._serverData = args.data; | 71 | this._serverData = args.data; |
75 | this._decryptedData = null; | 72 | this._decryptedData = null; |
76 | 73 | ||
77 | return this; | 74 | return this; |
78 | } | 75 | } |
79 | 76 | ||
80 | Clipperz.PM.DataModel.RecordVersion.prototype = MochiKit.Base.update(null, { | 77 | Clipperz.PM.DataModel.RecordVersion.prototype = MochiKit.Base.update(null, { |
81 | 78 | ||
82 | 'toString': function() { | 79 | 'toString': function() { |
83 | return "RecordVersion"; | 80 | return "RecordVersion"; |
84 | }, | 81 | }, |
85 | 82 | ||
86 | //------------------------------------------------------------------------- | 83 | //------------------------------------------------------------------------- |
87 | 84 | ||
88 | 'record': function() { | 85 | 'record': function() { |
89 | return this._record; | 86 | return this._record; |
90 | }, | 87 | }, |
91 | 88 | ||
92 | //------------------------------------------------------------------------- | 89 | //------------------------------------------------------------------------- |
93 | 90 | ||
94 | 'reference': function() { | 91 | 'reference': function() { |
95 | return this._reference; | 92 | return this._reference; |
96 | }, | 93 | }, |
97 | 94 | ||
98 | 'setReference': function(aValue) { | 95 | 'setReference': function(aValue) { |
99 | this._reference = aValue; | 96 | this._reference = aValue; |
100 | }, | 97 | }, |
101 | 98 | ||
102 | //------------------------------------------------------------------------- | 99 | //------------------------------------------------------------------------- |
103 | 100 | ||
104 | 'key': function() { | 101 | 'key': function() { |
105 | //MochiKit.Logging.logDebug(">>> RecordVersion.key"); | 102 | //MochiKit.Logging.logDebug(">>> RecordVersion.key"); |
106 | //MochiKit.Logging.logDebug("--- RecordVersion.key - " + this._key); | 103 | //MochiKit.Logging.logDebug("--- RecordVersion.key - " + this._key); |
107 | return this._key; | 104 | return this._key; |
108 | }, | 105 | }, |
109 | 106 | ||
110 | 'setKey': function(aValue) { | 107 | 'setKey': function(aValue) { |
111 | this._key = aValue; | 108 | this._key = aValue; |
112 | }, | 109 | }, |
113 | 110 | ||
114 | //------------------------------------------------------------------------- | 111 | //------------------------------------------------------------------------- |
115 | 112 | ||
116 | 'serverData': function() { | 113 | 'serverData': function() { |
117 | return this._serverData; | 114 | return this._serverData; |
118 | }, | 115 | }, |
119 | 116 | ||
120 | 'setServerData': function(aValue) { | 117 | 'setServerData': function(aValue) { |