Skip to content

Commit

Permalink
Merge pull request #1057 from mahammedtaheer/release-1.2.0.1
Browse files Browse the repository at this point in the history
[MOSIP-28622] fixed firstname, lastname not populating in e-signet issue.
  • Loading branch information
vishwa-vyom authored Jul 31, 2023
2 parents e899246 + 50f576f commit dc07b68
Showing 1 changed file with 74 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public class KycServiceImpl implements KycService {
@Value("${ida.idp.consented.address.attribute.name:address}")
private String consentedAddressAttributeName;

@Value("${ida.idp.consented.name.attribute.name:name}")
private String consentedNameAttributeName;

@Value("${ida.idp.consented.individual_id.attribute.name:individual_id}")
private String consentedIndividualAttributeName;

Expand Down Expand Up @@ -534,6 +537,9 @@ private void addEntityForLangCodes(Map<String, String> mappedConsentedLocales, M
}
}
} else {
if (consentedAttribute.equals(consentedNameAttributeName)) {
addNameClaim(mappedConsentedLocales, idInfo, respMap, consentedAttribute, idSchemaAttributes);
}
if (consentedAttribute.equals(consentedAddressAttributeName)) {
if (mappedConsentedLocales.size() > 1) {
for (String consentedLocale: mappedConsentedLocales.keySet()) {
Expand Down Expand Up @@ -589,12 +595,14 @@ private void addFormattedAddress(List<String> idSchemaAttributes, Map<String, Li
}
}
} else {
if (Objects.nonNull(idInfoList) && idInfoList.size() == 1) {
if (Objects.nonNull(idInfoList) && idInfoList.size() == 1 && langCodeFound) {
identityInfoValue.append(idInfoList.get(0).getValue());
}
}
}
}
if (identityInfoValue.toString().trim().length() == 0)
return;
//String identityInfoValueStr = identityInfoValue.toString();
//String trimmedValue = identityInfoValueStr.substring(0, identityInfoValueStr.lastIndexOf(addressValueSeparator));
addressMap.put(IdAuthCommonConstants.ADDRESS_FORMATTED + localeAppendValue, identityInfoValue.toString());
Expand Down Expand Up @@ -629,7 +637,7 @@ private void addAddressClaim(String[] addressAttributes, Map<String, List<Identi
}
}
} else {
if (Objects.nonNull(idInfoList) && idInfoList.size() == 1) {
if (Objects.nonNull(idInfoList) && idInfoList.size() == 1 && langCodeFound) {
identityInfoValue.append(idInfoList.get(0).getValue());
}
}
Expand All @@ -638,12 +646,76 @@ private void addAddressClaim(String[] addressAttributes, Map<String, List<Identi
if (identityInfoValue.toString().trim().length() > 0)
addressMap.put(addressAttribute + localeAppendValue, identityInfoValue.toString());
}
if (addressMap.size() == 0)
return;

if (langCodeFound && addLocale)
respMap.put(consentedAddressAttributeName + localeAppendValue, addressMap);
else
respMap.put(consentedAddressAttributeName, addressMap);
}

private void addNameClaim(Map<String, String> mappedConsentedLocales, Map<String, List<IdentityInfoDTO>> idInfo,
Map<String, Object> respMap, String consentedAttribute, List<String> idSchemaAttributes) throws IdAuthenticationBusinessException{
if(mappedConsentedLocales.size() > 1) {
for (String consentedLocale: mappedConsentedLocales.keySet()) {
String consentedLocaleValue = mappedConsentedLocales.get(consentedLocale);
StringBuilder nameBuffer = new StringBuilder();
for (String idSchemaAttribute : idSchemaAttributes) {
List<IdentityInfoDTO> idInfoList = idInfo.get(idSchemaAttribute);

if (Objects.isNull(idInfoList)) {
mosipLogger.info(IdAuthCommonConstants.SESSION_ID, this.getClass().getSimpleName(), "addEntityForLangCodes",
"Data not available in Identity Info for the claim. So not adding to response claims. Claim Name: " + idSchemaAttribute);
continue;
}
if (nameBuffer.length() > 0) {
nameBuffer.append(" ");
}
Map<String, String> mappedLangCodes = langCodeMapping(idInfoList);
if (!mappedLangCodes.keySet().contains(consentedLocaleValue)) {
break;
}
for (IdentityInfoDTO identityInfo : idInfoList) {
String langCode = mappedLangCodes.get(consentedLocaleValue);
if (identityInfo.getLanguage().equalsIgnoreCase(langCode)) {
nameBuffer.append(identityInfo.getValue());
}
}
}
if (nameBuffer.toString().trim().length() > 0)
respMap.put(consentedAttribute + IdAuthCommonConstants.CLAIMS_LANG_SEPERATOR + consentedLocaleValue, nameBuffer.toString());
}
} else {
StringBuilder nameBuffer = new StringBuilder();
for (String idSchemaAttribute : idSchemaAttributes) {
List<IdentityInfoDTO> idInfoList = idInfo.get(idSchemaAttribute);

if (Objects.isNull(idInfoList)) {
mosipLogger.info(IdAuthCommonConstants.SESSION_ID, this.getClass().getSimpleName(), "addEntityForLangCodes",
"Data not available in Identity Info for the claim. So not adding to response claims. Claim Name: " + idSchemaAttribute);
continue;
}
if (nameBuffer.length() > 0) {
nameBuffer.append(" ");
}
Map<String, String> mappedLangCodes = langCodeMapping(idInfoList);
List<String> availableLangCodes = getAvailableLangCodes(mappedConsentedLocales, mappedLangCodes);
if (availableLangCodes.size() == 0) {
continue;
}
for (IdentityInfoDTO identityInfo : idInfoList) {
String langCode = mappedLangCodes.get(availableLangCodes.get(0));
if (identityInfo.getLanguage().equalsIgnoreCase(langCode)) {
nameBuffer.append(identityInfo.getValue());
}
}
}
if (nameBuffer.toString().trim().length() > 0)
respMap.put(consentedAttribute, nameBuffer.toString());
}
}

private String convertJP2ToJpeg(String jp2Image) {
try {
ConvertRequestDto convertRequestDto = new ConvertRequestDto();
Expand Down

0 comments on commit dc07b68

Please sign in to comment.