diff --git a/src/main/java/digital/slovensko/autogram/core/AppStarter.java b/src/main/java/digital/slovensko/autogram/core/AppStarter.java index cdb9d7f91..af27787b0 100644 --- a/src/main/java/digital/slovensko/autogram/core/AppStarter.java +++ b/src/main/java/digital/slovensko/autogram/core/AppStarter.java @@ -25,7 +25,8 @@ public class AppStarter { addOption(null, "slot-id", true, "Slot ID for PKCS11 driver. If not specified, first available slot is used."). addOption(null, "pdf-level", true, "PDF signature level. Supported values: PAdES_BASELINE_B (default), XAdES_BASELINE_B, CAdES_BASELINE_B."). addOption(null, "en319132", false, "Sign according to EN 319 132 or EN 319 122."). - addOption(null, "tsa-server", true, "Url of TimeStamp Authority server that should be used for timestamping in signature level BASELINE_T. If provided, BASELINE_T signatures are made."); + addOption(null, "tsa-server", true, "Url of TimeStamp Authority server that should be used for timestamping in signature level BASELINE_T. If provided, BASELINE_T signatures are made."). + addOption(null, "plain-xml", false, "Enable signing plain (non-slovak-eform) XML files."); public static void start(String[] args) { try { diff --git a/src/main/java/digital/slovensko/autogram/core/Autogram.java b/src/main/java/digital/slovensko/autogram/core/Autogram.java index 439d0b39c..842d9b8d4 100644 --- a/src/main/java/digital/slovensko/autogram/core/Autogram.java +++ b/src/main/java/digital/slovensko/autogram/core/Autogram.java @@ -262,4 +262,8 @@ public void initializeSignatureValidator(ScheduledExecutorService scheduledExecu public TSPSource getTspSource() { return settings.getTspSource(); } + + public boolean isPlainXmlEnabled() { + return settings.isPlainXmlEnabled(); + } } diff --git a/src/main/java/digital/slovensko/autogram/core/SigningJob.java b/src/main/java/digital/slovensko/autogram/core/SigningJob.java index f9cf5e0da..18cce7d69 100644 --- a/src/main/java/digital/slovensko/autogram/core/SigningJob.java +++ b/src/main/java/digital/slovensko/autogram/core/SigningJob.java @@ -179,21 +179,21 @@ public static SigningJob buildFromRequest(DSSDocument document, SigningParameter return build(document, params, responder); } - public static SigningJob buildFromFile(File file, Responder responder, boolean checkPDFACompliance, SignatureLevel signatureType, boolean isEn319132, TSPSource tspSource) { + public static SigningJob buildFromFile(File file, Responder responder, boolean checkPDFACompliance, SignatureLevel signatureType, boolean isEn319132, TSPSource tspSource, boolean plainXmlEnabled) { var document = createDSSFileDocumentFromFile(file); - var parameters = getParametersForFile(document, checkPDFACompliance, signatureType, isEn319132, tspSource); + var parameters = getParametersForFile(document, checkPDFACompliance, signatureType, isEn319132, tspSource, plainXmlEnabled); return build(document, parameters, responder); } - private static SigningParameters getParametersForFile(FileDocument document, boolean checkPDFACompliance, SignatureLevel signatureType, boolean isEn319132, TSPSource tspSource) { + private static SigningParameters getParametersForFile(FileDocument document, boolean checkPDFACompliance, SignatureLevel signatureType, boolean isEn319132, TSPSource tspSource, boolean plainXmlEnabled) { var level = SignatureValidator.getSignedDocumentSignatureLevel(document); if (level != null) switch (level) { case PAdES_BASELINE_B: return SigningParameters.buildForPDF(document, checkPDFACompliance, isEn319132, tspSource); case XAdES_BASELINE_B: - return SigningParameters.buildForASiCWithXAdES(document, isEn319132, tspSource); + return SigningParameters.buildForASiCWithXAdES(document, isEn319132, tspSource, plainXmlEnabled); case CAdES_BASELINE_B: - return SigningParameters.buildForASiCWithCAdES(document, isEn319132, tspSource); + return SigningParameters.buildForASiCWithCAdES(document, isEn319132, tspSource, plainXmlEnabled); default: ; } @@ -203,14 +203,14 @@ private static SigningParameters getParametersForFile(FileDocument document, boo case PAdES_BASELINE_B: return SigningParameters.buildForPDF(document, checkPDFACompliance, isEn319132, tspSource); case XAdES_BASELINE_B: - return SigningParameters.buildForASiCWithXAdES(document, isEn319132, tspSource); + return SigningParameters.buildForASiCWithXAdES(document, isEn319132, tspSource, plainXmlEnabled); case CAdES_BASELINE_B: - return SigningParameters.buildForASiCWithCAdES(document, isEn319132, tspSource); + return SigningParameters.buildForASiCWithCAdES(document, isEn319132, tspSource, plainXmlEnabled); default: ; } - return SigningParameters.buildForASiCWithXAdES(document, isEn319132, tspSource); + return SigningParameters.buildForASiCWithXAdES(document, isEn319132, tspSource, plainXmlEnabled); } public boolean shouldCheckPDFCompliance() { diff --git a/src/main/java/digital/slovensko/autogram/core/SigningParameters.java b/src/main/java/digital/slovensko/autogram/core/SigningParameters.java index cced233df..2da1e04eb 100644 --- a/src/main/java/digital/slovensko/autogram/core/SigningParameters.java +++ b/src/main/java/digital/slovensko/autogram/core/SigningParameters.java @@ -5,6 +5,7 @@ import digital.slovensko.autogram.core.eforms.EFormAttributes; import digital.slovensko.autogram.core.errors.AutogramException; import digital.slovensko.autogram.core.errors.SigningParametersException; +import digital.slovensko.autogram.core.errors.UnknownEformException; import digital.slovensko.autogram.util.AsicContainerUtils; import digital.slovensko.autogram.core.eforms.EFormResources; import digital.slovensko.autogram.core.eforms.EFormUtils; @@ -193,13 +194,13 @@ public static SigningParameters buildFromRequest(SignatureLevel level, ASiCConta String keyInfoCanonicalization, String schema, String transformation, String identifier, boolean checkPDFACompliance, int preferredPreviewWidth, boolean autoLoadEform, boolean embedUsedSchemas, String xsdIdentifier, String xsltIdentifier, String xsltLanguage, String xsltType, String xsltTarget, - DSSDocument document, TSPSource tspSource) throws AutogramException { + DSSDocument document, TSPSource tspSource, boolean plainXmlEnabled) throws AutogramException { return buildParameters(level, container, containerXmlns, packaging, digestAlgorithm, en319132, infoCanonicalization, propertiesCanonicalization, keyInfoCanonicalization, schema, transformation, identifier, checkPDFACompliance, preferredPreviewWidth, autoLoadEform, embedUsedSchemas, xsdIdentifier, new XsltParams(xsltIdentifier, xsltLanguage, xsltType, xsltTarget, null), - document, tspSource); + document, tspSource, plainXmlEnabled); } private static SigningParameters buildParameters(SignatureLevel level, ASiCContainerType container, @@ -207,8 +208,8 @@ private static SigningParameters buildParameters(SignatureLevel level, ASiCConta Boolean en319132, String infoCanonicalization, String propertiesCanonicalization, String keyInfoCanonicalization, String schema, String transformation, String identifier, boolean checkPDFACompliance, int preferredPreviewWidth, boolean autoLoadEform, boolean embedUsedSchemas, - String xsdIdentifier, XsltParams xsltParams, DSSDocument document, TSPSource tspSource) - throws AutogramException { + String xsdIdentifier, XsltParams xsltParams, DSSDocument document, TSPSource tspSource, + boolean plainXmlEnabled) throws AutogramException { if (level == null) throw new SigningParametersException("Nebol zadaný typ podpisu", "Typ/level podpisu je povinný atribút"); @@ -274,6 +275,9 @@ private static SigningParameters buildParameters(SignatureLevel level, ASiCConta throw new SigningParametersException("Nesprávny typ dokumentu", "Zadaný dokument nemožno podpísať ako elektronický formulár v XML Datacontaineri"); } + if (!plainXmlEnabled && (isXML(extractedDocumentMimeType) || isXDC(extractedDocumentMimeType)) && (transformation == null)) + throw new UnknownEformException(); + return new SigningParameters(level, container, containerXmlns, packaging, digestAlgorithm, en319132, infoCanonicalization, propertiesCanonicalization, keyInfoCanonicalization, schema, transformation, identifier, checkPDFACompliance, preferredPreviewWidth, autoLoadEform, embedUsedSchemas, xsdIdentifier, @@ -285,23 +289,23 @@ public static SigningParameters buildForPDF(DSSDocument document, boolean checkP (tspSource == null) ? SignatureLevel.PAdES_BASELINE_B : SignatureLevel.PAdES_BASELINE_T, null, null, null, DigestAlgorithm.SHA256, signAsEn319132, null, null, null, null, null, "", - checkPDFACompliance, 640, false, false, null, null, document, tspSource); + checkPDFACompliance, 640, false, false, null, null, document, tspSource, true); } - public static SigningParameters buildForASiCWithXAdES(DSSDocument document, boolean signAsEn319132, TSPSource tspSource) throws AutogramException { + public static SigningParameters buildForASiCWithXAdES(DSSDocument document, boolean signAsEn319132, TSPSource tspSource, boolean plainXmlEnabled) throws AutogramException { return buildParameters( (tspSource == null) ? SignatureLevel.XAdES_BASELINE_B : SignatureLevel.XAdES_BASELINE_T, ASiCContainerType.ASiC_E, null, SignaturePackaging.ENVELOPING, DigestAlgorithm.SHA256, signAsEn319132, null, null, null, null, null, "", - false, 640, true, false, null, null, document, tspSource); + false, 640, true, false, null, null, document, tspSource, plainXmlEnabled); } - public static SigningParameters buildForASiCWithCAdES(DSSDocument document, boolean signAsEn319132, TSPSource tspSource) throws AutogramException { + public static SigningParameters buildForASiCWithCAdES(DSSDocument document, boolean signAsEn319132, TSPSource tspSource, boolean plainXmlEnabled) throws AutogramException { return buildParameters( (tspSource == null) ? SignatureLevel.CAdES_BASELINE_B : SignatureLevel.CAdES_BASELINE_T, ASiCContainerType.ASiC_E, null, SignaturePackaging.ENVELOPING, DigestAlgorithm.SHA256, signAsEn319132, null, null, null, null, null, "", - false, 640, true, false, null, null, document, tspSource); + false, 640, true, false, null, null, document, tspSource, plainXmlEnabled); } public String getIdentifier() { diff --git a/src/main/java/digital/slovensko/autogram/core/UserSettings.java b/src/main/java/digital/slovensko/autogram/core/UserSettings.java index 82010c41a..a2cbbdee3 100644 --- a/src/main/java/digital/slovensko/autogram/core/UserSettings.java +++ b/src/main/java/digital/slovensko/autogram/core/UserSettings.java @@ -15,6 +15,7 @@ public class UserSettings implements PasswordManagerSettings, SignatureTokenSett private String driver; private int slotIndex; private boolean en319132; + private boolean plainXmlEnabled; private boolean signIndividually; private boolean correctDocumentDisplay; private boolean signaturesValidity; @@ -38,6 +39,7 @@ public static UserSettings load() { settings.setSlotIndex(prefs.getInt("SLOT_INDEX", -1)); settings.setEn319132(prefs.getBoolean("EN319132", false)); settings.setBulkEnabled(prefs.getBoolean("BULK_ENABLED", false)); + settings.setPlainXmlEnabled(prefs.getBoolean("PLAIN_XML_ENABLED", false)); settings.setSignIndividually(prefs.getBoolean("SIGN_INDIVIDUALLY", true)); settings.setCorrectDocumentDisplay(prefs.getBoolean("CORRECT_DOCUMENT_DISPLAY", true)); settings.setSignaturesValidity(prefs.getBoolean("SIGNATURES_VALIDITY", true)); @@ -61,6 +63,7 @@ public void save() { prefs.putInt("SLOT_INDEX", slotIndex); prefs.putBoolean("EN319132", en319132); prefs.putBoolean("BULK_ENABLED", bulkEnabled); + prefs.putBoolean("PLAIN_XML_ENABLED", plainXmlEnabled); prefs.putBoolean("SIGN_INDIVIDUALLY", signIndividually); prefs.putBoolean("CORRECT_DOCUMENT_DISPLAY", correctDocumentDisplay); prefs.putBoolean("SIGNATURES_VALIDITY", signaturesValidity); @@ -110,6 +113,14 @@ public void setDriver(String driver) { this.driver = driver; } + public boolean isPlainXmlEnabled() { + return plainXmlEnabled; + } + + public void setPlainXmlEnabled(boolean value) { + this.plainXmlEnabled = value; + } + public boolean isEn319132() { return en319132; } diff --git a/src/main/java/digital/slovensko/autogram/core/errors/UnknownEformException.java b/src/main/java/digital/slovensko/autogram/core/errors/UnknownEformException.java new file mode 100644 index 000000000..668f57a47 --- /dev/null +++ b/src/main/java/digital/slovensko/autogram/core/errors/UnknownEformException.java @@ -0,0 +1,7 @@ +package digital.slovensko.autogram.core.errors; + +public class UnknownEformException extends AutogramException { + public UnknownEformException() { + super("Neznámy formulár", "Formulár nie je možné podpísať", "Zvolený dokument nie je možné podpísať ako štátny elektronický formulár. Ak ste chceli podpísať elektronický formulár, ozvite sa nám, prosím, emailom na podpora@slovensko.digital"); + } +} diff --git a/src/main/java/digital/slovensko/autogram/server/SignEndpoint.java b/src/main/java/digital/slovensko/autogram/server/SignEndpoint.java index 4503dda2a..29b6ff598 100644 --- a/src/main/java/digital/slovensko/autogram/server/SignEndpoint.java +++ b/src/main/java/digital/slovensko/autogram/server/SignEndpoint.java @@ -29,7 +29,7 @@ public void handle(HttpExchange exchange) throws IOException { var responder = body.getBatchId() == null ? new ServerResponder(exchange) : new ResponderInBatch(new ServerResponder(exchange), autogram.getBatch(body.getBatchId())); - var job = SigningJob.buildFromRequest(body.getDocument(), body.getParameters(autogram.getTspSource()), responder); + var job = SigningJob.buildFromRequest(body.getDocument(), body.getParameters(autogram.getTspSource(), autogram.isPlainXmlEnabled()), responder); if (body.getBatchId() != null) autogram.batchSign(job, body.getBatchId()); diff --git a/src/main/java/digital/slovensko/autogram/server/dto/ServerSigningParameters.java b/src/main/java/digital/slovensko/autogram/server/dto/ServerSigningParameters.java index 35b76b40b..ba7102ee8 100644 --- a/src/main/java/digital/slovensko/autogram/server/dto/ServerSigningParameters.java +++ b/src/main/java/digital/slovensko/autogram/server/dto/ServerSigningParameters.java @@ -103,7 +103,7 @@ public ServerSigningParameters(SignatureLevel level, ASiCContainerType container this.transformationTargetEnvironment = transformationTargetEnvironment; } - public SigningParameters getSigningParameters(boolean isBase64, DSSDocument document, TSPSource tspSource) { + public SigningParameters getSigningParameters(boolean isBase64, DSSDocument document, TSPSource tspSource, boolean plainXmlEnabled) { return SigningParameters.buildFromRequest( getSignatureLevel(), getContainer(), @@ -120,7 +120,8 @@ identifier, checkPDFACompliance, getVisualizationWidth(), autoLoadEform, embedUs schemaIdentifier, transformationIdentifier, transformationLanguage, getTransformationMediaDestinationTypeDescription(), transformationTargetEnvironment, document, - tspSource); + tspSource, + plainXmlEnabled); } private String getTransformation(boolean isBase64) throws MalformedBodyException { diff --git a/src/main/java/digital/slovensko/autogram/server/dto/SignRequestBody.java b/src/main/java/digital/slovensko/autogram/server/dto/SignRequestBody.java index efab6674a..ba02e6933 100644 --- a/src/main/java/digital/slovensko/autogram/server/dto/SignRequestBody.java +++ b/src/main/java/digital/slovensko/autogram/server/dto/SignRequestBody.java @@ -57,8 +57,8 @@ public void validateSigningParameters() throws RequestValidationException, Malfo parameters.validate(getDocument().getMimeType()); } - public SigningParameters getParameters(TSPSource tspSource) { - return parameters.getSigningParameters(isBase64(), getDocument(), tspSource); + public SigningParameters getParameters(TSPSource tspSource, boolean plainXmlEnabled) { + return parameters.getSigningParameters(isBase64(), getDocument(), tspSource, plainXmlEnabled); } public String getBatchId() { diff --git a/src/main/java/digital/slovensko/autogram/ui/BatchGuiFileResponder.java b/src/main/java/digital/slovensko/autogram/ui/BatchGuiFileResponder.java index b7f4906f4..3bd9d303b 100644 --- a/src/main/java/digital/slovensko/autogram/ui/BatchGuiFileResponder.java +++ b/src/main/java/digital/slovensko/autogram/ui/BatchGuiFileResponder.java @@ -28,8 +28,9 @@ public class BatchGuiFileResponder extends BatchResponder { private final SignatureLevel pDFSignatureLevel; private final boolean isEn319132; private final TSPSource tspSource; + private final boolean plainXmlEnabled; - public BatchGuiFileResponder(Autogram autogram, List list, Path targetDirectory, boolean checkPDFACompliance, SignatureLevel pDFSignatureLevel, boolean signPDFAsPades, boolean isEn319132, TSPSource tspSource) { + public BatchGuiFileResponder(Autogram autogram, List list, Path targetDirectory, boolean checkPDFACompliance, SignatureLevel pDFSignatureLevel, boolean signPDFAsPades, boolean isEn319132, TSPSource tspSource, boolean plainXmlEnabled) { this.autogram = autogram; this.list = list; this.checkPDFACompliance = checkPDFACompliance; @@ -37,6 +38,7 @@ public BatchGuiFileResponder(Autogram autogram, List list, Path targetDire this.isEn319132 = isEn319132; this.targetPath = TargetPath.fromTargetDirectory(targetDirectory, signPDFAsPades); this.tspSource = tspSource; + this.plainXmlEnabled = plainXmlEnabled; } @Override @@ -62,7 +64,7 @@ public void onBatchStartSuccess(Batch batch) { onAllFilesSigned(batch); }), batch); - var job = SigningJob.buildFromFile(file, responder, checkPDFACompliance, pDFSignatureLevel, isEn319132, tspSource); + var job = SigningJob.buildFromFile(file, responder, checkPDFACompliance, pDFSignatureLevel, isEn319132, tspSource, plainXmlEnabled); autogram.batchSign(job, batch.getBatchId()); } catch (AutogramException e) { autogram.onSigningFailed(e); diff --git a/src/main/java/digital/slovensko/autogram/ui/cli/CliApp.java b/src/main/java/digital/slovensko/autogram/ui/cli/CliApp.java index 8549ea9df..973c1385e 100644 --- a/src/main/java/digital/slovensko/autogram/ui/cli/CliApp.java +++ b/src/main/java/digital/slovensko/autogram/ui/cli/CliApp.java @@ -32,7 +32,7 @@ public static void start(CommandLine cmd) { var jobs = Arrays.stream(sourceList).filter(f -> f.isFile()) .map(f -> SigningJob.buildFromFile(f, new SaveFileResponder(f, autogram, targetPathBuilder), settings.isPdfaCompliance(), settings.getSignatureLevel(), settings.isEn319132(), - settings.getTspSource())) + settings.getTspSource(), settings.isPlainXmlEnabled())) .toList(); if (settings.isPdfaCompliance()) { jobs.forEach(job -> { diff --git a/src/main/java/digital/slovensko/autogram/ui/cli/CliSettings.java b/src/main/java/digital/slovensko/autogram/ui/cli/CliSettings.java index e5eb090ae..73f433344 100644 --- a/src/main/java/digital/slovensko/autogram/ui/cli/CliSettings.java +++ b/src/main/java/digital/slovensko/autogram/ui/cli/CliSettings.java @@ -33,6 +33,7 @@ public static CliSettings fromCmd(CommandLine cmd) { settings.setTsaServer(cmd.getOptionValue("tsa-server", null)); settings.setTsaEnabled(settings.getTsaServer() != null); settings.setBulkEnabled(true); + settings.setPlainXmlEnabled(cmd.hasOption("plain-xml")); return settings; } diff --git a/src/main/java/digital/slovensko/autogram/ui/gui/MainMenuController.java b/src/main/java/digital/slovensko/autogram/ui/gui/MainMenuController.java index 5ec88c016..8801ca036 100644 --- a/src/main/java/digital/slovensko/autogram/ui/gui/MainMenuController.java +++ b/src/main/java/digital/slovensko/autogram/ui/gui/MainMenuController.java @@ -112,12 +112,12 @@ private void signFiles(List list) { var file = filesList.get(0); var job = SigningJob.buildFromFile(file, new SaveFileResponder(file, autogram, userSettings.shouldSignPDFAsPades()), - userSettings.isPdfaCompliance(), userSettings.getSignatureLevel(), userSettings.isEn319132(), tspSource); + userSettings.isPdfaCompliance(), userSettings.getSignatureLevel(), userSettings.isEn319132(), tspSource, userSettings.isPlainXmlEnabled()); autogram.sign(job); } else { autogram.batchStart(filesList.size(), new BatchGuiFileResponder(autogram, filesList, filesList.get(0).toPath().getParent().resolve("signed"), userSettings.isPdfaCompliance(), - userSettings.getSignatureLevel(), userSettings.shouldSignPDFAsPades(), userSettings.isEn319132(), tspSource)); + userSettings.getSignatureLevel(), userSettings.shouldSignPDFAsPades(), userSettings.isEn319132(), tspSource, userSettings.isPlainXmlEnabled())); } } @@ -136,7 +136,7 @@ private void signDirectory(File dir) { autogram.batchStart(filesList.size(), new BatchGuiFileResponder(autogram, filesList, targetDirectory, userSettings.isPdfaCompliance(), userSettings.getSignatureLevel(), userSettings.shouldSignPDFAsPades(), - userSettings.isEn319132(), tspSource)); + userSettings.isEn319132(), tspSource, userSettings.isPlainXmlEnabled())); } public void onAboutButtonAction() { diff --git a/src/main/java/digital/slovensko/autogram/ui/gui/SettingsDialogController.java b/src/main/java/digital/slovensko/autogram/ui/gui/SettingsDialogController.java index 5391fcdf9..998461e31 100644 --- a/src/main/java/digital/slovensko/autogram/ui/gui/SettingsDialogController.java +++ b/src/main/java/digital/slovensko/autogram/ui/gui/SettingsDialogController.java @@ -31,6 +31,8 @@ public class SettingsDialogController { @FXML private HBox en319132Radios; @FXML + private HBox plainXmlEnabledRadios; + @FXML private ChoiceBox driverChoiceBox; @FXML private VBox trustedCountriesList; @@ -71,6 +73,7 @@ public void initialize() { initializeTsaServer(); initializeBulkEnabledCheckbox(); initializeEn319132CheckBox(); + initializePlainXmlEnabledCheckBox(); initializeCorrectDocumentDisplayCheckBox(); initializeSignatureValidationCheckBox(); initializeCheckPDFAComplianceCheckBox(); @@ -178,6 +181,10 @@ private void initializeEn319132CheckBox() { initializeBooleanRadios(en319132Radios, t -> userSettings.setEn319132(t), userSettings.isEn319132()); } + private void initializePlainXmlEnabledCheckBox() { + initializeBooleanRadios(plainXmlEnabledRadios, t -> userSettings.setPlainXmlEnabled(t), userSettings.isPlainXmlEnabled()); + } + private void initializeCorrectDocumentDisplayCheckBox() { initializeBooleanRadios(correctDocumentDisplayRadios, t -> userSettings.setCorrectDocumentDisplay(t), userSettings.isCorrectDocumentDisplay()); diff --git a/src/main/resources/digital/slovensko/autogram/ui/gui/settings-dialog.fxml b/src/main/resources/digital/slovensko/autogram/ui/gui/settings-dialog.fxml index 43d9cfd79..885fdea35 100644 --- a/src/main/resources/digital/slovensko/autogram/ui/gui/settings-dialog.fxml +++ b/src/main/resources/digital/slovensko/autogram/ui/gui/settings-dialog.fxml @@ -165,6 +165,24 @@ styleClass="autogram-smaller-radio-buttons" /> + + + + + Podpisovanie neznámych XML + + + + + Podpisovanie XML súborov, ktoré nie je možné podpísať ako štátny elektronický formulár. + + + + + + + diff --git a/src/test/java/digital/slovensko/autogram/AutogramTests.java b/src/test/java/digital/slovensko/autogram/AutogramTests.java index 786543aeb..9b82ea2b4 100644 --- a/src/test/java/digital/slovensko/autogram/AutogramTests.java +++ b/src/test/java/digital/slovensko/autogram/AutogramTests.java @@ -2,6 +2,7 @@ import digital.slovensko.autogram.core.*; import digital.slovensko.autogram.core.errors.AutogramException; +import digital.slovensko.autogram.core.errors.UnknownEformException; import digital.slovensko.autogram.core.visualization.Visualization; import digital.slovensko.autogram.drivers.TokenDriver; import digital.slovensko.autogram.ui.BatchUiResult; @@ -13,6 +14,7 @@ import eu.europa.esig.dss.token.DSSPrivateKeyEntry; import eu.europa.esig.dss.token.Pkcs12SignatureToken; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -43,7 +45,7 @@ void testSignAsiceXadesHappyScenario(InMemoryDocument document) { var newUI = new FakeUI(); var autogram = new Autogram(newUI, settings); - var parameters = SigningParameters.buildForASiCWithXAdES(document, false, null); + var parameters = SigningParameters.buildForASiCWithXAdES(document, false, null, true); var responder = mock(Responder.class); autogram.pickSigningKeyAndThen( @@ -52,6 +54,28 @@ void testSignAsiceXadesHappyScenario(InMemoryDocument document) { verify(responder).onDocumentSigned(any()); } + @ParameterizedTest + @MethodSource({ "digital.slovensko.autogram.TestMethodSources#nonEformXmlProvider"}) + void testSignNonEformHappyScenario(InMemoryDocument document) { + var settings = new TestSettings(); + var newUI = new FakeUI(); + var autogram = new Autogram(newUI, settings); + + var parameters = SigningParameters.buildForASiCWithXAdES(document, false, null, true); + var responder = mock(Responder.class); + + autogram.pickSigningKeyAndThen( + key -> autogram.sign(SigningJob.buildFromRequest(document, parameters, responder), key)); + + verify(responder).onDocumentSigned(any()); + } + + @ParameterizedTest + @MethodSource({ "digital.slovensko.autogram.TestMethodSources#nonEformXmlProvider"}) + void testSignNonEformNegativeScenario(InMemoryDocument document) { + Assertions.assertThrows(UnknownEformException.class, () -> SigningParameters.buildForASiCWithXAdES(document, false, null, false)); + } + @ParameterizedTest @MethodSource({"digital.slovensko.autogram.TestMethodSources#validOtherDocumentsProvider", "digital.slovensko.autogram.TestMethodSources#validCadesDocumentsProvider"}) @@ -60,13 +84,11 @@ void testSignAsiceCadesHappyScenario(InMemoryDocument document) { var settings = new TestSettings(); var autogram = new Autogram(newUI, settings); - var parameters = SigningParameters.buildForASiCWithCAdES(document, false, null); + var parameters = SigningParameters.buildForASiCWithCAdES(document, false, null, true); var responder = mock(Responder.class); autogram.pickSigningKeyAndThen( key -> autogram.sign(SigningJob.buildFromRequest(document, parameters, responder), key)); - - verify(responder).onDocumentSigned(any()); } @ParameterizedTest @@ -109,7 +131,7 @@ void testSignBuildFromFileHappyScenario(InMemoryDocument document) throws IOExce var responder = mock(Responder.class); autogram.pickSigningKeyAndThen( - key -> autogram.sign(SigningJob.buildFromFile(file, responder, false, SignatureLevel.XAdES_BASELINE_B, false, null), key)); + key -> autogram.sign(SigningJob.buildFromFile(file, responder, false, SignatureLevel.XAdES_BASELINE_B, false, null, true), key)); verify(responder).onDocumentSigned(any()); } diff --git a/src/test/java/digital/slovensko/autogram/SigningJobTests.java b/src/test/java/digital/slovensko/autogram/SigningJobTests.java index d838fd73b..8d0058b0f 100644 --- a/src/test/java/digital/slovensko/autogram/SigningJobTests.java +++ b/src/test/java/digital/slovensko/autogram/SigningJobTests.java @@ -50,7 +50,7 @@ void testEnd2EndHtmlTransformationEncoding() throws IOException, RequestValidati null); var signRequestBody = new SignRequestBody(new Document(content), ssParams, "application/xml;base64"); - var job = SigningJob.buildFromRequest(signRequestBody.getDocument(), signRequestBody.getParameters(null), null); + var job = SigningJob.buildFromRequest(signRequestBody.getDocument(), signRequestBody.getParameters(null, true), null); Visualization visualization = null; try { visualization = DocumentVisualizationBuilder.fromJob(job); diff --git a/src/test/java/digital/slovensko/autogram/SigningParametersTests.java b/src/test/java/digital/slovensko/autogram/SigningParametersTests.java index 34ee9d987..82a7c8e4c 100644 --- a/src/test/java/digital/slovensko/autogram/SigningParametersTests.java +++ b/src/test/java/digital/slovensko/autogram/SigningParametersTests.java @@ -60,7 +60,7 @@ void testThrowsAutogramExceptionWhenNoMimeType() throws IOException { Assertions.assertThrows(SigningParametersException.class, () -> SigningParameters.buildFromRequest(SignatureLevel.XAdES_BASELINE_B, asice, xdcXmlns, enveloping, null, false, inclusive, inclusive, inclusive, null, null, "id1/asa", false, 800, false, false, - null, null, null, null, null, document, tspSource)); + null, null, null, null, null, document, tspSource, true)); } @Test @@ -68,7 +68,7 @@ void testThrowsAutogramExceptionWhenNoDocument() { Assertions.assertThrows(SigningParametersException.class, () -> SigningParameters.buildFromRequest(SignatureLevel.XAdES_BASELINE_B, asice, xdcXmlns, enveloping, null, false, inclusive, inclusive, inclusive, null, "", "id1/asa", false, 800, false, false, - null, null, null, null, null, null, tspSource)); + null, null, null, null, null, null, tspSource, true)); } @Test @@ -78,7 +78,7 @@ void testThrowsXMLValidationFailedWhenNoXML() { Assertions.assertThrows(SigningParametersException.class, () -> SigningParameters.buildFromRequest(SignatureLevel.XAdES_BASELINE_B, asice, xdcXmlns, enveloping, null, false, inclusive, inclusive, inclusive, null, xsltTransformation, "id1/asa", false, 800, false, false, - null, null, null, null, null, document, tspSource)); + null, null, null, null, null, document, tspSource, true)); } @Test @@ -87,7 +87,7 @@ void testThrowsAutogramExceptionWhenNoSignatureLevel() { Assertions.assertThrows(SigningParametersException.class, () -> SigningParameters.buildFromRequest(null, asice, xdcXmlns, enveloping, null, false, inclusive, - inclusive, inclusive, null, "", "id1/asa", false, 800, false, false, null, null, null, null, null, document, tspSource)); + inclusive, inclusive, null, "", "id1/asa", false, 800, false, false, null, null, null, null, null, document, tspSource, true)); } @ParameterizedTest @@ -96,7 +96,7 @@ void testDoesNotThrowWithMinimalParametersForXadesNoConatiner(DSSDocument docume Assertions.assertDoesNotThrow( () -> SigningParameters.buildFromRequest(SignatureLevel.XAdES_BASELINE_B, null, null, null, null, false, null, null, null, null, null, null, false, 800, false, false, - null, null, null, null, null, document, tspSource)); + null, null, null, null, null, document, tspSource, true)); } @ParameterizedTest @@ -105,7 +105,7 @@ void testDoesNotThrowWithMinimalParametersForXadesInAsice(DSSDocument document) Assertions.assertDoesNotThrow( () -> SigningParameters.buildFromRequest(SignatureLevel.XAdES_BASELINE_B, asice, null, null, null, false, null, null, null, null, null, null, false, 800, false, false, - null, null, null, null, null, document, tspSource)); + null, null, null, null, null, document, tspSource, true)); } @ParameterizedTest @@ -114,7 +114,7 @@ void testDoesNotThrowWithMinimalParametersForXadesXdcInAsiceWith(DSSDocument doc Assertions.assertDoesNotThrow( () -> SigningParameters.buildFromRequest(SignatureLevel.XAdES_BASELINE_B, asice, xdcXmlns, null, null, false, null, null, null, xsdSchema, xsltTransformation, identifier, false, 800, false, false, - null, null, null, null, null, document, tspSource)); + null, null, null, null, null, document, tspSource, true)); } @ParameterizedTest @@ -123,7 +123,7 @@ void testDoesNotThrowWithMinimalParametersForXadesXdcInAsiceAutoLoadEform(DSSDoc // TODO: mock eform S3 resource Assertions.assertDoesNotThrow( () -> SigningParameters.buildFromRequest(SignatureLevel.XAdES_BASELINE_B, null, null, null, null, - false, null, null, null, null, null, null, false, 800, true, false, null, null, null, null, null, document, tspSource)); + false, null, null, null, null, null, null, false, 800, true, false, null, null, null, null, null, document, tspSource, true)); } @ParameterizedTest @@ -132,7 +132,7 @@ void testThrowsAutogramExceptionWithInvalidXml(DSSDocument document) { Assertions.assertThrows(XMLValidationException.class, () -> SigningParameters.buildFromRequest(SignatureLevel.XAdES_BASELINE_B, asice, xdcXmlns, null, null, false, null, null, null, xsdSchema, xsltTransformation, identifier, false, 800, false, false, - null, null, null, null, null, document, tspSource)); + null, null, null, null, null, document, tspSource, true)); } @ParameterizedTest @@ -141,7 +141,7 @@ void testThrowsAutogramExceptionWithInvalidXmlWithAutoLoadEform(DSSDocument docu // TODO: mock eform S3 resource Assertions.assertThrows(XMLValidationException.class, () -> SigningParameters.buildFromRequest(SignatureLevel.XAdES_BASELINE_B, null, null, null, null, - false, null, null, null, null, null, null, false, 800, true, false, null, null, null, null, null, document, tspSource)); + false, null, null, null, null, null, null, false, 800, true, false, null, null, null, null, null, document, tspSource, true)); } @ParameterizedTest @@ -150,7 +150,7 @@ void testThrowsAutogramExceptionWithInvalidXmlSchema(DSSDocument document) { Assertions.assertThrows(XMLValidationException.class, () -> SigningParameters.buildFromRequest(SignatureLevel.XAdES_BASELINE_B, asice, xdcXmlns, null, null, false, null, null, null, xsdSchema, xsltTransformation, identifier, false, 800, false, false, - null, null, null, null, null, document, tspSource)); + null, null, null, null, null, document, tspSource, true)); } @ParameterizedTest @@ -159,7 +159,7 @@ void testThrowsAutogramExceptionWithInvalidXmlSchemaWithAutoLoadEform(DSSDocumen // TODO: mock eform S3 resource Assertions.assertThrows(XMLValidationException.class, () -> SigningParameters.buildFromRequest(SignatureLevel.XAdES_BASELINE_B, null, null, null, null, - false, null, null, null, null, null, null, false, 800, true, false, null, null, null, null, null, document, tspSource)); + false, null, null, null, null, null, null, false, 800, true, false, null, null, null, null, null, document, tspSource, true)); } @ParameterizedTest @@ -167,7 +167,7 @@ void testThrowsAutogramExceptionWithInvalidXmlSchemaWithAutoLoadEform(DSSDocumen void testThrowsAutogramExceptionWithUnknownEformXml(DSSDocument document) { Assertions.assertThrows(SigningParametersException.class, () -> SigningParameters.buildFromRequest(SignatureLevel.XAdES_BASELINE_B, asice, xdcXmlns, null, null, - false, null, null, null, null, null, null, false, 800, false, false, null, null, null, null, null, document, tspSource)); + false, null, null, null, null, null, null, false, 800, false, false, null, null, null, null, null, document, tspSource, true)); } @ParameterizedTest @@ -175,7 +175,7 @@ void testThrowsAutogramExceptionWithUnknownEformXml(DSSDocument document) { void testThrowsAutogramExceptionWithUnknownEformXmlWithAutoLoadEform(DSSDocument document) { Assertions.assertThrows(XMLValidationException.class, () -> SigningParameters.buildFromRequest(SignatureLevel.XAdES_BASELINE_B, null, null, null, null, - false, null, null, null, null, null, null, false, 800, true, false, null, null, null, null, null, document, tspSource)); + false, null, null, null, null, null, null, false, 800, true, false, null, null, null, null, null, document, tspSource, true)); } @ParameterizedTest @@ -184,7 +184,7 @@ void testThrowsAutogramExceptionWithMismatchedDigestsXml(DSSDocument document) { Assertions.assertThrows(XMLValidationException.class, () -> SigningParameters.buildFromRequest(SignatureLevel.XAdES_BASELINE_B, asice, xdcXmlns, null, null, false, null, null, null, xsdSchema, xsltTransformation, identifier, false, 800, false, false, - null, null, null, null, null, document, tspSource)); + null, null, null, null, null, document, tspSource, true)); } @ParameterizedTest @@ -192,14 +192,14 @@ void testThrowsAutogramExceptionWithMismatchedDigestsXml(DSSDocument document) { void testThrowsAutogramExceptionWithMismatchedDigestsXmlWithAutoLoadEform(DSSDocument document) { Assertions.assertThrows(XMLValidationException.class, () -> SigningParameters.buildFromRequest(SignatureLevel.XAdES_BASELINE_B, null, null, null, null, - false, null, null, null, null, null, null, false, 800, true, false, null, null, null, null, null, document, tspSource)); + false, null, null, null, null, null, null, false, 800, true, false, null, null, null, null, null, document, tspSource, true)); } @ParameterizedTest @MethodSource("digital.slovensko.autogram.TestMethodSources#invalidAsiceProvider") void testThrowsOriginalDocumentNotFoundWithAsiceWithoutSignature(DSSDocument document) throws IOException { Assertions.assertThrows(OriginalDocumentNotFoundException.class, - () -> SigningParameters.buildForASiCWithXAdES(document, false, tspSource)); + () -> SigningParameters.buildForASiCWithXAdES(document, false, tspSource, true)); } @Test @@ -209,7 +209,7 @@ void testThrowsExceptionWithAsiceWithEmptyXml() throws IOException { "empty_xml.asice"); Assertions.assertThrows(XMLValidationException.class, - () -> SigningParameters.buildForASiCWithXAdES(document, false, tspSource)); + () -> SigningParameters.buildForASiCWithXAdES(document, false, tspSource, true)); } @Test @@ -221,7 +221,7 @@ void testInvalidTransformation() throws IOException { Assertions.assertThrows(TransformationParsingErrorException.class, () -> SigningParameters.buildFromRequest(SignatureLevel.XAdES_BASELINE_B, asice, xdcXmlns, null, null, false, null, null, null, xsdSchema, transformation, identifier, false, 800, false, false, - null, null, null, null, null, document, tspSource)); + null, null, null, null, null, document, tspSource, true)); } } diff --git a/src/test/java/digital/slovensko/autogram/TestMethodSources.java b/src/test/java/digital/slovensko/autogram/TestMethodSources.java index 1941944d7..fe12511cd 100644 --- a/src/test/java/digital/slovensko/autogram/TestMethodSources.java +++ b/src/test/java/digital/slovensko/autogram/TestMethodSources.java @@ -123,6 +123,14 @@ public static Stream validOtherDocumentsProvider() throws IOEx ); } + public static Stream nonEformXmlProvider() throws IOException { + var nonEformXml = cls.getResourceAsStream("non_eform.xml").readAllBytes(); + + return Stream.of( + new InMemoryDocument(nonEformXml, "nonEformXml.xml", MimeTypeEnum.XML) + ); + } + public static Stream pdfForPadesProvider() throws IOException { var samplePdf = cls.getResourceAsStream("sample.pdf").readAllBytes(); var samplePdfSigned = cls.getResourceAsStream("sample_signed.pdf").readAllBytes(); diff --git a/src/test/java/digital/slovensko/autogram/TransformationTests.java b/src/test/java/digital/slovensko/autogram/TransformationTests.java index 60fe9b183..32f025525 100644 --- a/src/test/java/digital/slovensko/autogram/TransformationTests.java +++ b/src/test/java/digital/slovensko/autogram/TransformationTests.java @@ -53,7 +53,7 @@ void testSigningJobTransformToHtml() throws IOException, ParserConfigurationExce ASiCContainerType.ASiC_E, null, SignaturePackaging.ENVELOPING, DigestAlgorithm.SHA256, false, CanonicalizationMethod.INCLUSIVE, CanonicalizationMethod.INCLUSIVE, CanonicalizationMethod.INCLUSIVE, - null, transformation, "id1/asa", false, 800, false, false, null, null, null, null, null, document, null); + null, transformation, "id1/asa", false, 800, false, false, null, null, null, null, null, document, null, true); SigningJob job = SigningJob.buildFromRequest(document, params, dummyResponder); @@ -112,7 +112,7 @@ void testSigningJobTransformSb() throws IOException, ParserConfigurationExceptio ASiCContainerType.ASiC_E, null, SignaturePackaging.ENVELOPING, DigestAlgorithm.SHA256, false, CanonicalizationMethod.INCLUSIVE, CanonicalizationMethod.INCLUSIVE, CanonicalizationMethod.INCLUSIVE, - null, transformation, "id1/asa", false, 800, false, false,null, null, null, null, null, document, null); + null, transformation, "id1/asa", false, 800, false, false,null, null, null, null, null, document, null, true); SigningJob job = SigningJob.buildFromRequest(document, params, dummyResponder); diff --git a/src/test/java/digital/slovensko/autogram/XDCBuilderTests.java b/src/test/java/digital/slovensko/autogram/XDCBuilderTests.java index d5ef02209..41469ccfa 100644 --- a/src/test/java/digital/slovensko/autogram/XDCBuilderTests.java +++ b/src/test/java/digital/slovensko/autogram/XDCBuilderTests.java @@ -39,7 +39,7 @@ void testTransformsPlainHtmlWithoutAddingNamespaces() throws IOException { xsdSchema, transformation, "http://data.gov.sk/doc/eform/App.GeneralAgenda/1.9", - false, 800, false, false, null, null, null, null, null, document, null); + false, 800, false, false, null, null, null, null, null, document, null, true); var out = XDCBuilder.transform(params, document.getName(), EFormUtils.getXmlFromDocument(document)); var transformed = new String(out.openStream().readAllBytes(), StandardCharsets.UTF_8); diff --git a/src/test/java/digital/slovensko/autogram/server/dto/SignRequestBodyTest.java b/src/test/java/digital/slovensko/autogram/server/dto/SignRequestBodyTest.java index 9ff5dfae1..54bec6e1b 100644 --- a/src/test/java/digital/slovensko/autogram/server/dto/SignRequestBodyTest.java +++ b/src/test/java/digital/slovensko/autogram/server/dto/SignRequestBodyTest.java @@ -57,7 +57,7 @@ void testValidateXDCWithoutXSD() throws IOException { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null);}); + Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null, true);}); } @Test @@ -93,7 +93,7 @@ void testValidateXDCWithValidXmlAgainstXSD() throws IOException { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null);}); + Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null, true);}); } @Test @@ -129,7 +129,7 @@ void testValidateXDCWithInvalidXmlAgainstXSD() throws IOException { var signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(XMLValidationException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(XMLValidationException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -165,7 +165,7 @@ void testValidateXDCDigestMismatchXSD() throws IOException { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(XMLValidationException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(XMLValidationException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -202,7 +202,7 @@ void testValidateXDCDigestMismatchXSLT() throws IOException { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(XMLValidationException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(XMLValidationException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -239,7 +239,7 @@ void testValidateXDCInvalidXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(XMLValidationException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(XMLValidationException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -276,7 +276,7 @@ void testValidateXDCInvalidXSLT() throws IOException { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(XMLValidationException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(XMLValidationException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -313,7 +313,7 @@ void testValidateXDCEmptyXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(XMLValidationException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(XMLValidationException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -350,7 +350,7 @@ void testValidateXDCEmptyXSLT() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(TransformationParsingErrorException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(TransformationParsingErrorException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -386,7 +386,7 @@ void testValidateXDCMissingDigestvalues() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(XMLValidationException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(XMLValidationException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -422,7 +422,7 @@ void testValidateXDCMissingReferences() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(XMLValidationException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(XMLValidationException.class, () -> {signRequestBody.getParameters(null, true);}); } @@ -459,7 +459,7 @@ void testValidateXDCEmptyXmlData() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(XMLValidationException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(XMLValidationException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -496,7 +496,7 @@ void testValidateXDCBase64InvalidXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -533,7 +533,7 @@ void testValidateXDCInAsiceBase64InvalidXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -570,7 +570,7 @@ void testValidateXDCBase64InvalidXSLT() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -607,7 +607,7 @@ void testValidateXDCInAsiceBase64InvalidXSLT() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -644,7 +644,7 @@ void testValidateXDCBase64EmptyXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -681,7 +681,7 @@ void testValidateXDCInAsiceBase64EmptyXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -719,7 +719,7 @@ void testValidateXDCBase64EmptyXSLT() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(TransformationParsingErrorException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(TransformationParsingErrorException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -756,7 +756,7 @@ void testValidateXDCInAsiceBase64EmptyXSLT() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -793,7 +793,7 @@ void testValidateXDCBase64DigestMismatchXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -830,7 +830,7 @@ void testValidateXDCInAsiceBase64DigestMismatchXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -867,7 +867,7 @@ void testValidateXDCBase64DigestMismatchXSLT() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -904,7 +904,7 @@ void testValidateXDCInAsiceBase64DigestMismatchXSLT() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -940,7 +940,7 @@ void testValidateXDCBase64WithoutXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null);}); + Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null, true);}); } @Test @@ -976,7 +976,7 @@ void testValidateXDCInAsiceBase64WithoutXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null);}); + Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null, true);}); } @Test @@ -1013,7 +1013,7 @@ void testValidateXDCBase64WithValidXmlAgainstXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null);}); + Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null, true);}); } @Test @@ -1050,7 +1050,7 @@ void testValidateXDCInAsiceBase64WithValidXmlAgainstXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null);}); + Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null, true);}); } @Test @@ -1087,7 +1087,7 @@ void testValidateXDCBase64WithInvalidXmlAgainstXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null);}); + Assertions.assertThrows(MalformedBodyException.class, () -> {signRequestBody.getParameters(null, true);}); } @Test @@ -1123,7 +1123,7 @@ void testValidateXmlWithoutXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null);}); + Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null, true);}); } @Test @@ -1160,7 +1160,7 @@ void testValidateXmlInvalidXmlAgainstXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null);}); + Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null, true);}); } @Test @@ -1197,7 +1197,7 @@ void testValidateXmlValidXmlAgainstXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null);}); + Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null, true);}); } @Test @@ -1233,7 +1233,7 @@ void testValidateXmlBase64WithoutXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null);}); + Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null, true);}); } @Test @@ -1269,7 +1269,7 @@ void testValidateXmlInAsiceBase64WithoutXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null);}); + Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null, true);}); } @Test @@ -1306,7 +1306,7 @@ void testValidateXmlBase64InvalidXmlAgainstXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null);}); + Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null, true);}); } @Test @@ -1343,7 +1343,7 @@ void testValidateXmlBase64ValidXmlAgainstXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null);}); + Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null, true);}); } @Test @@ -1380,7 +1380,7 @@ void testValidateXmlInAsiceBase64ValidXmlAgainstXSD() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null);}); + Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null, true);}); } @Test @@ -1416,6 +1416,6 @@ void testValidateTxtInAsiceBase64() { SignRequestBody signRequestBody = new SignRequestBody(document, signingParameters, payloadMimeType); - Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null);}); + Assertions.assertDoesNotThrow(() -> {signRequestBody.getParameters(null, true);}); } }