Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
/**
Converts the {@link UserBiometric} and {@link BiometricsDto} to {@link BiometricRecord} and
{@link BiometricRecord array} respectively and calls the match method of Match-SDK library
to get the response of the decisions whether {@link Match MATCHED or NOT_MATCHED}
@param biometricType {@link BiometricType}
@param userBiometrics {@link UserBiometric}
@param biometricsDto {@link BiometricsDto}
@param iBioApiV2 {@link IBioApiV2}
@return boolean value matched or not based on the match result flag Match.MATCHED or Match.NOT_MATCHED.
*/

    private static boolean matchBiometrics(BiometricType biometricType, List<UserBiometric> userBiometrics, List<BiometricsDto> biometricsDto, IBioApiV2 iBioApiV2) {
        Map<String, List<BIR>> birMap = new HashMap<>();

        for (UserBiometric userBiometric : userBiometrics) {
            String userId = userBiometric.getUsrId();
            birMap.computeIfAbsent(userId, k -> new ArrayList<>())
                    .add(buildBir(userBiometric.getBioAttributeCode(),
                     userBiometric.getQualityScore(), userBiometric.getBioTemplate(), biometricType, ProcessedLevelType.PROCESSED, true));
        }

        List<BIR> birList = new ArrayList<>(biometricsDto.size());
        biometricsDto.forEach(biometricDto -> {
            birList.add(buildBir(biometricDto.getBioSubType(),
                    (long) biometricDto.getQualityScore(),
                    CryptoUtil.base64decoder.decode(biometricDto.getBioValue()), biometricType,
                    ProcessedLevelType.RAW, false));
        });

        BiometricRecord biometricRecord = new BiometricRecord();
        biometricRecord.getSegments().addAll(birList);

        List<BiometricRecord> biometricRecordList = new ArrayList<>();
        for(List<BIR> birListValue: birMap.values()){
            BiometricRecord biometricRecordValue = new BiometricRecord();
            biometricRecordValue.getSegments().addAll(birListValue);
            biometricRecordList.add(biometricRecordValue);
        }
        BiometricRecord [] biometricRecords = biometricRecordList.toArray(new BiometricRecord[0]);

        List<BiometricType> biometricTypes = new ArrayList<>();
        biometricTypes.add(biometricType);

        try {
            Response<MatchDecision[]> response = iBioApiV2.match(biometricRecord, biometricRecords, biometricTypes, new HashMap<>());
            if (response != null && response.getResponse() != null)
            {
                Match decision = Objects.requireNonNull(response.getResponse()[0].getDecisions().get(biometricType)).
                        getMatch();
                if(decision.equals(Match.MATCHED)){
                    return true;
                }
            }
        } catch (Exception e) {
            Log.e("Failed in dedupe check >> ", e.getMessage());
        }
        return false;
    }

Design consideration:

The kernel-biometric-api library is obtained from the bio-utils repository's develop branch - bio-utils/kernel-biometrics-api

The inclusion of kernel-biometric-api in the Android reg client app, in order to reference the IBioApiV2 interface, is implemented to prevent transitive dependency errors caused by the lombok and jackson libraries. This is necessary because those libraries were referencing older versions of the same dependencies.

Here are the specific changes done to the pom file:

Code Block
<properties>
	...
	<java.version>17</java.version> <!--21-->
	...
	<!--newly added versions-->
	<jackson.version>2.15.0</jackson.version> 
	<lombok.version>1.18.24</lombok.version>
	<junit.version>5.10.3</junit.version>
	...
	<!--<kernel.bom.version>1.2.1-SNAPSHOT</kernel.bom.version>--> <!--commented-->
	<kernel.core.version>1.2.0.1</kernel.core.version> <!--1.2.1-SNAPSHOT-->
</properties>	

<!-- Commented this section, kernel-bom not available to get downloaded as dependency
    <dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>io.mosip.kernel</groupId>
				<artifactId>kernel-bom</artifactId>
				<version>${kernel.bom.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>-->
	
    <dependencies>
		...
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<version>${lombok.version}</version> <!--newly added-->
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>${jackson.version}</version> <!--newly added-->
		</dependency>
		<dependency>
			<groupId>org.junit.vintage</groupId>
			<artifactId>junit-vintage-engine</artifactId>
			<version>${junit.version}</version> <!--newly added-->
		</dependency>
	</dependencies>