private void addIPAddressPermissions( final LinkedList<IPAddressPermission> permissions, final String hostname) throws ServiceException { try { final InetAddress[] localIps = InetAddress.getAllByName(hostname); for (final InetAddress localIp : localIps) { if (localIp instanceof Inet4Address) { permissions.add(new ExactIPAddressPermission(localIp.getAddress())); } else { permissions.add(new ExactIPv6AddressPermission(localIp.getAddress())); } } } catch (UnknownHostException e) { throw new ServiceException("Could not get " + hostname + " inet address", e); } }
public static IPAddressPermission getIPAddressMask(String mask) { if (StartWithIPAddressPermission.canSupport(mask)) { return new StartWithIPAddressPermission(mask); } else if (ExactIPAddressPermission.canSupport(mask)) { return new ExactIPAddressPermission(mask); } else if (FactorizedIPAddressPermission.canSupport(mask)) { return new FactorizedIPAddressPermission(mask); } else if (NetmaskIPAddressPermission.canSupport(mask)) { return new NetmaskIPAddressPermission(mask); } else if (ExactIPv6AddressPermission.canSupport(mask)) { return new ExactIPv6AddressPermission(mask); } else if (NetmaskIPv6AddressPermission.canSupport(mask)) { return new NetmaskIPv6AddressPermission(mask); } throw new IllegalArgumentException("Mask " + mask + " is not supported."); } }
public static IPAddressPermission getIPAddressMask(String mask) { if (StartWithIPAddressPermission.canSupport(mask)) { return new StartWithIPAddressPermission(mask); } else if (ExactIPAddressPermission.canSupport(mask)) { return new ExactIPAddressPermission(mask); } else if (FactorizedIPAddressPermission.canSupport(mask)) { return new FactorizedIPAddressPermission(mask); } else if (NetmaskIPAddressPermission.canSupport(mask)) { return new NetmaskIPAddressPermission(mask); } else if (ExactIPv6AddressPermission.canSupport(mask)) { return new ExactIPv6AddressPermission(mask); } else if (NetmaskIPv6AddressPermission.canSupport(mask)) { return new NetmaskIPv6AddressPermission(mask); } throw new IllegalArgumentException("Mask " + mask + " is not supported."); } }
private void addIPAddressPermissions( LinkedList<IPAddressPermission> permissions, String hostname) throws ServiceException { try { InetAddress[] localIps = InetAddress.getAllByName(hostname); for (int i = 0; i < localIps.length; i++) { if (localIps[i] instanceof Inet4Address) { permissions.add(new ExactIPAddressPermission(localIps[i].getAddress())); } else { permissions.add(new ExactIPv6AddressPermission(localIps[i].getAddress())); } } } catch (UnknownHostException e) { throw new ServiceException("Could not get " + hostname + " inet address", e); } }