summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--backend/php/src/configuration.php6
-rw-r--r--backend/php/src/index.php189
-rw-r--r--frontend/beta/js/Clipperz/PM/DataModel/Record.js7
-rw-r--r--frontend/beta/js/Clipperz/PM/Proxy.js3
-rwxr-xr-xfrontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js262
-rw-r--r--frontend/gamma/html/index_template.html5
-rw-r--r--frontend/gamma/js/Clipperz/Async.js19
-rw-r--r--frontend/gamma/js/Clipperz/PM/Proxy.js2
8 files changed, 205 insertions, 288 deletions
diff --git a/backend/php/src/configuration.php b/backend/php/src/configuration.php
index 291e3a1..85f680e 100644
--- a/backend/php/src/configuration.php
+++ b/backend/php/src/configuration.php
@@ -1,36 +1,36 @@
<?php
global $configuration;
$configuration['soap'] = "http://www.phpobjectgenerator.com/services/soap.php?wsdl";
$configuration['homepage'] = "http://www.phpobjectgenerator.com";
$configuration['revisionNumber'] = "";
$configuration['versionNumber'] = "3.0d";
$configuration['setup_password'] = '';
// to enable automatic data encoding, run setup, go to the manage plugins tab and install the base64 plugin.
// then set db_encoding = 1 below.
// when enabled, db_encoding transparently encodes and decodes data to and from the database without any
// programmatic effort on your part.
$configuration['db_encoding'] = 0;
// edit the information below to match your database settings
-$configuration['db'] = 'clipperz'; // database name
+$configuration['db'] = 'clipperz'; // database name
$configuration['host'] = 'localhost'; // database host
-$configuration['user'] = 'root'; // database user
-$configuration['pass'] = 'pass'; // database password
+$configuration['user'] = 'clipperz'; // database user
+$configuration['pass'] = 'clipperz'; // database password
$configuration['port'] = '3306'; // database port
//proxy settings - if you are behnd a proxy, change the settings below
$configuration['proxy_host'] = false;
$configuration['proxy_port'] = false;
$configuration['proxy_username'] = false;
$configuration['proxy_password'] = false;
//plugin settings
$configuration['plugins_path'] = dirname(__FILE__).'/plugins';
?> \ No newline at end of file
diff --git a/backend/php/src/index.php b/backend/php/src/index.php
index 214ac01..da7c60c 100644
--- a/backend/php/src/index.php
+++ b/backend/php/src/index.php
@@ -1,755 +1,918 @@
<?php
include "./configuration.php";
include "./objects/class.database.php";
include "./objects/class.user.php";
include "./objects/class.record.php";
include "./objects/class.recordversion.php";
include "./objects/class.onetimepassword.php";
include "./objects/class.onetimepasswordstatus.php";
//-----------------------------------------------------------------------------
if ( !function_exists('json_decode') ) {
function json_decode($content, $assoc=false) {
require_once 'json/JSON.php';
if ( $assoc ) {
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
} else {
$json = new Services_JSON;
}
return $json->decode($content);
}
}
if ( !function_exists('json_encode') ) {
function json_encode($content) {
require_once 'json/JSON.php';
$json = new Services_JSON;
return $json->encode($content);
}
}
//-----------------------------------------------------------------------------
// 'dec2base', 'base2dec' and 'digits' are functions found on the following
// PHP manual page: http://ch2.php.net/manual/en/ref.bc.php
//
function dec2base($dec, $base, $digits=FALSE) {
if ($base<2 or $base>256) {
die("Invalid Base: ".$base);
}
bcscale(0);
$value="";
if (!$digits) {
$digits = digits($base);
}
while ($dec > $base-1) {
$rest = bcmod($dec, $base);
$dec = bcdiv($dec, $base);
$value = $digits[$rest].$value;
}
$value=$digits[intval($dec)].$value;
return (string)$value;
}
//.............................................................................
// convert another base value to its decimal value
function base2dec($value, $base, $digits=FALSE) {
if ($base<2 or $base>256) {
die("Invalid Base: ".$base);
}
bcscale(0);
if ($base<37) {
$value=strtolower($value);
}
if (!$digits) {
$digits=digits($base);
}
$size = strlen($value);
$dec="0";
for ($loop=0; $loop<$size; $loop++) {
$element = strpos($digits, $value[$loop]);
$power = bcpow($base, $size-$loop-1);
$dec = bcadd($dec, bcmul($element,$power));
}
return (string)$dec;
}
//.............................................................................
function digits($base) {
if ($base>64) {
$digits="";
for ($loop=0; $loop<256; $loop++) {
$digits.=chr($loop);
}
} else {
$digits ="0123456789abcdefghijklmnopqrstuvwxyz";
$digits.="ABCDEFGHIJKLMNOPQRSTUVWXYZ-_";
}
$digits=substr($digits,0,$base);
return (string)$digits;
}
//-----------------------------------------------------------------------------
function clipperz_hash($value) {
return hash("sha256", hash("sha256", $value, true));
}
//-----------------------------------------------------------------------------
function clipperz_randomSeed() {
$result;
srand((double) microtime()*1000000);
$result = "";
while(strlen($result) < 64) {
$result = $result.dec2base(rand(), 16);
}
$result = substr($result, 0, 64);
return $result;
}
//-----------------------------------------------------------------------------
function updateUserCredentials($parameters, &$user) {
$user->username = $parameters["C"];
$user->srp_s = $parameters["s"];
$user->srp_v = $parameters["v"];
$user->auth_version = $parameters["version"];
}
function updateUserData($parameters, &$user) {
$user->header = $parameters["header"];
$user->statistics = $parameters["statistics"];
$user->version = $parameters["version"];
- $user->lock = $parameters["lock"];
+ if (array_key_exists("lock", $parameters)) {
+ $user->lock = $parameters["lock"];
+ }
}
function updateRecordData($parameters, &$record, &$recordVersion) {
$recordData = $parameters["record"];
$record->reference = $recordData["reference"];
$record->data = $recordData["data"];
$record->version = $recordData["version"];
$recordVersionData = $parameters["currentRecordVersion"];
$recordVersion->reference = $recordVersionData ["reference"];
$recordVersion->data = $recordVersionData ["data"];
$recordVersion->version = $recordVersionData ["version"];
- $recordVersion->previous_version_id = $recordVersionData ["previousVersion"];
+ if (array_key_exists("previousVersion", $recordVersionData)) {
+ $recordVersion->previous_version_id = $recordVersionData ["previousVersion"];
+ }
$recordVersion->previous_version_key = $recordVersionData ["previousVersionKey"];
}
//-----------------------------------------------------------------------------
function updateOTPStatus(&$otp, $status) {
$otpStatus = new onetimepasswordstatus();
$selectedStatuses = $otpStatus->GetList(array(array("code", "=", $status)));
$otpStatus = $selectedStatuses[0];
$otp->SetOnetimepasswordstatus($otpStatus);
}
function updateOTP($parameters, &$otp, $status) {
$otp->reference = $parameters["reference"];
$otp->key = $parameters["key"];
$otp->key_checksum = $parameters["keyChecksum"];
$otp->data = $parameters["data"];
$otp->version = $parameters["version"];
updateOTPStatus($otp, $status);
}
function resetOTP(&$otp, $status) {
$otp->data = "";
updateOTPStatus($otp, $status);
$otp->Save();
}
//-----------------------------------------------------------------------------
function fixOTPStatusTable() {
$otpStatus = new onetimepasswordstatus();
$otpStatusList = $otpStatus->GetList();
if (count($otpStatusList) != 4) {
$otpStatus->DeleteList();
$otpStatus->code = "ACTIVE"; $otpStatus->name = "Active"; $otpStatus->description = "Active"; $otpStatus->SaveNew();
$otpStatus->code = "REQUESTED"; $otpStatus->name = "Requested"; $otpStatus->description = "Requested"; $otpStatus->SaveNew();
$otpStatus->code = "USED"; $otpStatus->name = "Used"; $otpStatus->description = "Used"; $otpStatus->SaveNew();
$otpStatus->code = "DISABLED"; $otpStatus->name = "Disabled"; $otpStatus->description = "Disabled"; $otpStatus->SaveNew();
}
}
//-----------------------------------------------------------------------------
function arrayContainsValue($array, $value) {
$object = NULL;
for ($i=0; $i<count($array); $i++) {
if ($array[$i] == $value) {
$object = $value;
}
}
return !is_null($object);
}
//-----------------------------------------------------------------------------
$result = Array();
session_start();
$method = $_POST['method'];
if (get_magic_quotes_gpc()) {
$parameters = json_decode(stripslashes($_POST['parameters']), true);
} else {
$parameters = json_decode($_POST['parameters'], true);
}
$parameters = $parameters["parameters"];
switch($method) {
case "registration":
error_log("registration");
$message = $parameters["message"];
if ($message == "completeRegistration") {
$user = new user();
updateUserCredentials($parameters["credentials"], $user);
updateUserData($parameters["user"], $user);
$user->Save();
$result["lock"] = $user->lock;
$result["result"] = "done";
}
break;
case "handshake":
error_log("handshake");
$srp_g = "2";
$srp_n = base2dec("115b8b692e0e045692cf280b436735c77a5a9e8a9e7ed56c965f87db5b2a2ece3", 16);
$message = $parameters["message"];
//=============================================================
if ($message == "connect") {
$user= new user();
$_SESSION["C"] = $parameters["parameters"]["C"];
$_SESSION["A"] = $parameters["parameters"]["A"];
$userList = $user->GetList(array(array("username", "=", $_SESSION["C"])));
if (count($userList) == 1) {
$currentUser = $userList[ 0 ];
if (array_key_exists("otpId", $_SESSION)) {
$otp = new onetimepassword();
$otp = $otp->Get($_SESSION["otpId"]);
if ($otp->GetUser()->userId != $currentUser->userId) {
throw new Exception("User missmatch between the current session and 'One Time Password' user");
} else if ($otp->GetOnetimepasswordstatus()->code != "REQUESTED") {
throw new Exception("Tring to use an 'One Time Password' in the wrong state");
}
resetOTP($otp, "USED");
$result["oneTimePassword"] = $otp->reference;
}
$_SESSION["s"] = $currentUser->srp_s;
$_SESSION["v"] = $currentUser->srp_v;
$_SESSION["userId"] = $currentUser->userId;
} else {
$_SESSION["s"] = "112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00";
$_SESSION["v"] = "112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00";
}
$_SESSION["b"] = clipperz_randomSeed();
// $_SESSION["b"] = "5761e6c84d22ea3c5649de01702d60f674ccfe79238540eb34c61cd020230c53";
$_SESSION["B"] = dec2base(bcadd(base2dec($_SESSION["v"], 16), bcpowmod($srp_g, base2dec($_SESSION["b"], 16), $srp_n)), 16);
$result["s"] = $_SESSION["s"];
$result["B"] = $_SESSION["B"];
//=============================================================
} else if ($message == "credentialCheck") {
error_log("credentialCheck");
$u = clipperz_hash(base2dec($_SESSION["B"],16));
$A = base2dec($_SESSION["A"], 16);
$S = bcpowmod(bcmul($A, bcpowmod(base2dec($_SESSION["v"], 16), base2dec($u, 16), $srp_n)), base2dec($_SESSION["b"], 16), $srp_n);
$K = clipperz_hash($S);
$M1 = clipperz_hash($A.base2dec($_SESSION["B"],16).$K);
//$result["B"] = $_SESSION["B"];
//$result["u"] = $u;
//$result["A"] = $A;
//$result["S"] = $S;
//$result["K"] = $K;
//$result["M1"] = $M1;
//$result["_M1"] = $parameters["parameters"]["M1"];
if ($M1 == $parameters["parameters"]["M1"]) {
$_SESSION["K"] = $K;
$M2 = clipperz_hash($A.$M1.$K);
$result["M2"] = $M2;
$result["connectionId"] = "";
$result["loginInfo"] = array();
$result["loginInfo"]["latest"] = array();
$result["loginInfo"]["current"] = array();
$result["offlineCopyNeeded"] = "false";
$result["lock"] = "----";
} else {
$result["error"] = "?";
}
//=============================================================
} else if ($message == "oneTimePassword") {
error_log("oneTimePassword");
//{
// "message":"oneTimePassword",
// "version":"0.2",
// "parameters":{
// "oneTimePasswordKey":"06dfa7f428081f8b2af98b0895e14e18af90b0ef2ff32828e55cc2ac6b24d29b",
// "oneTimePasswordKeyChecksum":"60bcba3f72e56f6bb3f0ff88509b9a0e5ec730dfa71daa4c1e892dbd1b0c360d"
// }
//}
$otp = new onetimepassword();
$otpList = $otp->GetList(array(array("key", "=", $parameters["parameters"]["oneTimePasswordKey"])));
if (count($otpList) == 1) {
$currentOtp = $otpList[0];
if ($currentOtp->GetOnetimepasswordstatus()->code == "ACTIVE") {
if ($currentOtp->key_checksum == $parameters["parameters"]["oneTimePasswordKeyChecksum"]) {
$_SESSION["userId"] = $currentOtp->GetUser()->userId;
$_SESSION["otpId"] = $currentOtp->onetimepasswordId;
$result["data"] = $currentOtp->data;
$result["version"] = $currentOtp->version;
resetOTP($currentOtp, "REQUESTED");
} else {
resetOTP($currentOtp, "DISABLED");
throw new Exception("The requested One Time Password has been disabled, due to a wrong keyChecksum");
}
} else {
throw new Exception("The requested One Time Password was not active");
}
} else {
throw new Exception("The requested One Time Password has not been found");
}
//=============================================================
}
break;
case "message":
error_log("message");
+//error_log("message: ".json_encode($parameters));
if ($parameters["srpSharedSecret"] == $_SESSION["K"]) {
$message = $parameters["message"];
//=============================================================
if ($message == "getUserDetails") {
//{"message":"getUserDetails", "srpSharedSecret":"f18e5cf7c3a83b67d4db9444af813ee48c13daf4f8f6635397d593e52ba89a08", "parameters":{}}
$user = new user();
$user = $user->Get($_SESSION["userId"]);
$result["header"] = $user->header;
$records = $user->GetRecordList();
foreach ($records as $record) {
$recordStats["updateDate"] = $record->update_date;
$recordsStats[$record->reference] = $recordStats;
}
$result["recordsStats"] = $recordsStats;
$result["statistics"] = $user->statistics;
$result["version"] = $user->version;
//=============================================================
} else if ($message == "addNewRecords") {
/*
//{
// "message":"addNewRecords",
// "srpSharedSecret":"b58fdf62acebbcb67f63d28c0437f166069f45690c648cd4376a792ae7a325f7",
// "parameters":{
// "records":[
// {
// "record":{
// "reference":"fda703707fee1fff42443124cd0e705f5bea0ac601758d81b2e832705339a610",
// "data":"OBSGtcb6blXq/xaYG.....4EqlQqgAvITN",
// "version":"0.3"
// },
// "currentRecordVersion":{
// "reference":"83ad301525c18f2afd72b6ac82c0a713382e1ef70ac69935ca7e2869dd4ff980",
// "recordReference":"fda703707fee1fff42443124cd0e705f5bea0ac601758d81b2e832705339a610",
// "data":"NXJ5jiZhkd0CMiwwntAq....1TjjF+SGfE=",
// "version":"0.3",
// "previousVersion":"3e174a86afc322271d8af28bc062b0f1bfd7344fad01212cd08b2757c4b199c4",
// "previousVersionKey":"kozaaGCzXWr71LbOKu6Z3nz520V..5U85tSBvb+u44twttv54Kw=="
// }
// }
// ],
// "user":{
// "header":"{\"reco...ersion\":\"0.1\"}",
// "statistics":"rKI6nR6iqggygQJ3SQ58bFUX",
// "version":"0.3",
// "lock":"----"
// }
// }
//}
*/
$user = new user();
$record = new record();
$recordVersion = new recordversion();
$user = $user->Get($_SESSION["userId"]);
updateUserData($parameters["parameters"]["user"], $user);
$recordParameterList = $parameters["parameters"]["records"];
$c = count($recordParameterList);
for ($i=0; $i<$c; $i++) {
updateRecordData($recordParameterList[$i], $record, $recordVersion);
$record->SaveNew();
$recordVersion->SaveNew();
$record->AddRecordversion($recordVersion);
$user->AddRecord($record);
$record->Save();
$recordVersion->Save();
}
$user->Save();
$result["lock"] = $user->lock;
$result["result"] = "done";
//=============================================================
+ } else if ($message == "saveChanges") {
+
+//{
+// "message":"saveChanges",
+// "srpSharedSecret":"edc78508907c942173818f7247fa64869ba80672a7aa8d27b8fa6bfe524fb9c8",
+// "parameters":{
+// "records":{
+// "updated":[
+// {
+// "currentRecordVersion":{
+// "previousVersionKey":"####",
+// "reference":"08c8eb7ec528fbf987bbfb84fe2e960cf9ae937b19fbb5f05d8d90a7039fac6a",
+// "data":"WYQ16AjodjsmyZDXa4MKxOju0F…beD/zXlbVb0Zj0ZI/N55bZ",
+// "version":"0.3"
+// },
+// "record":{
+// "reference":"83de5304f60a808e48a815c6203d7d3f24874d3f40faba420bbc60b376fcc356",
+// "data":"B6uBuBE Aly0knvgrUppodDTGZQC…guizL9QvHCWyM bQQBGBVvHZ6LfA==",
+// "version":"0.3"
+// }
+// }
+// ],
+// "deleted":[
+//
+// ]
+// },
+// "user":{
+// "header":"{\"rec…sion\":\"0.1\"}",
+// "statistics":"e6iXVEM4i8ZatPZFCCads/9F",
+// "version":"0.3"
+// }
+// }
+//}
+ $user = new user();
+ $user = $user->Get($_SESSION["userId"]);
+ updateUserData($parameters["parameters"]["user"], $user);
+
+ $recordToUpdateParameterList = $parameters["parameters"]["records"]["updated"];
+ $c = count($recordToUpdateParameterList);
+ for ($i=0; $i<$c; $i++) {
+ $recordList = $user->GetRecordList(array(array("reference", "=", $recordToUpdateParameterList [$i]["record"]["reference"])));
+ if (count($recordList) == 0) {
+ $currentRecord = new record();
+ $currentVersion = new recordversion();
+ $isNewRecord = true;
+ } else {
+ $currentRecord = $recordList[0];
+ $currentRecordVersions = $currentRecord->GetRecordversionList();
+ $currentVersion = $currentRecordVersions[0];
+ $isNewRecord = false;
+ }
+
+ updateRecordData($recordToUpdateParameterList[$i], $currentRecord, $currentVersion);
+
+ if ($isNewRecord == true) {
+ $currentRecord->SaveNew();
+ $currentVersion->SaveNew();
+
+ $currentRecord->AddRecordversion($currentVersion);
+ $user->AddRecord($currentRecord);
+ }
+
+ $currentRecord->Save();
+ $currentVersion->Save();
+ }
+
+ $user->Save();
+
+ $recordToDeleteReferenceList = $parameters["parameters"]["records"]["deleted"];
+ $recordList = array();
+ $c = count($recordToDeleteReferenceList);
+ for ($i=0; $i<$c; $i++) {
+ array_push($recordList, array("reference", "=", $recordToDeleteReferenceList[$i]));
+ }
+
+ $record = new record();
+ $record->DeleteList($recordList, true);
+
+ $result["lock"] = $user->lock;
+ $result["result"] = "done";
+
+ //=============================================================
} else if ($message == "getRecordDetail") {
//{
// "message":"getRecordDetail",
// "srpSharedSecret":"4c00dcb66a9f2aea41a87e4707c526874e2eb29cc72d2c7086837e53d6bf2dfe",
// "parameters":{
// "reference":"740009737139a189cfa2b1019a6271aaa39467b59e259706564b642ff3838d50"
// }
//}
//
// result = {
// currentVersion:{
// reference:"88943d709c3ea2442d4f58eaaec6409276037e5a37e0a6d167b9dad9e947e854",
// accessDate:"Wed, 13 February 2008 14:25:12 UTC",
// creationDate:"Tue, 17 April 2007 17:17:52 UTC",
// version:"0.2",
// data:"xI3WXddQLFtL......EGyKnnAVik",
// updateDate:"Tue, 17 April 2007 17:17:52 UTC",
// header:"####"
// }
// reference:"13a5e52976337ab210903cd04872588e1b21fb72bc183e91aa25c494b8138551",
// oldestUsedEncryptedVersion:"0.2",
// accessDate:"Wed, 13 February 2008 14:25:12 UTC",
// creationDate:"Wed, 14 March 2007 13:53:11 UTC",
// version:"0.2",
// updatedDate:"Tue, 17 April 2007 17:17:52 UTC",
// data:"0/BjzyY6jeh71h...pAw2++NEyylGhMC5C5f5m8pBApYziN84s4O3JQ3khW/1UttQl4="
// }
+
+
+// # Actual result (causing error in /gamma)
+// {
+// "result" : {
+// "currentVersion" : {
+// "reference" : "cb05177f96a832062c6b936d24323cb74a64e2ef1d97ee026cd1003755af7495",
+// "data" : "RAnoHmikp7RmiZ2WVyEMW+Ia",
+// "header" : "",
+// "version" : "0.3",
+// "creationDate" : "0000-00-00 00:00:00",
+// "updateDate" : "2011-10-09 19:49:11",
+// "accessDate" : "2011-10-09 19:49:11"
+// },
+// "reference" : "b07e2afa2ba782b9f379649b36ded6de0452b43c27e6b887c7ce4f2a93f44346",
+// "data" : "NtK1nkLUabbJQx5uO8ept...ZJ5dkJYYkyh3VQ==",
+// "version" : "0.3",
+// "creationDate" : "2011-10-09 19:49:11",
+// "updateDate" : "Tue, 30 Nov 1999 00:00:00 +0000",
+// "accessDate" : "0000-00-00 00:00:00",
+// "oldestUsedEncryptedVersion" : "---"
+// }
+// }
+
+
+// # Response from the online /gamma version
+// {
+// "result" : {
+// "versions" : {
+// "e2c193f017ad4f6babf51de59f7550a40596afc0c27373b6a360e426b5bc06de" : {
+// "reference" : "e2c193f017ad4f6babf51de59f7550a40596afc0c27373b6a360e426b5bc06de",
+// "data" : "s\/3ClggH4uCcf+BkIMqQ...+W0PVt\/MJ3t7s1g0g",
+// "creationDate" : "Mon, 10 October 2011 14:42:42 UTC",
+// "header" : "####",
+// "updateDate" : "Mon, 10 October 2011 14:42:42 UTC",
+// "previousVersion" : "a96a6d8b9ac73fcdf874d8a8534ffb2d43da8f5222e96a4a29bd2ae437619463",
+// "version" : "0.3",
+// "accessDate" : "Mon, 10 October 2011 14:42:42 UTC",
+// "previousVersionKey" : "####"
+// },
+// [...]
+// "a96a6d8b9ac73fcdf874d8a8534ffb2d43da8f5222e96a4a29bd2ae437619463" : {
+// "reference" : "a96a6d8b9ac73fcdf874d8a8534ffb2d43da8f5222e96a4a29bd2ae437619463",
+// "accessDate" : "Mon, 10 October 2011 14:41:17 UTC",
+// "creationDate" : "Mon, 27 October 2008 08:16:14 UTC",
+// "version" : "0.3",
+// "data" : "m3yhZu81UAjCY6U2Kn...IUCb9suV0fldGOg=",
+// "updateDate" : "Mon, 27 October 2008 08:16:14 UTC",
+// "header" : "####"
+// }
+// },
+// "oldestUsedEncryptedVersion" : "0.2",
+// "reference" : "36ec1a41118813ced3553534fa2607d781cba687768db305beed368a8e06e113",
+// "data" : "frlUkTbaOWD9j2ROat...ruWioCK0Mss27oHjPg==",
+// "creationDate" : "Wed, 14 March 2007 17:39:35 UTC",
+// "version" : "0.3",
+// "accessDate" : "Mon, 10 October 2011 14:45:12 UTC",
+// "currentVersion" : "e2c193f017ad4f6babf51de59f7550a40596afc0c27373b6a360e426b5bc06de",
+// "updatedDate" : "Mon, 10 October 2011 14:45:12 UTC"
+// },
+// "toll" : {
+// "requestType" : "MESSAGE",
+// "targetValue" : "a516c942a3792cc620775a41f8870a6c7b51796d9a94da978a75da6a52eb1e10",
+// "cost" : 2
+// }
+// }
+
$record = new record();
$recordList = $record->GetList(array(array("reference", "=", $parameters["parameters"]["reference"])));
$currentRecord = $recordList[0];
$currentRecordVersions = $currentRecord->GetRecordversionList();
$currentVersion = $currentRecordVersions[0];
-
- $result["currentVersion"] = array();
- $result["currentVersion"]["reference"] = $currentVersion->reference;
- $result["currentVersion"]["data"] = $currentVersion->data;
- $result["currentVersion"]["header"] = $currentVersion->header;
- $result["currentVersion"]["version"] = $currentVersion->version;
- $result["currentVersion"]["creationDate"] = $currentVersion->creation_date;
- $result["currentVersion"]["updateDate"] = $currentVersion->update_date;
- $result["currentVersion"]["accessDate"] = $currentVersion->access_date;
+
+ $result["versions"] = array();
+// foreach ($currentRecordVersions as $currentVersion) {
+ $result["versions"][$currentVersion->reference] = array();
+ $result["versions"][$currentVersion->reference]["reference"] = $currentVersion->reference;
+ $result["versions"][$currentVersion->reference]["data"] = $currentVersion->data;
+ $result["versions"][$currentVersion->reference]["header"] = $currentVersion->header;
+ $result["versions"][$currentVersion->reference]["version"] = $currentVersion->version;
+ $result["versions"][$currentVersion->reference]["creationDate"] = $currentVersion->creation_date;
+ $result["versions"][$currentVersion->reference]["updateDate"] = $currentVersion->update_date;
+ $result["versions"][$currentVersion->reference]["accessDate"] = $currentVersion->access_date;
+
+// }
+ $result["currentVersion"] = $currentVersion->reference;
+// $result["currentVersion"] = $currentRecord->currentVersion; // ????
$result["reference"] = $currentRecord->reference;
$result["data"] = $currentRecord->data;
$result["version"] = $currentRecord->version;
$result["creationDate"] = $currentRecord->creation_date;
$result["updateDate"] = $currentRecord->update_date;
$result["accessDate"] = $currentRecord->access_date;
$result["oldestUsedEncryptedVersion"] = "---";
//=============================================================
} else if ($message == "updateData") {
//{
// "message":"updateData",
// "srpSharedSecret":"4e4aadb1d64513ec4dd42f5e8d5b2d4363de75e4424b6bcf178c9d6a246356c5",
// "parameters":{
// "records":[
// {
// "record":{
// "reference":"740009737139a189cfa2b1019a6271aaa39467b59e259706564b642ff3838d50",
// "data":"8hgR0Z+JDrUa812polDJ....JnZUKXNEqKI",
// "version":"0.3"
// },
// "currentRecordVersion":{
// "reference":"b1d82aeb9a0c4f6584bea68ba80839f43dd6ede79791549e29a1860554b144ee",
// "recordReference":"740009737139a189cfa2b1019a6271aaa39467b59e259706564b642ff3838d50",
// "data":"2d/UgKxxV+kBPV9GRUE.....VGonDoW0tqefxOJo=",
// "version":"0.3",
// "previousVersion":"55904195249037394316d3be3f5e78f08073170103bf0e7ab49a911c159cb0be",
// "previousVersionKey":"YWiaZeMIVHaIl96OWW+2e8....6d6nHbn6cr2NA/dbQRuC2w=="
// }
// }
// ],
// "user":{
// "header":"{\"rec.....sion\":\"0.1\"}",
// "statistics":"tt3uU9hWBy8rNnMckgCnxMJh",
// "version":"0.3",
// "lock":"----"
// }
// }
//}
$user = new user();
$user = $user->Get($_SESSION["userId"]);
updateUserData($parameters["parameters"]["user"], $user);
$user->Save();
$recordParameterList = $parameters["parameters"]["records"];
$c = count($recordParameterList);
for ($i=0; $i<$c; $i++) {
$recordList = $user->GetRecordList(array(array("reference", "=", $recordParameterList[$i]["record"]["reference"])));
$currentRecord = $recordList[0];
$currentRecordVersions = $currentRecord->GetRecordversionList();
$currentVersion = $currentRecordVersions[0];
updateRecordData($recordParameterList[$i], $currentRecord, $currentVersion);
$currentRecord->Save();
$currentVersion->Save();
}
$result["lock"] = $user->lock;
$result["result"] = "done";
//=============================================================
} else if ($message == "deleteRecords") {
//{
// "message":"deleteRecords",
// "srpSharedSecret":"4a64982f7ee366954ec50b9efea62a902a097ef111410c2aa7c4d5343bd1cdd1",
// "parameters":{
// "recordReferences":["46494c81d10b80ab190d41e6806ef63869cfcc7a0ab8fe98cc3f93de4729bb9a"],
// "user":{
// "header":"{\"rec...rsion\":\"0.1\"}",
// "statistics":"44kOOda0xYZjbcugJBdagBQx",
// "version":"0.3",
// "lock":"----"
// }
// }
//}
$user = new user();
$user = $user->Get($_SESSION["userId"]);
$recordReferenceList = $parameters["parameters"]["recordReferences"];
$recordList = array();
$c = count($recordReferenceList);
for ($i=0; $i<$c; $i++) {
array_push($recordList, array("reference", "=", $recordReferenceList[$i]));
}
$record = new record();
$record->DeleteList($recordList, true);
updateUserData($parameters["parameters"]["user"], $user);
$user->Save();
$result["recordList"] = $recordList;
$result["lock"] = $user->lock;
$result["result"] = "done";
//=============================================================
} else if ($message == "deleteUser") {
//{"message":"deleteUser", "srpSharedSecret":"e8e4ca6544dca49c95b3647d8358ad54c317048b74d2ac187ac25f719c9bac58", "parameters":{}}
$user = new user();
$user->Get($_SESSION["userId"]);
$user->Delete(true);
$result["result"] = "ok";
//=============================================================
} else if ($message == "addNewOneTimePassword") {
//{
// "message":"addNewOneTimePassword",
// "srpSharedSecret":"96fee4af06c09ce954fe7a9f87970e943449186bebf70bac0af1d6ebb818dabb",
// "parameters":{
// "user":{
// "header":"{\"records\":{\"index\":{\"419ea6....rsion\":\"0.1\"}",
// "statistics":"rrlwNbDt83rpWT4S72upiVsC",
// "version":"0.3",
// "lock":"----"
// },
// "oneTimePassword":{
// "reference":"29e26f3a2aae61fe5cf58c45296c6df4f3dceafe067ea550b455be345f44123c",
// "key":"afb848208758361a96a298b9db08995cf036011747809357a90645bc93fdfa03",
// "keyChecksum":"d1599ae443b5a566bfd93c0aeec4c81b42c0506ee09874dae050449580bb3486",
// "data":"hsyY8DHksgR52x6c4j7XAtIUeY.....dxsr3XWt7CbGg==",
// "version":"0.3"
// }
// }
//}
fixOTPStatusTable();
$user = new user();
$user = $user->Get($_SESSION["userId"]);
$otp = new onetimepassword();
updateOTP($parameters["parameters"]["oneTimePassword"], $otp, "ACTIVE");
$user->AddOnetimepassword($otp);
updateUserData($parameters["parameters"]["user"], $user);
$user->Save();
$result["lock"] = $user->lock;
$result["result"] = "done";
//=============================================================
} else if ($message == "updateOneTimePasswords") {
//{
// "message":"updateOneTimePasswords",
// "srpSharedSecret":"c78f8ed099ea421f4dd0a4e02dbaf1f7da925f0088188d99399874ff064a3d27",
// "parameters":{
// "user":{
// "header":"{\"reco...sion\":\"0.1\"}",
// "statistics":"UeRq75RZHzDC7elzrh/+OB5d",
// "version":"0.3",
// "lock":"----"
// },
// "oneTimePasswords":["f5f44c232f239efe48ab81a6236deea1a840d52946f7d4d782dad52b4c5359ce"]
// }
//}
$user = new user();
$user = $user->Get($_SESSION["userId"]);
$validOtpReferences = $parameters["parameters"]["oneTimePasswords"];
$otpList = $user->GetOnetimepasswordList();
$c = count($otpList);
for ($i=0; $i<$c; $i++) {
$currentOtp = $otpList[$i];
if (arrayContainsValue($validOtpReferences, $currentOtp->reference) == false) {
$currentOtp->Delete();
}
}
updateUserData($parameters["parameters"]["user"], $user);
$user->Save();
$result["result"] = $user->lock;
//=============================================================
} else if ($message == "getOneTimePasswordsDetails") {
//=============================================================
} else if ($message == "getLoginHistory") {
$result["result"] = array();
//=============================================================
} else if ($message == "upgradeUserCredentials") {
//{
// "message":"upgradeUserCredentials",
// "srpSharedSecret":"f1c25322e1478c8fb26063e9eef2f6fc25e0460065a31cb718f80bcff8f8a735",
// "parameters":{
// "user":{
// "header":"{\"reco...sion\":\"0.1\"}",
// "statistics":"s72Xva+w7CLgH+ihwqwXUbyu",
// "version":"0.3",
// "lock":"----"
// },
// "credentials":{
// "C":"57d15a8afbc1ae08103bd991d387ddfd8d26824276476fe709d754f098b6c26d",
// "s":"d6735fc0486f391c4f3c947928f9e61a2418e7bed2bc9b25bb43f93acc52f636",
// "v":"540c2ebbf941a481b6b2c9026c07fb46e8202e4408ed96864a696deb622baece",
// "version":"0.2"
// },
// "oneTimePasswords":{
// "923cdc61c4b877b263236124c44d69b459d240453a461cce8ddf7518b423ca94": "1HD6Ta0xsifEDhDwE....9WDK6tvrS6w==",
// "fb1573cb9497652a81688a099a524fb116e604c6fbc191cf33406eb8438efa5f": "CocN0cSxLmMRdgNF9....o3xhGUEY68Q=="
// }
// }
//}
$user = new user();
$user->Get($_SESSION["userId"]);
$otp = new onetimepassword();
updateUserCredentials($parameters["parameters"]["credentials"], $user);
updateUserData($parameters["parameters"]["user"], $user);
$otpList = $parameters["parameters"]["oneTimePasswords"];
foreach($otpList as $otpReference=>$otpData) {
$otpList = $otp->GetList(array(array("reference", "=", $otpReference)));
$currentOtp = $otpList[0];
$currentOtp->data = $otpData;
$currentOtp->Save();
}
$user->Save();
$result["lock"] = $user->lock;
$result["result"] = "done";
//=============================================================
} else if ($message == "echo") {
$result["result"] = $parameters;
}
//=============================================================
} else if (isset($_SESSION['K'])) {
$result["error"] = "Wrong shared secret!";
} else {
$result["result"] = "EXCEPTION";
$result["message"] = "Trying to communicate without an active connection";
}
break;
case "logout":
error_log("logout");
session_destroy();
break;
default:
error_log("default");
$result["result"] = $parameters;
break;
}
session_write_close();
+
+ $finalResult = Array();
+ $finalResult["result"] = $result;
- echo(json_encode($result));
-error_log("result: ".json_encode($result));
+ echo(json_encode($finalResult));
+error_log("result: ".json_encode($finalResult));
?>
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/Record.js b/frontend/beta/js/Clipperz/PM/DataModel/Record.js
index 270f2ae..ffb45de 100644
--- a/frontend/beta/js/Clipperz/PM/DataModel/Record.js
+++ b/frontend/beta/js/Clipperz/PM/DataModel/Record.js
@@ -1,756 +1,761 @@
/*
Copyright 2008-2011 Clipperz Srl
This file is part of Clipperz Community Edition.
Clipperz Community Edition is an online password manager.
For further information about its features and functionalities please
refer to http://www.clipperz.com.
* Clipperz Community Edition 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.
* Clipperz Community Edition 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 Clipperz Community Edition. If not, see
<http://www.gnu.org/licenses/>.
*/
if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; }
//#############################################################################
Clipperz.PM.DataModel.Record = function(args) {
args = args || {};
this._user = args['user'] || null;
this._reference = args['reference'] || Clipperz.PM.Crypto.randomKey();
this._version = args['version'] || Clipperz.PM.Crypto.encryptingFunctions.currentVersion;
this._key = args['key'] || Clipperz.PM.Crypto.randomKey();
this.setLabel(args['label'] || Clipperz.PM.Strings['newRecordTitleLabel']);
this.setHeaderNotes(args['headerNotes'] || null);
this.setNotes(args['notes'] || args['headerNotes'] || "");
//MochiKit.Logging.logDebug("--- new Record ('" + this._label + "')- _headerNotes: '" + this._headerNotes + "'");
//MochiKit.Logging.logDebug("--- new Record ('" + this._label + "')- _notes: '" + this._notes + "'");
// this._notes = args.notes || "";
this._versions = {};
this._directLogins = {};
this._removedDirectLogins = [];
this.setIsBrandNew(args['reference'] == null);
this.setShouldLoadData(this.isBrandNew() ? false: true);
this.setShouldDecryptData(this.isBrandNew() ? false: true);
this.setShouldProcessData(this.isBrandNew() ? false: true);
this.setCurrentVersion(this.isBrandNew() ? new Clipperz.PM.DataModel.RecordVersion(this, null): null);
this.setCurrentVersionKey(null);
this._serverData = null;
this._decryptedData = null;
this._cachedData = null;
return this;
}
Clipperz.PM.DataModel.Record.prototype = MochiKit.Base.update(null, {
'toString': function() {
return "Record (" + this.label() + ")";
},
//-------------------------------------------------------------------------
'isBrandNew': function() {
return this._isBrandNew;
},
'setIsBrandNew': function(aValue) {
this._isBrandNew = aValue;
},
//-------------------------------------------------------------------------
/*
'shouldRunTheRecordCreationWizard': function() {
return (this.isBrandNew() && (MochiKit.Base.keys(this.currentVersion().fields()).length == 0));
},
*/
//-------------------------------------------------------------------------
'user': function() {
return this._user;
},
//-------------------------------------------------------------------------
'reference': function() {
return this._reference;
},
//-------------------------------------------------------------------------
'key': function() {
return this._key;
},
'updateKey': function() {
this._key = Clipperz.PM.Crypto.randomKey();
},
//-------------------------------------------------------------------------
'label': function() {
return this._label;
},
'setLabel': function(aValue) {
this._label = aValue;
},
'lowerCaseLabel': function() {
return this.label().toLowerCase();
},
//-------------------------------------------------------------------------
'versions': function() {
return this._versions;
},
//-------------------------------------------------------------------------
'currentVersion': function() {
return this._currentVersion;
},
'setCurrentVersion': function(aValue) {
this._currentVersion = aValue;
},
//-------------------------------------------------------------------------
'currentVersionKey': function() {
return this._currentVersionKey;
},
'setCurrentVersionKey': function(aValue) {
this._currentVersionKey = aValue;
},
//-------------------------------------------------------------------------
'deferredData': function() {
var deferredResult;
//MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.deferredData - this: " + this);
deferredResult = new MochiKit.Async.Deferred();
deferredResult.addCallback(MochiKit.Base.method(this, 'loadData'));
deferredResult.addCallback(MochiKit.Base.method(this, 'decryptData'));
deferredResult.addCallback(MochiKit.Base.method(this, 'processData'));
deferredResult.addCallback(function(aRecord) {
return aRecord.currentVersion().deferredData();
});
deferredResult.addCallback(MochiKit.Base.method(this, 'takeSnapshotOfCurrentData'));
deferredResult.addCallback(MochiKit.Async.succeed, this);
deferredResult.callback();
//MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.deferredData");
return deferredResult;
},
//-------------------------------------------------------------------------
'exportedData': function() {
var result;
result = {};
result['label'] = this.label();
result['data'] = this.serializedData();
result['currentVersion'] = this.currentVersion().serializedData();
result['currentVersion']['reference'] = this.currentVersion().reference();
// result['versions'] = MochiKit.Base.map(MochiKit.Base.methodcaller("serializedData"), MochiKit.Base.values(this.versions()));
return Clipperz.Base.serializeJSON(result);
},
//-------------------------------------------------------------------------
'shouldLoadData': function() {
return this._shouldLoadData;
},
'setShouldLoadData': function(aValue) {
this._shouldLoadData = aValue;
},
//-------------------------------------------------------------------------
'shouldDecryptData': function() {
return this._shouldDecryptData;
},
'setShouldDecryptData': function(aValue) {
this._shouldDecryptData = aValue;
},
//-------------------------------------------------------------------------
'shouldProcessData': function() {
return this._shouldProcessData;
},
'setShouldProcessData': function(aValue) {
this._shouldProcessData = aValue;
},
//-------------------------------------------------------------------------
'loadData': function() {
var result;
//MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.loadData - this: " + this);
if (this.shouldLoadData()) {
var deferredResult;
deferredResult = new MochiKit.Async.Deferred();
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'loadingRecordData');
deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'getRecordDetail', {reference: this.reference()});
deferredResult.addCallback(MochiKit.Base.method(this,'setServerData'));
deferredResult.callback();
result = deferredResult;
} else {
result = MochiKit.Async.succeed(this.serverData());
}
//MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.loadData");
return result;
},
//-------------------------------------------------------------------------
'decryptData': function(anEncryptedData) {
var result;
//MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.decryptData - this: " + this + " (" + anEncryptedData + ")");
if (this.shouldDecryptData()) {
var deferredResult;
deferredResult = new MochiKit.Async.Deferred();
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'decryptingRecordData');
deferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt, this.key(), anEncryptedData['data'], anEncryptedData['version']);
deferredResult.addCallback(function(anEncryptedData, someDecryptedValues) {
var result;
result = anEncryptedData;
result['data'] = someDecryptedValues;
return result;
}, anEncryptedData);
deferredResult.addCallback(MochiKit.Base.method(this, 'setDecryptedData'));
deferredResult.callback();
result = deferredResult;
} else {
result = MochiKit.Async.succeed(this.decryptedData());
}
//MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.decryptData");
return result;
},
//-------------------------------------------------------------------------
'processData': function(someValues) {
//MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.processData");
//MochiKit.Logging.logDebug("--- Record.processData: " + Clipperz.Base.serializeJSON(someValues));
if (this.shouldProcessData()) {
var currentVersionParameters;
+console.log("Record.processData", someValues);
this.processDataToExtractLegacyValues(someValues['data']);
if (typeof(someValues['data']['notes']) != 'undefined') {
this.setNotes(someValues['data']['notes']);
}
+
if (someValues['data']['currentVersionKey'] != null) {
this.setCurrentVersionKey(someValues['data']['currentVersionKey']);
} else {
this.setCurrentVersionKey(this.key());
}
- currentVersionParameters = someValues['currentVersion'];
+// currentVersionParameters = someValues['currentVersion'];
+ currentVersionParameters = someValues['versions'][someValues['currentVersion']];
+console.log("Record.processData - this.currentVersionKey()", this.currentVersionKey());
+console.log("Record.processData - currentVersionParameters", currentVersionParameters);
currentVersionParameters['key'] = this.currentVersionKey();
this.setCurrentVersion(new Clipperz.PM.DataModel.RecordVersion(this, currentVersionParameters));
if (someValues['data']['directLogins'] != null) {
var directLoginReference;
for (directLoginReference in someValues['data']['directLogins']) {
var directLogin;
var directLoginParameters;
directLoginParameters = someValues['data']['directLogins'][directLoginReference];
directLoginParameters.record = this;
directLoginParameters.reference = directLoginReference;
directLogin = new Clipperz.PM.DataModel.DirectLogin(directLoginParameters);
this.addDirectLogin(directLogin, true);
}
}
this.setShouldProcessData(false);
}
Clipperz.NotificationCenter.notify(this, 'recordDataReady');
//MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.processData");
//MochiKit.Logging.logDebug("<<< Record.processData");
return this;
},
//-------------------------------------------------------------------------
'processDataToExtractLegacyValues': function(someValues) {
//MochiKit.Logging.logDebug(">>> Record.processDataToExtractLegacyValues");
if (someValues['data'] != null) {
this.setNotes(someValues['data']);
}
if (
(typeof(someValues['loginFormData']) != "undefined")
&& (typeof(someValues['loginBindings'] != "undefined"))
&& (someValues['loginFormData'] != "")
&& (someValues['loginBindings'] != "")
) {
var directLogin;
directLogin = new Clipperz.PM.DataModel.DirectLogin({
record:this,
label:this.label() + Clipperz.PM.Strings['newDirectLoginLabelSuffix'],
reference:Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray(this.label() +
someValues['loginFormData'] +
someValues['loginBindings'])).toHexString().substring(2),
formData:Clipperz.Base.evalJSON(someValues['loginFormData']),
legacyBindingData:Clipperz.Base.evalJSON(someValues['loginBindings']),
bookmarkletVersion:'0.1'
});
this.addDirectLogin(directLogin, true);
}
//MochiKit.Logging.logDebug("<<< Record.processDataToExtractLegacyValues");
},
//-------------------------------------------------------------------------
'getReadyBeforeUpdatingVersionValues': function() {
},
//-------------------------------------------------------------------------
'addNewField': function() {
var newField;
//MochiKit.Logging.logDebug(">>> Record.addNewField - " + this);
this.getReadyBeforeUpdatingVersionValues();
newField = this.currentVersion().addNewField();
Clipperz.NotificationCenter.notify(this, 'recordUpdated');
//MochiKit.Logging.logDebug("<<< Record.addNewField");
return newField;
},
//-------------------------------------------------------------------------
'removeField': function(aField) {
this.getReadyBeforeUpdatingVersionValues();
this.currentVersion().removeField(aField);
Clipperz.NotificationCenter.notify(this, 'recordUpdated');
},
'removeEmptyFields': function() {
MochiKit.Iter.forEach(MochiKit.Base.values(this.currentVersion().fields()), MochiKit.Base.bind(function(aField) {
if (aField.isEmpty()) {
this.removeField(aField);
// this.currentVersion().removeField(aField);
}
}, this));
},
//-------------------------------------------------------------------------
'notes': function() {
return this._notes;
},
'setNotes': function(aValue) {
this._notes = aValue;
this.setHeaderNotes(null);
},
//-------------------------------------------------------------------------
'headerNotes': function() {
return this._headerNotes;
},
'setHeaderNotes': function(aValue) {
this._headerNotes = aValue;
},
//-------------------------------------------------------------------------
'remove': function() {
//MochiKit.Logging.logDebug(">>> Record.remove - " + this);
MochiKit.Iter.forEach(MochiKit.Base.values(this.directLogins()), MochiKit.Base.method(this, 'removeDirectLogin'));
this.syncDirectLoginReferenceValues();
this.user().removeRecord(this);
//MochiKit.Logging.logDebug("<<< Record.remove");
},
//-------------------------------------------------------------------------
'directLogins': function() {
return this._directLogins;
},
'addDirectLogin': function(aDirectLogin, shouldUpdateUser) {
this.directLogins()[aDirectLogin.reference()] = aDirectLogin;
if (shouldUpdateUser == true) {
this.user().addDirectLogin(aDirectLogin);
}
},
'removeDirectLogin': function(aDirectLogin) {
this.removedDirectLogins().push(aDirectLogin);
delete this.directLogins()[aDirectLogin.reference()];
// this.user().removeDirectLogin(aDirectLogin);
},
'resetDirectLogins': function() {
this._directLogins = {};
},
'removedDirectLogins': function() {
return this._removedDirectLogins;
},
'resetRemovedDirectLogins': function() {
this._removedDirectLogins = [];
},
//-------------------------------------------------------------------------
'serverData': function() {
return this._serverData;
},
'setServerData': function(aValue) {
this._serverData = aValue;
this.setShouldLoadData(false);
return aValue;
},
//-------------------------------------------------------------------------
'decryptedData': function() {
return this._decryptedData;
},
'setDecryptedData': function(aValue) {
this._decryptedData = aValue;
this.setShouldDecryptData(false);
return aValue;
},
//-------------------------------------------------------------------------
'cachedData': function() {
return this._cachedData;
},
'setCachedData': function(aValue) {
//MochiKit.Logging.logDebug(">>> Record.setCachedData");
//MochiKit.Logging.logDebug("--- Record.setCachedData - aValue: " + Clipperz.Base.serializeJSON(aValue));
this._cachedData = aValue;
this.setShouldProcessData(false);
//MochiKit.Logging.logDebug("<<< Record.setCachedData");
return aValue;
},
//-------------------------------------------------------------------------
'hasPendingChanges': function() {
var result;
//MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.hasPendingChanges");
//MochiKit.Logging.logDebug(">>> Record.hasPendingChanges - cachedData: " + this.cachedData());
//MochiKit.Logging.logDebug(">>> Record.hasPendingChanges - cachedData: " + Clipperz.Base.serializeJSON(this.cachedData()));
//MochiKit.Logging.logDebug(">>> Record.hasPendingChanges - currentSnapshot: " + this.currentDataSnapshot());
//MochiKit.Logging.logDebug(">>> Record.hasPendingChanges - currentSnapshot: " + Clipperz.Base.serializeJSON(this.currentDataSnapshot()));
//console.log(">>> Record.hasPendingChanges - cachedData: %o", this.cachedData());
//console.log(">>> Record.hasPendingChanges - currentSnapshot: %o", this.currentDataSnapshot());
result = (MochiKit.Base.compare(this.cachedData(), this.currentDataSnapshot()) != 0);
//MochiKit.Logging.logDebug("<<< Record.hasPendingChanges - " + result);
if ((result == false) && this.isBrandNew() && (this.label() != Clipperz.PM.Strings['newRecordTitleLabel'])) {
result = true;
}
//MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.hasPendingChanges");
return result;
},
//-------------------------------------------------------------------------
'currentDataSnapshot': function() {
var result;
//MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.currentDataSnapshot");
result = {
'label': this.label(),
'data': this.serializedData(),
'currentVersion': this.currentVersion().currentDataSnapshot()
};
// result['data']['data'] = this.notes();
result = Clipperz.Base.serializeJSON(result);
//MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.currentDataSnapshot");
//MochiKit.Logging.logDebug("<<< Record.currentDataSnapshot");
return result;
},
//.........................................................................
'takeSnapshotOfCurrentData': function() {
this.setCachedData(this.currentDataSnapshot());
},
//-------------------------------------------------------------------------
'headerData': function() {
var result;
result = {
'label': this.label(),
'key': this.key()
};
if (this.headerNotes() != null) {
result['headerNotes'] = this.headerNotes();
}
return result;
},
//-------------------------------------------------------------------------
'serializedData': function() {
var result;
var directLoginReference;
result = {};
result['currentVersionKey'] = this.currentVersion().key();
result['directLogins'] = {};
for (directLoginReference in this.directLogins()) {
result['directLogins'][directLoginReference] = this.directLogins()[directLoginReference].serializedData();
}
result['notes'] = this.notes();
return result;
},
//-------------------------------------------------------------------------
'encryptedData': function() {
var deferredResult;
var result;
//MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.encryptedData");
result = {}
//MochiKit.Logging.logDebug("--- Record.encryptedData - 1");
deferredResult = new MochiKit.Async.Deferred();
//MochiKit.Logging.logDebug("--- Record.encryptedData - 2");
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.encryptedData - 1: " + res); return res;});
deferredResult.addCallback(function(aResult, aRecord) {
aResult['reference'] = aRecord.reference();
return aResult;
}, result, this);
//MochiKit.Logging.logDebug("--- Record.encryptedData - 3");
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.encryptedData - 2: " + res); return res;});
deferredResult.addCallback(Clipperz.PM.Crypto.deferredEncryptWithCurrentVersion, this.key(), this.serializedData());
//MochiKit.Logging.logDebug("--- Record.encryptedData - 4");
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.encryptedData - 3: " + res); return res;});
deferredResult.addCallback(function(aResult, res) {
aResult['data'] = res;
return aResult;
}, result);
//MochiKit.Logging.logDebug("--- Record.encryptedData - 5");
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.encryptedData - 4: " + res); return res;});
deferredResult.addCallback(function(aResult) {
aResult['version'] = Clipperz.PM.Crypto.encryptingFunctions.currentVersion;
return aResult;
}, result);
//MochiKit.Logging.logDebug("--- Record.encryptedData - 6");
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.encryptedData - 5: " + res); return res;});
deferredResult.callback();
//MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.encryptedData");
return deferredResult;
},
//-------------------------------------------------------------------------
'syncDirectLoginReferenceValues': function() {
//MochiKit.Logging.logDebug(">>> Record.syncDirectLoginReferenceValues");
MochiKit.Iter.forEach(MochiKit.Base.values(this.directLogins()), function(aDirectLogin) {
aDirectLogin.record().user().synchronizeDirectLogin(aDirectLogin);
});
MochiKit.Iter.forEach(this.removedDirectLogins(), function(aDirectLogin) {
aDirectLogin.record().user().removeDirectLogin(aDirectLogin);
});
this.resetRemovedDirectLogins();
//MochiKit.Logging.logDebug("<<< Record.syncDirectLoginReferenceValues");
},
//-------------------------------------------------------------------------
'saveChanges': function() {
var result;
if (this.isBrandNew() == false) {
result = this.user().saveRecords([this], 'updateData');
} else {
result = this.user().saveRecords([this], 'addNewRecords');
}
return result;
},
/*
'saveChanges': function() {
var deferredResult;
var result;
Clipperz.NotificationCenter.notify(this.user(), 'updatedSection', 'records', true);
//MochiKit.Logging.logDebug(">>> Record.saveChanges");
//MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.saveChanges");
if (this.headerNotes() != null) {
this.setNotes(this.headerNotes());
}
this.syncDirectLoginReferenceValues();
this.currentVersion().createNewVersion();
result = {'records': [{}]};
deferredResult = new MochiKit.Async.Deferred();
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_collectRecordInfo');
deferredResult.addCallback(MochiKit.Base.method(this, 'updateKey'));
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_encryptUserData');
deferredResult.addCallback(MochiKit.Base.method(this.user(), 'encryptedData'));
deferredResult.addCallback(function(aResult, res) {
aResult['user'] = res;
return aResult;
}, result);
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_encryptRecordData');
deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedData'));
deferredResult.addCallback(function(aResult, res) {
//# aResult['record'] = res;
aResult['records'][0]['record'] = res;
return aResult;
}, result);
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_encryptRecordVersions');
deferredResult.addCallback(MochiKit.Base.method(this.currentVersion(), 'encryptedData'));
deferredResult.addCallback(function(aResult, res) {
// aResult['currentRecordVersion'] = res;
aResult['records'][0]['currentRecordVersion'] = res;
return aResult;
}, result);
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_sendingData');
if (this.isBrandNew() == false) {
deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'updateData');
} else {
//# deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'addNewRecord');
deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'addNewRecords');
}
deferredResult.addCallback(MochiKit.Base.method(this, 'takeSnapshotOfCurrentData'));
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_updatingInterface');
deferredResult.addCallback(MochiKit.Base.method(this, 'setIsBrandNew'), false);
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'recordUpdated');
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'directLoginUpdated');
deferredResult.callback();
return deferredResult;
},
*/
//-------------------------------------------------------------------------
'cancelChanges': function() {
//MochiKit.Logging.logDebug(">>> Record.cancelChanges");
//MochiKit.Logging.logDebug("--- Record.cancelChanges - cachedData: " + Clipperz.Base.serializeJSON(this.cachedData()));
if (this.isBrandNew()) {
this.user().removeRecord(this);
} else {
this.restoreValuesFromSnapshot(this.cachedData());
}
//MochiKit.Logging.logDebug("<<< Record.cancelChanges");
},
//-------------------------------------------------------------------------
'restoreValuesFromSnapshot': function(someSnapshotData) {
var snapshotData;
//MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.restoreValuesFromSnapshot");
snapshotData = Clipperz.Base.evalJSON(someSnapshotData);
//MochiKit.Logging.logDebug("--- Record.restoreValuesFromSnapshot - someSnapshotData (1): " + Clipperz.Base.serializeJSON(someSnapshotData));
this.setLabel(snapshotData['label']);
this.resetDirectLogins();
this.setShouldProcessData(true);
this.processData(snapshotData);
//MochiKit.Logging.logDebug("--- Record.restoreValuesFromSnapshot - snapshotData: (2)" + Clipperz.Base.serializeJSON(snapshotData));
this.resetRemovedDirectLogins();
{
var currentSnapshot;
var comparisonResult;
currentSnapshot = this.currentDataSnapshot();
//MochiKit.Logging.logDebug("--- Record.restoreValuesFromSnapshot - 1");
//console.log("snapshot data: %o", someSnapshotData.currentVersion);
//console.log("current data: %o", currentSnapshot.currentVersion);
//MochiKit.Logging.logDebug("--- Record.restoreValuesFromSnapshot - someSnapshotData: " + Clipperz.Base.serializeJSON(someSnapshotData.currentVersion));
//MochiKit.Logging.logDebug("--- Record.restoreValuesFromSnapshot - currentSnapshot: " + Clipperz.Base.serializeJSON(currentSnapshot.currentVersion));
comparisonResult = MochiKit.Base.compare(someSnapshotData.currentVersion, currentSnapshot.currentVersion);
//MochiKit.Logging.logDebug("--- Record.restoreValuesFromSnapshot - " + comparisonResult);
}
//MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.restoreValuesFromSnapshot");
},
//-------------------------------------------------------------------------
__syntaxFix__: "syntax fix"
});
diff --git a/frontend/beta/js/Clipperz/PM/Proxy.js b/frontend/beta/js/Clipperz/PM/Proxy.js
index f476196..bec9195 100644
--- a/frontend/beta/js/Clipperz/PM/Proxy.js
+++ b/frontend/beta/js/Clipperz/PM/Proxy.js
@@ -1,170 +1,169 @@
/*
Copyright 2008-2011 Clipperz Srl
This file is part of Clipperz Community Edition.
Clipperz Community Edition is an online password manager.
For further information about its features and functionalities please
refer to http://www.clipperz.com.
* Clipperz Community Edition 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.
* Clipperz Community Edition 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 Clipperz Community Edition. If not, see
<http://www.gnu.org/licenses/>.
*/
if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
//=============================================================================
Clipperz.PM.Proxy = function(args) {
args = args || {};
this._shouldPayTolls = args.shouldPayTolls || false;
this._tolls = {
'CONNECT': [],
'REGISTER': [],
'MESSAGE': []
};
if (args.isDefault === true) {
Clipperz.PM.Proxy.defaultProxy = this;
}
return this;
}
Clipperz.PM.Proxy.prototype = MochiKit.Base.update(null, {
'toString': function() {
return "Clipperz.PM.Proxy";
},
//=========================================================================
'shouldPayTolls': function() {
return this._shouldPayTolls;
},
//-------------------------------------------------------------------------
'tolls': function() {
return this._tolls;
},
//-------------------------------------------------------------------------
'payToll': function(aRequestType, someParameters) {
var deferredResult;
//console.log(">>> Proxy.payToll", aRequestType, someParameters);
if (this.shouldPayTolls()) {
deferredResult = new MochiKit.Async.Deferred();
if (this.tolls()[aRequestType].length == 0) {
deferredResult.addCallback(MochiKit.Base.method(this, 'sendMessage', 'knock', {requestType:aRequestType}));
deferredResult.addCallback(MochiKit.Base.method(this, 'setTollCallback'));
}
deferredResult.addCallback(MochiKit.Base.method(this.tolls()[aRequestType], 'pop'));
deferredResult.addCallback(MochiKit.Base.methodcaller('deferredPay'));
deferredResult.addCallback(function(aToll) {
var result;
result = {
parameters: someParameters,
toll: aToll
}
return result;
});
deferredResult.callback();
} else {
deferredResult = MochiKit.Async.succeed({parameters:someParameters});
}
//console.log("<<< Proxy.payToll");
return deferredResult;
},
//-------------------------------------------------------------------------
'addToll': function(aToll) {
//console.log(">>> Proxy.addToll", aToll);
this.tolls()[aToll.requestType()].push(aToll);
//console.log("<<< Proxy.addToll");
},
//=========================================================================
'setTollCallback': function(someParameters) {
//console.log(">>> Proxy.setTollCallback", someParameters);
if (typeof(someParameters['toll']) != 'undefined') {
//console.log("added a new toll", someParameters['toll']);
this.addToll(new Clipperz.PM.Toll(someParameters['toll']));
}
//console.log("<<< Proxy.setTallCallback", someParameters['result']);
- //return someParameters['result'];
- return someParameters;
+ return someParameters['result'];
},
//=========================================================================
'registration': function (someParameters) {
return this.processMessage('registration', someParameters, 'REGISTER');
},
'handshake': function (someParameters) {
return this.processMessage('handshake', someParameters, 'CONNECT');
},
'message': function (someParameters) {
return this.processMessage('message', someParameters, 'MESSAGE');
},
'logout': function (someParameters) {
return this.processMessage('logout', someParameters, 'MESSAGE');
},
//=========================================================================
'processMessage': function (aFunctionName, someParameters, aRequestType) {
var deferredResult;
deferredResult = new MochiKit.Async.Deferred();
deferredResult.addCallback(MochiKit.Base.method(this, 'payToll', aRequestType));
deferredResult.addCallback(MochiKit.Base.method(this, 'sendMessage', aFunctionName));
deferredResult.addCallback(MochiKit.Base.method(this, 'setTollCallback'));
deferredResult.callback(someParameters);
return deferredResult;
},
//=========================================================================
'sendMessage': function () {
throw Clipperz.Base.exception.AbstractMethod;
},
//=========================================================================
'isReadOnly': function () {
return false;
},
//=========================================================================
__syntaxFix__: "syntax fix"
});
diff --git a/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js b/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js
deleted file mode 100755
index 34a10c2..0000000
--- a/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js
+++ b/dev/null
@@ -1,262 +0,0 @@
-/*
-
-Copyright 2008-2011 Clipperz Srl
-
-This file is part of Clipperz Community Edition.
-Clipperz Community Edition is an online password manager.
-For further information about its features and functionalities please
-refer to http://www.clipperz.com.
-
-* Clipperz Community Edition 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.
-
-* Clipperz Community Edition 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 Clipperz Community Edition. If not, see
- <http://www.gnu.org/licenses/>.
-
-*/
-
-if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
-if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
-
-//=============================================================================
-
-Clipperz.PM.Proxy.PHP = function(args) {
- Clipperz.PM.Proxy.PHP.superclass.constructor.call(this, args);
-/*
- this._tolls = {
- 'CONNECT': [],
- 'REGISTER': [],
- 'MESSAGE': []
- };
-*/
- return this;
-}
-
-YAHOO.extendX(Clipperz.PM.Proxy.PHP, Clipperz.PM.Proxy, {
-
- 'toString': function() {
- return "Clipperz.PM.Proxy.PHP - " + this.args();
- },
-
- //=========================================================================
-/*
- 'tolls': function() {
- return this._tolls;
- },
-*/
- //-------------------------------------------------------------------------
-/*
- 'payToll': function(aRequestType, someParameters) {
- var deferredResult;
-
-//MochiKit.Logging.logDebug(">>> Proxy.DWR.payToll: " + aRequestType);
- if (this.tolls()[aRequestType].length > 0) {
- deferredResult = MochiKit.Async.succeed(this.tolls()[aRequestType].pop());
- } else {
-//MochiKit.Logging.logDebug("### " + aRequestType + " toll NOT immediately available; request queued.");
- deferredResult = new MochiKit.Async.Deferred();
- deferredResult.addCallback(function(someParameters) {
- return new Clipperz.PM.Toll(someParameters['toll']);
- })
- com_clipperz_pm_Proxy.knock(Clipperz.Base.serializeJSON({requestType:aRequestType}), {
- callback:MochiKit.Base.method(deferredResult, 'callback'),
- errorHandler:MochiKit.Base.method(deferredResult, 'errback')
- });
- }
-
- deferredResult.addCallback(function(aToll) {
- return aToll.deferredPay();
- });
- deferredResult.addCallback(function(someParameters, aToll) {
- var result;
-
- result = {
- parameters: someParameters,
- toll: aToll
- }
-
- return result;
- }, someParameters);
-
- return deferredResult;
- },
-*/
- //-------------------------------------------------------------------------
-/*
- 'addToll': function(aToll) {
- this.tolls()[aToll.requestType()].push(aToll);
- },
-*/
- //=========================================================================
-/*
- 'setTollCallback': function(someParameters) {
-//MochiKit.Logging.logDebug(">>> Proxy.DWR.setTollCallback");
-//MochiKit.Logging.logDebug("--- Proxy.DWR.setTollCallback - " + Clipperz.Base.serializeJSON(someParameters));
- if (typeof(someParameters['toll']) != 'undefined') {
- this.addToll(new Clipperz.PM.Toll(someParameters['toll']));
- }
- return someParameters['result'];
- },
-*/
- //=========================================================================
-
- 'registration': function(someParameters) {
- return this.sendMessage('registration', someParameters, 'REGISTER');
- },
-
- //-------------------------------------------------------------------------
-
- 'handshake': function(someParameters) {
-/*
- _s = "e8a2162f29aeaabb729f5625e9740edbf0cd80ac77c6b19ab951ed6c88443b8c";
- _v = new Clipperz.Crypto.BigInt("955e2db0f7844aca372f5799e5f7e51b5866718493096908bd66abcf1d068108", 16);
- _b = new Clipperz.Crypto.BigInt("5761e6c84d22ea3c5649de01702d60f674ccfe79238540eb34c61cd020230c53", 16);
-
- _B = _v.add(Clipperz.Crypto.SRP.g().powerModule(_b, Clipperz.Crypto.SRP.n()));
- _u = new Clipperz.Crypto.BigInt(Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(_B.asString(10))).toHexString(), 16);
- _A = new Clipperz.Crypto.BigInt("3b3567ec33d73673552e960872eb154d091a2488915941038aef759236a27e64", 16);
- _S = (_A.multiply(_v.powerModule(_u, Clipperz.Crypto.SRP.n()))).powerModule(_b, Clipperz.Crypto.SRP.n());
- _K = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(_S.asString(10))).toHexString().slice(2);
- _M1 = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(_A.asString(10) + _B.asString(10) + _K)).toHexString().slice(2);
- _M2 = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(_A.asString(10) + _M1 + _K)).toHexString().slice(2);
-
-// MochiKit.Logging.logDebug("b = " + _b.asString(16));
-// MochiKit.Logging.logDebug("v = " + _v.asString(16));
- MochiKit.Logging.logDebug("B = " + _B.asString(16));
- MochiKit.Logging.logDebug("u = " + _u.asString(16));
- MochiKit.Logging.logDebug("S = " + _S.asString(16));
- MochiKit.Logging.logDebug("K = " + _K);
- MochiKit.Logging.logDebug("M1 = " + _M1);
- MochiKit.Logging.logDebug("M2 = " + _M2);
-// MochiKit.Logging.logDebug("someParameters.version: " + someParameters.version);
-*/
- return this.sendMessage('handshake', someParameters, 'CONNECT');
- },
-
- //-------------------------------------------------------------------------
-
- 'message': function(someParameters) {
- return this.sendMessage('message', someParameters, 'MESSAGE');
- },
-
- //-------------------------------------------------------------------------
-
- 'logout': function(someParameters) {
-//MochiKit.Logging.logDebug("=== Proxy.DWR.logout");
- return this.sendMessage('logout', someParameters, 'MESSAGE');
- },
-
- //=========================================================================
-
- 'sendMessage': function(aFunctionName, someParameters, aRequestType) {
-/*
- var deferredResult;
- var proxy;
-
-//MochiKit.Logging.logDebug(">>> Proxy.DWR.sendMessage - " + aFunctionName + " - " + aRequestType);
- proxy = this;
-
- deferredResult = new MochiKit.Async.Deferred();
-//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.1 Proxy.DWR.sendMessage - 1: " + res); return res;});
- deferredResult.addCallback(MochiKit.Base.method(proxy, 'payToll'), aRequestType);
-//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.2 Proxy.DWR.sendMessage - 2: " + Clipperz.Base.serializeJSON(res)); return res;});
- deferredResult.addCallback(MochiKit.Base.method(proxy, 'sendRemoteMessage'), aFunctionName);
-//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.DWR.sendMessage - 3: " + res); return res;});
-//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.DWR.sendMessage - 3: " + Clipperz.Base.serializeJSON(res)); return res;});
- deferredResult.callback(someParameters);
-
-//MochiKit.Logging.logDebug("<<< Proxy.DWR.sendMessage");
- return deferredResult;
-*/
-
-// return this.sendRemoteMessage(aFunctionName, someParameters);
-
-
- var deferredResult;
- var proxy;
-
- proxy = this;
-
- deferredResult = new MochiKit.Async.Deferred();
- deferredResult.addCallback(MochiKit.Base.method(proxy, 'sendRemoteMessage'), aFunctionName);
-//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.PHP.sendMessage - 3: " + res); return res;});
-//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.PHP.sendMessage - 3.1: " + Clipperz.Base.serializeJSON(res)); return res;});
-
- deferredResult.callback(someParameters);
-
- return deferredResult;
- },
-
- //=========================================================================
-
- 'sendRemoteMessage': function(aFunctionName, someParameters) {
-/*
- var deferredResult;
-
-//MochiKit.Logging.logDebug(">>> Proxy.DWR.sendRemoteMessage('" + aFunctionName + "', " + Clipperz.Base.serializeJSON(someParameters) + ") - " + this);
- deferredResult = new MochiKit.Async.Deferred();
-//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Proxy.DWR.sendRemoteMessage - 1: " + res); return res;});
-// deferredResult.addCallback(MochiKit.Base.method(this, 'setTollCallback'));
-//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Proxy.DWR.sendRemoteMessage - 2: " + res); return res;});
-
- com_clipperz_pm_Proxy[aFunctionName](Clipperz.Base.serializeJSON(someParameters), {
- callback:MochiKit.Base.method(deferredResult, 'callback'),
- errorHandler:MochiKit.Base.method(deferredResult, 'errback')
- });
-//MochiKit.Logging.logDebug("<<< Proxy.PHP.sendRemoteMessage - result: " + deferredResult);
-
- return deferredResult;
-*/
-
- var deferredResult;
- var parameters;
-
-//MochiKit.Logging.logDebug(">>> Proxy.PHP.sendRemoteMessage('" + aFunctionName + "', " + Clipperz.Base.serializeJSON(someParameters) + ") - " + this);
- parameters = {};
- parameters['method'] = aFunctionName;
-// parameters['version'] = someParameters['version'];
-// parameters['message'] = someParameters['message'];
- parameters['parameters'] = Clipperz.Base.serializeJSON(someParameters);
-//MochiKit.Logging.logDebug("--- Proxy.PHP.sendRemoteMessage('" + Clipperz.Base.serializeJSON(parameters) + ") - " + this);
- deferredResult = new MochiKit.Async.Deferred();
- deferredResult.addCallback(MochiKit.Async.doXHR, "./php/index.php", {
- method:'POST',
- sendContent:MochiKit.Base.queryString(parameters),
- headers:{"Content-Type":"application/x-www-form-urlencoded"}
- });
-//deferredResult.addCallback(function(res) {MochiKit.Logging.logDebug("Proxy.PHP.response - 2: " + res.responseText); return res;});
-//deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("Proxy.PHP.response - ERROR: " + res); return res;});
- deferredResult.addCallback(MochiKit.Async.evalJSONRequest);
- deferredResult.addCallback(function (someValues) {
- if (someValues['result'] == 'EXCEPTION') {
- throw someValues['message'];
- }
- return someValues;
- })
- deferredResult.callback();
-
- return deferredResult;
- },
-
- //=========================================================================
-
- 'isReadOnly': function() {
- return false;
- },
-
- //=========================================================================
- __syntaxFix__: "syntax fix"
-
-});
-
-//=============================================================================
-
-//Clipperz.PM.Proxy.defaultProxy = new Clipperz.PM.Proxy.PHP("Proxy.PHP - async test");
diff --git a/frontend/gamma/html/index_template.html b/frontend/gamma/html/index_template.html
index 8cf838c..bedb243 100644
--- a/frontend/gamma/html/index_template.html
+++ b/frontend/gamma/html/index_template.html
@@ -1,62 +1,67 @@
<html>
<head>
<title>@page.title@</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<!--
@copyright@
-->
@css@
<link rel="shortcut icon" href="./clipperz.ico" />
<meta name="description" content="Login to your web accounts with just one click. Never type a password again! Use multiple complex passwords and forget them. A password manager that enhances your online security." />
<meta name="keywords" content="password manager,gestor de contraseñas,gerenciador de senhas,Kennwortmanager,passwords,security,privacy,cryptography" />
<script>
Clipperz_IEisBroken = false;
Clipperz_normalizedNewLine = '\n';
Clipperz_dumpUrl = "/dump/";
</script>
<!--[if IE]><script>
Clipperz_IEisBroken = true;
Clipperz_normalizedNewLine = '\x0d\x0a';
</script><![endif]-->
@js_DEBUG@
</head>
<body>
<div id="mainDiv">
<div id="loading">
<a href="http://www.clipperz.com" target="_blank"><div id="logo"></div></a>
<h5 class="clipperzPayoff">keep it to yourself!</h5>
<h2>loading ...</h2>
</div>
@js_INSTALL@
</div>
<div id="applicationVersionType" class="@application.version.type@"></div>
+<script>
+ Clipperz.PM.Proxy.defaultProxy = new Clipperz.PM.Proxy.JSON({'url':'@request.path@', 'shouldPayTolls':@should.pay.toll@});
+ /*offline_data_placeholder*/
+</script>
+
<!-- -->
<div id="javaScriptAlert">
<div class="mask"></div>
<div class="message">
<div class="header"></div>
<div class="body">
<div class="alertLogo"></div>
<div class="alert">
<h1>Attention!</h1>
<p>If you can read this message, the chances are that your browser does not properly support JavaScript? or you have disabled this functionality yourself.</p>
<h3>Javascript is required to access Clipperz.</h3>
<h5>Please enable scripting or upgrade your browser.</h5>
</div>
</div>
<div class="footer"></div>
</div>
</div>
<!-- -->
</body>
</html>
diff --git a/frontend/gamma/js/Clipperz/Async.js b/frontend/gamma/js/Clipperz/Async.js
index 7c9d783..97d8ecf 100644
--- a/frontend/gamma/js/Clipperz/Async.js
+++ b/frontend/gamma/js/Clipperz/Async.js
@@ -1,704 +1,711 @@
/*
Copyright 2008-2011 Clipperz Srl
This file is part of Clipperz Community Edition.
Clipperz Community Edition is an online password manager.
For further information about its features and functionalities please
refer to http://www.clipperz.com.
* Clipperz Community Edition 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.
* Clipperz Community Edition 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 Clipperz Community Edition. If not, see
<http://www.gnu.org/licenses/>.
*/
//Clipperz.Async = MochiKit.Async;
if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
if (typeof(Clipperz.Async) == 'undefined') { Clipperz.Async = {}; }
Clipperz.Async.VERSION = "0.1";
Clipperz.Async.NAME = "Clipperz.Async";
Clipperz.Async.Deferred = function(aName, args) {
args = args || {};
Clipperz.Async.Deferred.superclass.constructor.call(this, args.canceller);
this._args = args;
this._name = aName || "Anonymous deferred";
this._count = 0;
this._shouldTrace = ((CLIPPERZ_DEFERRED_TRACING_ENABLED === true) || (args.trace === true));
this._vars = null;
return this;
}
//=============================================================================
Clipperz.Base.extend(Clipperz.Async.Deferred, MochiKit.Async.Deferred, {
'name': function () {
return this._name;
},
'args': function () {
return this._args;
},
//-----------------------------------------------------------------------------
'callback': function (aValue) {
if (this._shouldTrace) {
- Clipperz.log("CALLBACK " + this._name, aValue);
+ // Clipperz.log("CALLBACK " + this._name, aValue);
+ console.log("CALLBACK " + this._name, aValue);
}
if (this.chained == false) {
var message;
message = "ERROR [" + this._name + "]";
this.addErrback(function(aResult) {
if (! (aResult instanceof MochiKit.Async.CancelledError)) {
Clipperz.log(message, aResult);
}
return aResult;
});
if (this._shouldTrace) {
var resultMessage;
resultMessage = "RESULT " + this._name + " <==";
// this.addCallback(function(aResult) {
Clipperz.Async.Deferred.superclass.addCallback.call(this, function(aResult) {
- Clipperz.log(resultMessage, aResult);
+ // Clipperz.log(resultMessage, aResult);
+ console.log(resultMessage, aResult);
return aResult;
});
}
}
if (CLIPPERZ_DEFERRED_CALL_LOGGING_ENABLED === true) {
Clipperz.log("callback " + this._name, this);
}
return Clipperz.Async.Deferred.superclass.callback.apply(this, arguments);
},
//-----------------------------------------------------------------------------
'addCallback': function () {
var message;
if (this._shouldTrace) {
this._count ++;
message = "[" + this._count + "] " + this._name + " ";
// this.addBoth(function(aResult) {Clipperz.log(message + "-->", aResult); return aResult;});
this.addCallbacks(
- function(aResult) {Clipperz.log("-OK- " + message + "-->"/*, aResult*/); return aResult;},
- function(aResult) {Clipperz.log("FAIL " + message + "-->"/*, aResult*/); return aResult;}
+ // function(aResult) {Clipperz.log("-OK- " + message + "-->"/*, aResult*/); return aResult;},
+ function(aResult) {console.log("-OK- " + message + "-->"/*, aResult*/); return aResult;},
+ // function(aResult) {Clipperz.log("FAIL " + message + "-->"/*, aResult*/); return aResult;}
+ function(aResult) {console.log("FAIL " + message + "-->"/*, aResult*/); return aResult;}
);
}
Clipperz.Async.Deferred.superclass.addCallback.apply(this, arguments);
if (this._shouldTrace) {
// this.addBoth(function(aResult) {Clipperz.log(message + "<--", aResult); return aResult;});
this.addCallbacks(
- function(aResult) {Clipperz.log("-OK- " + message + "<--", aResult); return aResult;},
- function(aResult) {Clipperz.log("FAIL " + message + "<--", aResult); return aResult;}
+ // function(aResult) {Clipperz.log("-OK- " + message + "<--", aResult); return aResult;},
+ function(aResult) {console.log("-OK- " + message + "<--", aResult); return aResult;},
+ // function(aResult) {Clipperz.log("FAIL " + message + "<--", aResult); return aResult;}
+ function(aResult) {console.log("FAIL " + message + "<--", aResult); return aResult;}
);
}
},
//=============================================================================
'addCallbackPass': function() {
var passFunction;
passFunction = MochiKit.Base.partial.apply(null, arguments);
this.addCallback(function() {
var result;
result = arguments[arguments.length -1];
passFunction();
return result;
});
},
//-----------------------------------------------------------------------------
'addErrbackPass': function() {
var passFunction;
passFunction = MochiKit.Base.partial.apply(null, arguments);
this.addErrback(function() {
var result;
result = arguments[arguments.length -1];
passFunction();
return result;
});
},
//-----------------------------------------------------------------------------
'addBothPass': function() {
var passFunction;
passFunction = MochiKit.Base.partial.apply(null, arguments);
this.addBoth(function() {
var result;
result = arguments[arguments.length -1];
passFunction();
return result;
});
},
//-----------------------------------------------------------------------------
'addIf': function (aThenBlock, anElseBlock) {
this.addCallback(MochiKit.Base.bind(function (aValue) {
var deferredResult;
if (!MochiKit.Base.isUndefinedOrNull(aValue) && aValue) {
deferredResult = Clipperz.Async.callbacks(this._name + " <then>", aThenBlock, null, aValue);
} else {
deferredResult = Clipperz.Async.callbacks(this._name + " <else>", anElseBlock, null, aValue);
}
return deferredResult;
}))
},
//-----------------------------------------------------------------------------
'addMethod': function () {
this.addCallback(MochiKit.Base.method.apply(this, arguments));
},
//-----------------------------------------------------------------------------
'addMethodcaller': function () {
this.addCallback(MochiKit.Base.methodcaller.apply(this, arguments));
},
//=============================================================================
'addLog': function (aLog) {
if (CLIPPERZ_DEFERRED_LOGGING_ENABLED) {
this.addBothPass(function(res) {Clipperz.log(aLog + " ", res);});
// this.addBothPass(function(res) {console.log(aLog + " ", res);});
}
},
//=============================================================================
'acquireLock': function (aLock) {
// this.addCallback(function (aResult) {
// return Clipperz.Async.callbacks("Clipperz.Async.acquireLock", [
// MochiKit.Base.method(aLock, 'acquire'),
// MochiKit.Base.partial(MochiKit.Async.succeed, aResult)
// ], {trace:false});
// });
this.addCallback(MochiKit.Base.method(aLock, 'acquire'));
},
'releaseLock': function (aLock) {
// this.addCallback(function (aResult) {
// return Clipperz.Async.callbacks("Clipperz.Async.release <ok>", [
// MochiKit.Base.method(aLock, 'release'),
// MochiKit.Base.partial(MochiKit.Async.succeed, aResult)
// ], {trace:false});
// });
// this.addErrback(function (aResult) {
///console.log("releaseLock.addErrback:", aResult);
// return Clipperz.Async.callbacks("Clipperz.Async.release <fail>", [
// MochiKit.Base.method(aLock, 'release'),
// MochiKit.Base.partial(MochiKit.Async.fail, aResult)
// ], {trace:false});
// });
// this.addBothPass(MochiKit.Base.method(aLock, 'release'));
this.addCallbackPass(MochiKit.Base.method(aLock, 'release'));
this.addErrback(function (anError) {
aLock.release();
return anError;
});
},
//=============================================================================
'collectResults': function (someRequests) {
this.addCallback(Clipperz.Async.collectResults(this._name + " <collect results>", someRequests, this._args));
},
'addCallbackList': function (aRequestList) {
this.addCallback(Clipperz.Async.callbacks, this._name + " <callback list>", aRequestList, this._args);
},
//=============================================================================
'vars': function () {
if (this._vars == null) {
this._vars = {}
}
return this._vars;
},
'setValue': function (aKey) {
this.addCallback(MochiKit.Base.bind(function (aValue) {
this.vars()[aKey] = aValue;
return aValue;
}, this));
},
'getValue': function (aKey) {
this.addCallback(MochiKit.Base.bind(function () {
return this.vars()[aKey];
}, this));
},
//=============================================================================
__syntaxFix__: "syntax fix"
});
//#############################################################################
Clipperz.Async.DeferredSynchronizer = function(aName, someMethods) {
this._name = aName || "Anonymous deferred Synchronizer";
this._methods = someMethods;
this._numberOfMethodsDone = 0;
this._methodResults = [];
this._result = new Clipperz.Async.Deferred("Clipperz.Async.DeferredSynchronizer # " + this.name(), {trace:false});
this._result.addMethod(this, 'methodResults');
this._result.addCallback(function(someResults) {
var cancels;
var errors;
var result;
cancels = MochiKit.Base.filter(function(aResult) { return (aResult instanceof MochiKit.Async.CancelledError)}, someResults);
if (cancels.length == 0) {
errors = MochiKit.Base.filter(function(aResult) { return (aResult instanceof Error)}, someResults);
if (errors.length == 0) {
// result = MochiKit.Async.succeed(someResults);
result = someResults;
} else {
result = MochiKit.Async.fail(someResults);
}
} else {
result = MochiKit.Async.fail(cancels[0]);
}
return result;
}/*, this._methodResults */);
return this;
}
MochiKit.Base.update(Clipperz.Async.DeferredSynchronizer.prototype, {
//-----------------------------------------------------------------------------
'name': function() {
return this._name;
},
//-----------------------------------------------------------------------------
'methods': function() {
return this._methods;
},
'methodResults': function() {
return this._methodResults;
},
//-----------------------------------------------------------------------------
'result': function() {
return this._result;
},
//-----------------------------------------------------------------------------
'numberOfMethodsDone':function() {
return this._numberOfMethodsDone;
},
'incrementNumberOfMethodsDone': function() {
this._numberOfMethodsDone ++;
},
//-----------------------------------------------------------------------------
'run': function(args, aValue) {
var deferredResults;
var i, c;
deferredResults = [];
args = args || {};
c = this.methods().length;
for (i=0; i<c; i++) {
var deferredResult;
var methodCalls;
var ii, cc;
//console.log("TYPEOF", typeof(this.methods()[i]));
if (typeof(this.methods()[i]) == 'function') {
methodCalls = [ this.methods()[i] ];
} else {
methodCalls = this.methods()[i];
}
cc = methodCalls.length;
deferredResult = new Clipperz.Async.Deferred("Clipperz.Async.DeferredSynchronizer.run => " + this.name() + "[" + i + "]", args);
for (ii=0; ii<cc; ii++) {
deferredResult.addCallback(methodCalls[ii]);
}
deferredResult.addBoth(MochiKit.Base.method(this, 'handleMethodCallDone', i));
deferredResults.push(deferredResult);
}
for (i=0; i<c; i++) {
deferredResults[i].callback(aValue);
}
return this.result();
},
//-----------------------------------------------------------------------------
'handleMethodCallDone': function(anIndexValue, aResult) {
this.incrementNumberOfMethodsDone();
this.methodResults()[anIndexValue] = aResult;
if (this.numberOfMethodsDone() < this.methods().length) {
// nothing to do here other than possibly log something
} else if (this.numberOfMethodsDone() == this.methods().length) {
this.result().callback();
} else if (this.numberOfMethodsDone() > this.methods().length) {
+ alert("Clipperz.Async.Deferred.handleMethodCallDone -> WTF!");
// WTF!!! :(
}
},
//-----------------------------------------------------------------------------
__syntaxFix__: "syntax fix"
});
//#############################################################################
MochiKit.Base.update(Clipperz.Async, {
'callbacks': function (aName, someFunctions, someArguments, aCallbackValue) {
var deferredResult;
var i, c;
deferredResult = new Clipperz.Async.Deferred(aName, someArguments);
c = someFunctions.length;
for (i=0; i<c; i++) {
deferredResult.addCallback(someFunctions[i]);
}
deferredResult.callback(aCallbackValue);
return deferredResult;
},
//-------------------------------------------------------------------------
'forkAndJoin': function (aName, someMethods, args) {
return MochiKit.Base.partial(function (aName, someMethods, args, aValue) {
var synchronizer;
var result;
args = args || {};
synchronizer = new Clipperz.Async.DeferredSynchronizer(aName, someMethods);
result = synchronizer.run(args, aValue);
return result;
}, aName, someMethods, args);
},
//-------------------------------------------------------------------------
'collectResults': function(aName, someRequests, args) {
return MochiKit.Base.partial(function(aName, someRequests, args, aValue) {
var deferredResult;
var requestKeys;
var methods;
requestKeys = MochiKit.Base.keys(someRequests);
methods = MochiKit.Base.values(someRequests);
deferredResult = new Clipperz.Async.Deferred(aName, args);
deferredResult.addCallback(Clipperz.Async.forkAndJoin(aName + " [inner forkAndJoin]", methods, args));
deferredResult.addBoth(function(someResults) {
var returnFunction;
var results;
var i,c;
var result;
if (someResults instanceof MochiKit.Async.CancelledError) {
returnFunction = MochiKit.Async.fail;
result = someResults;
} else {
if (someResults instanceof Error) {
returnFunction = MochiKit.Async.fail;
results = someResults['message'];
} else {
returnFunction = MochiKit.Async.succeed;
results = someResults;
}
result = {};
c = requestKeys.length;
for (i=0; i<c; i++) {
result[requestKeys[i]] = results[i];
}
}
return returnFunction.call(null, result);
});
deferredResult.callback(aValue);
return deferredResult;
}, aName, someRequests, args);
},
//-------------------------------------------------------------------------
'collectAll': function (someDeferredObjects) {
var deferredResult;
deferredResult = new MochiKit.Async.DeferredList(someDeferredObjects, false, false, false);
deferredResult.addCallback(function (aResultList) {
return MochiKit.Base.map(function (aResult) {
if (aResult[0]) {
return aResult[1];
} else {
throw aResult[1];
}
}, aResultList);
});
return deferredResult;
},
//-------------------------------------------------------------------------
'setItem': function (anObject, aKey, aValue) {
anObject[aKey] = aValue;
return anObject;
},
'setItemOnObject': function (aKey, aValue, anObject) {
anObject[aKey] = aValue;
return anObject;
},
'setDeferredItemOnObject': function (aKey, aDeferredFunction, anObject) {
return Clipperz.Async.callbacks("Clipperz.Async.setDeferredItemOnObject", [
aDeferredFunction,
MochiKit.Base.partial(Clipperz.Async.setItem, anObject, aKey)
], {trace:false}, anObject);
},
//-------------------------------------------------------------------------
'deferredIf': function (aName, aThenBlock, anElseBlock) {
return function (aValue) {
var deferredResult;
if (!MochiKit.Base.isUndefinedOrNull(aValue) && aValue) {
deferredResult = Clipperz.Async.callbacks(aName + " <then>", aThenBlock, null, aValue);
} else {
deferredResult = Clipperz.Async.callbacks(aName + " <else>", anElseBlock, null, aValue);
}
return deferredResult;
}
},
//-------------------------------------------------------------------------
'log': function(aMessage, aResult) {
if (CLIPPERZ_DEFERRED_LOGGING_ENABLED) {
Clipperz.log(aMessage + " ", aResult);
}
return aResult;
},
//=========================================================================
'deferredCompare': function (aComparator, aDeferred, bDeferred) {
var deferredResult;
deferredResult = new Clipperz.Async.Deferred("Clipperz.Async.deferredCompare", {trace:false});
deferredResult.addCallback(Clipperz.Async.collectAll, [aDeferred, bDeferred]);
deferredResult.addCallback(function (someResults) {
var result;
if (aComparator(someResults[0], someResults[1]) > 0) {
result = MochiKit.Async.succeed();
} else {
result = MochiKit.Async.fail();
};
return result;
});
deferredResult.callback();
return deferredResult;
},
//-------------------------------------------------------------------------
'insertIntoSortedArray': function (anObject, aDeferredComparator, aSortedResult) {
var deferredResult;
var i, c;
if (aSortedResult.length == 0) {
deferredResult = MochiKit.Async.succeed([anObject]);
} else {
deferredResult = new Clipperz.Async.Deferred("Clipperz.Async.insertIntoSortedArray", {trace:false});
c = aSortedResult.length + 1;
for (i=0; i<c; i++) {
deferredResult.addCallback(function (aDeferredComparator, aObject, bObject, aContext) {
var innerDeferredResult;
innerDeferredResult = new Clipperz.Async.Deferred("Clipperz.Async.insertIntoSortedArray <inner compare>", {trace:false});
innerDeferredResult.addCallback(aDeferredComparator, aObject, bObject);
innerDeferredResult.addErrback(MochiKit.Async.fail, aContext);
innerDeferredResult.callback();
return innerDeferredResult;
}, aDeferredComparator, anObject, aSortedResult[i], i);
}
deferredResult.addMethod(aSortedResult, 'push', anObject);
deferredResult.addErrback(function (anError) {
aSortedResult.splice(anError.message, 0, anObject);
})
deferredResult.addBoth(MochiKit.Async.succeed, aSortedResult);
deferredResult.callback();
}
return deferredResult;
},
//-------------------------------------------------------------------------
'deferredSort': function (aDeferredComparator, someObjects) {
var deferredResult;
var i, c;
deferredResult = new Clipperz.Async.Deferred("Clipperz.Async.deferredSort", {trace:false});
c = someObjects.length;
for (i=0; i<c; i++) {
deferredResult.addCallback(Clipperz.Async.insertIntoSortedArray, someObjects[i], aDeferredComparator);
if ((i % 50) == 0) {
// console.log("######### sort wait ##########");
deferredResult.addCallback(MochiKit.Async.wait, 0.5);
}
}
deferredResult.callback([]);
return deferredResult;
},
//=========================================================================
'deferredFilter': function (aFunction, someObjects) {
var deferredResult;
var i, c;
deferredResult = new Clipperz.Async.Deferred("Clipperz.Async.deferredFilter", {trace:false});
c = someObjects.length;
for (i=0; i<c; i++) {
deferredResult.addCallback(function (aFunction, anObject, anIndex, aResult) {
var innerDeferredResult;
innerDeferredResult = new Clipperz.Async.Deferred("Clipperz.Async.deferredFilter <inner - " + anIndex + ">", {trace:false});
innerDeferredResult.addCallback(aFunction, anObject);
innerDeferredResult.addCallback(function (aFilterResult) {
if (aFilterResult) {
aResult.push(anObject);
};
});
innerDeferredResult.addBoth(MochiKit.Async.succeed, aResult);
innerDeferredResult.callback();
return innerDeferredResult;
}, aFunction, someObjects[i], i);
}
deferredResult.callback([]);
return deferredResult;
},
'forEach': function (aFunction) {
return MochiKit.Base.partial(function (aFunction, anIterable) {
MochiKit.Iter.forEach(anIterable, aFunction);
}, aFunction);
},
//=========================================================================
'or': function (someValues) {
return Clipperz.Async.callbacks("Clipperz.Async.or", [
MochiKit.Base.values,
MochiKit.Base.flattenArguments,
//function (aValue) { console.log("Record.hasAnyCleanTextData - flatten", aValue); return aValue; },
function(someInnerValues) {
return MochiKit.Iter.some(someInnerValues, MochiKit.Base.operator.identity);
}
], {trace:false}, someValues);
},
//=========================================================================
'clearResult': function () {},
//=========================================================================
__syntaxFix__: "syntax fix"
});
//#############################################################################
CLIPPERZ_DEFERRED_LOGGING_ENABLED = true;
CLIPPERZ_DEFERRED_TRACING_ENABLED = false;
CLIPPERZ_DEFERRED_CALL_LOGGING_ENABLED = false;
diff --git a/frontend/gamma/js/Clipperz/PM/Proxy.js b/frontend/gamma/js/Clipperz/PM/Proxy.js
index 190bffd..9817eac 100644
--- a/frontend/gamma/js/Clipperz/PM/Proxy.js
+++ b/frontend/gamma/js/Clipperz/PM/Proxy.js
@@ -1,169 +1,169 @@
/*
Copyright 2008-2011 Clipperz Srl
This file is part of Clipperz Community Edition.
Clipperz Community Edition is an online password manager.
For further information about its features and functionalities please
refer to http://www.clipperz.com.
* Clipperz Community Edition 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.
* Clipperz Community Edition 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 Clipperz Community Edition. If not, see
<http://www.gnu.org/licenses/>.
*/
if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
//=============================================================================
Clipperz.PM.Proxy = function(args) {
args = args || {};
this._shouldPayTolls = args.shouldPayTolls || false;
this._tolls = {
'CONNECT': [],
'REGISTER': [],
'MESSAGE': []
};
if (args.isDefault === true) {
Clipperz.PM.Proxy.defaultProxy = this;
}
return this;
}
Clipperz.PM.Proxy.prototype = MochiKit.Base.update(null, {
'toString': function() {
return "Clipperz.PM.Proxy";
},
//=========================================================================
'shouldPayTolls': function() {
return this._shouldPayTolls;
},
//-------------------------------------------------------------------------
'tolls': function() {
return this._tolls;
},
//-------------------------------------------------------------------------
'payToll': function(aRequestType, someParameters) {
var deferredResult;
//console.log(">>> Proxy.payToll", aRequestType, someParameters);
if (this.shouldPayTolls()) {
deferredResult = new Clipperz.Async.Deferred("Proxy.payToll", {trace:false});
if (this.tolls()[aRequestType].length == 0) {
deferredResult.addMethod(this, 'sendMessage', 'knock', {requestType:aRequestType});
deferredResult.addMethod(this, 'setTollCallback');
}
deferredResult.addMethod(this.tolls()[aRequestType], 'pop');
deferredResult.addCallback(MochiKit.Base.methodcaller('deferredPay'));
deferredResult.addCallback(function(aToll) {
var result;
result = {
parameters: someParameters,
toll: aToll
}
return result;
});
deferredResult.callback();
} else {
deferredResult = MochiKit.Async.succeed({parameters:someParameters});
}
//console.log("<<< Proxy.payToll");
return deferredResult;
},
//-------------------------------------------------------------------------
'addToll': function(aToll) {
//console.log(">>> Proxy.addToll", aToll);
this.tolls()[aToll.requestType()].push(aToll);
//console.log("<<< Proxy.addToll");
},
//=========================================================================
'setTollCallback': function(someParameters) {
//console.log(">>> Proxy.setTollCallback", someParameters);
if (typeof(someParameters['toll']) != 'undefined') {
//console.log("added a new toll", someParameters['toll']);
this.addToll(new Clipperz.PM.Toll(someParameters['toll']));
}
//console.log("<<< Proxy.setTallCallback", someParameters['result']);
return someParameters['result'];
},
//=========================================================================
'registration': function (someParameters) {
return this.processMessage('registration', someParameters, 'REGISTER');
},
'handshake': function (someParameters) {
return this.processMessage('handshake', someParameters, 'CONNECT');
},
'message': function (someParameters) {
return this.processMessage('message', someParameters, 'MESSAGE');
},
'logout': function (someParameters) {
return this.processMessage('logout', someParameters, 'MESSAGE');
},
//=========================================================================
'processMessage': function (aFunctionName, someParameters, aRequestType) {
var deferredResult;
- deferredResult = new Clipperz.Async.Deferred("Proxy.processMessage", {trace:false});
+ deferredResult = new Clipperz.Async.Deferred("Proxy.processMessage", {trace:true});
deferredResult.addMethod(this, 'payToll', aRequestType);
deferredResult.addMethod(this, 'sendMessage', aFunctionName);
deferredResult.addMethod(this, 'setTollCallback');
deferredResult.callback(someParameters);
return deferredResult;
},
//=========================================================================
'sendMessage': function () {
throw Clipperz.Base.exception.AbstractMethod;
},
//=========================================================================
'isReadOnly': function () {
return false;
},
//=========================================================================
__syntaxFix__: "syntax fix"
});