X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=iotjava%2Fiotrmi%2FJava%2Fsample%2FTestClass_Stub.java;h=a08ce6282871d19f54a61fa19aa80db801b3e3b4;hb=8e565033fd19c4696f67862ade27f0ebbacf5682;hp=89e6a6e05a391886b3ad0cf5c3d825f92a74787d;hpb=85fe913ad1c6f10b89ad73476315ed8e2453e080;p=iot2.git diff --git a/iotjava/iotrmi/Java/sample/TestClass_Stub.java b/iotjava/iotrmi/Java/sample/TestClass_Stub.java index 89e6a6e..a08ce62 100644 --- a/iotjava/iotrmi/Java/sample/TestClass_Stub.java +++ b/iotjava/iotrmi/Java/sample/TestClass_Stub.java @@ -16,18 +16,26 @@ public class TestClass_Stub implements TestClassInterface { * Class Properties */ private IoTRMICall rmiCall; + private IoTRMIObject rmiObj; private String address; private int[] ports; - private List listCBObj; - private IoTRMIObject rmiObj; /** * Class Constants */ - private final static int NUM_CB_OBJ = 1; 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 set0Allowed; + + /** + * Properties and constants for Callbacks! + */ + private List listCBObj; + private final static int NUM_CB_OBJ = 1; private static int objIdCnt = 0; // Counter for callback object Ids + /** * Constructors */ @@ -36,6 +44,10 @@ public class TestClass_Stub implements TestClassInterface { address = _address; ports = _ports; rmiCall = new IoTRMICall(_port, _address, _rev); + + set0Allowed = Arrays.asList(object0Permission); + + // Only for callbacks!!! listCBObj = new ArrayList(); ___initCallBack(); } @@ -56,11 +68,14 @@ public class TestClass_Stub implements TestClassInterface { Thread thread = new Thread() { public void run() { try{ - System.out.println("Created server with port: " + ports[0]); rmiObj = new IoTRMIObject(ports[0]); - 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) { @@ -233,7 +248,7 @@ public class TestClass_Stub implements TestClassInterface { paramCls2[pos] = int.class; paramObj2[pos++] = data[i].year; } - System.out.println(Arrays.toString(paramObj2)); + //System.out.println(Arrays.toString(paramObj2)); Object retObj = rmiCall.remoteCall(objectId, methodId2, retType2, null, paramCls2, paramObj2); // RETURN STRUCT // Get the length of the struct first