public NetClientImpl(VertxInternal vertx, NetClientOptions options, boolean useCreatingContext) { this.vertx = vertx; this.options = new NetClientOptions(options); this.sslHelper = new SSLHelper(options, options.getKeyCertOptions(), options.getTrustOptions()); this.closeHook = completionHandler -> { NetClientImpl.this.close(); completionHandler.handle(Future.succeededFuture()); }; if (useCreatingContext) { creatingContext = vertx.getContext(); if (creatingContext != null) { creatingContext.addCloseHook(closeHook); } } else { creatingContext = null; } VertxMetrics metrics = vertx.metricsSPI(); this.metrics = metrics != null ? metrics.createNetClientMetrics(options) : null; logEnabled = options.getLogActivity(); idleTimeout = options.getIdleTimeout(); idleTimeoutUnit = options.getIdleTimeoutUnit(); }
assertEquals(ksPassword, ((JksOptions) options.getKeyCertOptions()).getPassword()); assertEquals(ksPath, ((JksOptions) options.getKeyCertOptions()).getPath()); assertNotSame(trustStoreOptions, options.getTrustOptions()); assertEquals(tsPassword, ((JksOptions) options.getTrustOptions()).getPassword()); assertEquals(tsPath, ((JksOptions) options.getTrustOptions()).getPath()); assertEquals(1, options.getEnabledCipherSuites().size()); assertTrue(options.getEnabledCipherSuites().contains(enabledCipher)); .put("pfxTrustOptions", new JsonObject().put("password", tsPassword)); options = new NetClientOptions(json); assertTrue(options.getTrustOptions() instanceof PfxOptions); assertTrue(options.getKeyCertOptions() instanceof PfxOptions); .put("pemTrustOptions", new JsonObject()); options = new NetClientOptions(json); assertTrue(options.getTrustOptions() instanceof PemTrustOptions); assertTrue(options.getKeyCertOptions() instanceof PemKeyCertOptions);
assertNotSame(keyStoreOptions, copy.getKeyCertOptions()); assertEquals(ksPassword, ((JksOptions) copy.getKeyCertOptions()).getPassword()); assertNotSame(trustStoreOptions, copy.getTrustOptions()); assertEquals(tsPassword, ((JksOptions)copy.getTrustOptions()).getPassword()); assertEquals(1, copy.getEnabledCipherSuites().size()); assertTrue(copy.getEnabledCipherSuites().contains(enabledCipher));
public NetClientImpl(VertxInternal vertx, NetClientOptions options, boolean useCreatingContext) { this.vertx = vertx; this.options = new NetClientOptions(options); this.sslHelper = new SSLHelper(options, options.getKeyCertOptions(), options.getTrustOptions()); this.closeHook = completionHandler -> { NetClientImpl.this.close(); completionHandler.handle(Future.succeededFuture()); }; if (useCreatingContext) { creatingContext = vertx.getContext(); if (creatingContext != null) { if (creatingContext.isMultiThreadedWorkerContext()) { throw new IllegalStateException("Cannot use NetClient in a multi-threaded worker verticle"); } creatingContext.addCloseHook(closeHook); } } else { creatingContext = null; } VertxMetrics metrics = vertx.metricsSPI(); this.metrics = metrics != null ? metrics.createNetClientMetrics(options) : null; logEnabled = options.getLogActivity(); idleTimeout = options.getIdleTimeout(); idleTimeoutUnit = options.getIdleTimeoutUnit(); }
assertEquals(keyStoreOptions, options.getKeyCertOptions()); assertNull(options.getTrustOptions()); JksOptions trustStoreOptions = new JksOptions().setPath(TestUtils.randomAlphaString(100)).setPassword(TestUtils.randomAlphaString(100)); assertEquals(options, options.setTrustStoreOptions(trustStoreOptions)); assertEquals(trustStoreOptions, options.getTrustOptions());
assertEquals(ksPassword, ((JksOptions) options.getKeyCertOptions()).getPassword()); assertEquals(ksPath, ((JksOptions) options.getKeyCertOptions()).getPath()); assertNotSame(trustStoreOptions, options.getTrustOptions()); assertEquals(tsPassword, ((JksOptions) options.getTrustOptions()).getPassword()); assertEquals(tsPath, ((JksOptions) options.getTrustOptions()).getPath()); assertEquals(1, options.getEnabledCipherSuites().size()); assertTrue(options.getEnabledCipherSuites().contains(enabledCipher)); .put("pfxTrustOptions", new JsonObject().put("password", tsPassword)); options = new NetClientOptions(json); assertTrue(options.getTrustOptions() instanceof PfxOptions); assertTrue(options.getKeyCertOptions() instanceof PfxOptions); .put("pemTrustOptions", new JsonObject()); options = new NetClientOptions(json); assertTrue(options.getTrustOptions() instanceof PemTrustOptions); assertTrue(options.getKeyCertOptions() instanceof PemKeyCertOptions);
assertNotSame(keyStoreOptions, copy.getKeyCertOptions()); assertEquals(ksPassword, ((JksOptions) copy.getKeyCertOptions()).getPassword()); assertNotSame(trustStoreOptions, copy.getTrustOptions()); assertEquals(tsPassword, ((JksOptions)copy.getTrustOptions()).getPassword()); assertEquals(1, copy.getEnabledCipherSuites().size()); assertTrue(copy.getEnabledCipherSuites().contains(enabledCipher));
assertEquals(keyStoreOptions, options.getKeyCertOptions()); assertNull(options.getTrustOptions()); JksOptions trustStoreOptions = new JksOptions().setPath(TestUtils.randomAlphaString(100)).setPassword(TestUtils.randomAlphaString(100)); assertEquals(options, options.setTrustStoreOptions(trustStoreOptions)); assertEquals(trustStoreOptions, options.getTrustOptions());
public PgConnectionFactory(Context context, boolean registerCloseHook, PgConnectOptions options) { hook = this::close; this.registerCloseHook = registerCloseHook; ctx = context; if (registerCloseHook) { ctx.addCloseHook(hook); } NetClientOptions netClientOptions = new NetClientOptions(options); // Make sure ssl=false as we will use STARTLS netClientOptions.setSsl(false); this.sslMode = options.getSslMode(); this.hostnameVerificationAlgorithm = netClientOptions.getHostnameVerificationAlgorithm(); this.trustOptions = netClientOptions.getTrustOptions(); this.host = options.getHost(); this.port = options.getPort(); this.database = options.getDatabase(); this.username = options.getUser(); this.password = options.getPassword(); this.cachePreparedStatements = options.getCachePreparedStatements(); this.pipeliningLimit = options.getPipeliningLimit(); this.isUsingDomainSocket = options.isUsingDomainSocket(); this.client = context.owner().createNetClient(netClientOptions); }
public PgConnectionFactory(Context context, boolean registerCloseHook, PgConnectOptions options) { hook = this::close; this.registerCloseHook = registerCloseHook; ctx = context; if (registerCloseHook) { ctx.addCloseHook(hook); } NetClientOptions netClientOptions = new NetClientOptions(options); // Make sure ssl=false as we will use STARTLS netClientOptions.setSsl(false); this.sslMode = options.getSslMode(); this.hostnameVerificationAlgorithm = netClientOptions.getHostnameVerificationAlgorithm(); this.trustOptions = netClientOptions.getTrustOptions(); this.host = options.getHost(); this.port = options.getPort(); this.database = options.getDatabase(); this.username = options.getUser(); this.password = options.getPassword(); this.cachePreparedStatements = options.getCachePreparedStatements(); this.pipeliningLimit = options.getPipeliningLimit(); this.isUsingDomainSocket = options.isUsingDomainSocket(); this.client = context.owner().createNetClient(netClientOptions); }