Skip to content

Commit

Permalink
Merge pull request #19 from 2060-io/feat/add-emrtd-command
Browse files Browse the repository at this point in the history
feat: add eMRTD command
  • Loading branch information
lotharking authored Oct 23, 2024
2 parents a0bc1a4 + dcb6d45 commit 33d9ca6
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 53 deletions.
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Changelog

## [2.0.12](https://central.sonatype.com/artifact/io.2060/service-agent-java-client/2.0.12) (2024-10-22)


### Features

* feat: implement EMrtdData in dataGroups ([468ea49](https://github.com/2060-io/2060-service-agent-java-client/pull/19/commits/468ea4934be6e778346667374a6ff21871c0eee1))
* Add eMRTD commands to NFC reading ([55b7937](https://github.com/2060-io/2060-service-agent-java-client/pull/19/commits/55b79378c9416c8b1aee6f98e2ee3eb29d268fbb))
* Add randomCipheringData method ([c7d85f5](https://github.com/2060-io/2060-service-agent-java-client/pull/19/commits/c7d85f5c80f890c9c8c0cc8b2cf54fb5d09ef6b2))

## [2.0.11](https://central.sonatype.com/artifact/io.2060/service-agent-java-client/2.0.11) (2024-10-07)


### Features

* Add I18n manager ([a0bc1a4](https://github.com/2060-io/2060-service-agent-java-client/commit/a0bc1a4dd265abe4670afa14a5c2003a5a248621))

## [2.0.10](https://central.sonatype.com/artifact/io.2060/service-agent-java-client/2.0.10) (2024-10-02)


### Features

* Add mrz message parameters ([5dc9cd1](https://github.com/2060-io/2060-service-agent-java-client/commit/5dc9cd16635bcc3605b9ee66d1e2425d37396117))

## [2.0.9](https://central.sonatype.com/artifact/io.2060/service-agent-java-client/2.0.9) (2024-10-01)


### Features

* Add profile message parameters ([63d65f3](https://github.com/2060-io/2060-service-agent-java-client/commit/63d65f3143ade06b8c2f3c571d34b589bde76699))

## [2.0.8](https://central.sonatype.com/artifact/io.2060/service-agent-java-client/2.0.8) (2024-09-27)


### Features

* Add call's command ([471ed0f](https://github.com/2060-io/2060-service-agent-java-client/commit/471ed0f17f89ae8906de9c5e6299396fc9cacce2))
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ Client tools for building Quarkus java DIDcomm Verifiable Credential powered con
- On dev mode use the command `mvn clean install -Dgpg.skip` to run the project
- To apply format run `mvn fmt:format`

## Releases

| Version | Release Date | Type of Change | Description |
|---------|--------------|---------------------|-----------------------------------------------------------------------------|
| 2.0.11 | 2024-10-07 | Patch | - add I18n manager |
| 2.0.10 | 2024-10-02 | Patch | - add mrz message parameters |
| 2.0.9 | 2024-10-01 | Patch | - add profile message parameters |
| 2.0.8 | 2024-09-27 | Patch | - add call's command |


## License

Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.2060</groupId>
<artifactId>service-agent-java-client</artifactId>
<version>2.0.11</version>
<version>2.0.12</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
Expand Down Expand Up @@ -79,6 +79,7 @@
<goals>
<goal>format</goal>
</goals>
<phase>clean</phase>
</execution>
</executions>
<configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import io.twentysixty.sa.client.model.message.calls.CallEndRequestMessage;
import io.twentysixty.sa.client.model.message.calls.CallOfferRequestMessage;
import io.twentysixty.sa.client.model.message.calls.CallRejectRequestMessage;
import io.twentysixty.sa.client.model.message.mrtd.EMrtdDataRequestMessage;
import io.twentysixty.sa.client.model.message.mrtd.EMrtdDataSubmitMessage;
import io.twentysixty.sa.client.model.message.mrtd.MrzDataRequestMessage;
import io.twentysixty.sa.client.model.message.mrtd.MrzDataSubmitMessage;
import io.twentysixty.sa.client.util.InstantDeserializer;
Expand Down Expand Up @@ -47,7 +49,9 @@
@Type(value = CallOfferRequestMessage.class, name = "call-offer"),
@Type(value = CallRejectRequestMessage.class, name = "call-reject"),
@Type(value = MrzDataRequestMessage.class, name = "mrz-data-request"),
@Type(value = MrzDataSubmitMessage.class, name = "mrz-data-submit")
@Type(value = MrzDataSubmitMessage.class, name = "mrz-data-submit"),
@Type(value = EMrtdDataRequestMessage.class, name = "emrtd-data-request"),
@Type(value = EMrtdDataSubmitMessage.class, name = "emrtd-data-submit")
})
public abstract class BaseMessage implements Serializable {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
package io.twentysixty.sa.client.model.message;

import java.io.Serializable;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Setter
@Getter
@ToString
public class Ciphering implements Serializable {

private static final long serialVersionUID = -8660299956191649637L;
private String algorithm;
private Parameters parameters;

public String getAlgorithm() {
return algorithm;
}

public void setAlgorithm(String algorithm) {
this.algorithm = algorithm;
}

public Parameters getParameters() {
return parameters;
}

public void setParameters(Parameters parameters) {
this.parameters = parameters;
}

@Override
public String toString() {
return "Ciphering [algorithm=" + algorithm + ", parameters=" + parameters + "]";
}
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
package io.twentysixty.sa.client.model.message;

import java.io.Serializable;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Setter
@Getter
@ToString
public class Parameters implements Serializable {

private static final long serialVersionUID = -3591319454008944749L;
private String key;
private String iv;

public String getKey() {
return key;
}

public void setKey(String key) {
this.key = key;
}

public String getIv() {
return iv;
}

public void setIv(String iv) {
this.iv = iv;
}

@Override
public String toString() {
return "Parameters [key=" + key + ", iv=" + iv + "]";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package io.twentysixty.sa.client.model.message.mrtd;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@Getter
@Setter
@ToString
public class EMrtdData implements Serializable {

private static final long serialVersionUID = -5234275638176689315L;

private Map<String, Object> raw;
private EMrtdProcessedData processed;

@Getter
@Setter
@ToString
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public static class EMrtdProcessedData {
private String documentType;
private String documentNumber;
private String issuingState;
private String dateOfBirth;
private String dateOfExpiry;
private String sex;
private String nationality;
private String lastName;
private String firstName;
private String mrzOptionalData;
private List<String> faceImages;
private String nameOfHolder;
private List<String> otherNames;
private String personalNumber;
private List<String> placeOfBirth;
private List<String> permanentAddress;
private String telephone;
private String profession;
private String title;
private String personalSummary;
private String custodyInformation;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.twentysixty.sa.client.model.message.mrtd;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import io.twentysixty.sa.client.model.message.BaseMessage;
import java.util.UUID;

@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class EMrtdDataRequestMessage extends BaseMessage {

private static final long serialVersionUID = -2840211856886673672L;

public static EMrtdDataRequestMessage build(UUID connectionId, UUID threadId) {
EMrtdDataRequestMessage emrtd = new EMrtdDataRequestMessage();
emrtd.setConnectionId(connectionId);
emrtd.setThreadId(threadId);
return emrtd;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.twentysixty.sa.client.model.message.mrtd;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import io.twentysixty.sa.client.model.message.BaseMessage;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@Getter
@Setter
@ToString
public class EMrtdDataSubmitMessage extends BaseMessage {

private static final long serialVersionUID = -2840411856886673672L;

private EMrtdData dataGroups;
}
21 changes: 21 additions & 0 deletions src/main/java/io/twentysixty/sa/client/util/Aes256cbc.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package io.twentysixty.sa.client.util;

import io.twentysixty.sa.client.model.message.Ciphering;
import io.twentysixty.sa.client.model.message.Parameters;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import org.jboss.logging.Logger;
Expand Down Expand Up @@ -40,4 +44,21 @@ public static byte[] decrypt(String key, String iv, byte[] encrypted) throws Exc
byte[] decrypted = cipher.doFinal(encrypted);
return decrypted;
}

public static Ciphering randomCipheringData() throws Exception {
Ciphering c = new Ciphering();
Parameters p = new Parameters();
p.setKey(randomKey(32));
p.setIv(randomKey(16));
c.setAlgorithm(cI);
c.setParameters(p);
return c;
}

private static String randomKey(int size) throws Exception {
KeyGenerator keyGen = KeyGenerator.getInstance(alg);
keyGen.init(size * 8);
SecretKey secretKey = keyGen.generateKey();
return ISOUtil.hexString(secretKey.getEncoded());
}
}

0 comments on commit 33d9ca6

Please sign in to comment.