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

Added support for user info response type [ES-2164] #88

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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 @@ -20,4 +20,5 @@ public class KycExchangeRequestDto {
private String individualId;
private List<String> acceptedClaims;
private List<String> claimLocales;
private String respType;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not have the field "respType" in the mock-identity-system. Are you planning to introduce v3 version of kyc-exchange?
Refs -> https://github.com/mosip/esignet-mock-services/blob/develop/mock-identity-system/src/main/java/io/mosip/esignet/mock/identitysystem/dto/KycExchangeRequestDto.java

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ public class VerifiedKycExchangeRequestDto{
private Map<String,Object> acceptedClaims;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private List<String> claimLocales;
private Map<String, JsonNode> acceptedClaimDetail;
private String respType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public KycExchangeResult doKycExchange(String relyingPartyId, String clientId, K
kycExchangeRequestDto.setIndividualId(kycExchangeDto.getIndividualId());
kycExchangeRequestDto.setAcceptedClaims(kycExchangeDto.getAcceptedClaims());
kycExchangeRequestDto.setClaimLocales(convertLangCodesToISO3LanguageCodes(kycExchangeDto.getClaimsLocales()));
kycExchangeRequestDto.setRespType(kycExchangeDto.getUserInfoResponseType());

String requestBody = objectMapper.writeValueAsString(kycExchangeRequestDto);
RequestEntity requestEntity = RequestEntity
Expand Down Expand Up @@ -194,6 +195,7 @@ private VerifiedKycExchangeRequestDto buildVerifiedKycExchangeRequestDto(Verifie
verifiedKycExchangeRequestDto.setIndividualId(verifiedKycExchangeDto.getIndividualId());
verifiedKycExchangeRequestDto.setClaimLocales(Arrays.asList(verifiedKycExchangeDto.getClaimsLocales()));
verifiedKycExchangeRequestDto.setAcceptedClaimDetail(verifiedKycExchangeDto.getAcceptedClaimDetails());
verifiedKycExchangeRequestDto.setRespType(verifiedKycExchangeRequestDto.getRespType());
return verifiedKycExchangeRequestDto;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ public class SunbirdRCAuthenticationService implements Authenticator {
@Value("${mosip.esignet.authenticator.sunbird-rc.kbi.entity-id-field}")
private String entityIdField;

@Value("${mosip.esignet.authenticator.sunbird-rc.kyc.encrypt:false}")
private boolean encryptKyc;

@Value("${mosip.esignet.authenticator.sunbird-rc.registry-get-url}")
private String registryUrl;

Expand Down Expand Up @@ -157,7 +154,9 @@ public KycExchangeResult doKycExchange(String relyingPartyId, String clientId, K
Map<String, Object> kyc = buildKycDataBasedOnPolicy(responseRegistryMap,
kycExchangeDto.getAcceptedClaims(), kycExchangeDto.getClaimsLocales());
kyc.put("sub", kycExchangeDto.getIndividualId());
String finalKyc = this.encryptKyc ? getJWE(relyingPartyId, signKyc(kyc)) : signKyc(kyc);
String finalKyc;
String userInfoResponseType = kycExchangeDto.getUserInfoResponseType();
finalKyc = "JWE".equals(userInfoResponseType) ? getJWE(relyingPartyId, signKyc(kyc)) : signKyc(kyc);
KycExchangeResult kycExchangeResult = new KycExchangeResult();
kycExchangeResult.setEncryptedKyc(finalKyc);
return kycExchangeResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,13 @@ public void doKycAuthWithOutChallenge_thenFail() {
public void doKycExchangeWithValidParams_thenPass() throws KycExchangeException, JsonProcessingException {
Map<String,String> oidcClaimsMapping= Map.of("name","name","email","email","phone","mobile","address","address");
ReflectionTestUtils.setField(sunbirdRCAuthenticationService, "oidcClaimsMapping", oidcClaimsMapping);
ReflectionTestUtils.setField(sunbirdRCAuthenticationService, "encryptKyc", false);
String relyingPartyId = "relyingPartyId";
String clientId = "clientId";
KycExchangeDto kycExchangeDto = new KycExchangeDto();
kycExchangeDto.setKycToken("kyc-token");
kycExchangeDto.setAcceptedClaims(Arrays.asList("name", "address"));
kycExchangeDto.setClaimsLocales(new String[]{"en"});
kycExchangeDto.setUserInfoResponseType("JWS");

Map<String, Object> registryData = new HashMap<>();
registryData.put("name", "John");
Expand Down Expand Up @@ -322,13 +322,13 @@ public void doKycExchangeWithNullRegistryData_thenFail() {
public void doKycExchangeWithEncryptKycAsTrue_throwKycExchangeException_thenFail() throws JsonProcessingException {
Map<String,String> oidcClaimsMapping= Map.of("name","name","email","email","phone","mobile","address","address");
ReflectionTestUtils.setField(sunbirdRCAuthenticationService, "oidcClaimsMapping", oidcClaimsMapping);
ReflectionTestUtils.setField(sunbirdRCAuthenticationService, "encryptKyc", true);
String relyingPartyId = "relyingPartyId";
String clientId = "clientId";
KycExchangeDto kycExchangeDto = new KycExchangeDto();
kycExchangeDto.setKycToken("kyc-token");
kycExchangeDto.setAcceptedClaims(Arrays.asList("name", "address"));
kycExchangeDto.setClaimsLocales(new String[]{"en"});
kycExchangeDto.setUserInfoResponseType("JWE");

Map<String, Object> registryData = new HashMap<>();
registryData.put("name", "John");
Expand Down
Loading