Skip to content

Commit

Permalink
Merge pull request #141 from scottslewis/sslcontext
Browse files Browse the repository at this point in the history
Added support for usage of sslContextFactory.getInstance(protocol) and
  • Loading branch information
scottslewis authored Dec 19, 2024
2 parents 5794d20 + 02c9568 commit 06d6e4a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
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

0 comments on commit 06d6e4a

Please sign in to comment.