-rw-r--r-- | backend/php/src/index.php | 7 | ||||
-rwxr-xr-x | frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js | 6 |
2 files changed, 11 insertions, 2 deletions
diff --git a/backend/php/src/index.php b/backend/php/src/index.php index eb3d75a..58c10a9 100644 --- a/backend/php/src/index.php +++ b/backend/php/src/index.php | |||
@@ -628,117 +628,120 @@ error_log("message"); | |||
628 | $result["result"] = "done"; | 628 | $result["result"] = "done"; |
629 | 629 | ||
630 | //============================================================= | 630 | //============================================================= |
631 | } else if ($message == "updateOneTimePasswords") { | 631 | } else if ($message == "updateOneTimePasswords") { |
632 | //{ | 632 | //{ |
633 | //"message":"updateOneTimePasswords", | 633 | //"message":"updateOneTimePasswords", |
634 | //"srpSharedSecret":"c78f8ed099ea421f4dd0a4e02dbaf1f7da925f0088188d99399874ff064a3d27", | 634 | //"srpSharedSecret":"c78f8ed099ea421f4dd0a4e02dbaf1f7da925f0088188d99399874ff064a3d27", |
635 | //"parameters":{ | 635 | //"parameters":{ |
636 | // "user":{ | 636 | // "user":{ |
637 | // "header":"{\"reco...sion\":\"0.1\"}", | 637 | // "header":"{\"reco...sion\":\"0.1\"}", |
638 | // "statistics":"UeRq75RZHzDC7elzrh/+OB5d", | 638 | // "statistics":"UeRq75RZHzDC7elzrh/+OB5d", |
639 | // "version":"0.3", | 639 | // "version":"0.3", |
640 | // "lock":"----" | 640 | // "lock":"----" |
641 | // }, | 641 | // }, |
642 | // "oneTimePasswords":["f5f44c232f239efe48ab81a6236deea1a840d52946f7d4d782dad52b4c5359ce"] | 642 | // "oneTimePasswords":["f5f44c232f239efe48ab81a6236deea1a840d52946f7d4d782dad52b4c5359ce"] |
643 | //} | 643 | //} |
644 | //} | 644 | //} |
645 | 645 | ||
646 | $user = new user(); | 646 | $user = new user(); |
647 | $user = $user->Get($_SESSION["userId"]); | 647 | $user = $user->Get($_SESSION["userId"]); |
648 | 648 | ||
649 | $validOtpReferences = $parameters["parameters"]["oneTimePasswords"]; | 649 | $validOtpReferences = $parameters["parameters"]["oneTimePasswords"]; |
650 | 650 | ||
651 | $otpList = $user->GetOnetimepasswordList(); | 651 | $otpList = $user->GetOnetimepasswordList(); |
652 | $c = count($otpList); | 652 | $c = count($otpList); |
653 | for ($i=0; $i<$c; $i++) { | 653 | for ($i=0; $i<$c; $i++) { |
654 | $currentOtp = $otpList[$i]; | 654 | $currentOtp = $otpList[$i]; |
655 | if (arrayContainsValue($validOtpReferences, $currentOtp->reference) == false) { | 655 | if (arrayContainsValue($validOtpReferences, $currentOtp->reference) == false) { |
656 | $currentOtp->Delete(); | 656 | $currentOtp->Delete(); |
657 | } | 657 | } |
658 | } | 658 | } |
659 | 659 | ||
660 | updateUserData($parameters["parameters"]["user"], $user); | 660 | updateUserData($parameters["parameters"]["user"], $user); |
661 | $user->Save(); | 661 | $user->Save(); |
662 | 662 | ||
663 | $result["result"] = $user->lock; | 663 | $result["result"] = $user->lock; |
664 | 664 | ||
665 | //============================================================= | 665 | //============================================================= |
666 | } else if ($message == "getOneTimePasswordsDetails") { | 666 | } else if ($message == "getOneTimePasswordsDetails") { |
667 | 667 | ||
668 | //============================================================= | 668 | //============================================================= |
669 | } else if ($message == "getLoginHistory") { | 669 | } else if ($message == "getLoginHistory") { |
670 | $result["result"] = array(); | 670 | $result["result"] = array(); |
671 | 671 | ||
672 | //============================================================= | 672 | //============================================================= |
673 | } else if ($message == "upgradeUserCredentials") { | 673 | } else if ($message == "upgradeUserCredentials") { |
674 | //{ | 674 | //{ |
675 | //"message":"upgradeUserCredentials", | 675 | //"message":"upgradeUserCredentials", |
676 | //"srpSharedSecret":"f1c25322e1478c8fb26063e9eef2f6fc25e0460065a31cb718f80bcff8f8a735", | 676 | //"srpSharedSecret":"f1c25322e1478c8fb26063e9eef2f6fc25e0460065a31cb718f80bcff8f8a735", |
677 | //"parameters":{ | 677 | //"parameters":{ |
678 | // "user":{ | 678 | // "user":{ |
679 | // "header":"{\"reco...sion\":\"0.1\"}", | 679 | // "header":"{\"reco...sion\":\"0.1\"}", |
680 | // "statistics":"s72Xva+w7CLgH+ihwqwXUbyu", | 680 | // "statistics":"s72Xva+w7CLgH+ihwqwXUbyu", |
681 | // "version":"0.3", | 681 | // "version":"0.3", |
682 | // "lock":"----" | 682 | // "lock":"----" |
683 | // }, | 683 | // }, |
684 | // "credentials":{ | 684 | // "credentials":{ |
685 | // "C":"57d15a8afbc1ae08103bd991d387ddfd8d26824276476fe709d754f098b6c26d", | 685 | // "C":"57d15a8afbc1ae08103bd991d387ddfd8d26824276476fe709d754f098b6c26d", |
686 | // "s":"d6735fc0486f391c4f3c947928f9e61a2418e7bed2bc9b25bb43f93acc52f636", | 686 | // "s":"d6735fc0486f391c4f3c947928f9e61a2418e7bed2bc9b25bb43f93acc52f636", |
687 | // "v":"540c2ebbf941a481b6b2c9026c07fb46e8202e4408ed96864a696deb622baece", | 687 | // "v":"540c2ebbf941a481b6b2c9026c07fb46e8202e4408ed96864a696deb622baece", |
688 | // "version":"0.2" | 688 | // "version":"0.2" |
689 | // }, | 689 | // }, |
690 | // "oneTimePasswords":{ | 690 | // "oneTimePasswords":{ |
691 | // "923cdc61c4b877b263236124c44d69b459d240453a461cce8ddf7518b423ca94": "1HD6Ta0xsifEDhDwE....9WDK6tvrS6w==", | 691 | // "923cdc61c4b877b263236124c44d69b459d240453a461cce8ddf7518b423ca94": "1HD6Ta0xsifEDhDwE....9WDK6tvrS6w==", |
692 | // "fb1573cb9497652a81688a099a524fb116e604c6fbc191cf33406eb8438efa5f": "CocN0cSxLmMRdgNF9....o3xhGUEY68Q==" | 692 | // "fb1573cb9497652a81688a099a524fb116e604c6fbc191cf33406eb8438efa5f": "CocN0cSxLmMRdgNF9....o3xhGUEY68Q==" |
693 | // } | 693 | // } |
694 | //} | 694 | //} |
695 | //} | 695 | //} |
696 | 696 | ||
697 | $user = new user(); | 697 | $user = new user(); |
698 | $user->Get($_SESSION["userId"]); | 698 | $user->Get($_SESSION["userId"]); |
699 | 699 | ||
700 | $otp = new onetimepassword(); | 700 | $otp = new onetimepassword(); |
701 | 701 | ||
702 | updateUserCredentials($parameters["parameters"]["credentials"], $user); | 702 | updateUserCredentials($parameters["parameters"]["credentials"], $user); |
703 | updateUserData($parameters["parameters"]["user"], $user); | 703 | updateUserData($parameters["parameters"]["user"], $user); |
704 | 704 | ||
705 | $otpList = $parameters["parameters"]["oneTimePasswords"]; | 705 | $otpList = $parameters["parameters"]["oneTimePasswords"]; |
706 | foreach($otpList as $otpReference=>$otpData) { | 706 | foreach($otpList as $otpReference=>$otpData) { |
707 | $otpList = $otp->GetList(array(array("reference", "=", $otpReference))); | 707 | $otpList = $otp->GetList(array(array("reference", "=", $otpReference))); |
708 | $currentOtp = $otpList[0]; | 708 | $currentOtp = $otpList[0]; |
709 | $currentOtp->data = $otpData; | 709 | $currentOtp->data = $otpData; |
710 | $currentOtp->Save(); | 710 | $currentOtp->Save(); |
711 | } | 711 | } |
712 | 712 | ||
713 | $user->Save(); | 713 | $user->Save(); |
714 | 714 | ||
715 | $result["lock"] = $user->lock; | 715 | $result["lock"] = $user->lock; |
716 | $result["result"] = "done"; | 716 | $result["result"] = "done"; |
717 | 717 | ||
718 | //============================================================= | 718 | //============================================================= |
719 | } else if ($message == "echo") { | 719 | } else if ($message == "echo") { |
720 | $result["result"] = $parameters; | 720 | $result["result"] = $parameters; |
721 | } | 721 | } |
722 | 722 | ||
723 | //============================================================= | 723 | //============================================================= |
724 | } else { | 724 | } else if (isset($_SESSION['K'])) { |
725 | $result["error"] = "Wrong shared secret!"; | 725 | $result["error"] = "Wrong shared secret!"; |
726 | } else { | ||
727 | $result["result"] = "EXCEPTION"; | ||
728 | $result["message"] = "Trying to communicate without an active connection"; | ||
726 | } | 729 | } |
727 | break; | 730 | break; |
728 | 731 | ||
729 | case "logout": | 732 | case "logout": |
730 | error_log("logout"); | 733 | error_log("logout"); |
731 | session_destroy(); | 734 | session_destroy(); |
732 | break; | 735 | break; |
733 | 736 | ||
734 | default: | 737 | default: |
735 | error_log("default"); | 738 | error_log("default"); |
736 | $result["result"] = $parameters; | 739 | $result["result"] = $parameters; |
737 | break; | 740 | break; |
738 | } | 741 | } |
739 | 742 | ||
740 | session_write_close(); | 743 | session_write_close(); |
741 | 744 | ||
742 | echo(json_encode($result)); | 745 | echo(json_encode($result)); |
743 | error_log("result: ".json_encode($result)); | 746 | error_log("result: ".json_encode($result)); |
744 | ?> \ No newline at end of file | 747 | ?> |
diff --git a/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js b/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js index e7c2bc1..6185fd6 100755 --- a/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js +++ b/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js | |||
@@ -145,115 +145,121 @@ YAHOO.extendX(Clipperz.PM.Proxy.PHP, Clipperz.PM.Proxy, { | |||
145 | }, | 145 | }, |
146 | 146 | ||
147 | //------------------------------------------------------------------------- | 147 | //------------------------------------------------------------------------- |
148 | 148 | ||
149 | 'message': function(someParameters) { | 149 | 'message': function(someParameters) { |
150 | return this.sendMessage('message', someParameters, 'MESSAGE'); | 150 | return this.sendMessage('message', someParameters, 'MESSAGE'); |
151 | }, | 151 | }, |
152 | 152 | ||
153 | //------------------------------------------------------------------------- | 153 | //------------------------------------------------------------------------- |
154 | 154 | ||
155 | 'logout': function(someParameters) { | 155 | 'logout': function(someParameters) { |
156 | //MochiKit.Logging.logDebug("=== Proxy.DWR.logout"); | 156 | //MochiKit.Logging.logDebug("=== Proxy.DWR.logout"); |
157 | return this.sendMessage('logout', someParameters, 'MESSAGE'); | 157 | return this.sendMessage('logout', someParameters, 'MESSAGE'); |
158 | }, | 158 | }, |
159 | 159 | ||
160 | //========================================================================= | 160 | //========================================================================= |
161 | 161 | ||
162 | 'sendMessage': function(aFunctionName, someParameters, aRequestType) { | 162 | 'sendMessage': function(aFunctionName, someParameters, aRequestType) { |
163 | /* | 163 | /* |
164 | vardeferredResult; | 164 | vardeferredResult; |
165 | var proxy; | 165 | var proxy; |
166 | 166 | ||
167 | //MochiKit.Logging.logDebug(">>> Proxy.DWR.sendMessage - " + aFunctionName + " - " + aRequestType); | 167 | //MochiKit.Logging.logDebug(">>> Proxy.DWR.sendMessage - " + aFunctionName + " - " + aRequestType); |
168 | proxy = this; | 168 | proxy = this; |
169 | 169 | ||
170 | deferredResult = new MochiKit.Async.Deferred(); | 170 | deferredResult = new MochiKit.Async.Deferred(); |
171 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.1 Proxy.DWR.sendMessage - 1: " + res); return res;}); | 171 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.1 Proxy.DWR.sendMessage - 1: " + res); return res;}); |
172 | deferredResult.addCallback(MochiKit.Base.method(proxy, 'payToll'), aRequestType); | 172 | deferredResult.addCallback(MochiKit.Base.method(proxy, 'payToll'), aRequestType); |
173 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.2 Proxy.DWR.sendMessage - 2: " + Clipperz.Base.serializeJSON(res)); return res;}); | 173 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.2 Proxy.DWR.sendMessage - 2: " + Clipperz.Base.serializeJSON(res)); return res;}); |
174 | deferredResult.addCallback(MochiKit.Base.method(proxy, 'sendRemoteMessage'), aFunctionName); | 174 | deferredResult.addCallback(MochiKit.Base.method(proxy, 'sendRemoteMessage'), aFunctionName); |
175 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.DWR.sendMessage - 3: " + res); return res;}); | 175 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.DWR.sendMessage - 3: " + res); return res;}); |
176 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.DWR.sendMessage - 3: " + Clipperz.Base.serializeJSON(res)); return res;}); | 176 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.DWR.sendMessage - 3: " + Clipperz.Base.serializeJSON(res)); return res;}); |
177 | deferredResult.callback(someParameters); | 177 | deferredResult.callback(someParameters); |
178 | 178 | ||
179 | //MochiKit.Logging.logDebug("<<< Proxy.DWR.sendMessage"); | 179 | //MochiKit.Logging.logDebug("<<< Proxy.DWR.sendMessage"); |
180 | return deferredResult; | 180 | return deferredResult; |
181 | */ | 181 | */ |
182 | 182 | ||
183 | // return this.sendRemoteMessage(aFunctionName, someParameters); | 183 | // return this.sendRemoteMessage(aFunctionName, someParameters); |
184 | 184 | ||
185 | 185 | ||
186 | vardeferredResult; | 186 | vardeferredResult; |
187 | var proxy; | 187 | var proxy; |
188 | 188 | ||
189 | proxy = this; | 189 | proxy = this; |
190 | 190 | ||
191 | deferredResult = new MochiKit.Async.Deferred(); | 191 | deferredResult = new MochiKit.Async.Deferred(); |
192 | deferredResult.addCallback(MochiKit.Base.method(proxy, 'sendRemoteMessage'), aFunctionName); | 192 | deferredResult.addCallback(MochiKit.Base.method(proxy, 'sendRemoteMessage'), aFunctionName); |
193 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.PHP.sendMessage - 3: " + res); return res;}); | 193 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.PHP.sendMessage - 3: " + res); return res;}); |
194 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.PHP.sendMessage - 3.1: " + Clipperz.Base.serializeJSON(res)); return res;}); | 194 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.PHP.sendMessage - 3.1: " + Clipperz.Base.serializeJSON(res)); return res;}); |
195 | 195 | ||
196 | deferredResult.callback(someParameters); | 196 | deferredResult.callback(someParameters); |
197 | 197 | ||
198 | return deferredResult; | 198 | return deferredResult; |
199 | }, | 199 | }, |
200 | 200 | ||
201 | //========================================================================= | 201 | //========================================================================= |
202 | 202 | ||
203 | 'sendRemoteMessage': function(aFunctionName, someParameters) { | 203 | 'sendRemoteMessage': function(aFunctionName, someParameters) { |
204 | /* | 204 | /* |
205 | vardeferredResult; | 205 | vardeferredResult; |
206 | 206 | ||
207 | //MochiKit.Logging.logDebug(">>> Proxy.DWR.sendRemoteMessage('" + aFunctionName + "', " + Clipperz.Base.serializeJSON(someParameters) + ") - " + this); | 207 | //MochiKit.Logging.logDebug(">>> Proxy.DWR.sendRemoteMessage('" + aFunctionName + "', " + Clipperz.Base.serializeJSON(someParameters) + ") - " + this); |
208 | deferredResult = new MochiKit.Async.Deferred(); | 208 | deferredResult = new MochiKit.Async.Deferred(); |
209 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Proxy.DWR.sendRemoteMessage - 1: " + res); return res;}); | 209 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Proxy.DWR.sendRemoteMessage - 1: " + res); return res;}); |
210 | // deferredResult.addCallback(MochiKit.Base.method(this, 'setTollCallback')); | 210 | // deferredResult.addCallback(MochiKit.Base.method(this, 'setTollCallback')); |
211 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Proxy.DWR.sendRemoteMessage - 2: " + res); return res;}); | 211 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Proxy.DWR.sendRemoteMessage - 2: " + res); return res;}); |
212 | 212 | ||
213 | com_clipperz_pm_Proxy[aFunctionName](Clipperz.Base.serializeJSON(someParameters), { | 213 | com_clipperz_pm_Proxy[aFunctionName](Clipperz.Base.serializeJSON(someParameters), { |
214 | callback:MochiKit.Base.method(deferredResult, 'callback'), | 214 | callback:MochiKit.Base.method(deferredResult, 'callback'), |
215 | errorHandler:MochiKit.Base.method(deferredResult, 'errback') | 215 | errorHandler:MochiKit.Base.method(deferredResult, 'errback') |
216 | }); | 216 | }); |
217 | //MochiKit.Logging.logDebug("<<< Proxy.PHP.sendRemoteMessage - result: " + deferredResult); | 217 | //MochiKit.Logging.logDebug("<<< Proxy.PHP.sendRemoteMessage - result: " + deferredResult); |
218 | 218 | ||
219 | return deferredResult; | 219 | return deferredResult; |
220 | */ | 220 | */ |
221 | 221 | ||
222 | vardeferredResult; | 222 | vardeferredResult; |
223 | var parameters; | 223 | var parameters; |
224 | 224 | ||
225 | //MochiKit.Logging.logDebug(">>> Proxy.PHP.sendRemoteMessage('" + aFunctionName + "', " + Clipperz.Base.serializeJSON(someParameters) + ") - " + this); | 225 | //MochiKit.Logging.logDebug(">>> Proxy.PHP.sendRemoteMessage('" + aFunctionName + "', " + Clipperz.Base.serializeJSON(someParameters) + ") - " + this); |
226 | parameters = {}; | 226 | parameters = {}; |
227 | parameters['method'] = aFunctionName; | 227 | parameters['method'] = aFunctionName; |
228 | // parameters['version'] = someParameters['version']; | 228 | // parameters['version'] = someParameters['version']; |
229 | // parameters['message'] = someParameters['message']; | 229 | // parameters['message'] = someParameters['message']; |
230 | parameters['parameters'] = Clipperz.Base.serializeJSON(someParameters); | 230 | parameters['parameters'] = Clipperz.Base.serializeJSON(someParameters); |
231 | //MochiKit.Logging.logDebug("--- Proxy.PHP.sendRemoteMessage('" + Clipperz.Base.serializeJSON(parameters) + ") - " + this); | 231 | //MochiKit.Logging.logDebug("--- Proxy.PHP.sendRemoteMessage('" + Clipperz.Base.serializeJSON(parameters) + ") - " + this); |
232 | deferredResult = new MochiKit.Async.Deferred(); | 232 | deferredResult = new MochiKit.Async.Deferred(); |
233 | deferredResult.addCallback(MochiKit.Async.doXHR, "./php/index.php", { | 233 | deferredResult.addCallback(MochiKit.Async.doXHR, "./php/index.php", { |
234 | method:'POST', | 234 | method:'POST', |
235 | sendContent:MochiKit.Base.queryString(parameters), | 235 | sendContent:MochiKit.Base.queryString(parameters), |
236 | headers:{"Content-Type":"application/x-www-form-urlencoded"} | 236 | headers:{"Content-Type":"application/x-www-form-urlencoded"} |
237 | }); | 237 | }); |
238 | //deferredResult.addCallback(function(res) {MochiKit.Logging.logDebug("Proxy.PHP.response - 2: " + res.responseText); return res;}); | 238 | //deferredResult.addCallback(function(res) {MochiKit.Logging.logDebug("Proxy.PHP.response - 2: " + res.responseText); return res;}); |
239 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("Proxy.PHP.response - ERROR: " + res); return res;}); | 239 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("Proxy.PHP.response - ERROR: " + res); return res;}); |
240 | deferredResult.addCallback(MochiKit.Async.evalJSONRequest); | 240 | deferredResult.addCallback(MochiKit.Async.evalJSONRequest); |
241 | deferredResult.addCallback(function (someValues) { | ||
242 | if (someValues['result'] == 'EXCEPTION') { | ||
243 | throw someValues['message']; | ||
244 | } | ||
245 | return someValues; | ||
246 | }) | ||
241 | deferredResult.callback(); | 247 | deferredResult.callback(); |
242 | 248 | ||
243 | return deferredResult; | 249 | return deferredResult; |
244 | }, | 250 | }, |
245 | 251 | ||
246 | //========================================================================= | 252 | //========================================================================= |
247 | 253 | ||
248 | 'isReadOnly': function() { | 254 | 'isReadOnly': function() { |
249 | return false; | 255 | return false; |
250 | }, | 256 | }, |
251 | 257 | ||
252 | //========================================================================= | 258 | //========================================================================= |
253 | __syntaxFix__: "syntax fix" | 259 | __syntaxFix__: "syntax fix" |
254 | 260 | ||
255 | }); | 261 | }); |
256 | 262 | ||
257 | //============================================================================= | 263 | //============================================================================= |
258 | 264 | ||
259 | //Clipperz.PM.Proxy.defaultProxy = new Clipperz.PM.Proxy.PHP("Proxy.PHP - async test"); | 265 | //Clipperz.PM.Proxy.defaultProxy = new Clipperz.PM.Proxy.PHP("Proxy.PHP - async test"); |