com.applitools.connectivity.api.HttpClientImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eyes-connectivity-java3-net Show documentation
Show all versions of eyes-connectivity-java3-net Show documentation
Applitools Eyes SDK REST API communication implementation depending on java.net
package com.applitools.connectivity.api;
import com.applitools.eyes.AbstractProxySettings;
import com.applitools.eyes.Logger;
import com.applitools.eyes.logging.Stage;
import com.applitools.utils.GeneralUtils;
import com.applitools.utils.NetworkUtils;
import org.apache.commons.lang3.tuple.Pair;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;
import java.net.URI;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.HashSet;
public class HttpClientImpl extends HttpClient {
public HttpClientImpl(Logger logger, int timeout, AbstractProxySettings abstractProxySettings) {
super(logger, timeout, abstractProxySettings);
logger.log(new HashSet(), Stage.GENERAL, Pair.of("connectivityPackage", "java.net"));
try {
HttpsURLConnection.setDefaultSSLSocketFactory(NetworkUtils.getDisabledSSLContext().getSocketFactory());
} catch (NoSuchAlgorithmException | KeyManagementException e) {
GeneralUtils.logExceptionStackTrace(logger, Stage.GENERAL, e);
}
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String s, SSLSession sslSession) {
return true;
}
});
}
@Override
public ConnectivityTarget target(URI baseUrl) {
return new ConnectivityTargetImpl(logger, baseUrl.toString(), abstractProxySettings, timeout);
}
@Override
public ConnectivityTarget target(String path) {
return new ConnectivityTargetImpl(logger, path, abstractProxySettings, timeout);
}
@Override
public void close() {
isClosed = true;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy