out.write("\t<rule access=\"deny\" network=\"127.0.0.1\"/>");
out.write("</firewall>\n");
out.close();
// Load config
ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(mainFile);
ApplicationRegistry.initialise(reg);
// Test config
assertFalse(reg.getSecurityManager().accessVirtualhost("test", new InetSocketAddress("127.0.0.1", 65535)));
RandomAccessFile fileBRandom = new RandomAccessFile(fileB, "rw");
fileBRandom.setLength(0);
fileBRandom.seek(0);
fileBRandom.close();
out = new FileWriter(fileB);
out.write("<firewall>\n");
out.write("\t<rule access=\"allow\" network=\"127.0.0.1\"/>");
out.write("</firewall>\n");
out.close();
reg.getConfiguration().reparseConfigFileSecuritySections();
assertTrue(reg.getSecurityManager().accessVirtualhost("test", new InetSocketAddress("127.0.0.1", 65535)));
fileBRandom = new RandomAccessFile(fileB, "rw");
fileBRandom.setLength(0);
fileBRandom.seek(0);
fileBRandom.close();
out = new FileWriter(fileB);
out.write("<firewall>\n");
out.write("\t<rule access=\"deny\" network=\"127.0.0.1\"/>");
out.write("</firewall>\n");
out.close();
reg.getConfiguration().reparseConfigFileSecuritySections();
assertFalse(reg.getSecurityManager().accessVirtualhost("test", new InetSocketAddress("127.0.0.1", 65535)));
}