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

[MOSIP-31102] Validation of values for Type, Status, Env, Purpose #320

Merged
merged 1 commit into from
Jan 11, 2024
Merged
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 @@ -937,11 +937,11 @@ else if (purpose != null && purpose.trim().length() > 0 && !(purpose.equals(SBIC
int bioSubtypeCount = (bioSubtype != null ? bioSubtype.length : 0);
int finalCount = count + exceptionCount;

if (!isValidBioSubtypeValues(bioType, bioSubtype))
if (bioSubtypeCount != 0 && !isValidBioSubtypeValues(bioType, bioSubtype, false))
{
return SBIJsonInfo.getCaptureErrorJson (specVersion, lang, "122", "", true);
}
if (!isValidBioExceptionValues(bioType, bioException))
if (exceptionCount != 0 && !isValidBioExceptionValues(bioType, bioException))
{
return SBIJsonInfo.getCaptureErrorJson (specVersion, lang, "122", "", true);
}
Expand Down Expand Up @@ -1254,6 +1254,10 @@ else if (purpose != null && purpose.trim().length() > 0 && !(purpose.equals(SBIC
int requestScore = Integer.parseInt(mosipBioRequest.get(0).getRequestedScore() + "");
int bioCount = Integer.parseInt(mosipBioRequest.get(0).getCount() + "");

if (!isValidBioSubtypeValues(bioType, bioSubType, true))
{
return SBIJsonInfo.getCaptureErrorJson (specVersion, lang, "122", "", true);
}
if (deviceType != null)
{
if ((bioCount < 0 || bioCount > 10) && deviceType.equals(SBIConstant.MOSIP_BIOMETRIC_TYPE_FINGER))
Expand Down Expand Up @@ -2614,17 +2618,17 @@ private void delay(long millseconds)
private boolean isValidBioExceptionValues(String bioType, String[] bioExceptions) {
if (bioExceptions != null)
{
if (bioType.equals(SBIConstant.MOSIP_BIOMETRIC_TYPE_FINGER))
if (bioType.equals(SBIConstant.MOSIP_BIOMETRIC_TYPE_FINGER))
return bioExceptionsListFinger.containsAll(Arrays.asList(bioExceptions));
else if (bioType.equals(SBIConstant.MOSIP_BIOMETRIC_TYPE_IRIS))
return bioExceptionsListIris.containsAll(Arrays.asList(bioExceptions));
else if (bioType.equals(SBIConstant.MOSIP_BIOMETRIC_TYPE_FACE))
return true;
}
return false;
return true;
}

private boolean isValidBioSubtypeValues(String bioType, String[] bioSubtypes) {
private boolean isValidBioSubtypeValues(String bioType, String[] bioSubtypes, boolean isCapture) {
if (bioSubtypes != null)
{
if (bioType.equals(SBIConstant.MOSIP_BIOMETRIC_TYPE_FINGER))
Expand All @@ -2634,6 +2638,9 @@ else if (bioType.equals(SBIConstant.MOSIP_BIOMETRIC_TYPE_IRIS))
else if (bioType.equals(SBIConstant.MOSIP_BIOMETRIC_TYPE_FACE))
return true;
}
return false;
if (isCapture)
return false;
else
return true;
}
}
Loading