@@ -31,8 +31,9 @@ public class AzureEntraLoginCallbackHandler implements AuthenticateCallbackHandl
3131 private TokenRequestContext tokenRequestContext ;
3232
3333 @ Override
34- public void configure (
35- Map <String , ?> configs , String mechanism , List <AppConfigurationEntry > jaasConfigEntries ) {
34+ public void configure (Map <String , ?> configs ,
35+ String mechanism ,
36+ List <AppConfigurationEntry > jaasConfigEntries ) {
3637 tokenRequestContext = buildTokenRequestContext (configs );
3738 }
3839
@@ -45,16 +46,17 @@ private TokenRequestContext buildTokenRequestContext(Map<String, ?> configs) {
4546 return request ;
4647 }
4748
49+ @ SuppressWarnings ("unchecked" )
4850 private URI buildEventHubsServerUri (Map <String , ?> configs ) {
4951 final List <String > bootstrapServers = (List <String >) configs .get (BOOTSTRAP_SERVERS_CONFIG );
5052
51- if (null == bootstrapServers ) {
53+ if (bootstrapServers == null ) {
5254 final String message = BOOTSTRAP_SERVERS_CONFIG + " is missing from the Kafka configuration." ;
5355 log .error (message );
5456 throw new IllegalArgumentException (message );
5557 }
5658
57- if (bootstrapServers .size () != 1 ) {
59+ if (bootstrapServers .size () > 1 ) {
5860 final String message =
5961 BOOTSTRAP_SERVERS_CONFIG
6062 + " contains multiple bootstrap servers. Only a single bootstrap server is supported." ;
@@ -72,11 +74,10 @@ private String buildTokenAudience(URI uri) {
7274 @ Override
7375 public void handle (Callback [] callbacks ) throws UnsupportedCallbackException {
7476 for (Callback callback : callbacks ) {
75- if (callback instanceof OAuthBearerTokenCallback oauthCallback ) {
76- handleOAuthCallback (oauthCallback );
77- } else {
77+ if (!(callback instanceof OAuthBearerTokenCallback oauthCallback )) {
7878 throw new UnsupportedCallbackException (callback );
7979 }
80+ handleOAuthCallback (oauthCallback );
8081 }
8182 }
8283
@@ -91,7 +92,7 @@ private void handleOAuthCallback(OAuthBearerTokenCallback oauthCallback) {
9192 .block ();
9293
9394 oauthCallback .token (token );
94- } catch (final RuntimeException e ) {
95+ } catch (RuntimeException e ) {
9596 final String message =
9697 "Failed to acquire Azure token for Event Hub Authentication. "
9798 + "Please ensure valid Azure credentials are configured." ;
@@ -104,7 +105,7 @@ public void close() {
104105 // NOOP
105106 }
106107
107- void setTokenCredential (final TokenCredential tokenCredential ) {
108+ void setTokenCredential (TokenCredential tokenCredential ) {
108109 AzureEntraLoginCallbackHandler .tokenCredential = tokenCredential ;
109110 }
110111}
0 commit comments