Skip to content

Commit

Permalink
Rework
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubhangi-cs committed Dec 21, 2023
1 parent acb2dfc commit b095991
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.github.rholder.retry.RetryerBuilder;
import com.github.rholder.retry.StopStrategies;
import com.github.rholder.retry.WaitStrategies;
import com.google.common.base.Strings;
import io.cdap.cdap.api.retry.RetryableException;
import io.cdap.plugin.successfactors.common.exception.TransportException;
import io.cdap.plugin.successfactors.common.util.ResourceConstants;
Expand Down Expand Up @@ -197,6 +198,11 @@ private Request buildRequest(URL endpoint, String mediaType) {

/**
* Builds and configures an OkHttpClient with the specified proxy settings and authentication credentials.
* @param proxyUrl The URL of the proxy server (e.g., "http://proxy.example.com:8080").
* Set to null or an empty string to bypass proxy configuration.
* @param proxyUsername The username for proxy authentication. Set to null or an empty string if not required.
* @param proxyPassword The password for proxy authentication. Set to null or an empty string if not required.
* @return An OkHttpClient configured with the specified proxy settings and authentication credentials.
*/
private OkHttpClient buildConfiguredClient(String proxyUrl, String proxyUsername, String proxyPassword)
throws MalformedURLException, TransportException {
Expand All @@ -207,7 +213,7 @@ private OkHttpClient buildConfiguredClient(String proxyUrl, String proxyUsername
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(url.getHost(), url.getPort()));
builder.proxy(proxy);

if (proxyUsername != null && !proxyUsername.isEmpty() && proxyPassword != null && !proxyPassword.isEmpty()) {
if (Strings.isNullOrEmpty(proxyUsername) && Strings.isNullOrEmpty(proxyPassword)) {
builder.proxyAuthenticator(new Authenticator() {
@Override
public Request authenticate(Route route, Response response) {
Expand Down

0 comments on commit b095991

Please sign in to comment.