Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for usage of sslContextFactory.getInstance(protocol) and #141

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ecf.core.security.SSLContextFactory;
import org.eclipse.ecf.core.util.Trace;
import org.eclipse.ecf.internal.provider.filetransfer.DebugOptions;
import org.eclipse.ecf.provider.filetransfer.httpclientjava.HttpClientOptions;
Expand All @@ -50,12 +51,25 @@ public class ECFHttpClientFactory implements IHttpClientFactory {

@Override
public HttpClient.Builder newClient() {

HttpClient.Builder builder = HttpClient.newBuilder().followRedirects(Redirect.NORMAL);
String sslContextProvider = HttpClientOptions.HTTPCLIENT_SSLCONTEXT_PROVIDER;
String sslContextProtocol = HttpClientOptions.HTTPCLIENT_SSLCONTEXT_PROTOCOL;
SSLContextFactory sslContextFactory = Activator.getDefault().getSSLContextFactory();
try {
builder.sslContext(Activator.getDefault().getSSLContextFactory().getDefault());
if (sslContextProvider == null) {
if (sslContextProtocol == null) {
builder.sslContext(sslContextFactory.getDefault());
} else {
builder.sslContext(sslContextFactory.getInstance(sslContextProtocol));
}
} else {
if (sslContextProtocol == null)
throw new NoSuchProviderException("Null protocol not supported for provider=" + sslContextProvider);
builder.sslContext(sslContextFactory.getInstance(sslContextProtocol, sslContextProvider));
}
} catch (NoSuchAlgorithmException | NoSuchProviderException e) {
Activator.getDefault().log(new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Could not set SSLContext when creating jre HttpClient", e));
Activator.getDefault().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
"Could not set SSLContext when creating jre HttpClient", e));
}
builder = Activator.getDefault().runModifiers(builder, new ModifierRunner<HttpClient.Builder>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,13 @@ public interface HttpClientOptions {
int NTLM_PROXY_RESPONSE_CODE = 477;
String FORCE_NTLM_PROP = "org.eclipse.ecf.provider.filetransfer.httpclient4.options.ForceNTLMProxy"; //$NON-NLS-1$

/**
* @since 2.0
*/
String HTTPCLIENT_SSLCONTEXT_PROTOCOL = System.getProperty("org.eclipse.ecf.provider.filetransfer.httpclient.sslcontext.protocol"); //$NON-NLS-1$

/**
* @since 2.0
*/
String HTTPCLIENT_SSLCONTEXT_PROVIDER = System.getProperty("org.eclipse.ecf.provider.filetransfer.httpclient.sslcontext.provider"); //$NON-NLS-1$
}
1 change: 0 additions & 1 deletion releng/org.eclipse.ecf.releng.target/ecf-2024-06.target
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
<unit id="org.apache.httpcomponents.httpclient" version="0.0.0"/>
<unit id="org.apache.httpcomponents.httpclient.win" version="0.0.0"/>
<unit id="org.apache.log4j" version="0.0.0"/>
<unit id="org.apache.lucene.analysis-smartcn" version="0.0.0"/>
<unit id="org.apiguardian.api" version="0.0.0"/>
<unit id="org.bndtools.headless.build.plugin.gradle" version="0.0.0"/>
<unit id="org.bndtools.templates.template" version="0.0.0"/>
Expand Down
Loading