use of org.ovirt.engine.core.uutils.net.HttpURLConnectionBuilder in project ovirt-engine by oVirt.
the class TransferImageCommand method getProxyConnection.
private HttpURLConnection getProxyConnection(String url) {
try {
HttpURLConnectionBuilder builder = new HttpURLConnectionBuilder().setURL(url);
// Set SSL details
builder.setTrustStore(EngineLocalConfig.getInstance().getPKITrustStore().getAbsolutePath()).setTrustStorePassword(EngineLocalConfig.getInstance().getPKITrustStorePassword()).setTrustStoreType(EngineLocalConfig.getInstance().getPKITrustStoreType()).setHttpsProtocol(Config.getValue(ConfigValues.ExternalCommunicationProtocol));
HttpURLConnection connection = builder.create();
connection.setDoOutput(true);
return connection;
} catch (Exception ex) {
throw new RuntimeException(String.format("Failed to communicate with ovirt-imageio-proxy: %s", ex.getMessage()));
}
}
use of org.ovirt.engine.core.uutils.net.HttpURLConnectionBuilder in project ovirt-engine by oVirt.
the class BaseProviderProxy method createConnection.
protected HttpURLConnection createConnection(String relativePath) {
URL hostUrl = getUrl();
HttpURLConnectionBuilder builder;
HttpURLConnection result;
try {
builder = new HttpURLConnectionBuilder().appendRelativePath(hostUrl, relativePath);
if (new File(EngineLocalConfig.getInstance().getExternalProvidersTrustStore().getAbsolutePath()).exists()) {
builder.setTrustStore(EngineLocalConfig.getInstance().getExternalProvidersTrustStore().getAbsolutePath()).setTrustStorePassword(EngineLocalConfig.getInstance().getExternalProvidersTrustStorePassword()).setTrustStoreType(EngineLocalConfig.getInstance().getExternalProvidersTrustStoreType()).setHttpsProtocol(Config.getValue(ConfigValues.ExternalCommunicationProtocol));
}
result = builder.create();
handleCredentials(result);
} catch (Exception ex) {
log.error("Cannot communicate with provider", ex);
throw new EngineException(EngineError.PROVIDER_FAILURE);
}
return result;
}
Aggregations