exceptionfactory commented on code in PR #11534:
URL: https://github.com/apache/nifi/pull/11534#discussion_r3866207982
##########
nifi-extension-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/main/java/org/apache/nifi/confluent/schemaregistry/client/RestSchemaRegistryClient.java:
##########
@@ -98,16 +100,38 @@ public RestSchemaRegistryClient(final List<String>
baseUrls,
final String password,
final ComponentLog logger,
final Map<String, String> httpHeaders) {
- this.baseUrls = new ArrayList<>(baseUrls);
- this.httpHeaders = new HashMap<>(httpHeaders);
+ this(baseUrls, timeoutMillis, sslContextProvider, logger, httpHeaders);
if (StringUtils.isNoneBlank(username, password)) {
final String credentials =
BASIC_CREDENTIALS_FORMAT.formatted(username, password);
final byte[] credentialsEncoded =
credentials.getBytes(StandardCharsets.UTF_8);
final String authorization =
Base64.getEncoder().encodeToString(credentialsEncoded);
final String basicAuthorization =
BASIC_AUTHORIZATION_FORMAT.formatted(authorization);
- this.httpHeaders.put(HttpHeaderName.AUTHORIZATION.getHeaderName(),
basicAuthorization);
+
this.httpHeaders.putIfAbsent(HttpHeaderName.AUTHORIZATION.getHeaderName(),
basicAuthorization);
}
+ }
+
+ public RestSchemaRegistryClient(final List<String> baseUrls,
+ final int timeoutMillis,
+ final SSLContextProvider
sslContextProvider,
+ final OAuth2AccessTokenProvider
oauth2AccessTokenProvider,
+ final ComponentLog logger,
+ final Map<String, String> httpHeaders) {
+ this(baseUrls, timeoutMillis, sslContextProvider, logger, httpHeaders);
+
+ if (oauth2AccessTokenProvider != null) {
+ final String accessToken =
oauth2AccessTokenProvider.getAccessDetails().getAccessToken();
Review Comment:
Retrieving the Access Token once in the constructor will run into expiration
issues over the lifecycle, so a different approach is needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]