m1a2st commented on code in PR #19622:
URL: https://github.com/apache/kafka/pull/19622#discussion_r2085007139
##########
clients/src/main/java/org/apache/kafka/common/security/oauthbearer/OAuthBearerValidatorCallbackHandler.java:
##########
@@ -135,37 +134,36 @@ public void configure(Map<String, ?> configs, String
saslMechanism, List<AppConf
new
RefCountingVerificationKeyResolver(VerificationKeyResolverFactory.create(configs,
saslMechanism, moduleOptions)));
}
- AccessTokenValidator accessTokenValidator =
AccessTokenValidatorFactory.create(configs, saslMechanism,
verificationKeyResolver);
- init(verificationKeyResolver, accessTokenValidator);
+ JwtValidator jwtValidator = new DefaultJwtValidator(configs,
saslMechanism, verificationKeyResolver);
+ configure(verificationKeyResolver, jwtValidator);
}
- public void init(CloseableVerificationKeyResolver verificationKeyResolver,
AccessTokenValidator accessTokenValidator) {
+ void configure(CloseableVerificationKeyResolver verificationKeyResolver,
JwtValidator jwtValidator) {
this.verificationKeyResolver = verificationKeyResolver;
- this.accessTokenValidator = accessTokenValidator;
+ this.jwtValidator = jwtValidator;
try {
verificationKeyResolver.init();
} catch (Exception e) {
- throw new KafkaException("The OAuth validator configuration
encountered an error when initializing the VerificationKeyResolver", e);
+ throw new KafkaException("The OAuth validator callback encountered
an error when initializing the VerificationKeyResolver", e);
}
- isInitialized = true;
+ try {
+ jwtValidator.init();
+ } catch (IOException e) {
+ throw new KafkaException("The OAuth validator callback encountered
an error when initializing the JwtValidator", e);
+ }
}
@Override
public void close() {
- if (verificationKeyResolver != null) {
- try {
- verificationKeyResolver.close();
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- }
- }
+ Utils.closeQuietly(jwtValidator, "The OAuth validator callback
encountered an error when closing the JwtValidator");
+ Utils.closeQuietly(verificationKeyResolver, "The OAuth validator
callback encountered an error when closing the VerificationKeyResolver");
Review Comment:
ditto
--
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]