private WebClient initWebClient() { if (this.client == null) { final WebClientOptions wco = new WebClientOptions(); final String proxyHost = this.getConsumerConfig().getProxy(); final int proxyPort = this.getConsumerConfig().getProxyPort(); if ((proxyHost != null) && (proxyPort > 0)) { final ProxyOptions po = new ProxyOptions(); wco.setProxyOptions(po); po.setHost(proxyHost).setPort(proxyPort); } // TODO: more options wco.setUserAgent("SFDC VertX REST Provider"); wco.setTryUseCompression(true); this.client = WebClient.create(this.vertx, wco); } return this.client; }
@Override protected void login(final Future<AuthInfo> futureAuthinfo) { final WebClientOptions wco = new WebClientOptions(); final String proxyHost = this.getAuthConfig().getProxy(); final int proxyPort = this.getAuthConfig().getProxyPort(); if ((proxyHost != null) && (proxyPort > 0)) { final ProxyOptions po = new ProxyOptions(); wco.setProxyOptions(po); po.setHost(proxyHost).setPort(proxyPort); } wco.setUserAgent("SDFC VertX Authenticator"); wco.setTryUseCompression(true); final WebClient authClient = WebClient.create(this.vertx, wco); final Buffer body = this.getAuthBody(this.getAuthConfig().getSfdcUser(), this.getAuthConfig().getSfdcPassword()); if (!this.shuttingDown && !this.shutdownCompleted) { authClient.post(Constants.TLS_PORT, this.getAuthConfig().getServerURL(), Constants.AUTH_SOAP_LOGIN) .putHeader("Content-Type", "text/xml").ssl(true).putHeader("SOAPAction", "Login") .putHeader("PrettyPrint", "Yes").sendBuffer(body, postReturn -> { this.resultOfAuthentication(postReturn, futureAuthinfo); }); } else { this.shutdownCompleted = true; futureAuthinfo.fail("Auth disruped by stop command"); } }
@Override public HttpClientOptions createHttpClientOptions() { HttpVersion ver = ServiceRegistryConfig.INSTANCE.getHttpVersion(); HttpClientOptions httpClientOptions = new HttpClientOptions(); httpClientOptions.setProtocolVersion(ver); httpClientOptions.setConnectTimeout(ServiceRegistryConfig.INSTANCE.getConnectionTimeout()); httpClientOptions.setIdleTimeout(ServiceRegistryConfig.INSTANCE.getIdleConnectionTimeout()); if (ServiceRegistryConfig.INSTANCE.isProxyEnable()) { ProxyOptions proxy = new ProxyOptions(); proxy.setHost(ServiceRegistryConfig.INSTANCE.getProxyHost()); proxy.setPort(ServiceRegistryConfig.INSTANCE.getProxyPort()); proxy.setUsername(ServiceRegistryConfig.INSTANCE.getProxyUsername()); proxy.setPassword(ServiceRegistryConfig.INSTANCE.getProxyPasswd()); httpClientOptions.setProxyOptions(proxy); } if (ver == HttpVersion.HTTP_2) { LOGGER.debug("service center client protocol version is HTTP/2"); httpClientOptions.setHttp2ClearTextUpgrade(false); } if (ServiceRegistryConfig.INSTANCE.isSsl()) { LOGGER.debug("service center client performs requests over TLS"); VertxTLSBuilder.buildHttpClientOptions(SSL_KEY, httpClientOptions); } return httpClientOptions; }
private WebClient initWebClient() { if (this.client == null) { final WebClientOptions wco = new WebClientOptions(); final String proxyHost = this.getListenerConfig().getProxy(); final int proxyPort = this.getListenerConfig().getProxyPort(); if ((proxyHost != null) && (proxyPort > 0)) { final ProxyOptions po = new ProxyOptions(); wco.setProxyOptions(po); po.setHost(proxyHost).setPort(proxyPort); } // TODO: more options wco.setUserAgent("SDFC VertX EventBus Client"); wco.setTryUseCompression(true); this.client = WebClient.create(this.vertx, wco); } return this.client; }
@Bean public HttpClientOptions httpClientOptions() { final HttpClientOptions options = new HttpClientOptions() .setPipelining(true); if (httpClientProxyHost != null) { final ProxyOptions proxyOptions = new ProxyOptions() .setHost(httpClientProxyHost) .setPort(httpClientProxyPort) .setType(httpClientProxyType) .setUsername(httpClientProxyUsername) .setPassword(httpClientProxyPassword); options.setProxyOptions(proxyOptions); } return options; }
public void load(Handler<AsyncResult<Void>> resultHandler) { WebClientOptions options = new WebClientOptions(); if (!"none".equalsIgnoreCase(PROXY_HOST)) { options.setProxyOptions(new ProxyOptions() .setType(ProxyType.HTTP) .setHost(PROXY_HOST) .setPort(PROXY_PORT)); } String wellKnownUrl = this.config.getWellKnownUrl(); WebClient.create(this.vertx, options) .getAbs(wellKnownUrl) .ssl(wellKnownUrl.startsWith("https://") ? true : false) .send(ar -> { if (ar.succeeded()) { JsonObject response = Optional.ofNullable(ar.result().bodyAsJsonObject()).orElseGet(JsonObject::new); this.parseAndStoreWellKnownFields(response, resultHandler); } else { LOG.error("Unable to retrieve well known fields from {}", wellKnownUrl, ar.cause()); resultHandler.handle(Future.failedFuture(ar.cause())); } }); }
private WebClientOptions initWebClientOptions(Request request) { WebClientOptions options = new WebClientOptions(); options.setKeepAlive(true).setReuseAddress(true); if (Preconditions.isNotBlank(request.getUserAgent())) { options.setUserAgent(request.getUserAgent()); } if (Preconditions.isNotBlank(request.getUrl())) { try { url = new URL(request.getUrl()); } catch (MalformedURLException e) { e.printStackTrace(); } } if (Preconditions.isNotBlank(request.getProxy())) { ProxyOptions proxyOptions = new ProxyOptions(); proxyOptions.setHost(request.getProxy().getIp()); proxyOptions.setPort(request.getProxy().getPort()); options.setProxyOptions(proxyOptions); } if (Preconditions.isNotBlank(request.getHeader())) { header = request.getHeader(); } return options; }
private static HttpClientOptions withProxyOptions (HttpClientOptions options) { String https_proxy = System.getenv ("https_proxy"); if (StringUtils.isNotEmpty (https_proxy)) { URI proxy = URI.create (https_proxy); options.setProxyOptions (new ProxyOptions ().setHost (proxy.getHost ()).setPort (proxy.getPort ())); } return options; }
@Override public PgConnectOptions setProxyOptions(ProxyOptions proxyOptions) { return (PgConnectOptions)super.setProxyOptions(proxyOptions); }
public ProxyOptions getProxyOptions() { return proxyOptions; }
public TelegramOptions setProxyOptions(ProxyOptions proxyOptions) { this.proxyOptions = proxyOptions; return this; }
@Override protected void doStart() throws Exception { // TODO: Prepare HttpClientOptions according to the endpoint to improve performance when creating a new // instance of the Vertx client httpClientOptions = new HttpClientOptions(); httpClientOptions.setPipelining(endpoint.getHttpClientOptions().isPipelining()); httpClientOptions.setKeepAlive(endpoint.getHttpClientOptions().isKeepAlive()); httpClientOptions.setIdleTimeout((int) (endpoint.getHttpClientOptions().getIdleTimeout() / 1000)); httpClientOptions.setConnectTimeout((int) endpoint.getHttpClientOptions().getConnectTimeout()); httpClientOptions.setUsePooledBuffers(true); httpClientOptions.setMaxPoolSize(endpoint.getHttpClientOptions().getMaxConcurrentConnections()); httpClientOptions.setTryUseCompression(endpoint.getHttpClientOptions().isUseCompression()); // Configure proxy HttpProxy proxy = endpoint.getHttpProxy(); if (proxy != null && proxy.isEnabled()) { ProxyOptions proxyOptions = new ProxyOptions(); proxyOptions.setHost(proxy.getHost()); proxyOptions.setPort(proxy.getPort()); proxyOptions.setUsername(proxy.getUsername()); proxyOptions.setPassword(proxy.getPassword()); proxyOptions.setType(ProxyType.valueOf(proxy.getType().name())); httpClientOptions.setProxyOptions(proxyOptions); } URI target = URI.create(endpoint.getTarget()); // Configure SSL HttpClientSslOptions sslOptions = endpoint.getHttpClientSslOptions(); if (sslOptions != null && sslOptions.isEnabled()) { httpClientOptions .setSsl(sslOptions.isEnabled()) .setVerifyHost(sslOptions.isHostnameVerifier()) .setTrustAll(sslOptions.isTrustAll()); if (sslOptions.getPem() != null && ! sslOptions.getPem().isEmpty()) { httpClientOptions.setPemTrustOptions( new PemTrustOptions().addCertValue( io.vertx.core.buffer.Buffer.buffer(sslOptions.getPem()))); } } else if(HTTPS_SCHEME.equalsIgnoreCase(target.getScheme())) { // SSL is not configured but the endpoint scheme is HTTPS so let's enable the SSL on Vert.x HTTP client // automatically httpClientOptions.setSsl(true).setTrustAll(true); } printHttpClientConfiguration(httpClientOptions); }
@Override public AmqpBridgeOptions setProxyOptions(ProxyOptions proxyOptions) { super.setProxyOptions(proxyOptions); return this; }
@Override public ProtonClientOptions setProxyOptions(ProxyOptions proxyOptions) { super.setProxyOptions(proxyOptions); return this; }
@Override public WebClientOptions setProxyOptions(ProxyOptions proxyOptions) { return (WebClientOptions) super.setProxyOptions(proxyOptions); }