Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/mosip/id-authentication
Browse files Browse the repository at this point in the history
…into MOSIP-30293-getting-auth-token-value-in-response-even-if-authentication-fails
  • Loading branch information
Neha Farheen committed Mar 14, 2024
2 parents a7076ae + d367b28 commit fe417ff
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ protected SendOtpResult sendOTP(String partnerId, String clientId, IdaSendOtpReq
ResponseEntity<IdaSendOtpResponse> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private void audit(String username, Action action, ActionStatus status, AuditDTO

if (responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) {
ResponseWrapper<AuditResponse> 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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public KycAuthResult doKycAuth(String relyingPartyId, String clientId, KycAuthDt

if(responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) {
IdaResponseWrapper<IdaKycAuthResponse> 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());
}
Expand Down Expand Up @@ -188,7 +188,7 @@ public KycExchangeResult doKycExchange(String relyingPartyId, String clientId, K

if(responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) {
IdaResponseWrapper<IdaKycExchangeResponse> 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());
Expand Down Expand Up @@ -241,7 +241,7 @@ public List<KycSigningCertificateData> getAllKycSigningCertificates() throws Kyc

if(responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) {
ResponseWrapper<GetAllCertificatesResponse> 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: {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public KeyBindingResult doKeyBinding(String individualId, List<AuthChallenge> ch

if(responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) {
IdaResponseWrapper<KeyBindingResponse> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public VCResult<JsonLDObject> getVerifiableCredentialWithLinkedDataProof(VCReque
requestEntity, new ParameterizedTypeReference<IdaResponseWrapper<IdaVcExchangeResponse<JsonLDObject>>>() {});
if (responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) {
IdaResponseWrapper<IdaVcExchangeResponse<JsonLDObject>> 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());
Expand Down

0 comments on commit fe417ff

Please sign in to comment.