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 3 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 @@ -160,8 +160,9 @@ 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 (idaSendOtpResponse != null && idaSendOtpRequest.getTransactionID().equals(idaSendOtpResponse.getTransactionID()) &&
idaSendOtpResponse.getResponse() != null) {
if (idaSendOtpRequest.getTransactionID().equals(idaSendOtpResponse.getTransactionID()) &&
idaSendOtpResponse.getResponse() != null) //NOSONAR idaSendOtpResponse is already evaluated to be not 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,8 @@ 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.getErrors() != null && !responseWrapper.getErrors().isEmpty()) //NOSONAR responseWrapper is already evaluated to be not null
{
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,14 +135,15 @@ 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.getResponse() != null && responseWrapper.getResponse().isKycStatus() && responseWrapper.getResponse().getKycToken() != null) //NOSONAR responseWrapper is already evaluated to be not null
{
return new KycAuthResult(responseWrapper.getResponse().getKycToken(),
responseWrapper.getResponse().getAuthToken()); //NOSONAR responseWrapper is already evaluated to be not null
}
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());
ErrorConstants.AUTH_FAILED : responseWrapper.getErrors().get(0).getErrorCode());
}

log.error("Error response received from IDA (Kyc-auth) with status : {}", responseEntity.getStatusCode());
Expand Down Expand Up @@ -188,12 +189,13 @@ 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.getResponse() != null && responseWrapper.getResponse().getEncryptedKyc() != null) //NOSONAR responseWrapper is already evaluated to be not null
{
return new KycExchangeResult(responseWrapper.getResponse().getEncryptedKyc());
}
log.error("Errors in response received from IDA Kyc Exchange: {}", responseWrapper.getErrors());
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 +243,14 @@ 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.getResponse() != null && responseWrapper.getResponse().getAllCertificates() != null) //NOSONAR responseWrapper is already evaluated to be not null
{
return responseWrapper.getResponse().getAllCertificates();
}
log.error("Error response received from getAllSigningCertificates with errors: {}",
responseWrapper.getErrors());
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.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,7 +132,8 @@ 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.getResponse() != null) //NOSONAR responseWrapper is already evaluated to be not null
{
VCResult vCResult = new VCResult();
vCResult.setCredential(responseWrapper.getResponse().getVerifiableCredentials());
vCResult.setFormat(vcRequestDto.getFormat());
Expand Down