From 1cf3ee27b8793e9c309fe78cd54899492e857160 Mon Sep 17 00:00:00 2001 From: palatsangeetha <138600841+palatsangeetha@users.noreply.github.com> Date: Wed, 6 Nov 2024 10:10:37 +0100 Subject: [PATCH] SD-335 Add signature validation in eblissuance (#216) --- .../action/CarrierScenarioParametersAction.java | 8 ++++---- .../action/IssuanceRequestResponseAction.java | 1 + .../standards/eblissuance/checks/IssuanceChecks.java | 9 ++++----- .../standards/eblissuance/party/EblIssuanceCarrier.java | 2 +- .../org/dcsa/conformance/frontend/SeleniumTestBase.java | 5 +++++ .../java/org/dcsa/conformance/manual/ManualTestBase.java | 2 ++ 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ebl-issuance/src/main/java/org/dcsa/conformance/standards/eblissuance/action/CarrierScenarioParametersAction.java b/ebl-issuance/src/main/java/org/dcsa/conformance/standards/eblissuance/action/CarrierScenarioParametersAction.java index 5bdff7e9..d1284cc0 100644 --- a/ebl-issuance/src/main/java/org/dcsa/conformance/standards/eblissuance/action/CarrierScenarioParametersAction.java +++ b/ebl-issuance/src/main/java/org/dcsa/conformance/standards/eblissuance/action/CarrierScenarioParametersAction.java @@ -4,6 +4,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import java.util.function.Consumer; import java.util.function.Supplier; + +import org.dcsa.conformance.standards.ebl.crypto.PayloadSignerFactory; import org.dcsa.conformance.standards.eblissuance.party.CarrierScenarioParameters; public class CarrierScenarioParametersAction extends IssuanceAction { @@ -40,14 +42,12 @@ public void importJsonState(JsonNode jsonState) { @Override public String getHumanReadablePrompt() { - return "Supply the parameters required by the scenario using the following format:"; + return "Supply the public key for validating the signed content using the following format:"; } @Override public JsonNode getJsonForHumanReadablePrompt() { - // DT-1794: To be redesigned with support automatic execution of manual scenario runs - // Keeping the unused parameter in place to avoid losing data on upgrade after DT-1794 fix. - return new CarrierScenarioParameters("Currently ignored, submit this without changing the value") + return new CarrierScenarioParameters("Provide the public key for validating the signed content in here.") .toJson(); } diff --git a/ebl-issuance/src/main/java/org/dcsa/conformance/standards/eblissuance/action/IssuanceRequestResponseAction.java b/ebl-issuance/src/main/java/org/dcsa/conformance/standards/eblissuance/action/IssuanceRequestResponseAction.java index bc0cac1b..d04a7388 100644 --- a/ebl-issuance/src/main/java/org/dcsa/conformance/standards/eblissuance/action/IssuanceRequestResponseAction.java +++ b/ebl-issuance/src/main/java/org/dcsa/conformance/standards/eblissuance/action/IssuanceRequestResponseAction.java @@ -13,6 +13,7 @@ import org.dcsa.conformance.core.check.*; import org.dcsa.conformance.core.traffic.ConformanceExchange; import org.dcsa.conformance.core.traffic.HttpMessageType; +import org.dcsa.conformance.standards.ebl.checks.SignatureChecks; import org.dcsa.conformance.standards.ebl.crypto.PayloadSignerFactory; import org.dcsa.conformance.standards.ebl.crypto.SignatureVerifier; import org.dcsa.conformance.standards.eblissuance.checks.IssuanceChecks; diff --git a/ebl-issuance/src/main/java/org/dcsa/conformance/standards/eblissuance/checks/IssuanceChecks.java b/ebl-issuance/src/main/java/org/dcsa/conformance/standards/eblissuance/checks/IssuanceChecks.java index b20f7103..883bffae 100644 --- a/ebl-issuance/src/main/java/org/dcsa/conformance/standards/eblissuance/checks/IssuanceChecks.java +++ b/ebl-issuance/src/main/java/org/dcsa/conformance/standards/eblissuance/checks/IssuanceChecks.java @@ -73,11 +73,10 @@ public static ActionCheck issuanceRequestSignatureChecks(UUID matched, String st matched, HttpMessageType.REQUEST, standardsVersion, - // DT-1794: To be redesigned with support automatic execution of manual scenario runs - // JsonAttribute.customValidator( - // "Signature of the issuanceManifestSignedContent is valid", - // path("issuanceManifestSignedContent", SignatureChecks.signatureValidates(signatureVerifierSupplier)) - // ), + JsonAttribute.customValidator( + "Signature of the issuanceManifestSignedContent is valid", + path("issuanceManifestSignedContent", SignatureChecks.signatureValidates(signatureVerifierSupplier)) + ), JsonAttribute.customValidator( "Schema validation of the payload of issuanceManifestSignedManifest", path("issuanceManifestSignedContent", SignatureChecks.signedContentSchemaValidation( diff --git a/ebl-issuance/src/main/java/org/dcsa/conformance/standards/eblissuance/party/EblIssuanceCarrier.java b/ebl-issuance/src/main/java/org/dcsa/conformance/standards/eblissuance/party/EblIssuanceCarrier.java index 0519ae43..85d22f82 100644 --- a/ebl-issuance/src/main/java/org/dcsa/conformance/standards/eblissuance/party/EblIssuanceCarrier.java +++ b/ebl-issuance/src/main/java/org/dcsa/conformance/standards/eblissuance/party/EblIssuanceCarrier.java @@ -116,7 +116,7 @@ private void supplyScenarioParameters(JsonNode actionPrompt) { asyncOrchestratorPostPartyInput( actionPrompt.required("actionId").asText(), carrierScenarioParameters.toJson()); addOperatorLogEntry( - "Submitting CarrierScenarioParameters: %s" + "Prompt answer for CarrierScenarioParameters: %s" .formatted(carrierScenarioParameters.toJson().toPrettyString())); } diff --git a/spring-boot/src/test/java/org/dcsa/conformance/frontend/SeleniumTestBase.java b/spring-boot/src/test/java/org/dcsa/conformance/frontend/SeleniumTestBase.java index 5b97dc24..11e04a6f 100644 --- a/spring-boot/src/test/java/org/dcsa/conformance/frontend/SeleniumTestBase.java +++ b/spring-boot/src/test/java/org/dcsa/conformance/frontend/SeleniumTestBase.java @@ -136,6 +136,11 @@ private boolean handleJsonPromptForText() { "Setup the system for transfer and provide the following details for the sender.")) { jsonPromptText = fetchPromptAnswer("initiateState"); } + // Flow for ebl issuance carrier scenarios + else if (promptText.contains( + "Supply the public key for validating the signed content using the following format:")) { + jsonPromptText = fetchPromptAnswer("CarrierScenarioParameters"); + } if (driver.findElements(By.id("actionInput")).isEmpty()) { log.error("Error: No actionInput element found, while a jsonForPromptText was displayed!"); diff --git a/spring-boot/src/test/java/org/dcsa/conformance/manual/ManualTestBase.java b/spring-boot/src/test/java/org/dcsa/conformance/manual/ManualTestBase.java index bd61f99e..3c2604e2 100644 --- a/spring-boot/src/test/java/org/dcsa/conformance/manual/ManualTestBase.java +++ b/spring-boot/src/test/java/org/dcsa/conformance/manual/ManualTestBase.java @@ -393,6 +393,8 @@ void runScenario( jsonForPrompt = fetchPromptAnswer(sandbox2, sandbox1, "supplyScenarioParameters"); } else if (promptText.contains("Setup the system for transfer and provide the following details for the sender.")) { jsonForPrompt = fetchPromptAnswer(sandbox2, sandbox1, "initiateState"); + } else if (promptText.contains("Supply the public key for validating the signed content using the following format:")) { + jsonForPrompt = fetchPromptAnswer(sandbox2, sandbox1, "CarrierScenarioParameters"); } handleActionInput(sandbox1, scenarioId, promptActionId, jsonForPrompt);