Skip to content

Commit c7ad841

Browse files
authored
Merge pull request mosip#147 from ase-101/1.3.3
DSD-8637
2 parents 1a84202 + ad1aee4 commit c7ad841

File tree

1 file changed

+4
-45
lines changed

1 file changed

+4
-45
lines changed

mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/service/IdaAuthenticatorImpl.java

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -105,49 +105,7 @@ public class IdaAuthenticatorImpl implements Authenticator {
105105
@Override
106106
public KycAuthResult doKycAuth(String relyingPartyId, String clientId, KycAuthDto kycAuthDto)
107107
throws KycAuthException {
108-
log.info("Started to build kyc-auth request with transactionId : {} && clientId : {}",
109-
kycAuthDto.getTransactionId(), clientId);
110-
try {
111-
IdaKycAuthRequest idaKycAuthRequest = new IdaKycAuthRequest();
112-
idaKycAuthRequest.setId(kycAuthId);
113-
idaKycAuthRequest.setVersion(idaVersion);
114-
idaKycAuthRequest.setRequestTime(HelperService.getUTCDateTime());
115-
idaKycAuthRequest.setDomainUri(idaDomainUri);
116-
idaKycAuthRequest.setEnv(idaEnv);
117-
idaKycAuthRequest.setConsentObtained(true);
118-
idaKycAuthRequest.setIndividualId(kycAuthDto.getIndividualId());
119-
idaKycAuthRequest.setTransactionID(kycAuthDto.getTransactionId());
120-
helperService.setAuthRequest(kycAuthDto.getChallengeList(), idaKycAuthRequest);
121-
122-
//set signature header, body and invoke kyc auth endpoint
123-
String requestBody = objectMapper.writeValueAsString(idaKycAuthRequest);
124-
RequestEntity requestEntity = RequestEntity
125-
.post(UriComponentsBuilder.fromUriString(kycAuthUrl).pathSegment(relyingPartyId, clientId).build().toUri())
126-
.contentType(MediaType.APPLICATION_JSON_UTF8)
127-
.header(SIGNATURE_HEADER_NAME, helperService.getRequestSignature(requestBody))
128-
.header(AUTHORIZATION_HEADER_NAME, AUTHORIZATION_HEADER_NAME)
129-
.body(requestBody);
130-
ResponseEntity<IdaResponseWrapper<IdaKycAuthResponse>> responseEntity = restTemplate.exchange(requestEntity,
131-
new ParameterizedTypeReference<IdaResponseWrapper<IdaKycAuthResponse>>() {});
132-
133-
if(responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) {
134-
IdaResponseWrapper<IdaKycAuthResponse> responseWrapper = responseEntity.getBody();
135-
if(responseWrapper!=null && responseWrapper.getResponse() != null && responseWrapper.getResponse().isKycStatus() && responseWrapper.getResponse().getKycToken() != null) {
136-
return new KycAuthResult(responseWrapper.getResponse().getKycToken(),
137-
responseWrapper.getResponse().getAuthToken());
138-
}
139-
log.error("Error response received from IDA KycStatus : {} && Errors: {}",
140-
responseWrapper.getResponse().isKycStatus(), responseWrapper.getErrors());
141-
throw new KycAuthException(CollectionUtils.isEmpty(responseWrapper.getErrors()) ?
142-
ErrorConstants.AUTH_FAILED : responseWrapper.getErrors().get(0).getErrorCode());
143-
}
144-
145-
log.error("Error response received from IDA (Kyc-auth) with status : {}", responseEntity.getStatusCode());
146-
} catch (KycAuthException e) { throw e; } catch (Exception e) {
147-
log.error("KYC-auth failed with transactionId : {} && clientId : {}", kycAuthDto.getTransactionId(),
148-
clientId, e);
149-
}
150-
throw new KycAuthException(ErrorConstants.AUTH_FAILED);
108+
return doKycAuthentication(relyingPartyId, clientId, kycAuthDto, false);
151109
}
152110

153111
@Override
@@ -289,8 +247,9 @@ public List<KycSigningCertificateData> getAllKycSigningCertificates() throws Kyc
289247
}
290248

291249
@Override
292-
public KycAuthResult doKycAuth(String relyingPartyId, String clientId, boolean claimsMetadataRequired, KycAuthDto kycAuthDto) throws KycAuthException {
293-
return doKycAuth(relyingPartyId, clientId, kycAuthDto); //TODO
250+
public KycAuthResult doKycAuth(String relyingPartyId, String clientId, boolean claimsMetadataRequired,
251+
KycAuthDto kycAuthDto) throws KycAuthException {
252+
return doKycAuthentication(relyingPartyId, clientId, kycAuthDto, claimsMetadataRequired);
294253
}
295254

296255
/**

0 commit comments

Comments
 (0)