Unverified Commit e14cfdf6 authored by Felix Förtsch's avatar Felix Förtsch
Browse files

add working anonymous checkin -- missing working URL resolution

parent 9bbd3c9c
Conflict
\ No newline at end of file
Conflict
\ No newline at end of file
Created
\ No newline at end of file
POST https://localhost/api/v3/traces/checkin
Content-Type: application/json
{
"deviceType": 1,
"iv": "fqUo5/kB1Z45hYpJFrg4dw==",
"mac": "m2z1+s0QLxwtp+Ayib5Uea3AiRnNYfZw2c2quT5JUdk=",
"data": "+Es+mgus3W4IfuDE7IlzpBAHBmWqs41difSF0nf5S1Nj/vEQWd+Eb9/Zz/k4e+jA11z8zHY35+Kuef3YhM+pUIHjwzTaUDDqgrKQ",
"publicKey": "BFF/GBlRK3ZW4h+q4SViEaRMoKPuc/VqCJNAi5ZKXN9zCHkCwCS0TUy3oQDZPGU1wePJrpXIOjnt6RIuPGAlsO8=",
"scannerId": "707a6fb6-56ba-407a-884f-5990a083214f",
"traceId": "KPyUAXZ+mPgPfAliNaYxqA==",
"timestamp": 1639174446
}
<> 2021-12-10T231438.201.txt
###
POST https://localhost/api/v3/traces/checkin
Content-Type: application/json
{
"deviceType": 1,
"iv": "7HOJ6xaMsBm4/pCz+DkGhA==",
"mac": "exWX26XIl4vgCLggJ0KG6XUBItN+TuNUhCAmaMRkuFg=",
"data": "/dBphmdsS6qq7baKuxOfQpKIsiqASlOcz0zTDldfV9KzVi51DEUvypqSf0LLKODLFGNVQEX1CVvjpVMgL6PzkkVsUFJ26XgOYsl0",
"publicKey": "BMN1kxXtoFOnf+ff2lDTWjiFENzq3Ah45BtxVZ6+/DiUeqAT9CsqqHdDDFyuLJFVTTZSQvCqwVfmAeL3RF/ixRY=",
"scannerId": "707a6fb6-56ba-407a-884f-5990a083214f",
"traceId": "5GHc+dlrkzn0vgw7hu6m2g==",
"timestamp": 1639273681
}
<> 2021-12-10T231354.409.txt
###
POST https://localhost/api/v3/traces/checkin
Content-Type: application/json
{
"deviceType": 1,
"iv": "7HOJ6xaMsBm4/pCz+DkGhA==",
"mac": "exWX26XIl4vgCLggJ0KG6XUBItN+TuNUhCAmaMRkuFg=",
"data": "/dBphmdsS6qq7baKuxOfQpKIsiqASlOcz0zTDldfV9KzVi51DEUvypqSf0LLKODLFGNVQEX1CVvjpVMgL6PzkkVsUFJ26XgOYsl0",
"publicKey": "BMN1kxXtoFOnf+ff2lDTWjiFENzq3Ah45BtxVZ6+/DiUeqAT9CsqqHdDDFyuLJFVTTZSQvCqwVfmAeL3RF/ixRY=",
"scannerId": "707a6fb6-56ba-407a-884f-5990a083214f",
"traceId": "5GHc+dlrkzn0vgw7hu6m2g==",
"timestamp": 1639173681
}
<> 2021-12-10T231336.409.txt
###
POST https://10.0.2.2/api/v3/traces/checkin
Content-Type: application/json
{
}
###
POST https://10.0.2.2/api/v3/traces/checkin
Content-Type: application/json
{
"deviceType": 1,
"iv": "7HOJ6xaMsBm4/pCz+DkGhA==",
"mac": "exWX26XIl4vgCLggJ0KG6XUBItN+TuNUhCAmaMRkuFg=",
"data": "/dBphmdsS6qq7baKuxOfQpKIsiqASlOcz0zTDldfV9KzVi51DEUvypqSf0LLKODLFGNVQEX1CVvjpVMgL6PzkkVsUFJ26XgOYsl0",
"publicKey": "BMN1kxXtoFOnf+ff2lDTWjiFENzq3Ah45BtxVZ6+/DiUeqAT9CsqqHdDDFyuLJFVTTZSQvCqwVfmAeL3RF/ixRY=",
"scannerId": "707a6fb6-56ba-407a-884f-5990a083214f",
"traceId": "5GHc+dlrkzn0vgw7hu6m2g==",
"timestamp": 1639173681
}
###
......@@ -11,6 +11,7 @@ import de.culture4life.luca.crypto.AsymmetricCipherProvider;
import de.culture4life.luca.crypto.CryptoManager;
import de.culture4life.luca.crypto.SymmetricCipherProvider;
import de.culture4life.luca.network.NetworkManager;
import de.culture4life.luca.network.pojo.CheckInRequestData;
import de.culture4life.luca.network.pojo.ContactData;
import de.culture4life.luca.network.pojo.UserRegistrationRequestData;
import de.culture4life.luca.registration.RegistrationData;
......@@ -28,6 +29,7 @@ import java.util.UUID;
import java.util.concurrent.TimeUnit;
import static de.culture4life.luca.util.SerializationUtil.serializeToBase64;
import static de.culture4life.luca.util.SerializationUtil.serializeToJson;
import static java.lang.String.valueOf;
public class FakeManager extends Manager {
......@@ -102,7 +104,7 @@ public class FakeManager extends Manager {
requestData.setGuestKeyPairPublicKey(serializedPublicKey);
// Make network request and get UserID
JsonObject jsonObject = networkManager.getLucaEndpoints().registerUser(requestData).blockingGet();
JsonObject jsonObject = networkManager.getLucaEndpointsV3().blockingGet().registerUser(requestData).blockingGet();
System.out.println(jsonObject.get("userId").getAsString());
return UUID.fromString(jsonObject.get("userId").getAsString());
......@@ -111,17 +113,16 @@ public class FakeManager extends Manager {
public void doFakeCheckin() {
// TODO: Scanner ID aus QR-Code einlesen
UUID scannerId = UUID.fromString("09eb8d41-1914-4950-9526-36ebc6ad58fe");
ECPublicKey publicKey = checkInManager.getLocationPublicKey(scannerId).blockingGet();
UUID scannerId = UUID.fromString("707a6fb6-56ba-407a-884f-5990a083214f");
DeviceData deviceData = new DeviceData();
VenueData venueData = new VenueData(cryptoManager, publicKey, deviceData, checkInManager);
VenueData venueData = new VenueData(cryptoManager, checkInManager, scannerId, deviceData);
CheckinData checkinData = new CheckinData(deviceData, venueData);
}
CheckInRequestData checkInRequestData = CheckinData.map(checkinData);
String json = serializeToJson(checkInRequestData).blockingGet();
networkManager.getLucaEndpointsV3().blockingGet().checkIn(checkInRequestData);
}
public static byte[] generateRandomData(Integer length) {
SecureRandom random = new SecureRandom();
......@@ -150,36 +151,54 @@ public class FakeManager extends Manager {
class CheckinData {
// Device
String traceId;
String timestamp;
String deviceType;
Long timestamp;
Integer deviceType;
// Venue
String scannerId;
String data;
String iv;
String mac;
String iv;
String publicKey;
public CheckinData(DeviceData deviceData, VenueData venueData) {
this.traceId = Arrays.toString(deviceData.traceId);
this.traceId = serializeToBase64(deviceData.traceId).blockingGet();
this.timestamp = deviceData.timestamp;
this.deviceType = deviceData.deviceType;
this.scannerId = scannerId;
// check_in_data = version || key_id || ephemeral_keys.public || verification_tag || enc_data
this.data = data;
this.iv = iv;
this.mac = mac;
this.publicKey = publicKey;
this.scannerId = venueData.scannerId;
this.data = venueData.data;
this.iv = serializeToBase64(venueData.iv).blockingGet();
this.mac = venueData.hmac;
this.publicKey = venueData.publicKey;
}
public static CheckInRequestData map(CheckinData checkinData) {
CheckInRequestData checkInRequestData = new CheckInRequestData();
checkInRequestData.setTraceId(checkinData.traceId);
checkInRequestData.setUnixTimestamp(checkinData.timestamp);
checkInRequestData.setDeviceType(checkinData.deviceType);
checkInRequestData.setScannerId(checkinData.scannerId);
checkInRequestData.setReEncryptedQrCodeData(checkinData.data);
checkInRequestData.setMac(checkinData.mac);
checkInRequestData.setIv(checkinData.iv);
checkInRequestData.setScannerEphemeralPublicKey(checkinData.publicKey);
return checkInRequestData;
}
}
class VenueData {
final byte[] iv = FakeManager.generateRandomData(16);
String scannerId;
String publicKey;
String data;
String hmac;
public VenueData(CryptoManager cryptoManager, ECPublicKey publicKey, DeviceData deviceData, CheckInManager checkInManager) {
public VenueData(CryptoManager cryptoManager, CheckInManager checkInManager, UUID scannerId, DeviceData deviceData) {
this.scannerId = scannerId.toString();
ECPublicKey publicKey = checkInManager.getLocationPublicKey(scannerId).blockingGet();
KeyPair ephScannerKeys = cryptoManager.generateScannerEphemeralKeyPair().blockingGet();
// dh = Diffie Hellman
......@@ -208,8 +227,8 @@ class VenueData {
}
class DeviceData {
final String deviceType = "1";
final String timestamp = valueOf(TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()));
final Integer deviceType = 1;
final Long timestamp = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
final byte version = 3;
final byte[] data = FakeManager.generateRandomData(32);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment