1212import javax .security .auth .callback .Callback ;
1313import javax .security .auth .callback .UnsupportedCallbackException ;
1414import javax .security .auth .login .AppConfigurationEntry ;
15+ import lombok .extern .slf4j .Slf4j ;
1516import org .apache .kafka .common .security .auth .AuthenticateCallbackHandler ;
1617import org .apache .kafka .common .security .oauthbearer .OAuthBearerToken ;
1718import org .apache .kafka .common .security .oauthbearer .OAuthBearerTokenCallback ;
18- import org .slf4j .Logger ;
19- import org .slf4j .LoggerFactory ;
2019
20+ @ Slf4j
2121public class AzureEntraLoginCallbackHandler implements AuthenticateCallbackHandler {
2222
23- private static final Logger LOGGER = LoggerFactory .getLogger (AzureEntraLoginCallbackHandler .class );
24-
2523 private static final Duration ACCESS_TOKEN_REQUEST_BLOCK_TIME = Duration .ofSeconds (10 );
2624
2725 private static final int ACCESS_TOKEN_REQUEST_MAX_RETRIES = 6 ;
@@ -52,15 +50,15 @@ private URI buildEventHubsServerUri(Map<String, ?> configs) {
5250
5351 if (null == bootstrapServers ) {
5452 final String message = BOOTSTRAP_SERVERS_CONFIG + " is missing from the Kafka configuration." ;
55- LOGGER .error (message );
53+ log .error (message );
5654 throw new IllegalArgumentException (message );
5755 }
5856
5957 if (bootstrapServers .size () != 1 ) {
6058 final String message =
6159 BOOTSTRAP_SERVERS_CONFIG
6260 + " contains multiple bootstrap servers. Only a single bootstrap server is supported." ;
63- LOGGER .error (message );
61+ log .error (message );
6462 throw new IllegalArgumentException (message );
6563 }
6664
@@ -88,7 +86,7 @@ private void handleOAuthCallback(OAuthBearerTokenCallback oauthCallback) {
8886 .getToken (tokenRequestContext )
8987 .map (AzureEntraOAuthBearerToken ::new )
9088 .timeout (ACCESS_TOKEN_REQUEST_BLOCK_TIME )
91- .doOnError (e -> LOGGER .warn ("Failed to acquire Azure token for Event Hub Authentication. Retrying." , e ))
89+ .doOnError (e -> log .warn ("Failed to acquire Azure token for Event Hub Authentication. Retrying." , e ))
9290 .retry (ACCESS_TOKEN_REQUEST_MAX_RETRIES )
9391 .block ();
9492
@@ -97,7 +95,7 @@ private void handleOAuthCallback(OAuthBearerTokenCallback oauthCallback) {
9795 final String message =
9896 "Failed to acquire Azure token for Event Hub Authentication. "
9997 + "Please ensure valid Azure credentials are configured." ;
100- LOGGER .error (message , e );
98+ log .error (message , e );
10199 oauthCallback .error ("invalid_grant" , message , null );
102100 }
103101 }
0 commit comments