List of usage examples for java.net URI getHost
public String getHost()
From source file:org.jnode.jersey.JNContainer.java
private String getServerAddress(final URI baseUri) throws URISyntaxException { return new URI(baseUri.getScheme(), null, baseUri.getHost(), baseUri.getPort(), null, null, null) .toString();// w w w . jav a2 s .c om }
From source file:com.smartitengineering.util.rest.client.HttpClient.java
public URI getAbsoluteUri(URI targetUri, URI currentUri) { if (targetUri == null) { return null; }/* www. ja v a2 s. co m*/ if (StringUtils.isNotBlank(targetUri.getHost())) { return targetUri; } else if (targetUri.getPath().startsWith("/")) { UriBuilder builder = UriBuilder.fromUri(targetUri); builder.host(host).port(port).scheme("http"); return builder.build(); } else { final UriBuilder builder; if (currentUri != null) { builder = UriBuilder.fromUri(currentUri); builder.path(targetUri.getPath()); } else { builder = UriBuilder.fromUri(targetUri); } builder.host(host).port(port).scheme("http"); return builder.build(); } }
From source file:com.hp.autonomy.hod.client.api.authentication.AuthenticationServiceImplTest.java
private void checkCombinedUrl(final SignedRequest request, final List<NameValuePair> expectedParameters) throws URISyntaxException { final URI uri = new URI(request.getUrl()); assertThat(uri.getScheme() + "://" + uri.getHost(), is(ENDPOINT)); assertThat(uri.getPath(), is(COMBINED_PATH)); final List<NameValuePair> pairs = URLEncodedUtils.parse(uri, "UTF-8"); assertThat(pairs, containsInAnyOrder(expectedParameters.toArray())); }
From source file:com.jaeksoft.searchlib.crawler.web.spider.ProxyHandler.java
public void check(RequestConfig.Builder configBuilder, URI uri, CredentialsProvider credentialsProvider) { if (proxy == null || uri == null) return;/*from www . j a v a 2s . c o m*/ if (exclusionSet.contains(uri.getHost())) return; configBuilder.setProxy(proxy); if (!StringUtils.isEmpty(username)) credentialsProvider.setCredentials(new AuthScope(proxy), new UsernamePasswordCredentials(username, password)); }
From source file:io.wcm.caravan.commons.httpclient.impl.HttpClientFactoryImpl.java
private HttpClientItem getFactoryItem(URI targetUrl, String wsAddressingToUri) { for (HttpClientItem item : factoryItems.values()) { if (item.matches(targetUrl.getHost(), wsAddressingToUri)) { return item; }/* www .j ava 2 s .c o m*/ } return defaultFactoryItem; }
From source file:f1db.configuration.ProductionProfile.java
@Bean public BasicDataSource dataSource() throws URISyntaxException { URI dbUri = new URI(System.getenv("DATABASE_URL")); String username = dbUri.getUserInfo().split(":")[0]; String password = dbUri.getUserInfo().split(":")[1]; String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + ':' + dbUri.getPort() + dbUri.getPath(); BasicDataSource basicDataSource = new BasicDataSource(); basicDataSource.setUrl(dbUrl);/*from w ww .j a v a 2s . c om*/ basicDataSource.setUsername(username); basicDataSource.setPassword(password); return basicDataSource; }
From source file:main.java.miro.validator.fetcher.RsyncFetcher.java
public boolean addPrefetchURI(URI pfUri) { if (pointsToFile(pfUri)) return false; List<URI> toBeRemoved = new ArrayList<URI>(); boolean alreadyContained = false; for (URI uri : prefetchURIs) { if (uri.getHost().equals(pfUri.getHost())) { if (pfUri.getPath().startsWith(uri.getPath())) alreadyContained = true; if (uri.getPath().startsWith(pfUri.getPath())) toBeRemoved.add(uri);//from w ww . j a va 2 s.c o m } } if (!alreadyContained) { prefetchURIs.add(pfUri); prefetchURIs.removeAll(toBeRemoved); } return !alreadyContained; }
From source file:com._4dconcept.springframework.data.marklogic.config.AbstractMarklogicConfiguration.java
@Bean public MarklogicFactoryBean marklogicContentSource() { URI marklogicUri = getMarklogicUri(); LOGGER.info("Init marklogic connexion at {}:{}", marklogicUri.getHost(), marklogicUri.getPort()); MarklogicFactoryBean marklogicFactoryBean = new MarklogicFactoryBean(); marklogicFactoryBean.setUri(marklogicUri); return marklogicFactoryBean; }
From source file:org.springframework.cloud.dataflow.rest.util.HttpClientConfigurer.java
protected HttpClientConfigurer(URI targetHost) { httpClientBuilder = HttpClientBuilder.create(); this.targetHost = new HttpHost(targetHost.getHost(), targetHost.getPort(), targetHost.getScheme()); }
From source file:org.mycontroller.standalone.restclient.RestFactory.java
public T createAPI(URI uri, String userName, String password) { CloseableHttpClient httpclient = HttpClientBuilder.create().build(); HttpHost targetHost = new HttpHost(uri.getHost(), uri.getPort()); CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort()), new UsernamePasswordCredentials(userName, password)); // Create AuthCache instance AuthCache authCache = new BasicAuthCache(); // Generate BASIC scheme object and add it to the local auth cache BasicScheme basicAuth = new BasicScheme(); authCache.put(targetHost, basicAuth); // Add AuthCache to the execution context HttpClientContext context = HttpClientContext.create(); context.setCredentialsProvider(credsProvider); context.setAuthCache(authCache);/*from w w w . j ava 2 s. c o m*/ ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpclient, context); ResteasyClient client = new ResteasyClientBuilder().httpEngine(engine).build(); client.register(JacksonJaxbJsonProvider.class); client.register(RequestLogger.class); client.register(ResponseLogger.class); ProxyBuilder<T> proxyBuilder = client.target(uri).proxyBuilder(proxyClazz); return proxyBuilder.build(); }