/** * Throw error on specific circumstances: * - no addresses available for binding * - when PreferedIPv4 flag is true and the host IP is IPV6 * @param location * @param tcpAddresses */ private void throwPreferedIPv4StackIPv6AddressError(String location, List<UdpResourceAddress> tcpAddresses) { try { InetAddress address = InetAddress.getByName(URIUtils.getHost(location)); boolean preferIPv4Stack = Boolean.parseBoolean(System.getProperty(JAVA_NET_PREFER_IPV4_STACK)); if (preferIPv4Stack && (address instanceof Inet6Address)) { throw new IllegalArgumentException(format(PREFER_IPV4_STACK_IPV6_ADDRESS_EXCEPTION_FORMATTER, location)); } } catch (UnknownHostException e) { // InetAddress.getByName(hostAddress) throws an exception (hostAddress may have an // unsupported format, e.g. network interface syntax) } }
/** * Throw error on specific circumstances: * - no addresses available for binding * - when PreferedIPv4 flag is true and the host IP is IPV6 * @param location * @param tcpAddresses */ private void throwPreferedIPv4StackIPv6AddressError(String location, List<TcpResourceAddress> tcpAddresses) { try { InetAddress address = InetAddress.getByName(URIUtils.getHost(location)); boolean preferIPv4Stack = Boolean.parseBoolean(System.getProperty(JAVA_NET_PREFER_IPV4_STACK)); if (preferIPv4Stack && (address instanceof Inet6Address)) { throw new IllegalArgumentException(format(PREFER_IPV4_STACK_IPV6_ADDRESS_EXCEPTION_FORMATTER, location)); } } catch (UnknownHostException e) { // InetAddress.getByName(hostAddress) throws an exception (hostAddress may have an // unsupported format, e.g. network interface syntax) } }
@Override protected HttpResourceAddress newResourceAddress0(String original, String location) { String host = URIUtils.getHost(location); int port = URIUtils.getPort(location); String path = URIUtils.getPath(location); if (host == null) { throw new IllegalArgumentException(format("Missing host in URI: %s", location)); } if (port == -1) { throw new IllegalArgumentException(format("Missing port in URI: %s", location)); } if (path == null || path.length() == 0) { throw new IllegalArgumentException(format("Missing path in URI: %s", location)); } URI uriLocation = URI.create(location); return new HttpResourceAddress(this, original, uriLocation); }
String canonicalURI = uri; if (uri != null) { String host = getHost(uri); String path = getPath(uri); final boolean emptyPath = "".equals(path);
List<TcpResourceAddress> tcpAddresses = new LinkedList<>(); try { String host = getHost(location); Matcher matcher = PATTERN_IPV6_HOST.matcher(host); if (matcher.matches()) { String host = getHost(location); Pattern pattern = Pattern.compile(URIUtils.NETWORK_INTERFACE_AUTHORITY); Matcher matcher = pattern.matcher(host);
List<UdpResourceAddress> udpAddresses = new LinkedList<>(); try { String host = getHost(location); Matcher matcher = PATTERN_IPV6_HOST.matcher(host); if (matcher.matches()) { String host = getHost(location); Pattern pattern = Pattern.compile(URIUtils.NETWORK_INTERFACE_AUTHORITY); Matcher matcher = pattern.matcher(host);
throw new IllegalArgumentException("Invalid port number specified for " + processing + ": " + member); String host = getHost(uri); if (scheme.equals("aws")) {
private String resolveURI(String uri) throws URISyntaxException { String schemeName = getScheme(uri); SchemeConfig schemeConfig = supplySchemeConfig(schemeName); int defaultPort = schemeConfig.getDefaultPort(); if (getPort(uri) == -1) { if (defaultPort == -1) { LOGGER.error("Missing port number in URI \"" + uri + "\". You must include an explicit port number in this URI in your gateway configuration file."); throw new IllegalArgumentException("Missing port for URI \"" + uri + "\""); } if (defaultPort != 0) { String host = getHost(uri); String path = getPath(uri); String query = getQuery(uri); String fragment = getFragment(uri); uri = buildURIAsString(schemeName, null, host, defaultPort, path, query, fragment); } } else { if (defaultPort == 0) { LOGGER.error("Port number not allowed in URI \"" + uri + "\". You must remove the port number from this URI in your gateway configuration file."); throw new IllegalArgumentException("Port not allowed in URI \"" + uri + "\""); } } return uri; }
String host = getHost(uri); if (!host.equalsIgnoreCase("security-group")) { throw new IllegalStateException("Invalid host '" + host +
String host = URIUtils.getHost(externalURI); String port = format("%d", URIUtils.getPort(externalURI)); connectSession.addWriteHeader(HEADER_X_FORWARDED_HOST, format("%s:%s", host, port));
@Override public void bind(final ResourceAddress address, IoHandler handler, BridgeSessionInitializer<? extends IoFuture> initializer) throws NioBindException { boolean useMCP = false; try { String uri = address.getExternalURI(); InetAddress inet = InetAddress.getByName(URIUtils.getHost(uri)); if (inet.isMulticastAddress()) { useMCP = true; } } catch (Exception e) { // do nothing } if (useMCP) { MulticastAcceptor acceptor = new MulticastAcceptor(); acceptor.setConfiguration(new Properties()); acceptor.setResourceAddressFactory(resourceAddressFactory); acceptor.setBridgeServiceFactory(bridgeServiceFactory); acceptor.bind(address, handler, initializer); } else { super.bind(address, handler, initializer); } }
@Override public ConnectFuture connect(ResourceAddress address, IoHandler handler, IoSessionInitializer<? extends ConnectFuture> initializer) { boolean useMCP = false; try { String uri = address.getExternalURI(); InetAddress inet = InetAddress.getByName(URIUtils.getHost(uri)); if (inet.isMulticastAddress()) { useMCP = true; } } catch (Exception e) { // do nothing } if (useMCP) { MulticastConnector connector = new MulticastConnector(); connector.setConfiguration(getProperties()); connector.setResourceAddressFactory(resourceAddressFactory); connector.setBridgeServiceFactory(bridgeServiceFactory); return connector.connect(address, handler, initializer); } else { return super.connect(address, handler, initializer); } }
String host = getHost(acceptURI); if (host == null || host.isEmpty()) { throw new IllegalArgumentException("Host is required for service \"" + acceptURI + "\".");
URIUtils.getHost(remoteExternalHttp11), URIUtils.getPort(remoteExternalHttp11), createResolvePath(localExternalHttp11, downstreamSuffix + sessionIdSuffix), URIUtils.getHost(remoteExternalHttp11), URIUtils.getPort(remoteExternalHttp11), createResolvePath(localExternalHttp11, upstreamSuffix + sessionIdSuffix),