Minor adjustments for Tomoyo for the fourth benchmark
[iot2.git] / iotjava / iotruntime / master / ProcessJailConfig.java
index d76d130..757313a 100644 (file)
@@ -38,6 +38,7 @@ public final class ProcessJailConfig {
 
        private static final String STR_MAC_POLICY_EXT          = ".tomoyo.pol";
        private static final String STR_OBJECT_NAME             = "<object-name>";
+       private static final String STR_OBJECT_CLASS_NAME       = "<object-class-name>";
        private static final String STR_MASTER_IP_ADDRESS       = "<master-ip-address>";
        private static final String STR_MASTER_COM_PORT         = "<master-com-port>";
        private static final String STR_RMI_REG_PORT            = "<rmi-reg-port>";
@@ -263,6 +264,7 @@ public final class ProcessJailConfig {
         *
         * @param   strConfigHost                       String hostname to be configured
         * @param   strObjectName                       String object name
+        * @param   strObjectClassName          String object class name
         * @param   strFileName                         String policy file path and name
         * @param   strMasterIPAddress          String master IP address
         * @param   iComPort                            Integer communication port (controller-driver)
@@ -270,17 +272,22 @@ public final class ProcessJailConfig {
         * @param   iRMIStubPort                        Integer RMI stub port
         * @return  void
         */
-       public void configureProcessJailDeviceDriverPolicies(String strConfigHost, String strObjectName, 
+       public void configureProcessJailDeviceDriverPolicies(String strConfigHost, String strObjectName, String strObjectClassName, 
                        String strFileName, String strMasterIPAddress, int iComPort, int iRMIRegPort, int iRMIStubPort) {
 
                PrintWriter pwConfig = getPrintWriter(strConfigHost);
                String strPolicyList = readFile(strFileName);
                // Replace the strings with the actual values
-               String strNewPolicyList = strPolicyList.replace(STR_OBJECT_NAME, strObjectName).replace(STR_MASTER_IP_ADDRESS,
-                       strMasterIPAddress).replace(STR_MASTER_COM_PORT, String.valueOf(iComPort)).replace(STR_RMI_REG_PORT,
-                       String.valueOf(iRMIRegPort)).replace(STR_RMI_STUB_PORT, String.valueOf(iRMIStubPort));
+               String strNewPolicyList = strPolicyList.replace(STR_OBJECT_NAME, strObjectName).
+                       replace(STR_OBJECT_CLASS_NAME, strObjectClassName).
+                       replace(STR_MASTER_IP_ADDRESS, strMasterIPAddress).
+                       replace(STR_MASTER_COM_PORT, String.valueOf(iComPort));
+                       //replace(STR_RMI_REG_PORT, String.valueOf(iRMIRegPort)).
+                       //replace(STR_RMI_STUB_PORT, String.valueOf(iRMIStubPort));
                pwConfig.println("\n");
                pwConfig.print(strNewPolicyList);
+               pwConfig.println("network inet stream bind/listen :: " + iRMIRegPort);
+               pwConfig.println("network inet stream bind/listen :: " + iRMIStubPort);
        }
 
 
@@ -309,6 +316,46 @@ public final class ProcessJailConfig {
        }
 
 
+       /**
+        * configureProcessJailDevicePolicies() method configures the device MAC policies
+        * <p>
+        * This method configures the device policies between device driver and device
+        *
+        * @param   strConfigHost                       String hostname to be configured
+        * @param   strRouterAddress            String router address
+        * @param   iPort                                       Integer port
+        * @return  void
+        */
+       public void configureProcessJailGWDevicePolicies(String strConfigHost, String strRouterAddress, int iPort) {
+
+               PrintWriter pwConfig = getPrintWriter(strConfigHost);
+               pwConfig.println("file read /home/iotuser/iot2/iotjava/iotruntime/\\*.jks");
+               pwConfig.println("file read /etc/resolv.conf");
+               pwConfig.println("file read /etc/hosts");
+               pwConfig.println("network inet dgram send " + strRouterAddress + " " + String.valueOf(iPort));
+       }
+
+
+       /**
+        * configureProcessJailDeviceDriverInetAddressPolicies() method configures the device MAC policies
+        * <p>
+        *
+        * @param   strConfigHost       String hostname to be configured
+        * @param   strAddress          String device IP address
+        * @return  void
+        */
+       public void configureProcessJailInetAddressPolicies(String strConfigHost, String strRouterAddress, String strAddress) {
+
+               PrintWriter pwConfig = getPrintWriter(strConfigHost);
+               //System.out.println("\n\nDEBUG: Writing the config host address setup!!!\n\n");
+               pwConfig.println("file read /etc/resolv.conf");
+               pwConfig.println("file read /etc/hosts");
+               pwConfig.println("file read /etc/host.conf");
+               pwConfig.println("network inet dgram send " + strRouterAddress + " " + String.valueOf(53));     // TCP/UDP access through router
+               pwConfig.println("network inet stream connect ::ffff:" + strAddress + " " + String.valueOf(80));        // HTTP access for this address
+       }
+
+
        /**
         * configureProcessJailControllerPolicies() method configures the main MAC policies for controller
         *
@@ -324,8 +371,10 @@ public final class ProcessJailConfig {
                PrintWriter pwConfig = getPrintWriter(strControllerName);
                String strPolicyList = readFile(strFileName);
                // Replace the strings with the actual values
-               String strNewPolicyList = strPolicyList.replace(STR_MASTER_IP_ADDRESS,
-                       strMasterIPAddress).replace(STR_MASTER_COM_PORT, String.valueOf(iComPort));
+               String strNewPolicyList = strPolicyList.replace(STR_OBJECT_NAME, strControllerName).
+                       replace(STR_OBJECT_CLASS_NAME, strControllerName).
+                       replace(STR_MASTER_IP_ADDRESS, strMasterIPAddress).
+                       replace(STR_MASTER_COM_PORT, String.valueOf(iComPort));
                pwConfig.println("\n");
                pwConfig.print(strNewPolicyList);
        }