Skip to content

Commit

Permalink
Merge pull request #92 from JanardhanBS-SyncByte/1.1.5.5
Browse files Browse the repository at this point in the history
MOSIP-30301
  • Loading branch information
vishwa-vyom authored Nov 17, 2023
2 parents 4508ef6 + fdc9f9f commit 274e871
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,20 @@ public Object extractTemplate(RequestDto request) {
extractTemplateRequestDto.getModalitiesToExtract(),
extractTemplateRequestDto.getFlags()
);
if(!validateExtractTemplateResponse(response))
{
StringBuilder info = new StringBuilder();
info.append("*********************************************************\n");
info.append("\nRequest \t\t:: " + request.getRequest());
info.append("\nResponse Code \t\t:: " + response.getStatusCode());
info.append("\nResponse Status\t\t:: " + response.getStatusMessage());
info.append("\nResponse \t\t:: " + response.getResponse());
info.append("\n*********************************************************\n");
logger.info(LOGGER_SESSIONID, LOGGER_IDTYPE, "extractTemplate: Invalid Info :: ", info.toString());
response.setStatusCode(ResponseStatus.UNKNOWN_ERROR.getStatusCode());
response.setStatusMessage("Extract Template validation failed on response from sdk");

}
logResponse(response);
} catch (Throwable e){
e.printStackTrace();
Expand Down Expand Up @@ -239,7 +253,21 @@ private void logBiometricRecord(BiometricRecord biometricRecord) {
logger.debug(Utils.toString(biometricRecord));
}
}

private boolean validateExtractTemplateResponse(Response<?> response)
{
//Validation
if (response != null && response.getResponse() != null)
{
BiometricRecord biometricRecord = (BiometricRecord)response.getResponse();
//Should have Valid BIR Segments
List<BIR> segments = biometricRecord.getSegments();
if (segments == null || (segments != null && segments.size() == 0))
return false;
return true;
}
return false;
}

private String decode(String data){
try {
return Utils.base64Decode(data);
Expand Down

0 comments on commit 274e871

Please sign in to comment.