Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/DataModel/EncryptedRemoteObject.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/DataModel/EncryptedRemoteObject.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/EncryptedRemoteObject.js b/frontend/gamma/js/Clipperz/PM/DataModel/EncryptedRemoteObject.js index 3408b08..cdeec8b 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/EncryptedRemoteObject.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/EncryptedRemoteObject.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 | try { if (typeof(Clipperz.KeyValueObjectStore) == 'undefined') { throw ""; }} catch (e) { | 26 | try { if (typeof(Clipperz.KeyValueObjectStore) == 'undefined') { throw ""; }} catch (e) { |
30 | throw "Clipperz.PM.DataModel.EncryptedRemoteObject depends on Clipperz.KeyValueObjectStore!"; | 27 | throw "Clipperz.PM.DataModel.EncryptedRemoteObject depends on Clipperz.KeyValueObjectStore!"; |
31 | } | 28 | } |
32 | 29 | ||
33 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
34 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | 31 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } |
35 | 32 | ||
36 | Clipperz.PM.DataModel.EncryptedRemoteObject = function(args) { | 33 | Clipperz.PM.DataModel.EncryptedRemoteObject = function(args) { |
37 | args = args || {}; | 34 | args = args || {}; |
38 | 35 | ||
39 | this._name = args.name || null; | 36 | this._name = args.name || null; |
40 | this._reference = args.reference || Clipperz.PM.Crypto.randomKey(); | 37 | this._reference = args.reference || Clipperz.PM.Crypto.randomKey(); |
41 | this._isBrandNew = ((args.reference == null) && (args.remoteData == null)); | 38 | this._isBrandNew = ((args.reference == null) && (args.remoteData == null)); |
42 | 39 | ||
43 | if ((this._isBrandNew == false) && (args['retrieveKeyFunction'] == null)) { | 40 | if ((this._isBrandNew == false) && (args['retrieveKeyFunction'] == null)) { |
44 | Clipperz.Base.exception.raise('MandatoryParameter'); | 41 | Clipperz.Base.exception.raise('MandatoryParameter'); |
45 | } else { | 42 | } else { |
46 | this._retrieveKeyFunction = args['retrieveKeyFunction']; | 43 | this._retrieveKeyFunction = args['retrieveKeyFunction']; |
47 | } | 44 | } |
48 | 45 | ||
49 | this._retrieveRemoteDataFunction = args.retrieveRemoteDataFunction|| null; | 46 | this._retrieveRemoteDataFunction = args.retrieveRemoteDataFunction|| null; |
50 | this._remoteData = args.remoteData || null; | 47 | this._remoteData = args.remoteData || null; |
51 | // this._remoteData = args.remoteData ? Clipperz.Base.deepClone(args.remoteData) : null; | 48 | // this._remoteData = args.remoteData ? Clipperz.Base.deepClone(args.remoteData) : null; |
52 | if ((!this._isBrandNew) && ((this._retrieveRemoteDataFunction == null) && (this._remoteData == null))) { | 49 | if ((!this._isBrandNew) && ((this._retrieveRemoteDataFunction == null) && (this._remoteData == null))) { |
53 | Clipperz.Base.exception.raise('MandatoryParameter'); | 50 | Clipperz.Base.exception.raise('MandatoryParameter'); |
54 | } | 51 | } |
55 | 52 | ||
56 | 53 | ||
57 | this._encryptedDataKeypath = args.encryptedDataKeypath || 'data'; //Clipperz.Base.exception.raise('MandatoryParameter'); | 54 | this._encryptedDataKeypath = args.encryptedDataKeypath || 'data'; //Clipperz.Base.exception.raise('MandatoryParameter'); |
58 | this._encryptedVersionKeypath = args.encryptedVersionKeypath || 'version';//Clipperz.Base.exception.raise('MandatoryParameter'); | 55 | this._encryptedVersionKeypath = args.encryptedVersionKeypath || 'version';//Clipperz.Base.exception.raise('MandatoryParameter'); |
59 | 56 | ||
60 | 57 | ||
61 | this._transientState = null; | 58 | this._transientState = null; |
62 | this._deferredLocks = {}; | 59 | this._deferredLocks = {}; |
63 | 60 | ||
64 | if (this._isBrandNew == true) { | 61 | if (this._isBrandNew == true) { |
65 | this._objectDataStore = new Clipperz.KeyValueObjectStore(/*{'name':'EncryptedRemoteObject.objectDataStore [1]'}*/); | 62 | this._objectDataStore = new Clipperz.KeyValueObjectStore(/*{'name':'EncryptedRemoteObject.objectDataStore [1]'}*/); |
66 | } else { | 63 | } else { |
67 | this._objectDataStore = null; | 64 | this._objectDataStore = null; |
68 | } | 65 | } |
69 | 66 | ||
70 | return this; | 67 | return this; |
71 | } | 68 | } |
72 | 69 | ||
73 | // | 70 | // |
74 | // Basic data workflow | 71 | // Basic data workflow |
75 | //======================= | 72 | //======================= |
76 | // | 73 | // |
77 | //getRemoteData | 74 | //getRemoteData |
78 | // unpackRemoteData | 75 | // unpackRemoteData |
79 | // getDecryptData [encryptedDataKeypath, encryptedVersionKeypath] | 76 | // getDecryptData [encryptedDataKeypath, encryptedVersionKeypath] |
80 | // unpackData | 77 | // unpackData |
81 | // | 78 | // |
82 | // | 79 | // |
83 | // ?? packData | 80 | // ?? packData |
84 | // ?? encryptDataWithKey | 81 | // ?? encryptDataWithKey |
85 | // ??packRemoteData [encryptedDataKeypath (?), encryptedVersionKeypath (?)] | 82 | // ??packRemoteData [encryptedDataKeypath (?), encryptedVersionKeypath (?)] |
86 | // | 83 | // |
87 | 84 | ||
88 | Clipperz.PM.DataModel.EncryptedRemoteObject.prototype = MochiKit.Base.update(null, { | 85 | Clipperz.PM.DataModel.EncryptedRemoteObject.prototype = MochiKit.Base.update(null, { |
89 | 86 | ||
90 | 'toString': function () { | 87 | 'toString': function () { |
91 | return "Clipperz.PM.DataModel.EncryptedRemoteObject" + (this.name() != null ? " - " + this.name() : ""); | 88 | return "Clipperz.PM.DataModel.EncryptedRemoteObject" + (this.name() != null ? " - " + this.name() : ""); |
92 | }, | 89 | }, |
93 | 90 | ||
94 | //------------------------------------------------------------------------- | 91 | //------------------------------------------------------------------------- |
95 | 92 | ||
96 | 'name': function () { | 93 | 'name': function () { |
97 | return this._name; | 94 | return this._name; |
98 | }, | 95 | }, |
99 | 96 | ||
100 | //------------------------------------------------------------------------- | 97 | //------------------------------------------------------------------------- |
101 | 98 | ||
102 | 'reference': function () { | 99 | 'reference': function () { |
103 | return this._reference; | 100 | return this._reference; |
104 | }, | 101 | }, |
105 | 102 | ||
106 | 'setReference': function (aValue) { | 103 | 'setReference': function (aValue) { |
107 | this._reference = aValue; | 104 | this._reference = aValue; |
108 | 105 | ||
109 | return this._reference; | 106 | return this._reference; |
110 | }, | 107 | }, |
111 | 108 | ||
112 | //------------------------------------------------------------------------- | 109 | //------------------------------------------------------------------------- |
113 | 110 | ||
114 | 'transientState': function () { | 111 | 'transientState': function () { |
115 | if (this._transientState == null) { | 112 | if (this._transientState == null) { |
116 | this._transientState = new Clipperz.KeyValueObjectStore(/*{'name':'EncryptedRemoteObject.transientState [2]'}*/); | 113 | this._transientState = new Clipperz.KeyValueObjectStore(/*{'name':'EncryptedRemoteObject.transientState [2]'}*/); |
117 | } | 114 | } |
118 | 115 | ||
119 | return this._transientState; | 116 | return this._transientState; |
120 | }, | 117 | }, |