Skip to content

Commit

Permalink
MOSIP-29978, MOSIP-30342, ES-480
Browse files Browse the repository at this point in the history
  • Loading branch information
JanardhanBS-SyncByte committed Nov 21, 2023
1 parent d702c0a commit c68b31b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ protected DeviceInfo getDeviceInfo(String deviceType, String deviceSubType, Digi
deviceInfo = objectMapper.readValue(new File(fileName), DeviceInfo.class);
if (deviceInfo != null)
{
deviceInfo.setDigitalId(getUnsignedDigitalId (digitalId, false));
deviceInfo.setDigitalId(getUnsignedDigitalId (digitalId, true));
deviceInfo.setDeviceStatus(getDeviceStatus());
deviceInfo.setPurpose(getPurpose ());
deviceInfo.setCallbackId("http://" + ApplicationPropertyHelper.getPropertyKeyValue(SBIConstant.SERVER_ADDRESS) + ":" + getPort() + "/");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import io.mosip.mock.sbi.devicehelper.iris.monocular.SBIIrisSingleBioExceptionInfo;
import io.mosip.mock.sbi.devicehelper.iris.monocular.SBIIrisSingleCaptureInfo;
import io.mosip.mock.sbi.devicehelper.iris.monocular.SBIIrisSingleHelper;
import io.mosip.mock.sbi.exception.SBIException;
import io.mosip.mock.sbi.util.ApplicationPropertyHelper;
import io.mosip.mock.sbi.util.StringHelper;
import io.mosip.registration.mdm.dto.BioMetricsDataDto;
Expand Down Expand Up @@ -1318,24 +1319,32 @@ else if (captureTimeOut)
}
else
{
List<BioMetricsDto> biometrics = getBioMetricsDtoList (lang, requestObject, deviceHelper, deviceSubId, true);
if (biometrics != null && biometrics.size() > 0)
List<BioMetricsDto> biometrics = null;
try
{
RCaptureResponse captureResponse = new RCaptureResponse ();
captureResponse.setBiometrics(biometrics);

ObjectMapper mapper = new ObjectMapper ();
SerializationConfig config = mapper.getSerializationConfig();
config.setSerializationInclusion(Inclusion.NON_NULL);
mapper.setSerializationConfig(config);

response = mapper.writeValueAsString(captureResponse);
}
else
biometrics = getBioMetricsDtoList (lang, requestObject, deviceHelper, deviceSubId, true);
if (biometrics != null && biometrics.size() > 0)
{
RCaptureResponse captureResponse = new RCaptureResponse ();
captureResponse.setBiometrics(biometrics);

ObjectMapper mapper = new ObjectMapper ();
SerializationConfig config = mapper.getSerializationConfig();
config.setSerializationInclusion(Inclusion.NON_NULL);
mapper.setSerializationConfig(config);

response = mapper.writeValueAsString(captureResponse);
}
else
{
response = SBIJsonInfo.getCaptureErrorJson (specVersion, lang, "708", "", false);
}
}
catch (Exception ex)
{
response = SBIJsonInfo.getCaptureErrorJson (specVersion, lang, "708", "", false);
response = SBIJsonInfo.getCaptureErrorJson (specVersion, lang, "999", ex.getLocalizedMessage(), false);
}

deviceHelper.deInitDevice();
deviceHelper.setDeviceStatus(SBIConstant.DEVICE_STATUS_ISREADY);
}
Expand Down Expand Up @@ -1377,7 +1386,7 @@ else if (captureTimeOut)
return response;
}

private List<BioMetricsDto> getBioMetricsDtoList (String lang, CaptureRequestDto requestObject, SBIDeviceHelper deviceHelper, int deviceSubId, boolean isForAuthenication) throws JsonGenerationException, JsonMappingException, IOException, NoSuchAlgorithmException, DecoderException
private List<BioMetricsDto> getBioMetricsDtoList (String lang, CaptureRequestDto requestObject, SBIDeviceHelper deviceHelper, int deviceSubId, boolean isForAuthenication) throws JsonGenerationException, JsonMappingException, IOException, NoSuchAlgorithmException, DecoderException, SBIException
{
List<BioMetricsDto> biometrics = new ArrayList<BioMetricsDto> ();
String specVersion = requestObject.getSpecVersion();
Expand Down Expand Up @@ -2196,7 +2205,7 @@ else if (deviceHelper.getDigitalId().getType().equalsIgnoreCase(SBIConstant.MOSI

private BioMetricsDto getBiometricData (String transactionId, CaptureRequestDto requestObject, SBIDeviceHelper deviceHelper,
String previousHash, String bioType, String bioSubType, String bioValue,
int qualityScore, int qualityRequestScore, String lang, String errorCode, boolean isUsedForAuthenication) throws JsonGenerationException, JsonMappingException, IOException, NoSuchAlgorithmException, DecoderException
int qualityScore, int qualityRequestScore, String lang, String errorCode, boolean isUsedForAuthenication) throws SBIException, JsonGenerationException, JsonMappingException, IOException, DecoderException, NoSuchAlgorithmException
{
DeviceInfo deviceInfo = deviceHelper.getDeviceInfo();

Expand Down Expand Up @@ -2236,12 +2245,11 @@ private BioMetricsDto getBiometricData (String transactionId, CaptureRequestDto
cryptoResult.get("ENC_DATA") : null);
biometric.setSessionKey(cryptoResult.get("ENC_SESSION_KEY"));
String thumbPrint = toHex (JwtUtility.getCertificateThumbprint(certificate)).replace ("-", "").toUpperCase();
//System.out.println("ThumbPrint>>" + thumbPrint);
biometric.setThumbprint(thumbPrint);
} catch (Exception ex) {
LOGGER.error("getBiometricData :: encrypt :: ", ex);
// TODO Auto-generated catch block
ex.printStackTrace();
LOGGER.error("getBiometricData :: encrypt :: ", ex);
throw new SBIException("IDA Biometric encryption Certificate not found", "IDA Biometric encryption Certificate not found", ex);
}
}

Expand Down
3 changes: 2 additions & 1 deletion MockMDS/src/main/java/org/biometric/provider/JwtUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public static byte[] getCertificateThumbprint(Certificate cert) throws Certifica
return DigestUtils.sha256(cert.getEncoded());
}

public String getCertificateFromIDA() {
public String getCertificateFromIDA() throws Exception {
OkHttpClient client = new OkHttpClient();
String requestBody = String.format(AUTH_REQ_TEMPLATE,
getPropertyValue("mosip.auth.appid"),
Expand Down Expand Up @@ -199,6 +199,7 @@ public String getCertificateFromIDA() {

} catch (IOException | JSONException e) {
e.printStackTrace();
throw e;
}
return null;
}
Expand Down
34 changes: 8 additions & 26 deletions mock-sdk/src/main/java/io/mosip/mock/sdk/service/MatchService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import org.springframework.util.CollectionUtils;

import io.mosip.kernel.biometrics.constant.BiometricType;
import io.mosip.kernel.biometrics.constant.Match;
Expand Down Expand Up @@ -383,23 +385,17 @@ private Decision compareFaces(List<BIR> sampleSegments, List<BIR> gallerySegment
break;

Boolean bio_found = false;
LOGGER.info("SampleBIR Value check",sampleBIR.getBdbInfo().getSubtype());
if (sampleBIR.getBdbInfo().getSubtype() != null && !sampleBIR.getBdbInfo().getSubtype().isEmpty()
&& sampleBIR.getBdbInfo().getSubtype().get(0) != null
&& !sampleBIR.getBdbInfo().getSubtype().get(0).isEmpty()) {
if (!CollectionUtils.isEmpty(sampleBIR.getBdbInfo().getType())
&& sampleBIR.getBdbInfo().getType().get(0).equals(BiometricType.FACE)) {
LOGGER.info("SampleBIR Value check", sampleBIR.getBdbInfo().getSubtype());
for (BIR galleryBIR : gallerySegments) {
// need to check isValidBIRParams and isValidBDBData too
// if (!isValidBirData(galleryBIR))
// break;
LOGGER.info("GalleryBIR Value check",galleryBIR.getBdbInfo().getSubtype());
if (galleryBIR.getBdbInfo().getSubtype() == null || galleryBIR.getBdbInfo().getSubtype().isEmpty() || galleryBIR.getBdbInfo().getSubtype().get(0)
.equals(sampleBIR.getBdbInfo().getSubtype().get(0))) {
if (!CollectionUtils.isEmpty(galleryBIR.getBdbInfo().getType())
&& galleryBIR.getBdbInfo().getType().get(0).equals(BiometricType.FACE)) {
if (Util.compareHash(galleryBIR.getBdb(), sampleBIR.getBdb())) {
LOGGER.info("Modality: {}; Subtype: {} -- matched", BiometricType.FACE.value(),
galleryBIR.getBdbInfo().getSubtype());
matched.add(true);
bio_found = true;
break;
} else {
LOGGER.info("Modality: {}; Subtype: {} -- not matched", BiometricType.FACE.value(),
galleryBIR.getBdbInfo().getSubtype());
Expand All @@ -408,21 +404,7 @@ private Decision compareFaces(List<BIR> sampleSegments, List<BIR> gallerySegment
}
}
}
} else {
for (BIR galleryBIR : gallerySegments) {
if (Util.compareHash(galleryBIR.getBdb(), sampleBIR.getBdb())) {
LOGGER.info("Modality: {}; Subtype: {} -- matched", BiometricType.FACE.value(),
galleryBIR.getBdbInfo().getSubtype());
matched.add(true);
bio_found = true;
} else {
LOGGER.info("Modality: {}; Subtype: {} -- not matched", BiometricType.FACE.value(),
galleryBIR.getBdbInfo().getSubtype());
matched.add(false);
bio_found = true;
}
}
}
}
if (!bio_found) {
LOGGER.info("Modality: {}; Subtype: {} -- not found", BiometricType.FACE.value(),
sampleBIR.getBdbInfo().getSubtype());
Expand Down

0 comments on commit c68b31b

Please sign in to comment.