private void ensureNotLoopbackAddresses(Props props, String propertyKey) { stream(requireValue(props, propertyKey).split(",")) .filter(StringUtils::isNotBlank) .map(StringUtils::trim) .map(s -> StringUtils.substringBefore(s, ":")) .forEach(ip -> { try { if (network.isLoopbackInetAddress(network.toInetAddress(ip))) { throw new MessageException(format("Property %s must not be a loopback address: %s", propertyKey, ip)); } } catch (UnknownHostException e) { throw new MessageException(format("Property %s must not a valid address: %s [%s]", propertyKey, ip, e.getMessage())); } }); }
private void ensureLocalButNotLoopbackAddress(Props props, String propertyKey) { String propertyValue = props.nonNullValue(propertyKey).trim(); try { InetAddress address = network.toInetAddress(propertyValue); if (!network.isLocalInetAddress(address) || network.isLoopbackInetAddress(address)) { throw new MessageException(format("Property %s must be a local non-loopback address: %s", propertyKey, propertyValue)); } } catch (UnknownHostException | SocketException e) { throw new MessageException(format("Property %s must be a local non-loopback address: %s [%s]", propertyKey, propertyValue, e.getMessage())); } }
private void ensureNotLoopbackAddresses(Props props, String propertyKey) { stream(requireValue(props, propertyKey).split(",")) .filter(StringUtils::isNotBlank) .map(StringUtils::trim) .map(s -> StringUtils.substringBefore(s, ":")) .forEach(ip -> { try { if (network.isLoopbackInetAddress(network.toInetAddress(ip))) { throw new MessageException(format("Property %s must not be a loopback address: %s", propertyKey, ip)); } } catch (UnknownHostException e) { throw new MessageException(format("Property %s must not a valid address: %s [%s]", propertyKey, ip, e.getMessage())); } }); }
private void ensureLocalButNotLoopbackAddress(Props props, String propertyKey) { String propertyValue = props.nonNullValue(propertyKey).trim(); try { InetAddress address = network.toInetAddress(propertyValue); if (!network.isLocalInetAddress(address) || network.isLoopbackInetAddress(address)) { throw new MessageException(format("Property %s must be a local non-loopback address: %s", propertyKey, propertyValue)); } } catch (UnknownHostException | SocketException e) { throw new MessageException(format("Property %s must be a local non-loopback address: %s [%s]", propertyKey, propertyValue, e.getMessage())); } }