@Test public void testIsPermissibleWithExactMatch() { assertTrue(ipsFirewall.isPermissible("2.2.2.2")); }
@Override public boolean isPermissible(final String hostOrIp) { try { if (subnetInfos.isEmpty()) { return true; } final String ip; try { ip = InetAddress.getByName(hostOrIp).getHostAddress(); } catch (final UnknownHostException uhe) { logger.warn("Blocking unknown host '{}'", hostOrIp, uhe); return false; } for (final SubnetUtils.SubnetInfo subnetInfo : subnetInfos) { if (subnetInfo.isInRange(ip)) { return true; } } logger.debug("Blocking host '{}' because it does not match our allowed list.", hostOrIp); return false; } catch (final IllegalArgumentException iae) { logger.debug("Blocking requested host, '{}', because it is malformed.", hostOrIp, iae); return false; } }
FileBasedClusterNodeFirewall implements ClusterNodeFirewall { @Override public boolean isPermissible(final String hostOrIp) { try { if (subnetInfos.isEmpty()) { return true; } final String ip; try { ip = InetAddress.getByName(hostOrIp).getHostAddress(); } catch (final UnknownHostException uhe) { logger.warn("Blocking unknown host '{}'", hostOrIp, uhe); return false; } for (final SubnetUtils.SubnetInfo subnetInfo : subnetInfos) { if (subnetInfo.isInRange(ip)) { return true; } } logger.debug("Blocking host '{}' because it does not match our allowed list.", hostOrIp); return false; } catch (final IllegalArgumentException iae) { logger.debug("Blocking requested host, '{}', because it is malformed.", hostOrIp, iae); return false; } } }
FileBasedClusterNodeFirewall implements ClusterNodeFirewall { @Override public boolean isPermissible(final String hostOrIp) { try { if (subnetInfos.isEmpty()) { return true; } final String ip; try { ip = InetAddress.getByName(hostOrIp).getHostAddress(); } catch (final UnknownHostException uhe) { logger.warn("Blocking unknown host '{}'", hostOrIp, uhe); return false; } for (final SubnetUtils.SubnetInfo subnetInfo : subnetInfos) { if (subnetInfo.isInRange(ip)) { return true; } } logger.debug("Blocking host '{}' because it does not match our allowed list.", hostOrIp); return false; } catch (final IllegalArgumentException iae) { logger.debug("Blocking requested host, '{}', because it is malformed.", hostOrIp, iae); return false; } } FileBasedClusterNodeFirewall(final File config);  FileBasedClusterNodeFirewall(final File config, final File restoreDirectory); }
FileBasedClusterNodeFirewall implements ClusterNodeFirewall { @Override public boolean isPermissible(final String hostOrIp) { try { if (subnetInfos.isEmpty()) { return true; } final String ip; try { ip = InetAddress.getByName(hostOrIp).getHostAddress(); } catch (final UnknownHostException uhe) { logger.warn("Blocking unknown host '{}'", hostOrIp, uhe); return false; } for (final SubnetUtils.SubnetInfo subnetInfo : subnetInfos) { if (subnetInfo.isInRange(ip)) { return true; } } logger.debug("Blocking host '{}' because it does not match our allowed list.", hostOrIp); return false; } catch (final IllegalArgumentException iae) { logger.debug("Blocking requested host, '{}', because it is malformed.", hostOrIp, iae); return false; } } FileBasedClusterNodeFirewall(final File config);  FileBasedClusterNodeFirewall(final File config, final File restoreDirectory); @Override boolean isPermissible(final String hostOrIp); }
FileBasedClusterNodeFirewall implements ClusterNodeFirewall { @Override public boolean isPermissible(final String hostOrIp) { try { if (subnetInfos.isEmpty()) { return true; } final String ip; try { ip = InetAddress.getByName(hostOrIp).getHostAddress(); } catch (final UnknownHostException uhe) { logger.warn("Blocking unknown host '{}'", hostOrIp, uhe); return false; } for (final SubnetUtils.SubnetInfo subnetInfo : subnetInfos) { if (subnetInfo.isInRange(ip)) { return true; } } logger.debug("Blocking host '{}' because it does not match our allowed list.", hostOrIp); return false; } catch (final IllegalArgumentException iae) { logger.debug("Blocking requested host, '{}', because it is malformed.", hostOrIp, iae); return false; } } FileBasedClusterNodeFirewall(final File config);  FileBasedClusterNodeFirewall(final File config, final File restoreDirectory); @Override boolean isPermissible(final String hostOrIp);  }