Return correct error messages on security exceptions.
authorLuc Yriarte <luc.yriarte@linux.intel.com>
Mon, 17 Sep 2012 13:14:59 +0000 (15:14 +0200)
committerLuc Yriarte <luc.yriarte@linux.intel.com>
Mon, 17 Sep 2012 13:14:59 +0000 (15:14 +0200)
cloudeebus/cloudeebus.js
doc/dbus-tools/dbus-register.html
doc/dbus-tools/dbus-send.html

index ff24013..442fd05 100644 (file)
@@ -36,6 +36,12 @@ cloudeebus.connect = function(uri, manifest, successCB, errorCB) {
        cloudeebus.reset();
        cloudeebus.uri = uri;
        
+       function onWAMPSessionAuthErrorCB(error) {
+               cloudeebus.log("Authentication error: " + error.desc);
+               if (errorCB)
+                       errorCB(error.desc);
+       }
+       
        function onWAMPSessionAuthenticatedCB(permissions) {
                cloudeebus.log("Connected to " + cloudeebus.uri);
                cloudeebus.sessionBus = new cloudeebus.BusConnection("session", cloudeebus.wampSession);
@@ -46,7 +52,7 @@ cloudeebus.connect = function(uri, manifest, successCB, errorCB) {
        
        function onWAMPSessionChallengedCB(challenge) {
                var signature = cloudeebus.wampSession.authsign(challenge, manifest.key);
-               cloudeebus.wampSession.auth(signature).then(onWAMPSessionAuthenticatedCB, errorCB);
+               cloudeebus.wampSession.auth(signature).then(onWAMPSessionAuthenticatedCB, onWAMPSessionAuthErrorCB);
        }
        
        function onWAMPSessionConnectedCB(session) {
@@ -55,11 +61,11 @@ cloudeebus.connect = function(uri, manifest, successCB, errorCB) {
                        cloudeebus.wampSession.authreq(
                                        manifest.name, 
                                        {permissions: JSON.stringify(manifest.permissions)}
-                               ).then(onWAMPSessionChallengedCB, errorCB);
+                               ).then(onWAMPSessionChallengedCB, onWAMPSessionAuthErrorCB);
                else
                        cloudeebus.wampSession.authreq().then(function() {
-                               cloudeebus.wampSession.auth().then(onWAMPSessionAuthenticatedCB, errorCB);
-                               }, errorCB);
+                               cloudeebus.wampSession.auth().then(onWAMPSessionAuthenticatedCB, onWAMPSessionAuthErrorCB);
+                               }, onWAMPSessionAuthErrorCB);
        }
 
        function onWAMPSessionErrorCB(code, reason) {
index 3c29817..ab284fa 100644 (file)
                // HTML DOM elements
                var mLog, mBus, mSender, mObject, mInterface, mSignal, mArgs, mUri;
 
+               // RPC success callback
+               function myAsyncFuncSuccessCB(res) {
+                       log_append("subscribing to: " + res + "\n");
+                       mSession.subscribe(res, sigHandler);
+               }
+
+               // RPC error callback
+               function myAsyncFuncErrorCB(error, desc) {
+                       var str = error.desc ? error.desc : desc;
+                       log_append("error: " + str + "\n");
+               }
+
                window.onload = function() {
 
                        function onSessionAuthenticatedCB() { // WAMP session was authenticated
@@ -19,8 +31,8 @@
                        function onSessionConnectedCB(session) { // WAMP session was established
                                mSession = session;
                                mSession.authreq().then(function() {
-                                       mSession.auth().then(onSessionAuthenticatedCB, log_append);
-                               }, log_append);
+                                       mSession.auth().then(onSessionAuthenticatedCB, myAsyncFuncErrorCB);
+                               }, myAsyncFuncErrorCB);
                        }
 
                        function onSessionErrorCB(code, reason) { // WAMP session is gone
                        log_append("data: " + data + "\n");
                }
 
-               function dbus_register() {
-                       // RPC success callback
-                       function myAsyncFuncSuccessCB(res) {
-                               log_append("subscribing to: " + res + "\n");
-                               mSession.subscribe(res, sigHandler);
-                       }
-
-                       // RPC error callback
-                       function myAsyncFuncErrorCB(error, desc) {
-                               log_append("error: " + desc + "\n");
-                       }
-
+               function dbus_register() 
+               {
                        log_append("dbusRegister: "
                                + mBus.options[mBus.selectedIndex].value + "\n\t"
                                + mSender.value + "\n\t"
index a442cdd..8d9b6f7 100644 (file)
                // HTML DOM elements
                var mLog, mBus, mDestination, mObject, mInterface, mMessage, mArgs, mUri;
 
+               // RPC success callback
+               function myAsyncFuncSuccessCB(res) {
+                       log_append("got result: " + res + "\n");
+               }
+
+               // RPC error callback
+               function myAsyncFuncErrorCB(error, desc) {
+                       var str = error.desc ? error.desc : desc;
+                       log_append("error: " + str + "\n");
+               }
+
                window.onload = function() {
 
                        function onSessionAuthenticatedCB() { // WAMP session was authenticated
@@ -19,8 +30,8 @@
                        function onSessionConnectedCB(session) { // WAMP session was established
                                mSession = session;
                                mSession.authreq().then(function() {
-                                       mSession.auth().then(onSessionAuthenticatedCB, log_append);
-                               }, log_append);
+                                       mSession.auth().then(onSessionAuthenticatedCB, myAsyncFuncErrorCB);
+                               }, myAsyncFuncErrorCB);
                        }
 
                        function onSessionErrorCB(code, reason) { // WAMP session is gone
 
                function dbus_send()
                {
-                       // RPC success callback
-                       function myAsyncFuncSuccessCB(res) {
-                               log_append("got result: " + res + "\n");
-                       }
-
-                       // RPC error callback
-                       function myAsyncFuncErrorCB(error, desc) {
-                               log_append("error: " + desc + "\n");
-                       }
-
                        log_append("dbusSend: "
                                + mBus.options[mBus.selectedIndex].value + "\n\t"
                                + mDestination.value + "\n\t"