From e2d5ef83555c2c468e95625caf4b6435629fc55a Mon Sep 17 00:00:00 2001 From: vincenzo-ingenito Date: Wed, 11 Dec 2024 16:46:57 +0000 Subject: [PATCH] feat: Add pfx name --- .../config/kafka/KafkaConsumerCFG.java | 1 + .../config/kafka/KafkaProducerCFG.java | 1 + .../config/kafka/KafkaPropertiesCFG.java | 3 +++ .../CustomAuthenticateCallbackHandler.java | 17 +++++++++++------ src/main/resources/application.properties | 1 + 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/kafka/KafkaConsumerCFG.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/kafka/KafkaConsumerCFG.java index e9cb8bc..74a35be 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/kafka/KafkaConsumerCFG.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/kafka/KafkaConsumerCFG.java @@ -94,6 +94,7 @@ public Map consumerConfigs() { props.put("sasl.login.callback.handler.class", CustomAuthenticateCallbackHandler.class); props.put("kafka.oauth.tenantId", kafkaPropsCfg.getTenantId()); props.put("kafka.oauth.appId", kafkaPropsCfg.getAppId()); + props.put("kafka.oauth.pfxName", kafkaPropsCfg.getPfxName()); props.put("kafka.oauth.pwd", kafkaPropsCfg.getPwd()); } diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/kafka/KafkaProducerCFG.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/kafka/KafkaProducerCFG.java index 640bf80..ce0d2d2 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/kafka/KafkaProducerCFG.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/kafka/KafkaProducerCFG.java @@ -76,6 +76,7 @@ public Map producerWithoutTransactionConfigs() { props.put("sasl.login.callback.handler.class", CustomAuthenticateCallbackHandler.class); props.put("kafka.oauth.tenantId", kafkaPropCFG.getTenantId()); props.put("kafka.oauth.appId", kafkaPropCFG.getAppId()); + props.put("kafka.oauth.pfxName", kafkaPropCFG.getPfxName()); props.put("kafka.oauth.pwd", kafkaPropCFG.getPwd()); } diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/kafka/KafkaPropertiesCFG.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/kafka/KafkaPropertiesCFG.java index 7399349..c80b312 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/kafka/KafkaPropertiesCFG.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/kafka/KafkaPropertiesCFG.java @@ -23,6 +23,9 @@ public class KafkaPropertiesCFG { @Value("${kafka.oauth.appId}") private String appId; + + @Value("${kafka.oauth.pfxName}") + private String pfxName; @Value("${kafka.oauth.pwd}") private String pwd; diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/kafka/oauth2/CustomAuthenticateCallbackHandler.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/kafka/oauth2/CustomAuthenticateCallbackHandler.java index 177d1a5..23ba4ab 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/kafka/oauth2/CustomAuthenticateCallbackHandler.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/kafka/oauth2/CustomAuthenticateCallbackHandler.java @@ -31,6 +31,7 @@ import com.microsoft.aad.msal4j.IAuthenticationResult; import com.microsoft.aad.msal4j.IClientCredential; +import it.finanze.sanita.fse2.ms.gtw.statusmanager.exceptions.BusinessException; import it.finanze.sanita.fse2.ms.gtw.statusmanager.utility.FileUtility; import lombok.extern.slf4j.Slf4j; @@ -39,8 +40,10 @@ public class CustomAuthenticateCallbackHandler implements AuthenticateCallbackHa private String tenantId; - private String clientId; + private String appId; + private String pfxName; + private String pwd; private ConfidentialClientApplication aadClient; @@ -57,7 +60,8 @@ public void configure(Map configs, String mechanism, List