diff --git a/MockMDS/src/main/java/io/mosip/mock/sbi/devicehelper/SBIDeviceHelper.java b/MockMDS/src/main/java/io/mosip/mock/sbi/devicehelper/SBIDeviceHelper.java index afd4f590..297a9d21 100644 --- a/MockMDS/src/main/java/io/mosip/mock/sbi/devicehelper/SBIDeviceHelper.java +++ b/MockMDS/src/main/java/io/mosip/mock/sbi/devicehelper/SBIDeviceHelper.java @@ -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() + "/"); diff --git a/MockMDS/src/main/java/io/mosip/mock/sbi/service/SBIServiceResponse.java b/MockMDS/src/main/java/io/mosip/mock/sbi/service/SBIServiceResponse.java index 3fc29342..acb6508c 100644 --- a/MockMDS/src/main/java/io/mosip/mock/sbi/service/SBIServiceResponse.java +++ b/MockMDS/src/main/java/io/mosip/mock/sbi/service/SBIServiceResponse.java @@ -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; @@ -1318,24 +1319,32 @@ else if (captureTimeOut) } else { - List biometrics = getBioMetricsDtoList (lang, requestObject, deviceHelper, deviceSubId, true); - if (biometrics != null && biometrics.size() > 0) + List 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); } @@ -1377,7 +1386,7 @@ else if (captureTimeOut) return response; } - private List getBioMetricsDtoList (String lang, CaptureRequestDto requestObject, SBIDeviceHelper deviceHelper, int deviceSubId, boolean isForAuthenication) throws JsonGenerationException, JsonMappingException, IOException, NoSuchAlgorithmException, DecoderException + private List getBioMetricsDtoList (String lang, CaptureRequestDto requestObject, SBIDeviceHelper deviceHelper, int deviceSubId, boolean isForAuthenication) throws JsonGenerationException, JsonMappingException, IOException, NoSuchAlgorithmException, DecoderException, SBIException { List biometrics = new ArrayList (); String specVersion = requestObject.getSpecVersion(); @@ -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(); @@ -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); } } diff --git a/MockMDS/src/main/java/org/biometric/provider/JwtUtility.java b/MockMDS/src/main/java/org/biometric/provider/JwtUtility.java index a0c59060..db8ad7ad 100644 --- a/MockMDS/src/main/java/org/biometric/provider/JwtUtility.java +++ b/MockMDS/src/main/java/org/biometric/provider/JwtUtility.java @@ -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"), @@ -199,6 +199,7 @@ public String getCertificateFromIDA() { } catch (IOException | JSONException e) { e.printStackTrace(); + throw e; } return null; } diff --git a/mock-sdk/src/main/java/io/mosip/mock/sdk/service/MatchService.java b/mock-sdk/src/main/java/io/mosip/mock/sdk/service/MatchService.java index 73391169..a21653fc 100644 --- a/mock-sdk/src/main/java/io/mosip/mock/sdk/service/MatchService.java +++ b/mock-sdk/src/main/java/io/mosip/mock/sdk/service/MatchService.java @@ -2,6 +2,7 @@ import java.security.NoSuchAlgorithmException; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -9,6 +10,7 @@ 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; @@ -383,23 +385,17 @@ private Decision compareFaces(List sampleSegments, List 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()); @@ -408,21 +404,7 @@ private Decision compareFaces(List sampleSegments, List 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());