From d367b28269bd9dd97d9d4afdca9926759da40514 Mon Sep 17 00:00:00 2001 From: pvsaidurga <132046494+pvsaidurga@users.noreply.github.com> Date: Tue, 12 Mar 2024 13:45:12 +0530 Subject: [PATCH] [ES-869] (#1215) * [ES-869] Signed-off-by: Venkata Saidurga Polamraju * reviewed changes Signed-off-by: Venkata Saidurga Polamraju * reviewed changes Signed-off-by: Venkata Saidurga Polamraju --------- Signed-off-by: Venkata Saidurga Polamraju --- .../service/websub/impl/OndemandTemplateEventPublisher.java | 4 ++-- .../esignet/integration/service/HelperService.java | 3 ++- .../esignet/integration/service/IdaAuditPluginImpl.java | 2 +- .../esignet/integration/service/IdaAuthenticatorImpl.java | 6 +++--- .../esignet/integration/service/IdaKeyBinderImpl.java | 2 +- .../integration/service/IdaVCIssuancePluginImpl.java | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) 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 10f7454bb19..4bc0178c3bc 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 @@ -135,9 +135,9 @@ private void sendEvents(BaseRequestDTO baserequestdto, String headerSignature, O 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()); + eventData.put(AUTH_PARTNER_ID, partner.map(PartnerDTO::getPartnerId).orElse(null)); eventData.put(INDIVIDUAL_ID_TYPE, baserequestdto.getIndividualIdType()); - eventData.put(ENTITY_NAME, partner.get().getPartnerName()); + eventData.put(ENTITY_NAME, partner.map(PartnerDTO::getPartnerName).orElse(null)); eventData.put(REQUEST_SIGNATURE, headerSignature); EventModel eventModel = createEventModel(onDemadTemplateExtractionTopic, eventData); publishEvent(eventModel); diff --git a/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/HelperService.java b/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/HelperService.java index 5a95185da93..6d6daa1a033 100644 --- a/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/HelperService.java +++ b/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/HelperService.java @@ -160,7 +160,8 @@ protected SendOtpResult sendOTP(String partnerId, String clientId, IdaSendOtpReq ResponseEntity responseEntity = restTemplate.exchange(requestEntity, IdaSendOtpResponse.class); if(responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) { IdaSendOtpResponse idaSendOtpResponse = responseEntity.getBody(); - if(idaSendOtpRequest.getTransactionID().equals(idaSendOtpResponse.getTransactionID()) && idaSendOtpResponse.getResponse() != null){ + if (idaSendOtpResponse != null && idaSendOtpRequest.getTransactionID().equals(idaSendOtpResponse.getTransactionID()) && + idaSendOtpResponse.getResponse() != null) { return new SendOtpResult(idaSendOtpResponse.getTransactionID(), idaSendOtpResponse.getResponse().getMaskedEmail(), idaSendOtpResponse.getResponse().getMaskedMobile()); diff --git a/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaAuditPluginImpl.java b/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaAuditPluginImpl.java index 8eb043021c4..f3b45acee45 100644 --- a/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaAuditPluginImpl.java +++ b/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaAuditPluginImpl.java @@ -104,7 +104,7 @@ private void audit(String username, Action action, ActionStatus status, AuditDTO if (responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) { ResponseWrapper responseWrapper = responseEntity.getBody(); - if (responseWrapper.getErrors() != null && !responseWrapper.getErrors().isEmpty()) { + if (responseWrapper != null && responseWrapper.getErrors() != null && !responseWrapper.getErrors().isEmpty()) { log.error("Error response received from audit service with errors: {}", responseWrapper.getErrors()); } diff --git a/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaAuthenticatorImpl.java b/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaAuthenticatorImpl.java index 0b6597853d2..cf59cc43efe 100644 --- a/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaAuthenticatorImpl.java +++ b/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaAuthenticatorImpl.java @@ -135,7 +135,7 @@ public KycAuthResult doKycAuth(String relyingPartyId, String clientId, KycAuthDt if(responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) { IdaResponseWrapper responseWrapper = responseEntity.getBody(); - if(responseWrapper.getResponse() != null && responseWrapper.getResponse().isKycStatus() && responseWrapper.getResponse().getKycToken() != null) { + if(responseWrapper != null && responseWrapper.getResponse() != null && responseWrapper.getResponse().isKycStatus() && responseWrapper.getResponse().getKycToken() != null) { return new KycAuthResult(responseEntity.getBody().getResponse().getKycToken(), responseEntity.getBody().getResponse().getAuthToken()); } @@ -188,7 +188,7 @@ public KycExchangeResult doKycExchange(String relyingPartyId, String clientId, K if(responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) { IdaResponseWrapper responseWrapper = responseEntity.getBody(); - if(responseWrapper.getResponse() != null && responseWrapper.getResponse().getEncryptedKyc() != null) { + if(responseWrapper != null && responseWrapper.getResponse() != null && responseWrapper.getResponse().getEncryptedKyc() != null) { return new KycExchangeResult(responseWrapper.getResponse().getEncryptedKyc()); } log.error("Errors in response received from IDA Kyc Exchange: {}", responseWrapper.getErrors()); @@ -241,7 +241,7 @@ public List getAllKycSigningCertificates() throws Kyc if(responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) { ResponseWrapper responseWrapper = responseEntity.getBody(); - if(responseWrapper.getResponse() != null && responseWrapper.getResponse().getAllCertificates() != null) { + if(responseWrapper != null && responseWrapper.getResponse() != null && responseWrapper.getResponse().getAllCertificates() != null) { return responseWrapper.getResponse().getAllCertificates(); } log.error("Error response received from getAllSigningCertificates with errors: {}", diff --git a/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaKeyBinderImpl.java b/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaKeyBinderImpl.java index 2848be4f3cb..0a762c2517b 100644 --- a/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaKeyBinderImpl.java +++ b/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaKeyBinderImpl.java @@ -142,7 +142,7 @@ public KeyBindingResult doKeyBinding(String individualId, List ch if(responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) { IdaResponseWrapper responseWrapper = responseEntity.getBody(); - if(responseWrapper.getResponse() == null) { + if(responseWrapper == null || responseWrapper.getResponse() == null) { log.error("Error response received from IDA (Key-binding) Errors: {}", responseWrapper.getErrors()); throw new KeyBindingException(CollectionUtils.isEmpty(responseWrapper.getErrors()) ? ErrorConstants.KEY_BINDING_FAILED : responseWrapper.getErrors().get(0).getErrorCode()); diff --git a/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaVCIssuancePluginImpl.java b/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaVCIssuancePluginImpl.java index 90f4fbe82e4..cfcdb655385 100644 --- a/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaVCIssuancePluginImpl.java +++ b/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaVCIssuancePluginImpl.java @@ -132,7 +132,7 @@ public VCResult getVerifiableCredentialWithLinkedDataProof(VCReque requestEntity, new ParameterizedTypeReference>>() {}); if (responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) { IdaResponseWrapper> responseWrapper = responseEntity.getBody(); - if (responseWrapper.getResponse() != null) { + if (responseWrapper != null || responseWrapper.getResponse() != null) { VCResult vCResult = new VCResult(); vCResult.setCredential(responseWrapper.getResponse().getVerifiableCredentials()); vCResult.setFormat(vcRequestDto.getFormat());