Skip to content

Commit

Permalink
Merge pull request mosip#1773 from sowmya695/MOSIP-29399_release
Browse files Browse the repository at this point in the history
MOSIP-29399 code fix
  • Loading branch information
vishwa-vyom committed Sep 13, 2023
2 parents b9cd259 + 17bc0ec commit 05e3b26
Showing 1 changed file with 26 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,15 @@ private String getUUID() {
}

private String getDataShareUrl(String id, String process) throws Exception {
Map<String, List<String>> typeAndSubtypMap = createTypeSubtypeMapping();
Map<String, List<String>> policyTypeAndSubTypeMap = createTypeSubtypeMapping();
List<String> modalities = new ArrayList<>();
for (Map.Entry<String, List<String>> entry : typeAndSubtypMap.entrySet()) {
List<String> policyTypeAndSubTypeList = new ArrayList<>();
modalities.addAll(policyTypeAndSubTypeMap.keySet());
for (Map.Entry<String, List<String>> entry : policyTypeAndSubTypeMap.entrySet()) {
if (entry.getValue() == null) {
modalities.add(entry.getKey());
policyTypeAndSubTypeList.add(entry.getKey());
} else {
modalities.addAll(entry.getValue());
policyTypeAndSubTypeList.addAll(entry.getValue());
}
}
JSONObject regProcessorIdentityJson = utility
Expand All @@ -590,19 +592,20 @@ private String getDataShareUrl(String id, String process) throws Exception {
JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.INDIVIDUAL_BIOMETRICS),
MappingJsonConstants.VALUE);
BiometricRecord biometricRecord = priorityBasedPacketManagerService.getBiometrics(id, individualBiometricsLabel,
modalities, process, ProviderStageName.BIO_DEDUPE);
policyTypeAndSubTypeList, process, ProviderStageName.BIO_DEDUPE);

Map<String, String> tags = packetManagerService.getAllTags(id);
String ageGroup = tags.get("AGE_GROUP");
Map<String, List<String>> biometricModalitySegmentsMap;
Map<String, List<String>> ageGroupModalitySegmentMap;
if(biometricModalitySegmentsMapforAgeGroup.containsKey(ageGroup)){
biometricModalitySegmentsMap = biometricModalitySegmentsMapforAgeGroup.get(ageGroup);
ageGroupModalitySegmentMap = biometricModalitySegmentsMapforAgeGroup.get(ageGroup);
}
else {
biometricModalitySegmentsMap = biometricModalitySegmentsMapforAgeGroup.get("DEFAULT");
ageGroupModalitySegmentMap = biometricModalitySegmentsMapforAgeGroup.get("DEFAULT");
}
validateBiometricRecord(biometricRecord, modalities, biometricModalitySegmentsMap,
priorityBasedPacketManagerService.getMetaInfo(id, process, ProviderStageName.BIO_DEDUPE));
validateBiometricRecord(biometricRecord, modalities, ageGroupModalitySegmentMap,
priorityBasedPacketManagerService.getMetaInfo(id, process, ProviderStageName.BIO_DEDUPE),
policyTypeAndSubTypeMap);

byte[] content = cbeffutil.createXML(filterExceptionBiometrics(biometricRecord,id,process).getSegments());

Expand Down Expand Up @@ -640,7 +643,8 @@ public String getFilename() {

@SuppressWarnings("deprecation")
private void validateBiometricRecord(BiometricRecord biometricRecord, List<String> modalities,
Map<String, List<String>> biometricModalitySegmentsMap, Map<String, String> metaInfoMap)
Map<String, List<String>> ageGroupModalitySegmentMap, Map<String, String> metaInfoMap,
Map<String, List<String>> policyTypeAndSubTypeMap)
throws DataShareException, JsonParseException, JsonMappingException, IOException {
if (modalities == null || modalities.isEmpty()) {
throw new DataShareException("Data Share Policy Modalities were Empty");
Expand All @@ -660,11 +664,18 @@ private void validateBiometricRecord(BiometricRecord biometricRecord, List<Strin
exceptionList = metaInfoExceptionBiometrics.get("applicant").keySet();
}
boolean isBioFound = false;
for (String biometricSegment : biometricModalitySegmentsMap.keySet()) {
if (!modalities.contains(biometricSegment)) {
throw new DataShareException("Biometrics Segments Not Configured for modality : " + biometricSegment);
for (String biometricModality : ageGroupModalitySegmentMap.keySet()) {
if (!modalities.contains(biometricModality)) {
throw new DataShareException(
"Modalities not Configured as per policy for modality : " + biometricModality);
}
for (String segment : biometricModalitySegmentsMap.get(biometricSegment)) {
List<String> policySegmentList = policyTypeAndSubTypeMap.get(biometricModality);
for (String segment : ageGroupModalitySegmentMap.get(biometricModality)) {
if (policySegmentList != null
&& !policySegmentList.contains(segment)) {
throw new DataShareException(
"Biometrics Segments Not Configured as per policy for modality : " + biometricModality);
}
Optional<BIR> optionalBIR = Optional.empty();
if (segment.equalsIgnoreCase("Face")) {
optionalBIR = biometricRecord.getSegments().stream()
Expand Down

0 comments on commit 05e3b26

Please sign in to comment.