1- package io .kafbat .ui .sasl . azure . entra ;
1+ package io .kafbat .ui .config . auth . azure ;
22
33import static org .apache .kafka .clients .CommonClientConfigs .BOOTSTRAP_SERVERS_CONFIG ;
44
5- import com .azure .core .credential .AccessToken ;
65import com .azure .core .credential .TokenCredential ;
76import com .azure .core .credential .TokenRequestContext ;
87import com .azure .identity .DefaultAzureCredentialBuilder ;
1312import javax .security .auth .callback .Callback ;
1413import javax .security .auth .callback .UnsupportedCallbackException ;
1514import javax .security .auth .login .AppConfigurationEntry ;
15+ import lombok .extern .slf4j .Slf4j ;
1616import org .apache .kafka .common .security .auth .AuthenticateCallbackHandler ;
1717import org .apache .kafka .common .security .oauthbearer .OAuthBearerToken ;
1818import org .apache .kafka .common .security .oauthbearer .OAuthBearerTokenCallback ;
19- import org .slf4j .Logger ;
20- import org .slf4j .LoggerFactory ;
2119
20+ @ Slf4j
2221public class AzureEntraLoginCallbackHandler implements AuthenticateCallbackHandler {
2322
24- private static final Logger LOGGER = LoggerFactory .getLogger (AzureEntraLoginCallbackHandler .class );
25-
2623 private static final Duration ACCESS_TOKEN_REQUEST_BLOCK_TIME = Duration .ofSeconds (10 );
2724
2825 private static final int ACCESS_TOKEN_REQUEST_MAX_RETRIES = 6 ;
@@ -53,15 +50,15 @@ private URI buildEventHubsServerUri(Map<String, ?> configs) {
5350
5451 if (null == bootstrapServers ) {
5552 final String message = BOOTSTRAP_SERVERS_CONFIG + " is missing from the Kafka configuration." ;
56- LOGGER .error (message );
53+ log .error (message );
5754 throw new IllegalArgumentException (message );
5855 }
5956
6057 if (bootstrapServers .size () != 1 ) {
6158 final String message =
6259 BOOTSTRAP_SERVERS_CONFIG
6360 + " contains multiple bootstrap servers. Only a single bootstrap server is supported." ;
64- LOGGER .error (message );
61+ log .error (message );
6562 throw new IllegalArgumentException (message );
6663 }
6764
@@ -87,9 +84,9 @@ private void handleOAuthCallback(OAuthBearerTokenCallback oauthCallback) {
8784 try {
8885 final OAuthBearerToken token = tokenCredential
8986 .getToken (tokenRequestContext )
90- .map (AzureEntraOAuthBearerTokenImpl ::new )
87+ .map (AzureEntraOAuthBearerToken ::new )
9188 .timeout (ACCESS_TOKEN_REQUEST_BLOCK_TIME )
92- .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 ))
9390 .retry (ACCESS_TOKEN_REQUEST_MAX_RETRIES )
9491 .block ();
9592
@@ -98,7 +95,7 @@ private void handleOAuthCallback(OAuthBearerTokenCallback oauthCallback) {
9895 final String message =
9996 "Failed to acquire Azure token for Event Hub Authentication. "
10097 + "Please ensure valid Azure credentials are configured." ;
101- LOGGER .error (message , e );
98+ log .error (message , e );
10299 oauthCallback .error ("invalid_grant" , message , null );
103100 }
104101 }
0 commit comments