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>";
private static final String STR_DEV_IP_ADDRESS = "<dev-ip-address>";
private static final String STR_DEV_COM_PORT = "<dev-com-port>";
private static final String STR_DEV_PORT = "<dev-port>";
+
+ private static final int INT_HTTP_PORT = 80;
+ private static final int INT_DNS_PORT = 53;
/**
}
}
+
+ /**
+ * flush() flushes all PrintWriter objects
+ *
+ * @return void
+ */
+ public void flush() {
+
+ for(PrintWriter pwConfig: mapHostToFile.values()) {
+ pwConfig.flush();
+ }
+ }
+
/**
* close() closes all PrintWriter objects
* @param iPort Integer port
* @return void
*/
- public void configureProcessJailGWDevicePolicies(String strConfigHost, String strRouterAddress, int iPort) {
+ public void configureProcessJailGWDevicePolicies(String strConfigHost, String strRouterAddress, String strDeviceIPAddress, 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 stream connect ::ffff:" + strDeviceIPAddress + " " + String.valueOf(INT_HTTP_PORT)); // HTTP access for this address
pwConfig.println("network inet dgram send " + strRouterAddress + " " + String.valueOf(iPort));
}
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
+ pwConfig.println("network inet dgram send " + strRouterAddress + " " + String.valueOf(INT_DNS_PORT)); // TCP/UDP access through router
+ pwConfig.println("network inet stream connect ::ffff:" + strAddress + " " + String.valueOf(INT_HTTP_PORT)); // HTTP access for this address
}
}
+ /**
+ * 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
*