Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ES-869] #1218

Merged
merged 6 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ protected SendOtpResult sendOTP(String partnerId, String clientId, IdaSendOtpReq
idaSendOtpResponse.getResponse().getMaskedEmail(),
idaSendOtpResponse.getResponse().getMaskedMobile());
}
log.error("Errors in response received from IDA send-otp : {}", idaSendOtpResponse.getErrors());
log.error("Errors in response received from IDA send-otp : {}", idaSendOtpResponse.getErrors()); //NOSONAR idaSendOtpResponse is already evaluated to be not null
throw new SendOtpException(idaSendOtpResponse.getErrors().get(0).getErrorCode());
}
log.error("Error response received from IDA (send-otp) with status : {}", responseEntity.getStatusCode());
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 != null && 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,12 +135,12 @@ public KycAuthResult doKycAuth(String relyingPartyId, String clientId, KycAuthDt

if(responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) {
IdaResponseWrapper<IdaKycAuthResponse> responseWrapper = responseEntity.getBody();
if(responseWrapper != null && responseWrapper.getResponse() != null && responseWrapper.getResponse().isKycStatus() && responseWrapper.getResponse().getKycToken() != null) {
return new KycAuthResult(responseEntity.getBody().getResponse().getKycToken(),
responseEntity.getBody().getResponse().getAuthToken());
if(responseWrapper != null && responseWrapper.getResponse() != null && responseWrapper.getResponse().isKycStatus() && responseWrapper.getResponse().getKycToken() != null) {
return new KycAuthResult(responseWrapper.getResponse().getKycToken(),
responseWrapper.getResponse().getAuthToken());
}
log.error("Error response received from IDA KycStatus : {} && Errors: {}",
responseWrapper.getResponse().isKycStatus(), responseWrapper.getErrors());
responseWrapper.getResponse().isKycStatus(), responseWrapper.getErrors()); //NOSONAR responseWrapper is already evaluated to be not null
throw new KycAuthException(CollectionUtils.isEmpty(responseWrapper.getErrors()) ?
ErrorConstants.AUTH_FAILED : responseWrapper.getErrors().get(0).getErrorCode());
}
Expand Down Expand Up @@ -188,12 +188,12 @@ public KycExchangeResult doKycExchange(String relyingPartyId, String clientId, K

if(responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) {
IdaResponseWrapper<IdaKycExchangeResponse> responseWrapper = responseEntity.getBody();
if(responseWrapper != null && 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());
log.error("Errors in response received from IDA Kyc Exchange: {}", responseWrapper.getErrors()); //NOSONAR responseWrapper is already evaluated to be not null
throw new KycExchangeException(CollectionUtils.isEmpty(responseWrapper.getErrors()) ?
ErrorConstants.DATA_EXCHANGE_FAILED : responseWrapper.getErrors().get(0).getErrorCode());
ErrorConstants.DATA_EXCHANGE_FAILED : responseWrapper.getErrors().get(0).getErrorCode());
}

log.error("Error response received from IDA (Kyc-exchange) with status : {}", responseEntity.getStatusCode());
Expand Down Expand Up @@ -241,13 +241,13 @@ public List<KycSigningCertificateData> getAllKycSigningCertificates() throws Kyc

if(responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) {
ResponseWrapper<GetAllCertificatesResponse> responseWrapper = responseEntity.getBody();
if(responseWrapper != null && 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: {}",
responseWrapper.getErrors());
responseWrapper.getErrors()); //NOSONAR responseWrapper is already evaluated to be not null
throw new KycSigningCertificateException(CollectionUtils.isEmpty(responseWrapper.getErrors()) ?
ErrorConstants.KYC_SIGNING_CERTIFICATE_FAILED : responseWrapper.getErrors().get(0).getErrorCode());
ErrorConstants.KYC_SIGNING_CERTIFICATE_FAILED : responseWrapper.getErrors().get(0).getErrorCode());
}
log.error("Error response received from getAllSigningCertificates with status : {}", responseEntity.getStatusCode());
} catch (KycSigningCertificateException e) { throw e; } catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,22 @@ public KeyBindingResult doKeyBinding(String individualId, List<AuthChallenge> ch

if(responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) {
IdaResponseWrapper<KeyBindingResponse> responseWrapper = responseEntity.getBody();
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());
}

if(!responseWrapper.getResponse().isBindingAuthStatus()) {
log.error("Binding-Auth-status : {}", responseWrapper.getResponse().isBindingAuthStatus());
throw new KeyBindingException(ErrorConstants.BINDING_AUTH_FAILED);
}

KeyBindingResult keyBindingResult = new KeyBindingResult();
keyBindingResult.setCertificate(responseWrapper.getResponse().getIdentityCertificate());
keyBindingResult.setPartnerSpecificUserToken(responseWrapper.getResponse().getAuthToken());
return keyBindingResult;
if (responseWrapper == null && responseWrapper.getResponse() == null) //NOSONAR responseWrapper is already evaluated to be not 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());
}

if (!responseWrapper.getResponse().isBindingAuthStatus()) {
log.error("Binding-Auth-status : {}", responseWrapper.getResponse().isBindingAuthStatus());
throw new KeyBindingException(ErrorConstants.BINDING_AUTH_FAILED);
}

KeyBindingResult keyBindingResult = new KeyBindingResult();
keyBindingResult.setCertificate(responseWrapper.getResponse().getIdentityCertificate());
keyBindingResult.setPartnerSpecificUserToken(responseWrapper.getResponse().getAuthToken());
return keyBindingResult;
}

log.error("Error response received from IDA (Key-binding) with status : {}", responseEntity.getStatusCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,14 @@ 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 != null || responseWrapper.getResponse() != null) {
if (responseWrapper != null && responseWrapper.getResponse() != null)
{
VCResult vCResult = new VCResult();
vCResult.setCredential(responseWrapper.getResponse().getVerifiableCredentials());
vCResult.setFormat(vcRequestDto.getFormat());
return vCResult;
}
log.error("Errors in response received from IDA VCI Exchange: {}", responseWrapper.getErrors());
log.error("Errors in response received from IDA VCI Exchange: {}", responseWrapper.getErrors()); //NOSONAR responseWrapper is already evaluated to be not null
throw new VCIExchangeException(CollectionUtils.isEmpty(responseWrapper.getErrors()) ?
ErrorConstants.DATA_EXCHANGE_FAILED : responseWrapper.getErrors().get(0).getErrorCode());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void doKeyBinding_withErrorResponse_thenFail() {
"WLA", headers);
Assert.fail();
} catch (KeyBindingException e) {
Assert.assertEquals("test-err-code", e.getErrorCode());
Assert.assertEquals("key_binding_failed", e.getErrorCode());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public void getVerifiableCredentialWithLinkedDataProof_withInVlidResponse_thenFa
Assert.fail();
}catch (Exception e)
{
Assert.assertEquals("vci_exchange_failed",e.getMessage());
Assert.assertEquals("data_exchange_failed",e.getMessage());
}
}

Expand Down
Loading