@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof Proxy) { Proxy p = (Proxy) obj; return (host != null ? host.equals(p.getHost()) : p.getHost() == null) && port == p.getPort() && (username != null ? username.equals(p.getUsername()) : p.getUsername() == null) && (password != null ? password.equals(p.getPassword()) : p.getPassword() == null) && authenticationRequired == p.authenticationRequired; } return false; } }
public Proxy getProxy() { if (this.proxy != null) { return proxy; } Proxy proxy = null; // use proxy overrides if they're set if ((getProxyPort() > 0 || getProxyHost() != null) && (getProxyUsername() == null || getProxyPassword() == null)) { proxy = new Proxy(getProxyHost(), getProxyPort()); } else if (getProxyUsername() != null && getProxyPassword() != null) { proxy = new Proxy(getProxyHost(), getProxyPort(), getProxyUsername(), getProxyPassword()); } this.proxy = proxy; return this.proxy; }
public Proxy getProxy() { if (this.proxy != null) { return proxy; } Proxy proxy = null; // use proxy overrides if they're set if ((getProxyPort() > 0 || getProxyHost() != null) && (getProxyUsername() == null || getProxyPassword() == null)) { proxy = new Proxy(getProxyHost(), getProxyPort()); } else if (getProxyUsername() != null && getProxyPassword() != null) { proxy = new Proxy(getProxyHost(), getProxyPort(), getProxyUsername(), getProxyPassword()); } this.proxy = proxy; return this.proxy; }
@Override public ClientBuilder setProxy(Proxy proxy) { if (proxy == null) { throw new IllegalArgumentException("proxy argument cannot be null."); } clientConfig.setProxyHost(proxy.getHost()); clientConfig.setProxyPort(proxy.getPort()); clientConfig.setProxyUsername(proxy.getUsername()); clientConfig.setProxyPassword(proxy.getPassword()); return this; }
private Proxy oktaSdkProxy() { OktaClientProperties.ClientProxyInfo proxyInfo = oktaClientProperties.getProxy(); if (proxyInfo == null || !Strings.hasText(proxyInfo.getHostname())) { return null; } Proxy proxy; if (Strings.hasText(proxyInfo.getUsername()) || Strings.hasText(proxyInfo.getPassword())) { proxy = new Proxy(proxyInfo.getHostname(), proxyInfo.getPort(), proxyInfo.getUsername(), proxyInfo.getPassword()); } else { proxy = new Proxy(proxyInfo.getHostname(), proxyInfo.getPort()); } return proxy; }
@Override public AuthenticationClientBuilder setProxy(Proxy proxy) { if (proxy == null) { throw new IllegalArgumentException("proxy argument cannot be null."); } clientConfig.setProxyHost(proxy.getHost()); clientConfig.setProxyPort(proxy.getPort()); clientConfig.setProxyUsername(proxy.getUsername()); clientConfig.setProxyPassword(proxy.getPassword()); return this; }
private Proxy oktaSdkProxy() { OktaClientProperties.ClientProxyInfo proxyInfo = oktaClientProperties.getProxy(); if (proxyInfo == null || !Strings.hasText(proxyInfo.getHostname())) { return null; } Proxy proxy; if (Strings.hasText(proxyInfo.getUsername()) || Strings.hasText(proxyInfo.getPassword())) { proxy = new Proxy(proxyInfo.getHostname(), proxyInfo.getPort(), proxyInfo.getUsername(), proxyInfo.getPassword()); } else { proxy = new Proxy(proxyInfo.getHostname(), proxyInfo.getPort()); } return proxy; }
@Override public ClientBuilder setProxy(Proxy proxy) { if (proxy == null) { throw new IllegalArgumentException("proxy argument cannot be null."); } clientConfig.setProxyHost(proxy.getHost()); clientConfig.setProxyPort(proxy.getPort()); clientConfig.setProxyUsername(proxy.getUsername()); clientConfig.setProxyPassword(proxy.getPassword()); return this; }
private static OkHttpClient createOkHttpClient(ClientConfiguration clientConfiguration) { OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder(); clientBuilder.connectTimeout(clientConfiguration.getConnectionTimeout(), TimeUnit.SECONDS); clientBuilder.readTimeout(clientConfiguration.getConnectionTimeout(), TimeUnit.SECONDS); clientBuilder.writeTimeout(clientConfiguration.getConnectionTimeout(), TimeUnit.SECONDS); clientBuilder.cookieJar(CookieJar.NO_COOKIES); clientBuilder.retryOnConnectionFailure(false); // handled by SDK final Proxy sdkProxy = clientConfiguration.getProxy(); if (sdkProxy != null) { java.net.Proxy proxy = new java.net.Proxy(java.net.Proxy.Type.HTTP, new InetSocketAddress(sdkProxy.getHost(), sdkProxy.getPort())); clientBuilder.proxy(proxy); if (sdkProxy.isAuthenticationRequired()) { clientBuilder.proxyAuthenticator((route, response) -> { String credential = Credentials.basic(sdkProxy.getUsername(), sdkProxy.getPassword()); return response.request().newBuilder() .header("Proxy-Authorization", credential) .build(); }); } } return clientBuilder.build(); }
HttpHost httpProxyHost = new HttpHost(proxy.getHost(), proxy.getPort()); httpClientBuilder.setProxy(httpProxyHost); if (proxy.isAuthenticationRequired()) { AuthScope authScope = new AuthScope(proxy.getHost(), proxy.getPort()); Credentials credentials = new UsernamePasswordCredentials(proxy.getUsername(), proxy.getPassword()); CredentialsProvider credentialsProviderProvider = new BasicCredentialsProvider(); credentialsProviderProvider.setCredentials(authScope, credentials);
HttpHost httpProxyHost = new HttpHost(proxy.getHost(), proxy.getPort()); httpClientBuilder.setProxy(httpProxyHost); if (proxy.isAuthenticationRequired()) { AuthScope authScope = new AuthScope(proxy.getHost(), proxy.getPort()); Credentials credentials = new UsernamePasswordCredentials(proxy.getUsername(), proxy.getPassword()); CredentialsProvider credentialsProviderProvider = new BasicCredentialsProvider(); credentialsProviderProvider.setCredentials(authScope, credentials);