org.apache.http.impl.conn.DefaultSchemePortResolver Java Examples
The following examples show how to use
org.apache.http.impl.conn.DefaultSchemePortResolver.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApacheHttpClient.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
public HttpClientConnectionManager create(ApacheHttpClient.DefaultBuilder configuration, AttributeMap standardOptions) { ConnectionSocketFactory sslsf = getPreferredSocketFactory(configuration, standardOptions); PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager( createSocketFactoryRegistry(sslsf), null, DefaultSchemePortResolver.INSTANCE, null, standardOptions.get(SdkHttpConfigurationOption.CONNECTION_TIME_TO_LIVE).toMillis(), TimeUnit.MILLISECONDS); cm.setDefaultMaxPerRoute(standardOptions.get(SdkHttpConfigurationOption.MAX_CONNECTIONS)); cm.setMaxTotal(standardOptions.get(SdkHttpConfigurationOption.MAX_CONNECTIONS)); cm.setDefaultSocketConfig(buildSocketConfig(standardOptions)); return cm; }
Example #2
Source File: ApacheConnectionManagerFactory.java From ibm-cos-sdk-java with Apache License 2.0 | 6 votes |
@Override public HttpClientConnectionManager create(final HttpClientSettings settings) { ConnectionSocketFactory sslsf = getPreferredSocketFactory(settings); final PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager( createSocketFactoryRegistry(sslsf), null, DefaultSchemePortResolver.INSTANCE, new DelegatingDnsResolver(settings.getDnsResolver()), settings.getConnectionPoolTTL(), TimeUnit.MILLISECONDS); cm.setValidateAfterInactivity(settings.getValidateAfterInactivityMillis()); cm.setDefaultMaxPerRoute(settings.getMaxConnections()); cm.setMaxTotal(settings.getMaxConnections()); cm.setDefaultSocketConfig(buildSocketConfig(settings)); cm.setDefaultConnectionConfig(buildConnectionConfig(settings)); return cm; }
Example #3
Source File: UDTProxyConfigurator.java From cyberduck with GNU General Public License v3.0 | 5 votes |
@Override public HttpClientBuilder build(final Proxy proxy, final TranscriptListener listener, final LoginCallback prompt) { final HttpClientBuilder builder = super.build(proxy, listener, prompt); // Add filter to inject custom headers to authenticate with proxy builder.setRequestExecutor( new CustomHeaderHttpRequestExecutor(headers) ); // Set proxy router planer builder.setRoutePlanner(new DefaultProxyRoutePlanner( new HttpHost(this.proxy.getHostname(), this.proxy.getPort(), this.proxy.getProtocol().getScheme().name()), new DefaultSchemePortResolver())); return builder; }
Example #4
Source File: VaultConfig.java From cloudbreak with Apache License 2.0 | 5 votes |
private ClientHttpRequestFactory usingHttpComponents(ClientOptions options, SslConfiguration sslConfiguration) throws GeneralSecurityException, IOException { HttpClientBuilder httpClientBuilder = HttpClients.custom(); httpClientBuilder.setRoutePlanner(new SystemDefaultRoutePlanner( DefaultSchemePortResolver.INSTANCE, ProxySelector.getDefault())); if (isNoneEmpty(httpsProxyUser, httpsProxyPassword)) { UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(httpsProxyUser, httpsProxyPassword); CredentialsProvider provider = new BasicCredentialsProvider(); provider.setCredentials(AuthScope.ANY, credentials); httpClientBuilder.setDefaultCredentialsProvider(provider); } if (hasSslConfiguration(sslConfiguration)) { SSLContext sslContext = getSSLContext(sslConfiguration, getTrustManagers(sslConfiguration)); SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory( sslContext); httpClientBuilder.setSSLSocketFactory(sslSocketFactory); httpClientBuilder.setSSLContext(sslContext); } RequestConfig requestConfig = RequestConfig .custom() .setConnectTimeout(Math.toIntExact(options.getConnectionTimeout().toMillis())) .setSocketTimeout(Math.toIntExact(options.getReadTimeout().toMillis())) .setAuthenticationEnabled(true) .build(); httpClientBuilder.setDefaultRequestConfig(requestConfig); httpClientBuilder.setRedirectStrategy(new LaxRedirectStrategy()); return new HttpComponentsClientHttpRequestFactory(httpClientBuilder.build()); }
Example #5
Source File: SSLTruststoreUtil.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public static HttpClient getHttpClientWithSSL(File keyStoreFile, String keyStorePassword, String keyStoreProvider, File trustStoreFile, String trustStorePassword, String trustStoreProvider) { try { KeyStore trustStore = KeyStore.getInstance(trustStoreProvider); try (FileInputStream fis = new FileInputStream(trustStoreFile)) { trustStore.load(fis, trustStorePassword.toCharArray()); } SSLContextBuilder sslContextBuilder = SSLContexts.custom() .setProtocol("TLS") .loadTrustMaterial(trustStore, null); if (keyStoreFile != null) { KeyStore keyStore = KeyStore.getInstance(keyStoreProvider); try (FileInputStream fis = new FileInputStream(keyStoreFile)) { keyStore.load(fis, keyStorePassword.toCharArray()); } sslContextBuilder.loadKeyMaterial(keyStore, keyStorePassword.toCharArray(), null); } SSLContext sslContext = sslContextBuilder.build(); SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE); Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create() .register("http", PlainConnectionSocketFactory.getSocketFactory()) .register("https", socketFactory) .build(); return HttpClientBuilder.create() .setSSLSocketFactory(socketFactory) //.setHostnameVerifier(SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER) .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE) .setConnectionManager(new PoolingHttpClientConnectionManager(registry)) .setSchemePortResolver(new DefaultSchemePortResolver()) .build(); } catch (Exception e) { LOGGER.error("Creating HttpClient with customized SSL failed. We are returning the default one instead.", e); return HttpClients.createDefault(); } }
Example #6
Source File: NexusHttpRoutePlanner.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
/** * @since 2.5 */ public NexusHttpRoutePlanner(final Map<String, HttpHost> proxies, @Nullable final Pattern nonProxyHostsPattern) { super(DefaultSchemePortResolver.INSTANCE); this.proxies = checkNotNull(proxies); this.nonProxyHostPattern = nonProxyHostsPattern; }
Example #7
Source File: VespaHttpClientBuilder.java From vespa with Apache License 2.0 | 5 votes |
private HttpHost resolveTarget(HttpHost host) throws HttpException { try { String originalScheme = host.getSchemeName(); String scheme = originalScheme.equalsIgnoreCase("http") ? "https" : originalScheme; int port = DefaultSchemePortResolver.INSTANCE.resolve(host); return new HttpHost(host.getHostName(), port, scheme); } catch (UnsupportedSchemeException e) { throw new HttpException(e.getMessage(), e); } }
Example #8
Source File: TestWithProxiedEmbeddedServer.java From Bastion with GNU General Public License v3.0 | 5 votes |
private static BasicHttpClientConnectionManager prepareConnectionManager(DnsResolver dnsResolver, DefaultSchemePortResolver schemePortResolver) { return new BasicHttpClientConnectionManager( RegistryBuilder.<ConnectionSocketFactory>create() .register("http", PlainConnectionSocketFactory.getSocketFactory()) .register("https", SSLConnectionSocketFactory.getSocketFactory()) .build(), null, schemePortResolver, dnsResolver ); }
Example #9
Source File: TestWithProxiedEmbeddedServer.java From Bastion with GNU General Public License v3.0 | 5 votes |
private static DefaultSchemePortResolver prepareSchemePortResolver() { return new DefaultSchemePortResolver() { @Override public int resolve(HttpHost host) throws UnsupportedSchemeException { if (host.getHostName().equalsIgnoreCase("sushi-shop.test")) { return 9876; } else { return super.resolve(host); } } }; }
Example #10
Source File: TestWithProxiedEmbeddedServer.java From Bastion with GNU General Public License v3.0 | 5 votes |
@BeforeClass public static void setupProxying() { DnsResolver dnsResolver = prepareProxiedDnsResolver(); DefaultSchemePortResolver schemePortResolver = prepareSchemePortResolver(); BasicHttpClientConnectionManager connManager = prepareConnectionManager(dnsResolver, schemePortResolver); HttpClient httpClient = prepareHttpClient(connManager); originalHttpClient = (HttpClient) Options.getOption(Option.HTTPCLIENT); Unirest.setHttpClient(httpClient); }
Example #11
Source File: AbstractRoutePlanner.java From lavaplayer with Apache License 2.0 | 5 votes |
protected AbstractRoutePlanner(final List<IpBlock> ipBlocks, final boolean handleSearchFailure) { this.ipBlock = new CombinedIpBlock(ipBlocks); this.failingAddresses = new HashMap<>(); this.schemePortResolver = DefaultSchemePortResolver.INSTANCE; this.handleSearchFailure = handleSearchFailure; log.info("Active RoutePlanner: {} using total of {} ips", getClass().getCanonicalName(), this.ipBlock.getSize()); }
Example #12
Source File: ExtendedConnectionOperator.java From lavaplayer with Apache License 2.0 | 5 votes |
public ExtendedConnectionOperator( Lookup<ConnectionSocketFactory> socketFactoryRegistry, SchemePortResolver schemePortResolver, DnsResolver dnsResolver ) { this.socketFactoryRegistry = socketFactoryRegistry; this.schemePortResolver = schemePortResolver != null ? schemePortResolver : DefaultSchemePortResolver.INSTANCE; this.dnsResolver = dnsResolver != null ? dnsResolver : SystemDefaultDnsResolver.INSTANCE; }
Example #13
Source File: ClientHttpRequestFactoryFactory.java From spring-vault with Apache License 2.0 | 5 votes |
static ClientHttpRequestFactory usingHttpComponents(ClientOptions options, SslConfiguration sslConfiguration) throws GeneralSecurityException, IOException { HttpClientBuilder httpClientBuilder = HttpClients.custom(); httpClientBuilder.setRoutePlanner( new SystemDefaultRoutePlanner(DefaultSchemePortResolver.INSTANCE, ProxySelector.getDefault())); if (hasSslConfiguration(sslConfiguration)) { SSLContext sslContext = getSSLContext(sslConfiguration, getTrustManagers(sslConfiguration)); SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(sslContext); httpClientBuilder.setSSLSocketFactory(sslSocketFactory); httpClientBuilder.setSSLContext(sslContext); } RequestConfig requestConfig = RequestConfig.custom() // .setConnectTimeout(Math.toIntExact(options.getConnectionTimeout().toMillis())) // .setSocketTimeout(Math.toIntExact(options.getReadTimeout().toMillis())) // .setAuthenticationEnabled(true) // .build(); httpClientBuilder.setDefaultRequestConfig(requestConfig); // Support redirects httpClientBuilder.setRedirectStrategy(new LaxRedirectStrategy()); return new HttpComponentsClientHttpRequestFactory(httpClientBuilder.build()); }
Example #14
Source File: SdkProxyRoutePlanner.java From ibm-cos-sdk-java with Apache License 2.0 | 4 votes |
public SdkProxyRoutePlanner(String proxyHost, int proxyPort, String nonProxyHosts) { super(DefaultSchemePortResolver.INSTANCE); proxy = new HttpHost(proxyHost, proxyPort); parseNonProxyHosts(nonProxyHosts); }
Example #15
Source File: SdkProxyRoutePlanner.java From aws-sdk-java-v2 with Apache License 2.0 | 4 votes |
public SdkProxyRoutePlanner(String proxyHost, int proxyPort, String proxyProtocol, Set<String> nonProxyHosts) { super(DefaultSchemePortResolver.INSTANCE); proxy = new HttpHost(proxyHost, proxyPort, proxyProtocol); this.hostPatterns = nonProxyHosts; }
Example #16
Source File: Substitute_RestClient.java From quarkus with Apache License 2.0 | 4 votes |
public NoSerializationBasicAuthCache(final SchemePortResolver schemePortResolver) { this.map = new ConcurrentHashMap<>(); this.schemePortResolver = schemePortResolver != null ? schemePortResolver : DefaultSchemePortResolver.INSTANCE; }
Example #17
Source File: HttpClientConfigurator.java From bintray-client-java with Apache License 2.0 | 4 votes |
public DefaultHostRoutePlanner(String defaultHost) { super(DefaultSchemePortResolver.INSTANCE); this.defaultHost = new HttpHost(defaultHost); }
Example #18
Source File: ProxyMappingsAwareRoutePlanner.java From keycloak with Apache License 2.0 | 4 votes |
public ProxyMappingsAwareRoutePlanner(ProxyMappings proxyMappings) { super(DefaultSchemePortResolver.INSTANCE); this.proxyMappings = proxyMappings; }