Java 类io.vertx.core.net.ProxyOptions 实例源码

项目:vertx-sfdc-platformevents    文件:RestConsumer.java   
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;
}
项目:vertx-sfdc-platformevents    文件:SoapApi.java   
@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");
    }
}
项目:incubator-servicecomb-java-chassis    文件:HttpClientPool.java   
@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;
}
项目:vertx-sfdc-platformevents    文件:CometD.java   
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;
}
项目:app-ms    文件:VertxConfig.java   
@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;
}
项目:DAVe    文件:JWKSAuthProviderImpl.java   
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()));
                }
            });
}
项目:NetDiscovery    文件:VertxDownloader.java   
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;
    }
项目:lumber-mill    文件:SimpleGraphiteClient.java   
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;
}
项目:reactive-pg-client    文件:PgConnectOptions.java   
@Override
public PgConnectOptions setProxyOptions(ProxyOptions proxyOptions) {
  return (PgConnectOptions)super.setProxyOptions(proxyOptions);
}
项目:vertx-telegram-bot-api    文件:TelegramOptions.java   
public ProxyOptions getProxyOptions() {
    return proxyOptions;
}
项目:vertx-telegram-bot-api    文件:TelegramOptions.java   
public TelegramOptions setProxyOptions(ProxyOptions proxyOptions) {
    this.proxyOptions = proxyOptions;
    return this;
}
项目:gravitee-gateway    文件:VertxHttpClient.java   
@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);
}
项目:vertx-amqp-bridge    文件:AmqpBridgeOptions.java   
@Override
public AmqpBridgeOptions setProxyOptions(ProxyOptions proxyOptions) {
  super.setProxyOptions(proxyOptions);
  return this;
}
项目:vertx-proton    文件:ProtonClientOptions.java   
@Override
public ProtonClientOptions setProxyOptions(ProxyOptions proxyOptions) {
  super.setProxyOptions(proxyOptions);
  return this;
}
项目:vertx-web    文件:WebClientOptions.java   
@Override
public WebClientOptions setProxyOptions(ProxyOptions proxyOptions) {
  return (WebClientOptions) super.setProxyOptions(proxyOptions);
}