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 7888c15c406..29dd07cd52a 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 @@ -111,17 +111,17 @@ public void publishEvent(EventModel eventModel) { webSubHelper.publishEvent(onDemadTemplateExtractionTopic, eventModel); } - public void notify(BaseRequestDTO baserequestdto, String apiresponsedate, String headerSignature, Optional partner, + public void notify(BaseRequestDTO baserequestdto, String headerSignature, Optional partner, IdAuthenticationBusinessException e, Map metadata) { try { - sendEvents(baserequestdto,apiresponsedate, 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(BaseRequestDTO baserequestdto, String apiresponsedate, String headerSignature, Optional partner, + private void sendEvents(BaseRequestDTO baserequestdto, String headerSignature, Optional partner, IdAuthenticationBusinessException e, Map metadata) { logger.info("Inside sendEvents ondemand extraction"); logger.info("Inside partner data to get certificate for ondemand extraction encryption"); @@ -132,7 +132,7 @@ private void sendEvents(BaseRequestDTO baserequestdto, String apiresponsedate, S Map eventData = new HashMap<>(); eventData.put(ERROR_CODE, e.getErrorCode()); eventData.put(ERROR_MESSAGE, e.getErrorText()); - eventData.put(REQUESTDATETIME, apiresponsedate); + eventData.put(REQUESTDATETIME, DateUtils.formatToISOString(DateUtils.getUTCCurrentDateTime())); eventData.put(INDIVIDUAL_ID, encryptIndividualId(baserequestdto.getIndividualId(), partnerDataCert.get().getCertificateData())); eventData.put(AUTH_PARTNER_ID, partner.get().getPartnerId()); diff --git a/authentication/authentication-otp-service/src/main/java/io/mosip/authentication/otp/service/controller/OTPController.java b/authentication/authentication-otp-service/src/main/java/io/mosip/authentication/otp/service/controller/OTPController.java index b3a9e75af09..f9baef81853 100644 --- a/authentication/authentication-otp-service/src/main/java/io/mosip/authentication/otp/service/controller/OTPController.java +++ b/authentication/authentication-otp-service/src/main/java/io/mosip/authentication/otp/service/controller/OTPController.java @@ -130,22 +130,21 @@ public OtpResponseDTO generateOTP(@Valid @RequestBody OtpRequestDTO otpRequestDt if(request instanceof ObjectWithMetadata) { ObjectWithMetadata requestWithMetadata = (ObjectWithMetadata) request; - OtpResponseDTO otpResponseDTO=null; boolean isPartnerReq = true; Optional partner = partnerService.getPartner(partnerId, otpRequestDto.getMetadata()); AuthTransactionBuilder authTxnBuilder = authTransactionHelper .createAndSetAuthTxnBuilderMetadataToRequest(otpRequestDto, !isPartnerReq, partner); try { - String idvidHash = securityManager.hash(otpRequestDto.getIndividualId()); String idType = Objects.nonNull(otpRequestDto.getIndividualIdType()) ? otpRequestDto.getIndividualIdType() : idTypeUtil.getIdType(otpRequestDto.getIndividualId()).getType(); logger.debug(IdAuthCommonConstants.SESSION_ID, this.getClass().getSimpleName(), GENERATE_OTP, "IdType...."+ idType); otpRequestDto.setIndividualIdType(idType); + String idvidHash = securityManager.hash(otpRequestDto.getIndividualId()); otpRequestValidator.validateIdvId(otpRequestDto.getIndividualId(), idType, errors, IdAuthCommonConstants.IDV_ID); DataValidationUtil.validate(errors); - otpResponseDTO = otpService.generateOtp(otpRequestDto, partnerId, requestWithMetadata); + OtpResponseDTO otpResponseDTO = otpService.generateOtp(otpRequestDto, partnerId, requestWithMetadata); logger.info(IdAuthCommonConstants.SESSION_ID, this.getClass().getSimpleName(), GENERATE_OTP, otpResponseDTO.getResponseTime()); @@ -164,7 +163,7 @@ public OtpResponseDTO generateOTP(@Valid @RequestBody OtpRequestDTO otpRequestDt } catch (IdAuthenticationBusinessException e) { logger.error(IdAuthCommonConstants.SESSION_ID, e.getClass().toString(), e.getErrorCode(), e.getErrorText()); if (IdAuthenticationErrorConstants.ID_NOT_AVAILABLE.getErrorCode().equals(e.getErrorCode())) { - ondemandTemplateEventPublisher.notify(otpRequestDto, otpResponseDTO.getResponseTime(), request.getHeader("signature"), partner, e, + ondemandTemplateEventPublisher.notify(otpRequestDto, request.getHeader("signature"), partner, e, otpRequestDto.getMetadata()); } auditHelper.audit(AuditModules.OTP_REQUEST, AuditEvents.OTP_TRIGGER_REQUEST_RESPONSE , otpRequestDto.getTransactionID(), diff --git a/authentication/authentication-service/src/main/java/io/mosip/authentication/service/controller/AuthController.java b/authentication/authentication-service/src/main/java/io/mosip/authentication/service/controller/AuthController.java index 765e2bc4d7e..a653e0917b0 100644 --- a/authentication/authentication-service/src/main/java/io/mosip/authentication/service/controller/AuthController.java +++ b/authentication/authentication-service/src/main/java/io/mosip/authentication/service/controller/AuthController.java @@ -131,7 +131,7 @@ public AuthResponseDTO authenticateIndividual(@Validated @RequestBody AuthReques if(request instanceof ObjectWithMetadata) { ObjectWithMetadata requestWithMetadata = (ObjectWithMetadata) request; - AuthResponseDTO authResponsedto = null; + boolean isAuth = true; Optional partner = partnerService.getPartner(partnerId, authrequestdto.getMetadata()); AuthTransactionBuilder authTxnBuilder = authTransactionHelper @@ -146,7 +146,7 @@ public AuthResponseDTO authenticateIndividual(@Validated @RequestBody AuthReques authRequestValidator.validateDeviceDetails(authrequestdto, errors); } DataValidationUtil.validate(errors); - authResponsedto = authFacade.authenticateIndividual(authrequestdto, true, partnerId, + AuthResponseDTO authResponsedto = authFacade.authenticateIndividual(authrequestdto, true, partnerId, partnerApiKey, IdAuthCommonConstants.CONSUME_VID_DEFAULT, requestWithMetadata); // Note: Auditing of success or failure status of each authentication (but not // the exception) is handled in respective authentication invocations in the facade @@ -163,7 +163,7 @@ public AuthResponseDTO authenticateIndividual(@Validated @RequestBody AuthReques mosipLogger.error(IdAuthCommonConstants.SESSION_ID, this.getClass().getSimpleName(), "authenticateApplication", e.getErrorCode() + " : " + e.getErrorText()); if (IdAuthenticationErrorConstants.ID_NOT_AVAILABLE.getErrorCode().equals(e.getErrorCode())) { - ondemandTemplateEventPublisher.notify(authrequestdto, authResponsedto.getResponseTime(), request.getHeader("signature"), partner, e, + ondemandTemplateEventPublisher.notify(authrequestdto, request.getHeader("signature"), partner, e, authrequestdto.getMetadata()); } auditHelper.auditExceptionForAuthRequestedModules(AuditEvents.AUTH_REQUEST_RESPONSE, authrequestdto, e); diff --git a/authentication/authentication-service/src/main/java/io/mosip/authentication/service/kyc/controller/KycAuthController.java b/authentication/authentication-service/src/main/java/io/mosip/authentication/service/kyc/controller/KycAuthController.java index 4cd342165af..eada0439155 100644 --- a/authentication/authentication-service/src/main/java/io/mosip/authentication/service/kyc/controller/KycAuthController.java +++ b/authentication/authentication-service/src/main/java/io/mosip/authentication/service/kyc/controller/KycAuthController.java @@ -160,7 +160,6 @@ public EKycAuthResponseDTO processKyc(@Validated @RequestBody EkycAuthRequestDTO if(request instanceof ObjectWithMetadata) { ObjectWithMetadata requestWrapperWithMetadata = (ObjectWithMetadata) request; - AuthResponseDTO authResponseDTO= null; boolean isAuth = true; Optional partner = partnerService.getPartner(partnerId, ekycAuthRequestDTO.getMetadata()); AuthTransactionBuilder authTxnBuilder = authTransactionHelper @@ -176,7 +175,7 @@ public EKycAuthResponseDTO processKyc(@Validated @RequestBody EkycAuthRequestDTO } DataValidationUtil.validate(errors); boolean externalAuthRequest = true; - authResponseDTO = kycFacade.authenticateIndividual(ekycAuthRequestDTO, externalAuthRequest, + AuthResponseDTO authResponseDTO = kycFacade.authenticateIndividual(ekycAuthRequestDTO, externalAuthRequest, partnerId, partnerApiKey, requestWrapperWithMetadata); EKycAuthResponseDTO kycAuthResponseDTO = new EKycAuthResponseDTO(); Map metadata = requestWrapperWithMetadata.getMetadata(); @@ -200,7 +199,7 @@ public EKycAuthResponseDTO processKyc(@Validated @RequestBody EkycAuthRequestDTO e.getErrorTexts().isEmpty() ? "" : e.getErrorText()); if (IdAuthenticationErrorConstants.ID_NOT_AVAILABLE.getErrorCode().equals(e.getErrorCode())) { - ondemandTemplateEventPublisher.notify(ekycAuthRequestDTO,authResponseDTO.getResponseTime(), request.getHeader("signature"), partner, + ondemandTemplateEventPublisher.notify(ekycAuthRequestDTO, request.getHeader("signature"), partner, e, ekycAuthRequestDTO.getMetadata()); } auditHelper.auditExceptionForAuthRequestedModules(AuditEvents.EKYC_REQUEST_RESPONSE, ekycAuthRequestDTO, e); @@ -247,7 +246,6 @@ public KycAuthResponseDTO processKycAuth(@Validated @RequestBody KycAuthRequestD Optional partner = partnerService.getPartner(partnerId, authRequestDTO.getMetadata()); AuthTransactionBuilder authTxnBuilder = authTransactionHelper .createAndSetAuthTxnBuilderMetadataToRequest(authRequestDTO, !isAuth, partner); - KycAuthResponseDTO kycAuthResponseDTO = new KycAuthResponseDTO(); try { String idType = Objects.nonNull(authRequestDTO.getIndividualIdType()) ? authRequestDTO.getIndividualIdType() : idTypeUtil.getIdType(authRequestDTO.getIndividualId()).getType(); @@ -260,6 +258,7 @@ public KycAuthResponseDTO processKycAuth(@Validated @RequestBody KycAuthRequestD boolean externalAuthRequest = true; AuthResponseDTO authResponseDTO = kycFacade.authenticateIndividual(authRequestDTO, externalAuthRequest, partnerId, oidcClientId, requestWrapperWithMetadata, IdAuthCommonConstants.KYC_AUTH_CONSUME_VID_DEFAULT); + KycAuthResponseDTO kycAuthResponseDTO = new KycAuthResponseDTO(); Map metadata = requestWrapperWithMetadata.getMetadata(); if (authResponseDTO != null && metadata != null && @@ -281,7 +280,7 @@ public KycAuthResponseDTO processKycAuth(@Validated @RequestBody KycAuthRequestD e.getErrorTexts().isEmpty() ? "" : e.getErrorText()); if (IdAuthenticationErrorConstants.ID_NOT_AVAILABLE.getErrorCode().equals(e.getErrorCode())) { - ondemandTemplateEventPublisher.notify(authRequestDTO, kycAuthResponseDTO.getResponseTime(), request.getHeader("signature"), partner, e, + ondemandTemplateEventPublisher.notify(authRequestDTO, request.getHeader("signature"), partner, e, authRequestDTO.getMetadata()); } auditHelper.auditExceptionForAuthRequestedModules(AuditEvents.KYC_REQUEST_RESPONSE, authRequestDTO, e);