routerConfig.configureHostMainPolicies(strIoTSlaveObjectHostAdd, strIoTSlaveControllerHostAdd,
strIoTSlaveObjectHostAdd, STR_TCP_PROTOCOL);
// Configure MAC policies for objects
- String strFileName = STR_MAC_POL_PATH + STR_JAVA + STR_MAC_POLICY_EXT;
if (STR_ACTIVATE_SANDBOXING.equals("Yes")) {
+ // Read config file
+ String strObjLanguage = readObjectLanguage(strObjName, strObjClassName);
+ String strFileName = null;
+ if(strObjLanguage.equals(STR_JAVA))
+ strFileName = STR_MAC_POL_PATH + STR_JAVA + STR_MAC_POLICY_EXT;
+ else
+ strFileName = STR_MAC_POL_PATH + STR_CPP + STR_MAC_POLICY_EXT;
processJailConfig.configureProcessJailDeviceDriverPolicies(strIoTSlaveObjectHostAdd, strObjName, strObjClassName,
strFileName, strIoTMasterHostAdd, commHan.getComPort(strObjName), commHan.getRMIRegPort(strObjName),
commHan.getRMIStubPort(strObjName));
- // Check for additional MAC policy
- String strMACConfigPath = STR_IOT_CODE_PATH + strObjClassName + "/";
- String strCfgFile = strMACConfigPath + strObjClassName + STR_CFG_FILE_EXT;
- String strAddMACPolicy = parseConfigFile(strCfgFile, STR_ADD_MAC_POL);
- if (strAddMACPolicy != null && strAddMACPolicy.equals("Yes"))
- processJailConfig.combineAdditionalMACPolicy(strMACConfigPath, strObjClassName, strIoTSlaveObjectHostAdd);
+ // Check for additional MAC policy
+ String strMACConfigPath = STR_IOT_CODE_PATH + strObjClassName + "/";
+ String strCfgFile = strMACConfigPath + strObjClassName + STR_CFG_FILE_EXT;
+ String strAddMACPolicy = parseConfigFile(strCfgFile, STR_ADD_MAC_POL);
+ if (strAddMACPolicy != null && strAddMACPolicy.equals("Yes"))
+ processJailConfig.combineAdditionalMACPolicy(strMACConfigPath, strObjClassName, strIoTSlaveObjectHostAdd);
processJailConfig.configureProcessJailContRMIPolicies(strObjControllerName, strIoTSlaveObjectHostAdd,
commHan.getRMIRegPort(strObjName), commHan.getRMIStubPort(strObjName));
}
printWriter.close();
runCommand("chmod 755 " + strFileName);
}
+
+ /**
+ * A private method to read the language of the object, i.e. driver
+ *
+ * @params strObjName String object name
+ * @params strObjClassName String object class name
+ * @return String
+ */
+ private String readObjectLanguage(String strObjName, String strObjClassName) {
+
+ // Read config file
+ String sCfgFile = STR_IOT_CODE_PATH + strObjClassName + "/" + strObjClassName + STR_CFG_FILE_EXT;
+ String strLanguageDriver = parseConfigFile(sCfgFile, STR_LANGUAGE + "_" + strObjName);
+ if(strLanguageDriver == null) // Read just the field LANGUAGE if the first read is null
+ strLanguageDriver = parseConfigFile(sCfgFile, STR_LANGUAGE);
+ if(strLanguageDriver == null) // Check nullness for the second time - report if it is still null
+ throw new Error("IoTMaster: Language specification missing in config file: " + sCfgFile);
+ return strLanguageDriver;
+ }
/**
* A private method to create an object on a specific machine
throws IOException, FileNotFoundException, ClassNotFoundException, InterruptedException {
// Read config file
- String sCfgFile = STR_IOT_CODE_PATH + strObjClassName + "/" + strObjClassName + STR_CFG_FILE_EXT;
- String strLanguageDriver = parseConfigFile(sCfgFile, STR_LANGUAGE + "_" + strObjName);
- if(strLanguageDriver == null) // Read just the field LANGUAGE if the first read is null
- strLanguageDriver = parseConfigFile(sCfgFile, STR_LANGUAGE);
- if(strLanguageDriver == null) // Check nullness for the second time - report if it is still null
- throw new Error("IoTMaster: Language specification missing in config file: " + sCfgFile);
+ String strLanguageDriver = readObjectLanguage(strObjName, strObjClassName);
// Construct ssh command line
// e.g. ssh rtrimana@dw-2.eecs.uci.edu cd <path>;
// java -cp $CLASSPATH:./*.jar
createMainObjectCpp(strObjControllerName, outStream, inStream);
}
// Write basic MAC policies for controller
- //String strFileName = STR_MAC_POL_PATH + strObjControllerName + STR_MAC_POLICY_EXT;
if (STR_ACTIVATE_SANDBOXING.equals("Yes")) {
- String strFileName = STR_MAC_POL_PATH + STR_JAVA + STR_MAC_POLICY_EXT;
+ String strFileName = null;
+ if(STR_LANGUAGE_CONTROLLER.equals(STR_JAVA))
+ strFileName = STR_MAC_POL_PATH + STR_JAVA + STR_MAC_POLICY_EXT;
+ else
+ strFileName = STR_MAC_POL_PATH + STR_CPP + STR_MAC_POLICY_EXT;
processJailConfig.configureProcessJailControllerPolicies(strObjControllerName, strFileName,
strIoTMasterHostAdd, commHan.getComPort(strObjControllerName));
// Whether or not we need additional Tomoyo policy?