Skip to content

Commit

Permalink
Merge pull request #310 from JanardhanBS-SyncByte/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
gsasikumar authored Nov 22, 2023
2 parents f6e6a18 + 32092eb commit e70e2ce
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 57 deletions.
2 changes: 1 addition & 1 deletion MockMDS/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -383,4 +383,4 @@
</plugins>
</build>

</project>
</project>
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
2 changes: 1 addition & 1 deletion mock-mv/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,4 @@
</plugins>
</build>

</project>
</project>
12 changes: 6 additions & 6 deletions mock-sdk-jpeg-extractor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<artifactId>mock-sdk-jpeg-extractor</artifactId>
<groupId>io.mosip.mock.sdk</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.0.1-B1-SNAPSHOT</version>
<name>mock-sdk-jpeg-extractor</name>
<description>Sample implementation of biometrics SDK-containing jpeg extraction</description>
<packaging>jar</packaging>
Expand Down Expand Up @@ -75,14 +75,14 @@
<maven.assembly.version>3.3.0</maven.assembly.version>
<maven-shade-plugin.version>2.3</maven-shade-plugin.version>

<kernel.biometricsdk.version>1.2.1-SNAPSHOT</kernel.biometricsdk.version>
<mosip.mock.version>1.2.1-SNAPSHOT</mosip.mock.version>
<mosip.bioutil.version>1.2.1-SNAPSHOT</mosip.bioutil.version>
<kernel.biometricsdk.version>1.2.0.1-B1</kernel.biometricsdk.version>
<mosip.mock.version>1.2.0.1-B1-SNAPSHOT</mosip.mock.version>
<mosip.bioutil.version>1.2.0.1-B1-SNAPSHOT</mosip.bioutil.version>
<maven.jar.plugin.version>3.0.2</maven.jar.plugin.version>
<spring.boot.version>2.0.2.RELEASE</spring.boot.version>
<lombok.version>1.18.8</lombok.version>
<lombok.version>1.18.8</lombok.version>
<jacoco.maven.plugin.version>0.8.5</jacoco.maven.plugin.version>
<logging.slf4j.version>1.7.25</logging.slf4j.version>
<logging.slf4j.version>1.7.25</logging.slf4j.version>

</properties>

Expand Down
2 changes: 1 addition & 1 deletion mock-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.mosip</groupId>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-bio-converter</artifactId>
<version>${kernel.bioconverter.version}</version>
<classifier>lib</classifier>
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 e70e2ce

Please sign in to comment.