summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/Connection.js
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Connection.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/Connection.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Connection.js b/frontend/beta/js/Clipperz/PM/Connection.js
index e81c7a6..613e7d6 100644
--- a/frontend/beta/js/Clipperz/PM/Connection.js
+++ b/frontend/beta/js/Clipperz/PM/Connection.js
@@ -1,214 +1,212 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2013 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz, the online password manager.
6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 6For further information about its features and functionalities please
8refer to http://www.clipperz.com. 7refer 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
26if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } 24if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
27if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } 25if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
28 26
29//----------------------------------------------------------------------------- 27//-----------------------------------------------------------------------------
30// 28//
31 // Abstract C O N N E C T I O N class 29 // Abstract C O N N E C T I O N class
32// 30//
33//----------------------------------------------------------------------------- 31//-----------------------------------------------------------------------------
34 32
35Clipperz.PM.Connection = function (args) { 33Clipperz.PM.Connection = function (args) {
36 args = args || {}; 34 args = args || {};
37 35
38 this._user = args.user; 36 this._user = args.user;
39 this._clipperz_pm_crypto_version = null; 37 this._clipperz_pm_crypto_version = null;
40 this._connectionId = null; 38 this._connectionId = null;
41 this._oneTimePassword = null; 39 this._oneTimePassword = null;
42 40
43 return this; 41 return this;
44} 42}
45 43
46Clipperz.PM.Connection.prototype = MochiKit.Base.update(null, { 44Clipperz.PM.Connection.prototype = MochiKit.Base.update(null, {
47 45
48 'user': function() { 46 'user': function() {
49 return this._user; 47 return this._user;
50 }, 48 },
51 49
52 'toString': function() { 50 'toString': function() {
53 return "Connection [" + this.version() + "] - user: " + this.user(); 51 return "Connection [" + this.version() + "] - user: " + this.user();
54 }, 52 },
55 53
56 //========================================================================= 54 //=========================================================================
57 55
58 'version': function() { 56 'version': function() {
59 throw Clipperz.Base.exception.AbstractMethod; 57 throw Clipperz.Base.exception.AbstractMethod;
60 }, 58 },
61 59
62 'clipperz_pm_crypto_version': function() { 60 'clipperz_pm_crypto_version': function() {
63 if (this._clipperz_pm_crypto_version == null) { 61 if (this._clipperz_pm_crypto_version == null) {
64 var connectionVersions; 62 var connectionVersions;
65 varversions; 63 varversions;
66 varversion; 64 varversion;
67 var i, c; 65 var i, c;
68 66
69 version = null; 67 version = null;
70 connectionVersions = Clipperz.PM.Crypto.communicationProtocol.versions; 68 connectionVersions = Clipperz.PM.Crypto.communicationProtocol.versions;
71 versions = MochiKit.Base.keys(connectionVersions); 69 versions = MochiKit.Base.keys(connectionVersions);
72 c = versions.length; 70 c = versions.length;
73 for (i=0; i<c; i++) { 71 for (i=0; i<c; i++) {
74 if (! (versions[i] == 'current')) { 72 if (! (versions[i] == 'current')) {
75 if (this instanceof connectionVersions[versions[i]]) { 73 if (this instanceof connectionVersions[versions[i]]) {
76 version = versions[i]; 74 version = versions[i];
77 }; 75 };
78 } 76 }
79 } 77 }
80 78
81 this._clipperz_pm_crypto_version = version; 79 this._clipperz_pm_crypto_version = version;
82 } 80 }
83 81
84 return this._clipperz_pm_crypto_version; 82 return this._clipperz_pm_crypto_version;
85 }, 83 },
86 84
87 //------------------------------------------------------------------------- 85 //-------------------------------------------------------------------------
88 86
89 'defaultErrorHandler': function(anErrorString, anException) { 87 'defaultErrorHandler': function(anErrorString, anException) {
90MochiKit.Logging.logError("### Connection.defaultErrorHandler: " + anErrorString + " (" + anException + ")"); 88MochiKit.Logging.logError("### Connection.defaultErrorHandler: " + anErrorString + " (" + anException + ")");
91 }, 89 },
92 90
93 //------------------------------------------------------------------------- 91 //-------------------------------------------------------------------------
94 92
95 'login': function(someArguments, aCallback) { 93 'login': function(someArguments, aCallback) {
96 throw Clipperz.Base.exception.AbstractMethod; 94 throw Clipperz.Base.exception.AbstractMethod;
97 }, 95 },
98 96
99 //------------------------------------------------------------------------- 97 //-------------------------------------------------------------------------
100 98
101 'message': function(someArguments, aCallback) { 99 'message': function(someArguments, aCallback) {
102 throw Clipperz.Base.exception.AbstractMethod; 100 throw Clipperz.Base.exception.AbstractMethod;
103 }, 101 },
104 102
105 //------------------------------------------------------------------------- 103 //-------------------------------------------------------------------------
106 104
107 'sharedSecret': function() { 105 'sharedSecret': function() {
108 throw Clipperz.Base.exception.AbstractMethod; 106 throw Clipperz.Base.exception.AbstractMethod;
109 }, 107 },
110 108
111 'serverSideUserCredentials': function() { 109 'serverSideUserCredentials': function() {
112 throw Clipperz.Base.exception.AbstractMethod; 110 throw Clipperz.Base.exception.AbstractMethod;
113 }, 111 },
114 112
115 //========================================================================= 113 //=========================================================================
116 114
117 'connectionId': function() { 115 'connectionId': function() {
118 return this._connectionId; 116 return this._connectionId;
119 }, 117 },
120 118
121 'setConnectionId': function(aValue) { 119 'setConnectionId': function(aValue) {
122 this._connectionId = aValue; 120 this._connectionId = aValue;
123 }, 121 },
124 122
125 //========================================================================= 123 //=========================================================================
126 124
127 'oneTimePassword': function() { 125 'oneTimePassword': function() {
128 return this._oneTimePassword; 126 return this._oneTimePassword;
129 }, 127 },
130 128
131 'setOneTimePassword': function(aValue) { 129 'setOneTimePassword': function(aValue) {
132 this._oneTimePassword = aValue; 130 this._oneTimePassword = aValue;
133 }, 131 },
134 132
135 //========================================================================= 133 //=========================================================================
136 __syntaxFix__: "syntax fix" 134 __syntaxFix__: "syntax fix"
137 135
138} 136}
139); 137);
140 138
141 139
142if (typeof(Clipperz.PM.Connection.SRP) == 'undefined') { Clipperz.PM.Connection.SRP = {}; } 140if (typeof(Clipperz.PM.Connection.SRP) == 'undefined') { Clipperz.PM.Connection.SRP = {}; }
143//----------------------------------------------------------------------------- 141//-----------------------------------------------------------------------------
144// 142//
145 // S R P [ 1 . 0 ] C O N N E C T I O N class 143 // S R P [ 1 . 0 ] C O N N E C T I O N class
146// 144//
147//----------------------------------------------------------------------------- 145//-----------------------------------------------------------------------------
148 146
149Clipperz.PM.Connection.SRP['1.0'] = function (args) { 147Clipperz.PM.Connection.SRP['1.0'] = function (args) {
150 args = args || {}; 148 args = args || {};
151 Clipperz.PM.Connection.call(this, args); 149 Clipperz.PM.Connection.call(this, args);
152 150
153 this._C = null; 151 this._C = null;
154 this._P = null; 152 this._P = null;
155 this._srpConnection = null; 153 this._srpConnection = null;
156 154
157 return this; 155 return this;
158} 156}
159 157
160Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz.PM.Connection(), { 158Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz.PM.Connection(), {
161 159
162 'version': function() { 160 'version': function() {
163 return '1.0'; 161 return '1.0';
164 }, 162 },
165 163
166 //========================================================================= 164 //=========================================================================
167 165
168 'register': function(anInvitationCode) { 166 'register': function(anInvitationCode) {
169 var deferredResult; 167 var deferredResult;
170 varparameters; 168 varparameters;
171 169
172//MochiKit.Logging.logError(">>> Connection.register: " + this); 170//MochiKit.Logging.logError(">>> Connection.register: " + this);
173 parameters = {}; 171 parameters = {};
174 deferredResult = new MochiKit.Async.Deferred(); 172 deferredResult = new MochiKit.Async.Deferred();
175//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Connection.register - 1: " + res); return res;}); 173//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Connection.register - 1: " + res); return res;});
176 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'registration_verify'); 174 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'registration_verify');
177//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Connection.register - 2: " + res); return res;}); 175//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Connection.register - 2: " + res); return res;});
178 deferredResult.addCallback(function(aConnection, anInvitationCode) { 176 deferredResult.addCallback(function(aConnection, anInvitationCode) {
179 var args; 177 var args;
180 178
181 args = {}; 179 args = {};
182 args.message = 'register'; 180 args.message = 'register';
183 args.version = aConnection.clipperz_pm_crypto_version(); 181 args.version = aConnection.clipperz_pm_crypto_version();
184 args.invitationCode = anInvitationCode; 182 args.invitationCode = anInvitationCode;
185 183
186 return args; 184 return args;
187 }, this); 185 }, this);
188//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Connection.register - 3: " + res); return res;}); 186//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Connection.register - 3: " + res); return res;});
189 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'registration_sendingCredentials'); 187 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'registration_sendingCredentials');
190//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Connection.register - 4: " + res); return res;}); 188//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Connection.register - 4: " + res); return res;});
191 deferredResult.addCallback(MochiKit.Base.method(this.user(), 'encryptedData')); 189 deferredResult.addCallback(MochiKit.Base.method(this.user(), 'encryptedData'));
192//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Connection.register - 5: " + res); return res;}); 190//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Connection.register - 5: " + res); return res;});
193 deferredResult.addCallback(function(someParameters, anUser, anEncryptedData) { 191 deferredResult.addCallback(function(someParameters, anUser, anEncryptedData) {
194 var currentVersionConnection; 192 var currentVersionConnection;
195 var args; 193 var args;
196 194
197 currentVersionConnection = new Clipperz.PM.Crypto.communicationProtocol.versions['current']({user:anUser}); 195 currentVersionConnection = new Clipperz.PM.Crypto.communicationProtocol.versions['current']({user:anUser});
198 196
199 args = someParameters 197 args = someParameters
200 args.credentials = currentVersionConnection.serverSideUserCredentials(); 198 args.credentials = currentVersionConnection.serverSideUserCredentials();
201 args.user = anEncryptedData; 199 args.user = anEncryptedData;
202 args.version = args.credentials.version; 200 args.version = args.credentials.version;
203 args.message = "completeRegistration"; 201 args.message = "completeRegistration";
204 202
205 return args; 203 return args;
206 }, parameters, this.user()); 204 }, parameters, this.user());
207//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Connection.register - 6: " + res); return res;}); 205//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Connection.register - 6: " + res); return res;});
208 deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Proxy.defaultProxy, 'registration')); 206 deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Proxy.defaultProxy, 'registration'));
209//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Connection.register - 7: " + Clipperz.Base.serializeJSON(res)); return res;}); 207//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Connection.register - 7: " + Clipperz.Base.serializeJSON(res)); return res;});
210 deferredResult.addCallback(MochiKit.Base.bind(function(res) { 208 deferredResult.addCallback(MochiKit.Base.bind(function(res) {
211 this.user().setLock(res['lock']); 209 this.user().setLock(res['lock']);
212 210
213 return res; 211 return res;
214 }, this)); 212 }, this));