io.vertx.core.net.ProxyOptions Java Examples
The following examples show how to use
io.vertx.core.net.ProxyOptions.
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: AmqpPropertiesConverter.java From vertx-spring-boot with Apache License 2.0 | 6 votes |
private void mapClientOptionsBase(AmqpProperties from, AmqpClientOptions to) { to.setConnectTimeout(from.getConnectTimeout()); to.setTrustAll(from.isTrustAll()); to.setMetricsName(from.getMetricsName()); to.setLocalAddress(from.getLocalAddress()); if (from.getProxy().isEnabled()) { ProxyOptions proxyOptions = new ProxyOptions() .setHost(from.getProxy().getHost()) .setPort(from.getProxy().getPort()) .setUsername(from.getProxy().getUsername()) .setPassword(from.getProxy().getPassword()) .setType(ProxyType.valueOf(from.getProxy().getType().name())); to.setProxyOptions(proxyOptions); } }
Example #2
Source File: OidcRecorder.java From quarkus with Apache License 2.0 | 6 votes |
protected static Optional<ProxyOptions> toProxyOptions(OidcTenantConfig.Proxy proxyConfig) { // Proxy is enabled if (at least) "host" is configured. if (!proxyConfig.host.isPresent()) { return Optional.empty(); } JsonObject jsonOptions = new JsonObject(); jsonOptions.put("host", proxyConfig.host.get()); jsonOptions.put("port", proxyConfig.port); if (proxyConfig.username.isPresent()) { jsonOptions.put("username", proxyConfig.username.get()); } if (proxyConfig.password.isPresent()) { jsonOptions.put("password", proxyConfig.password.get()); } return Optional.of(new ProxyOptions(jsonOptions)); }
Example #3
Source File: MailProxyTest.java From vertx-mail-client with Apache License 2.0 | 6 votes |
@Test public void testSetUpProxy(TestContext context) throws Exception { this.testContext = context; MailConfig mailConfig = configLogin().setProxyOptions(new ProxyOptions().setType(ProxyType.SOCKS5).setPort(11080)); proxy = new SocksProxy(null); proxy.start(vertx); Async async = testContext.async(); MailClient client = MailClient.createShared(vertx, mailConfig); client.sendMail(exampleMessage(), r -> { if (r.succeeded()) { assertEquals("localhost:1587", proxy.getLastUri()); async.complete(); } else { log.debug("Failed to send mail", r.cause()); testContext.fail(r.cause()); } }); }
Example #4
Source File: MailProxyTest.java From vertx-mail-client with Apache License 2.0 | 6 votes |
@Test public void testSetUpProxyAuth(TestContext context) throws Exception { this.testContext = context; MailConfig mailConfig = configLogin().setProxyOptions(new ProxyOptions() .setType(ProxyType.SOCKS5) .setPort(11080) .setUsername("proxyUser") .setPassword("proxyUser") ); proxy = new SocksProxy("proxyUser"); proxy.start(vertx); Async async = testContext.async(); MailClient client = MailClient.createShared(vertx, mailConfig); client.sendMail(exampleMessage(), r -> { if (r.succeeded()) { assertEquals("localhost:1587", proxy.getLastUri()); async.complete(); } else { log.debug("Failed to send mail", r.cause()); testContext.fail(r.cause()); } }); }
Example #5
Source File: HttpClientOptionsSPI.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
static HttpClientOptions createHttpClientOptions(HttpClientOptionsSPI spi) { HttpClientOptions httpClientOptions = new HttpClientOptions(); httpClientOptions.setProtocolVersion(spi.getHttpVersion()); httpClientOptions.setConnectTimeout(spi.getConnectTimeoutInMillis()); httpClientOptions.setIdleTimeout(spi.getIdleTimeoutInSeconds()); httpClientOptions.setTryUseCompression(spi.isTryUseCompression()); httpClientOptions.setMaxWaitQueueSize(spi.getMaxWaitQueueSize()); httpClientOptions.setMaxPoolSize(spi.getMaxPoolSize()); httpClientOptions.setKeepAlive(spi.isKeepAlive()); httpClientOptions.setMaxHeaderSize(spi.getMaxHeaderSize()); httpClientOptions.setKeepAliveTimeout(spi.getKeepAliveTimeout()); if (spi.isProxyEnable()) { ProxyOptions proxy = new ProxyOptions(); proxy.setHost(spi.getProxyHost()); proxy.setPort(spi.getProxyPort()); proxy.setUsername(spi.getProxyUsername()); proxy.setPassword( Encryptions.decode(spi.getProxyPassword(), spi.getConfigTag())); httpClientOptions.setProxyOptions(proxy); } if (spi.getHttpVersion() == HttpVersion.HTTP_2) { httpClientOptions.setHttp2ClearTextUpgrade(false); httpClientOptions.setUseAlpn(spi.isUseAlpn()); httpClientOptions.setHttp2MultiplexingLimit(spi.getHttp2MultiplexingLimit()); httpClientOptions.setHttp2MaxPoolSize(spi.getHttp2MaxPoolSize()); } if (spi.isSsl()) { VertxTLSBuilder.buildHttpClientOptions(spi.getConfigTag(), httpClientOptions); } return httpClientOptions; }
Example #6
Source File: VertxDownloader.java From NetDiscovery with Apache License 2.0 | 5 votes |
private WebClientOptions initWebClientOptions(Request request) { WebClientOptions options = new WebClientOptions(); options.setKeepAlive(SpiderConfig.getInstance().isKeepAlive()) .setReuseAddress(SpiderConfig.getInstance().isReuseAddress()) .setFollowRedirects(SpiderConfig.getInstance().isFollowRedirects()) .setConnectTimeout(SpiderConfig.getInstance().getConnectTimeout()) .setIdleTimeout(SpiderConfig.getInstance().getIdleTimeout()) .setMaxWaitQueueSize(SpiderConfig.getInstance().getMaxWaitQueueSize()); if (Preconditions.isNotBlank(request.getUserAgent())) { options.setUserAgent(request.getUserAgent()); } 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; }
Example #7
Source File: WebClientsConfiguration.java From graviteeio-access-management with Apache License 2.0 | 5 votes |
private WebClient createWebClient(Vertx vertx, URL url) { final int port = url.getPort() != -1 ? url.getPort() : (HTTPS_SCHEME.equals(url.getProtocol()) ? 443 : 80); WebClientOptions options = new WebClientOptions() .setDefaultPort(port) .setDefaultHost(url.getHost()) .setKeepAlive(true) .setMaxPoolSize(10) .setTcpKeepAlive(true) .setConnectTimeout(httpClientTimeout) .setSsl(url.getProtocol().equals(HTTPS_SCHEME)); if (this.isProxyConfigured) { ProxyOptions proxyOptions = new ProxyOptions(); proxyOptions.setType(ProxyType.valueOf(httpClientProxyType)); if (HTTPS_SCHEME.equals(url.getProtocol())) { proxyOptions.setHost(httpClientProxyHttpsHost); proxyOptions.setPort(httpClientProxyHttpsPort); proxyOptions.setUsername(httpClientProxyHttpsUsername); proxyOptions.setPassword(httpClientProxyHttpsPassword); } else { proxyOptions.setHost(httpClientProxyHttpHost); proxyOptions.setPort(httpClientProxyHttpPort); proxyOptions.setUsername(httpClientProxyHttpUsername); proxyOptions.setPassword(httpClientProxyHttpPassword); } options.setProxyOptions(proxyOptions); } return WebClient.create(vertx, options); }
Example #8
Source File: HttpClientServiceImpl.java From gravitee-management-rest-api with Apache License 2.0 | 5 votes |
private HttpClient getHttpClient(String uriScheme, Boolean useSystemProxy) { boolean ssl = HTTPS_SCHEME.equalsIgnoreCase(uriScheme); final HttpClientOptions options = new HttpClientOptions() .setSsl(ssl) .setTrustAll(true) .setMaxPoolSize(1) .setKeepAlive(false) .setTcpKeepAlive(false) .setConnectTimeout(httpClientTimeout); if ((useSystemProxy != null && useSystemProxy == Boolean.TRUE) || (useSystemProxy == null && this.isProxyConfigured)) { ProxyOptions proxyOptions = new ProxyOptions(); proxyOptions.setType(ProxyType.valueOf(httpClientProxyType)); if (HTTPS_SCHEME.equals(uriScheme)) { proxyOptions.setHost(httpClientProxyHttpsHost); proxyOptions.setPort(httpClientProxyHttpsPort); proxyOptions.setUsername(httpClientProxyHttpsUsername); proxyOptions.setPassword(httpClientProxyHttpsPassword); } else { proxyOptions.setHost(httpClientProxyHttpHost); proxyOptions.setPort(httpClientProxyHttpPort); proxyOptions.setUsername(httpClientProxyHttpUsername); proxyOptions.setPassword(httpClientProxyHttpPassword); } options.setProxyOptions(proxyOptions); } return vertx.createHttpClient(options); }
Example #9
Source File: VertxPluginRegistry.java From apiman with Apache License 2.0 | 5 votes |
/** * Constructor. * * @param vertx the vertx * @param vxEngineConfig the engine config * @param config the plugin config */ public VertxPluginRegistry(Vertx vertx, VertxEngineConfig vxEngineConfig, Map<String, String> config) { super(config); this.vertx = vertx; //Get HTTPS Proxy settings (useful for local dev tests and corporate CI) String sslProxyHost = System.getProperty("https.proxyHost", "none"); Integer sslProxyPort = Integer.valueOf(System.getProperty("https.proxyPort", "443")); sslNoProxy = System.getProperty("https.nonProxyHosts", "none"); //Set HTTPS proxy if defined if (!"none".equalsIgnoreCase(sslProxyHost)) { sslProxy = new ProxyOptions(); sslProxy.setHost(sslProxyHost); sslProxy.setPort(sslProxyPort); sslProxy.setType(ProxyType.HTTP); } //Get HTTP Proxy settings (useful for local dev tests and corporate CI) String proxyHost = System.getProperty("http.proxyHost", "none"); Integer proxyPort = Integer.valueOf(System.getProperty("http.proxyPort", "80")); noProxy = System.getProperty("http.nonProxyHosts", "none"); //Set HTTPS proxy if defined if (!"none".equalsIgnoreCase(proxyHost)) { proxy = new ProxyOptions(); proxy.setHost(proxyHost); proxy.setPort(proxyPort); proxy.setType(ProxyType.HTTP); } }
Example #10
Source File: MSSQLConnectOptions.java From vertx-sql-client with Apache License 2.0 | 4 votes |
@Override public MSSQLConnectOptions setProxyOptions(ProxyOptions proxyOptions) { return (MSSQLConnectOptions) super.setProxyOptions(proxyOptions); }
Example #11
Source File: S3ClientOptions.java From vertx-s3-client with Apache License 2.0 | 4 votes |
@Override public S3ClientOptions setProxyOptions(final ProxyOptions proxyOptions) { super.setProxyOptions(proxyOptions); return this; }
Example #12
Source File: MailConfig.java From vertx-mail-client with Apache License 2.0 | 4 votes |
public MailConfig setProxyOptions(ProxyOptions proxyOptions) { super.setProxyOptions(proxyOptions); return this; }
Example #13
Source File: ProtonClientOptions.java From vertx-proton with Apache License 2.0 | 4 votes |
@Override public ProtonClientOptions setProxyOptions(ProxyOptions proxyOptions) { super.setProxyOptions(proxyOptions); return this; }