private static void setupBasicAuth( OkHttpClient.Builder clientBuilder, ClientSession session, Optional<String> user, Optional<String> password) { if (user.isPresent() && password.isPresent()) { checkArgument(session.getServer().getScheme().equalsIgnoreCase("https"), "Authentication using username/password requires HTTPS to be enabled"); clientBuilder.addInterceptor(basicAuth(user.get(), password.get())); } }
private static void setupTokenAuth( OkHttpClient.Builder clientBuilder, ClientSession session, Optional<String> accessToken) { if (accessToken.isPresent()) { checkArgument(session.getServer().getScheme().equalsIgnoreCase("https"), "Authentication using an access token requires HTTPS to be enabled"); clientBuilder.addInterceptor(tokenAuth(accessToken.get())); } } }
public static void setupHttpProxy(OkHttpClient.Builder clientBuilder, Optional<HostAndPort> httpProxy) { setupProxy(clientBuilder, httpProxy, HTTP); }
setupCookieJar(builder); setupSocksProxy(builder, SOCKS_PROXY.getValue(properties)); setupHttpProxy(builder, HTTP_PROXY.getValue(properties)); throw new SQLException("Authentication using username/password requires SSL to be enabled"); builder.addInterceptor(basicAuth(getUser(), password)); setupSsl( builder, SSL_KEY_STORE_PATH.getValue(properties), throw new SQLException("Authentication using Kerberos requires SSL to be enabled"); setupKerberos( builder, KERBEROS_REMOTE_SERVICE_NAME.getRequiredValue(properties), throw new SQLException("Authentication using an access token requires SSL to be enabled"); builder.addInterceptor(tokenAuth(ACCESS_TOKEN.getValue(properties).get()));
this.debug = debug; this.sslSetup = builder -> setupSsl(builder, keystorePath, keystorePassword, truststorePath, truststorePassword); setupTimeouts(builder, 30, SECONDS); setupCookieJar(builder); setupSocksProxy(builder, socksProxy); setupHttpProxy(builder, httpProxy); setupBasicAuth(builder, session, user, password); setupTokenAuth(builder, session, accessToken); checkArgument(session.getServer().getScheme().equalsIgnoreCase("https"), "Authentication using Kerberos requires HTTPS to be enabled"); setupKerberos( builder, kerberosRemoteServiceName.get(),
public BenchmarkQueryRunner(int warm, int runs, boolean debug, int maxFailures, URI serverUri, Optional<HostAndPort> socksProxy) { checkArgument(warm >= 0, "warm is negative"); this.warm = warm; checkArgument(runs >= 1, "runs must be at least 1"); this.runs = runs; checkArgument(maxFailures >= 0, "maxFailures must be at least 0"); this.maxFailures = maxFailures; this.debug = debug; requireNonNull(socksProxy, "socksProxy is null"); HttpClientConfig httpClientConfig = new HttpClientConfig(); if (socksProxy.isPresent()) { httpClientConfig.setSocksProxy(socksProxy.get()); } this.httpClient = new JettyHttpClient(httpClientConfig.setConnectTimeout(new Duration(10, TimeUnit.SECONDS))); OkHttpClient.Builder builder = new OkHttpClient.Builder(); setupCookieJar(builder); setupSocksProxy(builder, socksProxy); this.okHttpClient = builder.build(); nodes = getAllNodes(requireNonNull(serverUri, "serverUri is null")); }
validateCertificates(keyStore); KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); keyManagerFactory.init(keyStore, keyManagerPassword); trustStore = loadTrustStore(new File(trustStorePath.get()), trustStorePassword);
this.debug = debug; this.sslSetup = builder -> setupSsl(builder, keystorePath, keystorePassword, truststorePath, truststorePassword); setupTimeouts(builder, 30, SECONDS); setupCookieJar(builder); setupSocksProxy(builder, socksProxy); setupHttpProxy(builder, httpProxy); setupBasicAuth(builder, session, user, password); setupTokenAuth(builder, session, accessToken); checkArgument(session.getServer().getScheme().equalsIgnoreCase("https"), "Authentication using Kerberos requires HTTPS to be enabled"); setupKerberos( builder, kerberosRemoteServiceName.get(),
private static void setupBasicAuth( OkHttpClient.Builder clientBuilder, ClientSession session, Optional<String> user, Optional<String> password) { if (user.isPresent() && password.isPresent()) { checkArgument(session.getServer().getScheme().equalsIgnoreCase("https"), "Authentication using username/password requires HTTPS to be enabled"); clientBuilder.addInterceptor(basicAuth(user.get(), password.get())); } }
private static void setupTokenAuth( OkHttpClient.Builder clientBuilder, ClientSession session, Optional<String> accessToken) { if (accessToken.isPresent()) { checkArgument(session.getServer().getScheme().equalsIgnoreCase("https"), "Authentication using an access token requires HTTPS to be enabled"); clientBuilder.addInterceptor(tokenAuth(accessToken.get())); } } }
public static void setupSocksProxy(OkHttpClient.Builder clientBuilder, Optional<HostAndPort> socksProxy) { setupProxy(clientBuilder, socksProxy, SOCKS); }