*/
private static final String STR_SSH_USERNAME_ROUTER = "root";
private static final String STR_SSH_USERNAME_HOST = "iotuser";
- private static final String STR_TCP_PROTOCOL = "tcp";
- private static final String STR_UDP_PROTOCOL = "udp";
- private static final String STR_TCPGW_PROTOCOL = "tcpgw";
- private static final String STR_NO_PROTOCOL = "nopro";
+ private static final String STR_TCP_PROTOCOL = "tcp";
+ private static final String STR_UDP_PROTOCOL = "udp";
+ 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
*/
public void getAddressList(String strRouterAddress) {
- //HashMap<String,String> hmMACToIPAdd = new HashMap<String,String>();
try {
// We can replace "cat /tmp/dhcp.leases" with "cat /proc/net/arp"
String cmd = "ssh " + STR_SSH_USERNAME_ROUTER + "@" + strRouterAddress +
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);
}
+ /**
+ * 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, 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));
+ }
+
+
+ /**
+ * 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);
+ 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(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
+ }
+
+
/**
* configureProcessJailControllerPolicies() method configures the main MAC policies for controller
*
}
+ /**
+ * 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
*