Adding permission checks for Java; fixing type translations for return and parameter...
[iot2.git] / iotjava / iotrmi / Java / sample / TestClass_Stub.java
index 9e2006d31f23ead3ad092c30a6614599510bdc02..bb6df9bb10759a78fca3d8febddc8540659ca294 100644 (file)
@@ -24,7 +24,9 @@ public class TestClass_Stub implements TestClassInterface {
         * Class Constants
         */
        private int objectId = 0;       // Default value is 0
-
+       // This is permission system for callback objects
+       private static Integer[] object0Permission = { 0, 1 };  // object0 is the callback object
+       private List<Integer> set0Allowed;
 
        /**
         * Properties and constants for Callbacks!
@@ -43,6 +45,8 @@ public class TestClass_Stub implements TestClassInterface {
                ports = _ports;
                rmiCall = new IoTRMICall(_port, _address, _rev);
 
+               set0Allowed = Arrays.asList(object0Permission);
+
                // Only for callbacks!!!
                listCBObj = new ArrayList<CallBackInterface>();
                ___initCallBack();
@@ -69,6 +73,11 @@ public class TestClass_Stub implements TestClassInterface {
                                        Object retObj = null;
                                        while (true) {
                                                byte[] method = rmiObj.getMethodBytes();
+                                               // Permission checking
+                                               int methId = IoTRMIObject.getMethodId(method);
+                                               if (!set0Allowed.contains(methId))
+                                                       throw new Error("CallBack_CBSkeleton: This object is not allowed to access method " + methId);
+
                                                int objId = IoTRMIObject.getObjectId(method);
                                                CallBack_CBSkeleton skel = (CallBack_CBSkeleton) listCBObj.get(objId);
                                                if (skel != null) {