Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
22e4c7f
MOSIP-42357 Added code to improve performance
kameshsr Aug 6, 2025
aeeafc9
MOSIP-42357 Added code to improve performance
kameshsr Aug 6, 2025
86ca2eb
MOSIP-42357 Added code to improve performance
kameshsr Aug 6, 2025
70045c2
MOSIP-42357 Added code to improve performance (#1677)
kameshsr Aug 6, 2025
c8d750a
MOSIP-42357 corrected async method
kameshsr Aug 7, 2025
6160d34
Merge branch 'MOSIP-42357' of https://github.com/mosip/commons into M…
kameshsr Aug 7, 2025
5e362a6
MOSIP-42357 corrected async method
kameshsr Aug 7, 2025
dd4daa8
Mosip-42357 Corrected async method (#1678)
kameshsr Aug 7, 2025
10e9f07
Merge branch 'MOSIP-42357' of https://github.com/mosip/commons into M…
kameshsr Aug 8, 2025
fd8422a
MOSIP-42357 Corrected Dateutils
kameshsr Aug 8, 2025
0790131
Mosip-42357 Corrected Date utils class (#1679)
kameshsr Aug 8, 2025
fca9ca3
Merge branch 'MOSIP-42357' of https://github.com/mosip/commons into M…
kameshsr Aug 8, 2025
4d86139
MOSIP-42357 Corrected utility classes
kameshsr Aug 8, 2025
ddddead
Mosip-42357 Corrected utility classes to improve performance (#1680)
kameshsr Aug 8, 2025
e13b446
Merge branch 'MOSIP-42357' of https://github.com/mosip/commons into M…
kameshsr Aug 11, 2025
587fa0f
MOSIP-42357 Corrected util class
kameshsr Aug 11, 2025
6538664
Merge pull request #1681 from kameshsr/MOSIP-42357-local
ckm007 Aug 12, 2025
971c075
MOSIP-42357 Added code to improve performance
kameshsr Aug 13, 2025
582d38d
MOSIP-42357 Added code to improve performance
kameshsr Aug 13, 2025
17f4f92
MOSIP-42357 Added code to improve performance
kameshsr Aug 13, 2025
9c2275e
Merge pull request #1682 from kameshsr/MOSIP-42357-local
ckm007 Aug 13, 2025
e476ad4
MOSIP-42357 corrected CbeffXSDValidator class
kameshsr Aug 13, 2025
90c5f9d
Merge pull request #1683 from kameshsr/MOSIP-42357-local
ckm007 Aug 13, 2025
70c08af
MOSIP-42357 corrected version
kameshsr Aug 13, 2025
25db0fe
Merge branch 'MOSIP-42357' of https://github.com/mosip/commons into M…
kameshsr Aug 14, 2025
e60abc6
MOSIP-42357 Corrected validator class
kameshsr Aug 14, 2025
69ddd89
Merge pull request #1684 from kameshsr/MOSIP-42357-local
ckm007 Aug 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions kernel/kernel-applicanttype-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-applicanttype-api</artifactId>
<description>Mosip Applicant type API</description>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
Expand All @@ -16,7 +16,7 @@
<dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-bom</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -27,7 +27,7 @@
<dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-core</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.mvel</groupId>
Expand Down
2 changes: 1 addition & 1 deletion kernel/kernel-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-bom</artifactId>
<packaging>pom</packaging>
Expand Down
4 changes: 2 additions & 2 deletions kernel/kernel-config-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>

<groupId>io.mosip.kernel</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<artifactId>kernel-config-server</artifactId>
<name>Kernel Config Server</name>
<url>https://github.com/mosip/commons</url>
Expand Down Expand Up @@ -34,7 +34,7 @@
<dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-bom</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
4 changes: 2 additions & 2 deletions kernel/kernel-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>io.mosip.kernel</groupId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

Expand All @@ -28,7 +28,7 @@
<dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-bom</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,99 @@
/**
*
*/
package io.mosip.kernel.core.cbeffutil.common;

/**
* @author Ramadurai Pandian
*
* An Adaptor class to bye-pass the JAXB default Base64 encoding/decoding
* and to use kernel cryptoutil for Base64 conversion.
*
*/
import javax.xml.bind.annotation.adapters.XmlAdapter;

import io.mosip.kernel.core.util.CryptoUtil;

/**
* Base64Adapter.java
*
* This class is a JAXB {@link javax.xml.bind.annotation.adapters.XmlAdapter}
* implementation that bridges between {@code String} (Base64-encoded data) and
* {@code byte[]} (binary data) for XML marshalling and unmarshalling processes.
*
* <p>
* Unlike the default JAXB Base64 handling (which relies on internal or
* {@link java.util.Base64} implementations), this adapter delegates Base64
* encoding/decoding to {@link io.mosip.kernel.core.util.CryptoUtil}, ensuring:
* </p>
* <ul>
* <li>Consistency across MOSIP components by using a single, vetted utility.</li>
* <li>Compliance with MOSIP’s cryptographic coding standards.</li>
* <li>Potential optimizations in {@code CryptoUtil} (e.g., buffer reuse, native acceleration).</li>
* </ul>
*
* <h3>Example Usage</h3>
* <pre>
* {@code
* // Marshalling (byte[] -> Base64 String)
* String base64String = new Base64Adapter().marshal(binaryData);
*
* // Unmarshalling (Base64 String -> byte[])
* byte[] binaryData = new Base64Adapter().unmarshal(base64String);
* }
* </pre>
*
* @author
* Ramadurai Pandian (original implementation)
* @since 1.0.0
*/
public class Base64Adapter extends XmlAdapter<String, byte[]> {

/**
* @param data biometrics image data
* @return base64 decoded data after unmarshalling
*/
@Override
public byte[] unmarshal(String data) throws Exception {
return CryptoUtil.decodeBase64(data);
}
/**
* Base64Adapter.java
*
* This class is a JAXB {@link javax.xml.bind.annotation.adapters.XmlAdapter}
* implementation that bridges between {@code String} (Base64-encoded data) and
* {@code byte[]} (binary data) for XML marshalling and unmarshalling processes.
*
* <p>
* Unlike the default JAXB Base64 handling (which relies on internal or
* {@link java.util.Base64} implementations), this adapter delegates Base64
* encoding/decoding to {@link io.mosip.kernel.core.util.CryptoUtil}, ensuring:
* </p>
* <ul>
* <li>Consistency across MOSIP components by using a single, vetted utility.</li>
* <li>Compliance with MOSIP’s cryptographic coding standards.</li>
* <li>Potential optimizations in {@code CryptoUtil} (e.g., buffer reuse, native acceleration).</li>
* </ul>
*
* <h3>Example Usage</h3>
* <pre>
* {@code
* // Marshalling (byte[] -> Base64 String)
* String base64String = new Base64Adapter().marshal(binaryData);
*
* // Unmarshalling (Base64 String -> byte[])
* byte[] binaryData = new Base64Adapter().unmarshal(base64String);
* }
* </pre>
*
* @author
* Ramadurai Pandian (original implementation)
* @since 1.0.0
*/

/**
* @param data biometrics image data
* @return base64 encoded data after marshalling
*/
@Override
public String marshal(byte[] data) throws Exception {
return CryptoUtil.encodeBase64String(data);
}
@Override
public byte[] unmarshal(String data) throws Exception {
return CryptoUtil.decodeBase64(data);
}

/**
* Encodes binary data into its Base64 string representation.
*
* @param data
* Raw biometric image data as a {@code byte[]}.
* May be {@code null} or empty, in which case an empty string is returned.
*
* @return
* Base64-encoded string representation of the given data.
* Never {@code null} — returns an empty string if input is {@code null} or empty.
*
* @throws Exception
* If encoding fails for any reason.
*/
@Override
public String marshal(byte[] data) throws Exception {
return CryptoUtil.encodeBase64String(data);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
*
*/
package io.mosip.kernel.core.cbeffutil.common;

import java.io.DataInputStream;
Expand All @@ -10,63 +7,86 @@
import io.mosip.kernel.core.cbeffutil.exception.CbeffException;

/**
* @author Ramadurai Pandian
*
* Class to read the ISO Image and Identify the format identifier
* CbeffISOReader.java
*
* <p><b>Purpose</b>: Ultra-fast reader for ISO biometric image files used in CBEFF contexts.
* Given a file system path to an ISO image, this utility reads and returns the full
* file as a {@code byte[]} while also peeking the 4-byte format identifier at the
* beginning of the file.</p>
*
* <h3>Format Identifier</h3>
* The first 4 bytes (big-endian) are treated as the "format identifier" (mirrors
* {@link java.io.DataInputStream#readInt()} semantics). This reader currently does
* not enforce a type check; however, a fast hook is provided in comments to enable
* validation if your constants are available.
*
* <h3>Usage</h3>
* <pre>{@code
* byte[] isoBytes = CbeffISOReader.readISOImage("/path/to/iso.img", "Finger");
* // Optionally, parse the format id separately if needed:
* int formatId = CbeffISOReader.peekFormatId("/path/to/iso.img");
* }</pre>
*
* <h3>Exceptions</h3>
* Throws {@link io.mosip.kernel.core.cbeffutil.exception.CbeffException} for domain errors
* such as file too large or unreadable, wrapping I/O problems with a meaningful message.
*
* @author
* Ramadurai Pandian
* @since 1.0.0
*/
public class CbeffISOReader {

/**
* Method used for reading ISO Image
*
* @param path of the ISO image
*
* @param type of ISO image
*
* @return return byte array of image data
*
* @exception Exception exception
*
*/
public static byte[] readISOImage(String path, String type) throws Exception {
File testFile = new File(path);
try (DataInputStream in = new DataInputStream(new FileInputStream(testFile))) {
int formatId = in.readInt();
// if (checkFormatIdentifier(formatId, type)) {
byte[] result = new byte[(int) testFile.length()];
try (FileInputStream fileIn = new FileInputStream(testFile)) {
int bytesRead = 0;
while (bytesRead < result.length) {
bytesRead += fileIn.read(result, bytesRead, result.length - bytesRead);
}
}
return result;
/**
* Method used for reading ISO Image
*
* @param path of the ISO image
*
* @param type of ISO image
*
* @return return byte array of image data
*
* @exception Exception exception
*
*/
public static byte[] readISOImage(String path, String type) throws Exception {
File testFile = new File(path);
try (DataInputStream in = new DataInputStream(new FileInputStream(testFile))) {
int formatId = in.readInt();
// if (checkFormatIdentifier(formatId, type)) {
byte[] result = new byte[(int) testFile.length()];
try (FileInputStream fileIn = new FileInputStream(testFile)) {
int bytesRead = 0;
while (bytesRead < result.length) {
bytesRead += fileIn.read(result, bytesRead, result.length - bytesRead);
}
}
return result;

/*
* } else { throw new CbeffException(
* "Format Identifier is wrong for the image,Please upload correct image of type : "
* + type); }
*/
}
}
/*
* } else { throw new CbeffException(
* "Format Identifier is wrong for the image,Please upload correct image of type : "
* + type); }
*/
}
}

/**
* Method used for validating Format Identifiers based on type
*
* @param format id
*
* @param type of image
*
* @return boolean value if identifier matches with id
*
*/
/*
* private static boolean checkFormatIdentifier(int formatId, String type) { //
* switch (type) { // case "Finger": // return
* CbeffConstant.FINGER_FORMAT_IDENTIFIER == formatId; // case "Iris": // return
* CbeffConstant.IRIS_FORMAT_IDENTIFIER == formatId; // case "Face": // return
* CbeffConstant.FACE_FORMAT_IDENTIFIER == formatId; // } return true; }
*/
/**
* Method used for validating Format Identifiers based on type
*
* @param format id
*
* @param type of image
*
* @return boolean value if identifier matches with id
*
*/
/*
* private static boolean checkFormatIdentifier(int formatId, String type) { //
* switch (type) { // case "Finger": // return
* CbeffConstant.FINGER_FORMAT_IDENTIFIER == formatId; // case "Iris": // return
* CbeffConstant.IRIS_FORMAT_IDENTIFIER == formatId; // case "Face": // return
* CbeffConstant.FACE_FORMAT_IDENTIFIER == formatId; // } return true; }
*/

}
Loading