Skip to content

Commit

Permalink
SD-335 Add signature validation in eblissuance (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
palatsangeetha authored Nov 6, 2024
1 parent 8d48ff8 commit 1cf3ee2
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1cf3ee2

Please sign in to comment.