Adding a new feature that makes process jailing rules more fine-grained - we can...
[iot2.git] / iotjava / iotruntime / master / ProcessJailConfig.java
index e19ee151f6b50e7488b4a5b49f4b13a93b930295..fba8cad773436bbf2d57f21f3bf0953b46a6367f 100644 (file)
@@ -36,6 +36,7 @@ public final class ProcessJailConfig {
        private static final String STR_TCPGW_PROTOCOL = "tcpgw";
        private static final String STR_NO_PROTOCOL = "nopro";
 
+       private static final String STR_ADD_MAC_EXT             = ".tomoyo";
        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>";
@@ -104,6 +105,19 @@ public final class ProcessJailConfig {
                }
        }
        
+       
+       /**
+        * flush() flushes all PrintWriter objects
+        *
+        * @return  void
+        */
+       public void flush() {
+
+               for(PrintWriter pwConfig: mapHostToFile.values()) {
+                       pwConfig.flush();
+               }
+       }
+       
 
        /**
         * close() closes all PrintWriter objects
@@ -403,6 +417,21 @@ public final class ProcessJailConfig {
        }
 
 
+       /**
+        * combineAdditionalMACPolicy() method combines the additional MAC policies into the right host policy file
+        *
+        * @param   strConfigHost                       String hostname to be configured
+        * @param   strFileName                         String policy file path and name
+        * @return  void
+        */
+       public void combineAdditionalMACPolicy(String strMACCfgPath, String strObjectName, String strConfigHost) {
+
+               PrintWriter pwConfig = getPrintWriter(strConfigHost);
+               String strPolicyList = readFile(strMACCfgPath + strObjectName + STR_ADD_MAC_EXT);
+               pwConfig.println(strPolicyList);
+       }
+
+
        /**
         * combineControllerMACPolicies() method combines the controller MAC policies into the right host policy file
         *