feat: allow user-specified default OkHttpClient instance #174
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit modifies the java core so that users can now
specify a fully-configured OkHttpClient instance to be
used by service and authenticator instances:
and getHttpClient(). These methods can be used to set and get
the default client configuration from which other OkHttpClient
instances are created.
setClient() and getClient(). These methods can be used to set
and get the specific OkHttpClient instance that should be used
by an authenticator when interacting with the token service.
These new methods are inherited by each of the request-based
authenticator implementation classes: ContainerAuthenticator,
CloudPakForDataAuthenticator, CloudPakForDataServiceAuthenticator,
CloudPakForDataServiceInstanceAuthenticator, IamAuthenticator, and
VpcInstanceAuthenticator.
Note:
I plan to update this PR slightly so that the HttpClientSingleton will create a default OkHttpClient instance that supports mutual TLS (if possible). First, I need to learn what those details are :) The PR can be reviewed in its current state as these follow-on changes should be fairly small and isolated to the HttpClientSingleton class.Upon further review, I'm going to go ahead with this PR as-is. If additional research into the mTLS topic reveals a path where I can configure the default OkHttpClient instance such that mTLS works out of the box without affecting existing use-cases, then I will follow-up with a new PR to make those changes.