From e51cb3d74ab6aa949115fc4c9d3c1032a8a55982 Mon Sep 17 00:00:00 2001 From: Venkata Saidurga Polamraju Date: Wed, 12 Jun 2024 12:50:10 +0530 Subject: [PATCH 1/4] [ES-1233] updated the authFactor from KBA to KBI Signed-off-by: Venkata Saidurga Polamraju --- .../mock/integration/dto/KycAuthRequestDto.java | 2 +- .../mock/integration/service/MockHelperService.java | 6 +++--- .../mock/identitysystem/dto/KycAuthRequestDto.java | 2 +- .../service/impl/AuthenticationServiceImpl.java | 12 ++++++------ .../src/main/resources/application-local.properties | 8 ++++---- .../service/impl/AuthenticationServiceImplTest.java | 12 ++++++------ 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/mock-esignet-integration-impl/src/main/java/io/mosip/esignet/mock/integration/dto/KycAuthRequestDto.java b/mock-esignet-integration-impl/src/main/java/io/mosip/esignet/mock/integration/dto/KycAuthRequestDto.java index 65d63850..b4b52c25 100644 --- a/mock-esignet-integration-impl/src/main/java/io/mosip/esignet/mock/integration/dto/KycAuthRequestDto.java +++ b/mock-esignet-integration-impl/src/main/java/io/mosip/esignet/mock/integration/dto/KycAuthRequestDto.java @@ -13,6 +13,6 @@ public class KycAuthRequestDto { private String otp; private String pin; private String biometrics; - private String kba; + private String kbi; private List tokens; } diff --git a/mock-esignet-integration-impl/src/main/java/io/mosip/esignet/mock/integration/service/MockHelperService.java b/mock-esignet-integration-impl/src/main/java/io/mosip/esignet/mock/integration/service/MockHelperService.java index 2ca4e53b..8e6e4a23 100644 --- a/mock-esignet-integration-impl/src/main/java/io/mosip/esignet/mock/integration/service/MockHelperService.java +++ b/mock-esignet-integration-impl/src/main/java/io/mosip/esignet/mock/integration/service/MockHelperService.java @@ -55,7 +55,7 @@ public class MockHelperService { supportedKycAuthFormats.put("PIN", List.of("number")); supportedKycAuthFormats.put("BIO", List.of("encoded-json")); supportedKycAuthFormats.put("WLA", List.of("jwt")); - supportedKycAuthFormats.put("KBA", List.of("base64url-encoded-json")); + supportedKycAuthFormats.put("KBI", List.of("base64url-encoded-json")); } @@ -140,8 +140,8 @@ public KycAuthResult doKycAuthMock(String relyingPartyId, String clientId, KycAu kycAuthRequestDto.setBiometrics(authChallenge.getChallenge()); } else if (Objects.equals(authChallenge.getAuthFactorType(), "WLA")) { kycAuthRequestDto.setTokens(List.of(authChallenge.getChallenge())); - } else if(Objects.equals(authChallenge.getAuthFactorType(),"KBA")){ - kycAuthRequestDto.setKba(authChallenge.getChallenge()); + } else if(Objects.equals(authChallenge.getAuthFactorType(),"kbi")){ + kycAuthRequestDto.setKbi(authChallenge.getChallenge()); } else { throw new KycAuthException("invalid_auth_challenge"); diff --git a/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/dto/KycAuthRequestDto.java b/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/dto/KycAuthRequestDto.java index 8e1fa31e..e6012da1 100644 --- a/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/dto/KycAuthRequestDto.java +++ b/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/dto/KycAuthRequestDto.java @@ -13,7 +13,7 @@ public class KycAuthRequestDto { private String otp; private String pin; private String biometrics; - private String kba; + private String kbi; private List tokens; } diff --git a/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/service/impl/AuthenticationServiceImpl.java b/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/service/impl/AuthenticationServiceImpl.java index 67ba095d..45877b5d 100644 --- a/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/service/impl/AuthenticationServiceImpl.java +++ b/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/service/impl/AuthenticationServiceImpl.java @@ -69,10 +69,10 @@ public class AuthenticationServiceImpl implements AuthenticationService { @Value("${mosip.esignet.mock.authenticator.ida.otp-channels}") private List otpChannels; - @Value("#{${mosip.esignet.authenticator.auth-factor.kba.field-details}}") + @Value("#{${mosip.esignet.authenticator.auth-factor.kbi.field-details}}") private List> fieldDetailList; - @Value("${mosip.esignet.authenticator.auth-factor.kba.field-language}") + @Value("${mosip.esignet.authenticator.auth-factor.kbi.field-language}") private String fieldLang; ArrayList trnHash = new ArrayList<>(); @@ -118,7 +118,7 @@ public KycAuthResponseDto kycAuth(String relyingPartyId, String clientId, KycAut authStatus = true; //TODO } - if(kycAuthRequestDto.getKba()!=null){ + if(kycAuthRequestDto.getKbi()!=null){ authStatus=validateKnowledgeBasedAuth(kycAuthRequestDto,identityData); } @@ -214,10 +214,10 @@ public SendOtpResult sendOtp(String relyingPartyId, String clientId, SendOtpDto private boolean validateKnowledgeBasedAuth(KycAuthRequestDto kycAuthRequestDto,IdentityData identityData){ if(CollectionUtils.isEmpty(fieldDetailList) || StringUtils.isEmpty(fieldLang)){ - log.error("KBA field details not configured"); + log.error("KBI field details not configured"); throw new MockIdentityException("auth-failed"); } - String encodedChallenge=kycAuthRequestDto.getKba(); + String encodedChallenge=kycAuthRequestDto.getKbi(); try{ byte[] decodedBytes = Base64.getUrlDecoder().decode(encodedChallenge); String challenge = new String(decodedBytes, StandardCharsets.UTF_8); @@ -238,7 +238,7 @@ private boolean validateKnowledgeBasedAuth(KycAuthRequestDto kycAuthRequestDto,I } } }catch (Exception e){ - log.error("Failed to decode KBA challenge or compare it with IdentityData", e); + log.error("Failed to decode KBI challenge or compare it with IdentityData", e); throw new MockIdentityException("auth-failed"); } return true; diff --git a/mock-identity-system/src/main/resources/application-local.properties b/mock-identity-system/src/main/resources/application-local.properties index d9dfcf39..1002bd00 100644 --- a/mock-identity-system/src/main/resources/application-local.properties +++ b/mock-identity-system/src/main/resources/application-local.properties @@ -66,7 +66,7 @@ crypto.PrependThumbprint.enable=true #Mock IDA integration props mosip.esignet.mock.authenticator.ida.otp-channels=email,phone -##---------------------------------KBA Configurations------------------------------------------------------ -#We can use any field from the IdentityData for KBA -mosip.esignet.authenticator.auth-factor.kba.field-details={{"id":"phone", "type":"text", "format":""},{"id":"email", "type":"text", "format":""},{"id":"dateOfBirth", "type":"date", "format":"yyyy-MM-dd"}} -mosip.esignet.authenticator.auth-factor.kba.field-language=eng \ No newline at end of file +##---------------------------------KBI Configurations------------------------------------------------------ +#We can use any field from the IdentityData for KBI +mosip.esignet.authenticator.auth-factor.kbi.field-details={{"id":"phone", "type":"text", "format":""},{"id":"email", "type":"text", "format":""},{"id":"dateOfBirth", "type":"date", "format":"yyyy-MM-dd"}} +mosip.esignet.authenticator.auth-factor.kbi.field-language=eng \ No newline at end of file diff --git a/mock-identity-system/src/test/java/io/mosip/esignet/mock/identitysystem/service/impl/AuthenticationServiceImplTest.java b/mock-identity-system/src/test/java/io/mosip/esignet/mock/identitysystem/service/impl/AuthenticationServiceImplTest.java index c02af1de..0405f20c 100644 --- a/mock-identity-system/src/test/java/io/mosip/esignet/mock/identitysystem/service/impl/AuthenticationServiceImplTest.java +++ b/mock-identity-system/src/test/java/io/mosip/esignet/mock/identitysystem/service/impl/AuthenticationServiceImplTest.java @@ -34,7 +34,7 @@ public class AuthenticationServiceImplTest { AuthenticationServiceImpl authenticationService; @Test - public void kycAuth_withValidKbaChallenge_thenPass() { + public void kycAuth_withValidKbiChallenge_thenPass() { List> fieldDetailList = List.of(Map.of("id","individualId","type","text","format","string") ,Map.of("id","fullName","type","text","format","") @@ -44,7 +44,7 @@ public void kycAuth_withValidKbaChallenge_thenPass() { ReflectionTestUtils.setField(authenticationService,"objectMapper",new ObjectMapper()); KycAuthRequestDto kycAuthRequestDto = new KycAuthRequestDto(); - kycAuthRequestDto.setKba("eyJmdWxsTmFtZSI6IlNpZGRoYXJ0aCBLIE1hbnNvdXIiLCJkYXRlT2ZCaXJ0aCI6IjE5ODctMTEtMjUifQ=="); + kycAuthRequestDto.setKbi("eyJmdWxsTmFtZSI6IlNpZGRoYXJ0aCBLIE1hbnNvdXIiLCJkYXRlT2ZCaXJ0aCI6IjE5ODctMTEtMjUifQ=="); kycAuthRequestDto.setIndividualId("individualId"); kycAuthRequestDto.setTransactionId("transactionId"); @@ -63,7 +63,7 @@ public void kycAuth_withValidKbaChallenge_thenPass() { } @Test - public void kycAuth_withInCorrectKbaChallenge_thenFail() { + public void kycAuth_withInCorrectKbiChallenge_thenFail() { List> fieldDetailList = List.of(Map.of("id","individualId","type","text","format","") ,Map.of("id","fullName","type","text","format","") @@ -72,7 +72,7 @@ public void kycAuth_withInCorrectKbaChallenge_thenFail() { ReflectionTestUtils.setField(authenticationService, "fieldLang", "eng"); ReflectionTestUtils.setField(authenticationService,"objectMapper",new ObjectMapper()); KycAuthRequestDto kycAuthRequestDto = new KycAuthRequestDto(); - kycAuthRequestDto.setKba("eyJmdWxsTmFtZSI6IlNpZGRoYXJ0aCBLIiwiZG9iIjoiMTk4Ny0xMS0yNSJ9"); + kycAuthRequestDto.setKbi("eyJmdWxsTmFtZSI6IlNpZGRoYXJ0aCBLIiwiZG9iIjoiMTk4Ny0xMS0yNSJ9"); kycAuthRequestDto.setIndividualId("individualId"); kycAuthRequestDto.setTransactionId("transactionId"); @@ -91,7 +91,7 @@ public void kycAuth_withInCorrectKbaChallenge_thenFail() { } @Test - public void kycAuth_withInValidKbaChallenge_thenFail() { + public void kycAuth_withInValidKbiChallenge_thenFail() { List> fieldDetailList = List.of(Map.of("id","individualId","type","text","format","") ,Map.of("id","fullName","type","text","format","") @@ -101,7 +101,7 @@ public void kycAuth_withInValidKbaChallenge_thenFail() { ReflectionTestUtils.setField(authenticationService,"objectMapper",new ObjectMapper()); KycAuthRequestDto kycAuthRequestDto = new KycAuthRequestDto(); - kycAuthRequestDto.setKba("xsTmFtZSI6IlNpZG0aCBLIiwiZG9iIjoiMTk4Ny0xMS0yNSJ9"); + kycAuthRequestDto.setKbi("xsTmFtZSI6IlNpZG0aCBLIiwiZG9iIjoiMTk4Ny0xMS0yNSJ9"); kycAuthRequestDto.setIndividualId("individualId"); kycAuthRequestDto.setTransactionId("transactionId"); From 5fdb17cb7ff296b1bcac919b468ad2b8fe2387e0 Mon Sep 17 00:00:00 2001 From: Venkata Saidurga Polamraju Date: Wed, 12 Jun 2024 12:55:39 +0530 Subject: [PATCH 2/4] [ES-1233] Signed-off-by: Venkata Saidurga Polamraju --- .../esignet/mock/integration/service/MockHelperService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mock-esignet-integration-impl/src/main/java/io/mosip/esignet/mock/integration/service/MockHelperService.java b/mock-esignet-integration-impl/src/main/java/io/mosip/esignet/mock/integration/service/MockHelperService.java index 8e6e4a23..d9659244 100644 --- a/mock-esignet-integration-impl/src/main/java/io/mosip/esignet/mock/integration/service/MockHelperService.java +++ b/mock-esignet-integration-impl/src/main/java/io/mosip/esignet/mock/integration/service/MockHelperService.java @@ -140,7 +140,7 @@ public KycAuthResult doKycAuthMock(String relyingPartyId, String clientId, KycAu kycAuthRequestDto.setBiometrics(authChallenge.getChallenge()); } else if (Objects.equals(authChallenge.getAuthFactorType(), "WLA")) { kycAuthRequestDto.setTokens(List.of(authChallenge.getChallenge())); - } else if(Objects.equals(authChallenge.getAuthFactorType(),"kbi")){ + } else if(Objects.equals(authChallenge.getAuthFactorType(),"KBI")){ kycAuthRequestDto.setKbi(authChallenge.getChallenge()); } else { From 44c04e0f42311d73fd4cc082f5bd53956907b681 Mon Sep 17 00:00:00 2001 From: pvsaidurga <132046494+pvsaidurga@users.noreply.github.com> Date: Mon, 24 Jun 2024 13:57:16 +0530 Subject: [PATCH 3/4] Update AuthenticationServiceImpl.java Signed-off-by: pvsaidurga <132046494+pvsaidurga@users.noreply.github.com> --- .../identitysystem/service/impl/AuthenticationServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/service/impl/AuthenticationServiceImpl.java b/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/service/impl/AuthenticationServiceImpl.java index 955626f9..e7dbaae1 100644 --- a/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/service/impl/AuthenticationServiceImpl.java +++ b/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/service/impl/AuthenticationServiceImpl.java @@ -266,7 +266,7 @@ private Boolean doKycAuthentication(KycAuthRequestDto kycAuthRequestDto,Identity authStatus = true; //TODO } - if(kycAuthRequestDto.getKba()!=null){ + if(kycAuthRequestDto.getKbi()!=null){ authStatus=validateKnowledgeBasedAuth(kycAuthRequestDto,identityData); } From 0fe2d4f8c2fa9f91fa63835447ab672b181cc930 Mon Sep 17 00:00:00 2001 From: pvsaidurga <132046494+pvsaidurga@users.noreply.github.com> Date: Mon, 24 Jun 2024 17:15:13 +0530 Subject: [PATCH 4/4] Update AuthenticationServiceImplTest.java Signed-off-by: pvsaidurga <132046494+pvsaidurga@users.noreply.github.com> --- .../service/impl/AuthenticationServiceImplTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mock-identity-system/src/test/java/io/mosip/esignet/mock/identitysystem/service/impl/AuthenticationServiceImplTest.java b/mock-identity-system/src/test/java/io/mosip/esignet/mock/identitysystem/service/impl/AuthenticationServiceImplTest.java index 3302811e..9f0246f9 100644 --- a/mock-identity-system/src/test/java/io/mosip/esignet/mock/identitysystem/service/impl/AuthenticationServiceImplTest.java +++ b/mock-identity-system/src/test/java/io/mosip/esignet/mock/identitysystem/service/impl/AuthenticationServiceImplTest.java @@ -123,7 +123,7 @@ public void kycAuth_withInValidKbiChallenge_thenFail() { } @Test - public void kycAuth2_withValidKbaChallenge_thenPass() throws Exception { + public void kycAuth2_withValidKbiChallenge_thenPass() throws Exception { List> fieldDetailList = List.of(Map.of("id","individualId","type","text","format","string") ,Map.of("id","fullName","type","text","format","") @@ -143,7 +143,7 @@ public void kycAuth2_withValidKbaChallenge_thenPass() throws Exception { ReflectionTestUtils.setField(authenticationService,"objectMapper",new ObjectMapper()); KycAuthRequestDto kycAuthRequestDto = new KycAuthRequestDto(); - kycAuthRequestDto.setKba("eyJmdWxsTmFtZSI6IlNpZGRoYXJ0aCBLIE1hbnNvdXIiLCJkYXRlT2ZCaXJ0aCI6IjE5ODctMTEtMjUifQ=="); + kycAuthRequestDto.setKbi("eyJmdWxsTmFtZSI6IlNpZGRoYXJ0aCBLIE1hbnNvdXIiLCJkYXRlT2ZCaXJ0aCI6IjE5ODctMTEtMjUifQ=="); kycAuthRequestDto.setIndividualId("individualId"); kycAuthRequestDto.setTransactionId("transactionId"); @@ -204,7 +204,7 @@ public void kycAuth2_withValidKbaChallenge_thenPass() throws Exception { @Test - public void kycAuth2_withValidKbaChallenge_and_withOutVerifiedClaim_thenPass() throws Exception { + public void kycAuth2_withValidKbiChallenge_and_withOutVerifiedClaim_thenPass() throws Exception { List> fieldDetailList = List.of(Map.of("id","individualId","type","text","format","string") ,Map.of("id","fullName","type","text","format","") @@ -224,7 +224,7 @@ public void kycAuth2_withValidKbaChallenge_and_withOutVerifiedClaim_thenPass() t ReflectionTestUtils.setField(authenticationService,"objectMapper",new ObjectMapper()); KycAuthRequestDto kycAuthRequestDto = new KycAuthRequestDto(); - kycAuthRequestDto.setKba("eyJmdWxsTmFtZSI6IlNpZGRoYXJ0aCBLIE1hbnNvdXIiLCJkYXRlT2ZCaXJ0aCI6IjE5ODctMTEtMjUifQ=="); + kycAuthRequestDto.setKbi("eyJmdWxsTmFtZSI6IlNpZGRoYXJ0aCBLIE1hbnNvdXIiLCJkYXRlT2ZCaXJ0aCI6IjE5ODctMTEtMjUifQ=="); kycAuthRequestDto.setIndividualId("individualId"); kycAuthRequestDto.setTransactionId("transactionId");