List of usage examples for java.net URI getPort
public int getPort()
From source file:com.garethahealy.resteastpathparamescape.utils.RestFactory.java
protected HttpClientContext getBasicAuthContext(URI uri, String userName, String password) { 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 // Generate BASIC scheme object and add it to the local auth cache AuthCache authCache = new BasicAuthCache(); authCache.put(targetHost, new BasicScheme()); // Add AuthCache to the execution context HttpClientContext context = HttpClientContext.create(); context.setCredentialsProvider(credsProvider); context.setAuthCache(authCache);/* w ww . j av a 2 s .com*/ return context; }
From source file:org.apache.olingo.client.core.http.BasicAuthHttpClientFactory.java
@Override public DefaultHttpClient create(final HttpMethod method, final URI uri) { final DefaultHttpClient httpclient = super.create(method, uri); httpclient.getCredentialsProvider().setCredentials(new AuthScope(uri.getHost(), uri.getPort()), new UsernamePasswordCredentials(username, password)); return httpclient; }
From source file:com.collective.celos.ci.deploy.JScpWorker.java
URI getURIRespectingUsername(URI uri) throws URISyntaxException { if (userName != null && uri.getUserInfo() == null) { uri = new URI(uri.getScheme(), userName, uri.getHost(), uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment());/*from www. j a v a 2 s. com*/ } return uri; }
From source file:com.subgraph.vega.impl.scanner.urls.UriParser.java
public IPathState processUri(URI uri) { final HttpHost host = new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme()); final IWebHost webHost = getWebHost(host); IWebPath path = webHost.getRootPath(); final boolean hasTrailingSlash = uri.getPath().endsWith("/"); String[] parts = uri.getPath().split("/"); IWebPath childPath;// w w w . j a v a 2 s. co m for (int i = 1; i < parts.length; i++) { synchronized (path) { childPath = path.getChildPath(parts[i]); if (childPath == null) { childPath = path.addChildPath(parts[i]); } processPath(childPath, uri, (i == (parts.length - 1)), hasTrailingSlash); } path = childPath; } return pathStateManager.getStateForPath(path); }
From source file:com.gopivotal.cla.repository.RepositoryConfiguration.java
@Bean DataSource dataSource() {/*from w w w . j ava 2 s . c o m*/ URI dbUri = URI.create(this.databaseUrl); String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + ':' + dbUri.getPort() + dbUri.getPath(); BoneCPDataSource dataSource = new BoneCPDataSource(); dataSource.setDriverClass(Driver.class.getCanonicalName()); dataSource.setJdbcUrl(dbUrl); String[] userInfoTokens = dbUri.getUserInfo().split(":"); dataSource.setUsername(userInfoTokens.length > 0 ? userInfoTokens[0] : ""); dataSource.setPassword(userInfoTokens.length > 1 ? userInfoTokens[1] : ""); dataSource.setMaxConnectionsPerPartition(2); Flyway flyway = new Flyway(); flyway.setDataSource(dataSource); flyway.setLocations("META-INF/db/migration"); flyway.migrate(); return dataSource; }
From source file:io.galeb.health.services.HealthCheckerService.java
private String buildHcHostFromTarget(Target target) { String hcHost;// www .j a v a2 s .c o m URI targetURI = URI.create(target.getName()); hcHost = targetURI.getHost() + ":" + targetURI.getPort(); return hcHost; }
From source file:org.jclouds.http.apachehc.ApacheHCHttpCommandExecutorService.java
private org.apache.http.HttpResponse executeRequest(HttpUriRequest nativeRequest) throws IOException, ClientProtocolException { URI endpoint = URI.create(nativeRequest.getRequestLine().getUri()); HttpHost host = new HttpHost(endpoint.getHost(), endpoint.getPort(), endpoint.getScheme()); org.apache.http.HttpResponse nativeResponse = client.execute(host, nativeRequest); return nativeResponse; }
From source file:com.abiquo.model.enumerator.RemoteServiceType.java
public String fixUri(final URI uri) { String protocol = uri.getScheme(); String domainName = uri.getHost(); Integer port = uri.getPort(); String path = uri.getPath();//from www .ja v a 2s . c o m String domainHost = domainName + (port != null ? ":" + port : ""); String fullURL = StringUtils.join(new String[] { fixProtocol(protocol), domainHost }); if (!StringUtils.isEmpty(path)) { fullURL = UriHelper.appendPathToBaseUri(fullURL, path); } return fullURL; }
From source file:io.soabase.client.apache.WrappedHttpClient.java
private HttpHost toHost(URI uri) { return new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme()); }
From source file:com.msopentech.odatajclient.engine.client.http.AbstractBasicAuthHttpClientFactory.java
@Override public HttpClient createHttpClient(final HttpMethod method, final URI uri) { final DefaultHttpClient httpclient = (DefaultHttpClient) super.createHttpClient(method, uri); httpclient.getCredentialsProvider().setCredentials(new AuthScope(uri.getHost(), uri.getPort()), new UsernamePasswordCredentials(getUsername(), getPassword())); return httpclient; }