From f2e7951ab0c24c78c06209b7a135fde75bed6a63 Mon Sep 17 00:00:00 2001 From: Martin Paljak Date: Fri, 22 Feb 2019 09:08:59 +0200 Subject: [PATCH] Fix statusCode location for UI operations --- .../com/fidesmo/fdsm/ServiceDeliverySession.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/fidesmo/fdsm/ServiceDeliverySession.java b/src/main/java/com/fidesmo/fdsm/ServiceDeliverySession.java index 601b608..0e11f60 100644 --- a/src/main/java/com/fidesmo/fdsm/ServiceDeliverySession.java +++ b/src/main/java/com/fidesmo/fdsm/ServiceDeliverySession.java @@ -63,7 +63,6 @@ public static ServiceDeliverySession getInstance(FidesmoCard card, FidesmoApiCli return new ServiceDeliverySession(card, client, formHandler); } - public boolean deliver(String appId, String serviceId, PrintStream debug) throws CardException, IOException { // Address #4 client.rpc(client.getURI(FidesmoApiClient.DEVICES_URL, HexUtils.bin2hex(card.getCIN()), new BigInteger(1, card.getBatchId()).toString())); @@ -199,6 +198,7 @@ protected ObjectNode processTransmitOperation(JsonNode operationId, String sessi } } + // Send an empty fetch request when APDU-s are done return emptyFetchRequest(sessionId); } @@ -279,6 +279,8 @@ protected ObjectNode processUIOperation(JsonNode operation, String sessionId, Js values.put(v.getKey(), value); } operationResult.set("fields", values); + operationResult.put("statusCode", 200); + if (encrypted) { operationResult.put("ephemeralKey", HexUtils.bin2hex(encryptSessionKey(spkey, sessionKey))); } @@ -288,6 +290,7 @@ protected ObjectNode processUIOperation(JsonNode operation, String sessionId, Js ObjectNode fetchRequest = emptyFetchRequest(sessionId); fetchRequest.set("operationResult", operationResult); + return fetchRequest; } @@ -315,7 +318,6 @@ protected ObjectNode processUserAction(JsonNode operation, String sessionId) thr return fetchRequest; } - private byte[] encrypt(String value, Key key) throws GeneralSecurityException { Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding"); c.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(new byte[16])); @@ -336,10 +338,9 @@ private byte[] encryptSessionKey(PublicKey publicKey, Key key) throws GeneralSec } private ObjectNode emptyFetchRequest(String sessionId) { - ObjectNode operationResult = JsonNodeFactory.instance.objectNode(); - operationResult.put("sessionId", sessionId); - operationResult.put("statusCode", sessionId); - return operationResult; + ObjectNode fetchRequest = JsonNodeFactory.instance.objectNode(); + fetchRequest.put("sessionId", sessionId); + return fetchRequest; } private ObjectNode mapToJsonNode(Map map) {