/** * Creates a "key" {@code URI} by dropping the <i>user-info</i>, <i>path</i>, <i>query</i>, and <i>fragment</i> * portions of the {@code URI}. * * @param requestURI the {@code URI} for which the key is to be generated * * @return a {@code URI} instance with the <i>user-info</i>, <i>path</i>, <i>query</i>, and <i>fragment</i> discarded */ private static URI createKey(URI requestURI) { try { URI keyURI = requestURI.parseServerAuthority(); return new URI(keyURI.getScheme(), null, keyURI.getHost(), keyURI.getPort(), null, null, null); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } }
public static URI parseServerAuthority(URI uri) throws URISyntaxException { return uri.parseServerAuthority(); }
public URI parseServerAuthority() throws URISyntaxException { return uri.parseServerAuthority(); }
public URI parseServerAuthority() throws URISyntaxException { return uri.parseServerAuthority(); }
private URI parseURL(String urlString) throws URISyntaxException { if (urlString.trim().length() == 0) { // This makes it possible to not use some of our default services. return null; } else if ("null".equalsIgnoreCase(urlString)) { // This is a workaround that JNLP doesn't take empty string as an // argument. return null; } else { return new URI(urlString).parseServerAuthority(); } }
private boolean filterEndpointUrls(EndpointDescription endpoint, String endpointUrl) { try { String requestedHost = new URI(endpointUrl).parseServerAuthority().getHost(); String endpointHost = new URI(endpoint.getEndpointUrl()).parseServerAuthority().getHost(); return requestedHost.equalsIgnoreCase(endpointHost); } catch (Throwable e) { logger.debug("Unable to create URI.", e); return false; } }
private static EndpointDescription updateEndpointUrl( EndpointDescription original, String hostname) throws URISyntaxException { URI uri = new URI(original.getEndpointUrl()).parseServerAuthority(); String endpointUrl = String.format( "%s://%s:%s%s", uri.getScheme(), hostname, uri.getPort(), uri.getPath() ); return new EndpointDescription( endpointUrl, original.getServer(), original.getServerCertificate(), original.getSecurityMode(), original.getSecurityPolicyUri(), original.getUserIdentityTokens(), original.getTransportProfileUri(), original.getSecurityLevel() ); }
.filter(discoveryUrl -> { try { String requestedHost = new URI(endpointUrl).parseServerAuthority().getHost(); String discoveryHost = new URI(discoveryUrl).parseServerAuthority().getHost(); .filter(discoveryUrl -> { try { String requestedHost = new URI(endpointUrl).parseServerAuthority().getHost(); String discoveryHost = new URI(discoveryUrl).parseServerAuthority().getHost(); InetAddress requestedHostAddress = InetAddress.getByName(requestedHost); InetAddress discoveryHostAddress = InetAddress.getByName(discoveryHost);
uri = uri.parseServerAuthority(); if (uri.getUserInfo() != null) { throw new MalformedURLException(
private ConnectionUri(final String theUriString) { final URI uri; try { uri = new URI(theUriString).parseServerAuthority(); } catch (final URISyntaxException e) { throw ConnectionUriInvalidException.newBuilder(theUriString).build(); } // validate self if (!isValid(uri)) { throw ConnectionUriInvalidException.newBuilder(theUriString).build(); } uriString = uri.toASCIIString(); protocol = uri.getScheme(); hostname = uri.getHost(); port = uri.getPort(); path = uri.getPath(); // initialize nullable fields final String userInfo = uri.getUserInfo(); if (userInfo != null && userInfo.contains(USERNAME_PASSWORD_SEPARATOR)) { final int separatorIndex = userInfo.indexOf(USERNAME_PASSWORD_SEPARATOR); userName = userInfo.substring(0, separatorIndex); password = userInfo.substring(separatorIndex + 1); } else { userName = null; password = null; } // must be initialized after all else uriStringWithMaskedPassword = createUriStringWithMaskedPassword(); }
proxyHostUri.parseServerAuthority(); } catch (final URISyntaxException e) { LOG.error(
private ConnectionUri(final String theUriString) { final URI uri; try { uri = new URI(theUriString).parseServerAuthority(); } catch (final URISyntaxException e) { throw ConnectionUriInvalidException.newBuilder(theUriString).build(); } // validate self if (!isValid(uri)) { throw ConnectionUriInvalidException.newBuilder(theUriString).build(); } uriString = uri.toASCIIString(); protocol = uri.getScheme(); hostname = uri.getHost(); port = uri.getPort(); path = uri.getPath(); // initialize nullable fields final String userInfo = uri.getUserInfo(); if (userInfo != null && userInfo.contains(USERNAME_PASSWORD_SEPARATOR)) { final int separatorIndex = userInfo.indexOf(USERNAME_PASSWORD_SEPARATOR); userName = userInfo.substring(0, separatorIndex); password = userInfo.substring(separatorIndex + 1); } else { userName = null; password = null; } // must be initialized after all else uriStringWithMaskedPassword = createUriStringWithMaskedPassword(); }
URI uri = new URI(client.getEndpointUrl()).parseServerAuthority();
scheme = Scheme.FILE; } else { originalUri = new URI(urlString).parseServerAuthority(); String originalScheme = originalUri.getScheme(); scheme = (originalScheme != null) ? determineScheme(originalScheme)
originalUri = originalUri.parseServerAuthority(); } catch (URISyntaxException e) { LOG.warn("Only server-based authorities are supported for non-opaque URLs");
public Proxy getProxy( RemoteRepository repository ) { List<java.net.Proxy> proxies = null; try { URI uri = new URI( repository.getUrl() ).parseServerAuthority(); proxies = java.net.ProxySelector.getDefault().select( uri ); } catch ( Exception e ) { // URL invalid or not accepted by selector or no selector at all, simply use no proxy } if ( proxies != null ) { for ( java.net.Proxy proxy : proxies ) { if ( java.net.Proxy.Type.DIRECT.equals( proxy.type() ) ) { break; } if ( java.net.Proxy.Type.HTTP.equals( proxy.type() ) && isValid( proxy.address() ) ) { InetSocketAddress addr = (InetSocketAddress) proxy.address(); return new Proxy( Proxy.TYPE_HTTP, addr.getHostName(), addr.getPort(), JreProxyAuthentication.INSTANCE ); } } } return null; }
public Proxy getProxy( RemoteRepository repository ) { List<java.net.Proxy> proxies = null; try { URI uri = new URI( repository.getUrl() ).parseServerAuthority(); proxies = java.net.ProxySelector.getDefault().select( uri ); } catch ( Exception e ) { // URL invalid or not accepted by selector or no selector at all, simply use no proxy } if ( proxies != null ) { for ( java.net.Proxy proxy : proxies ) { if ( java.net.Proxy.Type.DIRECT.equals( proxy.type() ) ) { break; } if ( java.net.Proxy.Type.HTTP.equals( proxy.type() ) && isValid( proxy.address() ) ) { InetSocketAddress addr = (InetSocketAddress) proxy.address(); return new Proxy( Proxy.TYPE_HTTP, addr.getHostName(), addr.getPort(), JreProxyAuthentication.INSTANCE ); } } } return null; }
try baseUri = new URI( repository.getUrl() ).parseServerAuthority(); if ( baseUri.isOpaque() )
brokerURL = new URI(broker).parseServerAuthority(); } catch (URISyntaxException e) { String message = "Broker URL is in a wrong format"; messageBoxURL = new URI(messageBox).parseServerAuthority(); } catch (URISyntaxException e) { String message = "Message box URL is in a wrong format";