mirror of
http://git.whoc.org.uk/git/password-manager.git
synced 2025-12-17 03:47:04 +01:00
First version of the newly restructured repository
This commit is contained in:
187
frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Legacy.js
Normal file
187
frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Legacy.js
Normal file
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library is free software: you can redistribute
|
||||
it and/or modify it under the terms of the GNU Affero General Public
|
||||
License as published by the Free Software Foundation, either version
|
||||
3 of the License, or (at your option) any later version.
|
||||
|
||||
* Javascript Crypto Library is distributed in the hope that it will
|
||||
be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
License along with Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
try { if (typeof(Clipperz.PM.DataModel.User) == 'undefined') { throw ""; }} catch (e) {
|
||||
throw "Clipperz.PM.DataModel.User.Header.Legacy depends on Clipperz.PM.DataModel.User!";
|
||||
}
|
||||
|
||||
if (typeof(Clipperz.PM.DataModel.User.Header) == 'undefined') { Clipperz.PM.DataModel.User.Header = {}; }
|
||||
|
||||
Clipperz.PM.DataModel.User.Header.Legacy = function(args) {
|
||||
// args = args || {};
|
||||
Clipperz.PM.DataModel.User.Header.Legacy.superclass.constructor.apply(this, arguments);
|
||||
|
||||
this._retrieveRecordDetailFunction = args.retrieveRecordDetailFunction || Clipperz.Base.exception.raise('MandatoryParameter');
|
||||
this._records = null;
|
||||
// this._directLogins = null;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Clipperz.Base.extend(Clipperz.PM.DataModel.User.Header.Legacy, Clipperz.PM.DataModel.EncryptedRemoteObject, {
|
||||
|
||||
'toString': function() {
|
||||
return "Clipperz.PM.DataModel.User.Header.Legacy";
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'retrieveRecordDetailFunction': function () {
|
||||
return this._retrieveRecordDetailFunction;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'getRecordKey': function (aRecordReference) {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("User.Header.Legacy.getRecordKey", {trace:false});
|
||||
deferredResult.addMethod(this, 'getRecordIndexData');
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter('key'))
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//=========================================================================
|
||||
|
||||
'getRecordIndexData': function (aRecordReference) {
|
||||
return this.getValue('records.' + aRecordReference);
|
||||
},
|
||||
|
||||
'updateRecordIndexData': function (aRecordReference, aKey, aValue) {
|
||||
return this.setValue('records.' + aRecordReference + "." + aKey, aValue);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'getDirectLoginIndexData': function (aDirectLoginReference) {
|
||||
return this.getValue('directLogins.' + aDirectLoginReference);
|
||||
},
|
||||
|
||||
'setDirectLoginIndexData': function (aDirectLoginReference, aKey, aValue) {
|
||||
return this.setValue('directLogins.' + aDirectLoginReference + '.' + aKey, aValue);
|
||||
},
|
||||
|
||||
'removeDirectLoginIndexData': function (aDirectLoginReference) {
|
||||
return this.removeValue('directLogins.' + aDirectLoginReference);
|
||||
},
|
||||
|
||||
//=========================================================================
|
||||
|
||||
'records': function () {
|
||||
var deferredResult;
|
||||
var deferredLock;
|
||||
|
||||
deferredLock = this.getDeferredLockForKey('records');
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("User.Header.Legacy.records", {trace:false});
|
||||
deferredResult.acquireLock(deferredLock);
|
||||
deferredResult.addCallback(MochiKit.Base.bind(function () {
|
||||
var innerDeferredResult;
|
||||
|
||||
if (this._records == null) {
|
||||
innerDeferredResult = new Clipperz.Async.Deferred("User.Header.Legacy.records <inner deferred>", {trace:false});
|
||||
innerDeferredResult.collectResults({
|
||||
'header': [
|
||||
// MochiKit.Base.method(this, 'getObjectDataStore'),
|
||||
// MochiKit.Base.methodcaller('values')
|
||||
MochiKit.Base.method(this, 'values')
|
||||
],
|
||||
'recordsStats': [
|
||||
MochiKit.Base.method(this, 'getRemoteData'),
|
||||
MochiKit.Base.itemgetter('recordsStats')
|
||||
]
|
||||
});
|
||||
innerDeferredResult.addCallback(MochiKit.Base.bind(function (someObjectData) {
|
||||
var reference;
|
||||
|
||||
this._records = {};
|
||||
// this._directLogins = {};
|
||||
|
||||
for (reference in someObjectData['header']['records']) {
|
||||
var record;
|
||||
|
||||
record = new Clipperz.PM.DataModel.Record({
|
||||
'reference': reference,
|
||||
'retrieveKeyFunction': MochiKit.Base.method(this, 'getRecordKey'),
|
||||
'retrieveRemoteDataFunction': this.retrieveRecordDetailFunction(),
|
||||
// 'encryptedDataKeypath': 'data',
|
||||
// 'encryptedVersionKeypath': 'version',
|
||||
|
||||
'retrieveIndexDataFunction': MochiKit.Base.method(this, 'getRecordIndexData'),
|
||||
'updateIndexDataFunction': MochiKit.Base.method(this, 'updateRecordIndexData'),
|
||||
'updateDate': someObjectData['recordsStats'][reference]['updateDate'],
|
||||
|
||||
'retrieveDirectLoginIndexDataFunction': MochiKit.Base.method(this, 'getDirectLoginIndexData'),
|
||||
'setDirectLoginIndexDataFunction': MochiKit.Base.method(this, 'setDirectLoginIndexData'),
|
||||
'removeDirectLoginIndexDataFunction': MochiKit.Base.method(this, 'removeDirectLoginIndexData')
|
||||
});
|
||||
|
||||
this._records[reference] = record;
|
||||
}
|
||||
|
||||
for (reference in someObjectData['header']['directLogins']) {
|
||||
var directLogin;
|
||||
var record;
|
||||
|
||||
record = this._records[someObjectData['header']['directLogins'][reference]['record']];
|
||||
if (record != null) {
|
||||
directLogin = new Clipperz.PM.DataModel.DirectLogin({
|
||||
'reference': reference,
|
||||
'record': record //,
|
||||
// 'retrieveIndexDataFunction': MochiKit.Base.method(this, 'getDirectLoginIndexData'),
|
||||
// 'setIndexDataFunction': MochiKit.Base.method(this, 'setDirectLoginIndexData'),
|
||||
// 'removeIndexDataFunction': MochiKit.Base.method(this, 'removeDirectLoginIndexData')
|
||||
});
|
||||
} else {
|
||||
Clipperz.log("WARNING: DIRECT LOGIN without a matching RECORD!!");
|
||||
}
|
||||
}
|
||||
|
||||
return this._records;
|
||||
}, this));
|
||||
innerDeferredResult.callback();
|
||||
} else {
|
||||
innerDeferredResult = MochiKit.Async.succeed(this._records);
|
||||
}
|
||||
|
||||
return innerDeferredResult;
|
||||
}, this));
|
||||
deferredResult.releaseLock(deferredLock);
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//=========================================================================
|
||||
__syntaxFix__: "syntax fix"
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user