From eb48b87bf79913ce8217896b293765ee506a5581 Mon Sep 17 00:00:00 2001 From: Neha Farheen Date: Mon, 29 Jan 2024 21:59:19 +0530 Subject: [PATCH] MOSIP-30687 On demand template extraction changes Signed-off-by: Neha Farheen --- .../transaction/manager/IdAuthSecurityManager.java | 2 +- .../websub/impl/OndemandTemplateEventPublisher.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/transaction/manager/IdAuthSecurityManager.java b/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/transaction/manager/IdAuthSecurityManager.java index 5ac7823db93..776de14e12e 100644 --- a/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/transaction/manager/IdAuthSecurityManager.java +++ b/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/transaction/manager/IdAuthSecurityManager.java @@ -513,7 +513,7 @@ public Tuple3 encryptData(byte[] data, String partnerCer return Tuples.of(CryptoUtil.encodeBase64Url(encryptedData.getT1()), CryptoUtil.encodeBase64Url(encryptedData.getT2()), digestAsPlainText(certificateThumbprint)); } - public byte[] encryptIdData(byte[] dataToEncrypt, String partnerCertificate) + public byte[] asymmetricEncryption(byte[] dataToEncrypt, String partnerCertificate) throws IdAuthenticationBusinessException { X509Certificate x509Certificate = getX509Certificate(partnerCertificate); PublicKey publicKey = x509Certificate.getPublicKey(); diff --git a/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/websub/impl/OndemandTemplateEventPublisher.java b/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/websub/impl/OndemandTemplateEventPublisher.java index 4dd00608ecd..ed7fe266122 100644 --- a/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/websub/impl/OndemandTemplateEventPublisher.java +++ b/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/websub/impl/OndemandTemplateEventPublisher.java @@ -100,27 +100,27 @@ public void publishEvent(EventModel eventModel) { webSubHelper.publishEvent(onDemadTemplateExtractionTopic, eventModel); } - public void notify(Object authrequestdto, String headerSignature, Optional partner, + public void notify(BaseRequestDTO baserequestdto, String headerSignature, Optional partner, IdAuthenticationBusinessException e, Map metadata) { try { - sendEvents(authrequestdto, headerSignature, partner, e, metadata); + sendEvents(baserequestdto, headerSignature, partner, e, metadata); } catch (Exception exception) { logger.error(IdRepoSecurityManager.getUser(), "On demand template extraction", "notify", exception.getMessage()); } } - private void sendEvents(Object authrequestdto, String headerSignature, Optional partner, + private void sendEvents(BaseRequestDTO baserequestdto, String headerSignature, Optional partner, IdAuthenticationBusinessException e, Map metadata) { logger.info("Inside sendEvents ondemand extraction"); Map eventData = new HashMap<>(); eventData.put(ERROR_CODE, e.getErrorCode()); eventData.put(ERROR_MESSAGE, e.getErrorText()); eventData.put(REQUESTDATETIME, DateUtils.formatToISOString(DateUtils.getUTCCurrentDateTime())); - eventData.put(INDIVIDUAL_ID, encryptIndividualId(((BaseRequestDTO) authrequestdto).getIndividualId(), + eventData.put(INDIVIDUAL_ID, encryptIndividualId(baserequestdto.getIndividualId(), metadata.get(IdAuthCommonConstants.PARTNER_CERTIFICATE).toString())); eventData.put(AUTH_PARTNER_ID, partner.get().getPartnerId()); - eventData.put(INDIVIDUAL_ID_TYPE, ((BaseRequestDTO) authrequestdto).getIndividualIdType()); + eventData.put(INDIVIDUAL_ID_TYPE, baserequestdto.getIndividualIdType()); eventData.put(ENTITY_NAME, partner.get().getPartnerName()); eventData.put(REQUEST_SIGNATURE, headerSignature); EventModel eventModel = createEventModel(onDemadTemplateExtractionTopic, eventData); @@ -144,7 +144,7 @@ private EventModel createEventModel(String topic, Map eventData) private byte[] encryptIndividualId(String id, String partnerCertificate) { try { - return securityManager.encryptIdData(id.getBytes(), partnerCertificate); + return securityManager.asymmetricEncryption(id.getBytes(), partnerCertificate); } catch (IdAuthenticationBusinessException e) { // TODO Auto-generated catch block e.printStackTrace();