diff --git a/src/main/java/digital/slovensko/autogram/core/eforms/FsEFormResources.java b/src/main/java/digital/slovensko/autogram/core/eforms/FsEFormResources.java index 18babf37..324a8bde 100644 --- a/src/main/java/digital/slovensko/autogram/core/eforms/FsEFormResources.java +++ b/src/main/java/digital/slovensko/autogram/core/eforms/FsEFormResources.java @@ -72,11 +72,11 @@ private static String getFormUrlFromXdcIdentifier(String xdcIdentifier) { r = getSlugAndVersion(xpath, parsed_meta_xml, "//" + ns + ":form[@xdcIdentifier=\"" + xdcIdentifier + "/1.0\"]"); if (r != null) - throw new EFormException("Nesprávny XDC identifikátor v podpísanom formulári", "XDC identifikátor v tomto konkrétnom podpísanom formulári by mal obsahovať ešte označenie verzie /1.0. Takto podpísaný formulár bude pravdepodobne odmietnutý informačným systémom Finančnej správy."); + return r; r = getSlugAndVersion(xpath, parsed_meta_xml, "//" + ns + ":form[@xdcIdentifier=\"" + xdcIdentifier.replace("/1.0", "") + "\"]"); if (r != null) - throw new EFormException("Nesprávny XDC identifikátor v podpísanom formulári", "XDC identifikátor v tomto konkrétnom podpísanom formulári by nemal obsahovať označenie verzie /1.0. Takto podpísaný formulár bude pravdepodobne odmietnutý informačným systémom Finančnej správy."); + return r; } catch (XPathExpressionException e) { throw new UnrecognizedException(e); @@ -175,6 +175,9 @@ public EFormAttributes getEformAttributes() { } public String getIdentifier() { - return xdcIdentifier; + if (xdcIdentifier.matches(".*/[v0-9.]+$")) + return xdcIdentifier; + + return xdcIdentifier + "/1.0"; } } \ No newline at end of file diff --git a/src/test/java/digital/slovensko/autogram/AutogramTests.java b/src/test/java/digital/slovensko/autogram/AutogramTests.java index 52dd0b2a..38bbaaee 100644 --- a/src/test/java/digital/slovensko/autogram/AutogramTests.java +++ b/src/test/java/digital/slovensko/autogram/AutogramTests.java @@ -40,8 +40,7 @@ class AutogramTests { "digital.slovensko.autogram.TestMethodSources#orsrDocumentsProvider", "digital.slovensko.autogram.TestMethodSources#validOtherDocumentsProvider", "digital.slovensko.autogram.TestMethodSources#validXadesDocumentsProvider", - "digital.slovensko.autogram.TestMethodSources#fsDPFOProvider", - "digital.slovensko.autogram.TestMethodSources#fsUnmarkedXdcProvider"}) + "digital.slovensko.autogram.TestMethodSources#fsDPFOProvider" }) void testSignAsiceXadesHappyScenario(InMemoryDocument document) { var settings = new TestSettings(); var newUI = new FakeUI(); diff --git a/src/test/java/digital/slovensko/autogram/SigningParametersTests.java b/src/test/java/digital/slovensko/autogram/SigningParametersTests.java index c0896120..5c4cf178 100644 --- a/src/test/java/digital/slovensko/autogram/SigningParametersTests.java +++ b/src/test/java/digital/slovensko/autogram/SigningParametersTests.java @@ -220,13 +220,6 @@ void testThrowsOriginalDocumentNotFoundWithAsiceWithoutSignature(DSSDocument doc () -> SigningParameters.buildForASiCWithXAdES(document, false, false, tspSource, true)); } - @ParameterizedTest - @MethodSource("digital.slovensko.autogram.TestMethodSources#fsWrongXdcIdentifierProvider") - void testThrowsEFormExceptionWithWrongFsXdcIdentifier(DSSDocument document) throws IOException { - Assertions.assertThrows(EFormException.class, - () -> SigningParameters.buildForASiCWithXAdES(document, false, false, tspSource, true)); - } - @Test void testThrowsExceptionWithAsiceWithEmptyXml() throws IOException { var document = new InMemoryDocument( diff --git a/src/test/java/digital/slovensko/autogram/TestMethodSources.java b/src/test/java/digital/slovensko/autogram/TestMethodSources.java index dd8f9911..4c8e12d8 100644 --- a/src/test/java/digital/slovensko/autogram/TestMethodSources.java +++ b/src/test/java/digital/slovensko/autogram/TestMethodSources.java @@ -67,18 +67,6 @@ public static Stream fsUnmarkedXdcProvider() throws IOException { ); } - public static Stream fsWrongXdcIdentifierProvider() throws IOException { - var xdc = cls.getResourceAsStream("fs_forms/d_fs792_772_xdc_wrong_identifier.xml").readAllBytes(); - var asice = cls.getResourceAsStream("fs_forms/signed_wrong_identifier.asice").readAllBytes(); - var asiceMarked = cls.getResourceAsStream("fs_forms/d_fs792_772_xdc_wrong_identifier.asice").readAllBytes(); - - return Stream.of( - new InMemoryDocument(xdc, "d_fs792_772_xdc_wrong_identifier.xml", AutogramMimeType.XML_DATACONTAINER), - new InMemoryDocument(asice, "signed_wrong_identifier.asice", MimeTypeEnum.ASICE), - new InMemoryDocument(asiceMarked, "d_fs792_772_xdc_wrong_identifier.asice", MimeTypeEnum.ASICE) - ); - } - public static Stream invalidXmlProvider() throws IOException { var notAnXml = "not an xml".getBytes(); var invalidXml = "".getBytes(); diff --git a/src/test/resources/digital/slovensko/autogram/fs_forms/DPFOBv23.asice b/src/test/resources/digital/slovensko/autogram/fs_forms/DPFOBv23.asice index b6c3f839..967d9719 100644 Binary files a/src/test/resources/digital/slovensko/autogram/fs_forms/DPFOBv23.asice and b/src/test/resources/digital/slovensko/autogram/fs_forms/DPFOBv23.asice differ diff --git a/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc.xml b/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc.xml index cdc177f3..88f3e7c3 100644 --- a/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc.xml +++ b/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc.xml @@ -1 +1 @@ -2120515056100202385590Ostatné vzdelávanie i. n.SurnameNameStaré grunty1884104BratislavaSlovenská republika00000000000000000000000000000000000000000000000000000000000000000000000000028800.0028800.0017280.006000.00923.086000.00923.080010100.00000028800.0017280.0011520.0011520.0020202021202211520.0011520.006000.00923.085076.925076.9211520.004922.820.00180.005102.820.005076.92964.61964.615102.826417.186417.1828800.00962.58962.580.000.001927.191927.191927.191927.19010000407.03.20240000007350.000.000https://ekr.financnasprava.sk/Formulare/xsd/dpfo_b2023.xsdhttps://ekr.financnasprava.sk/Formulare/xslt/dpfo_b2023Plaintext.xsl \ No newline at end of file +2120515056100202385590Ostatné vzdelávanie i. n.SurnameNameStaré grunty1884104BratislavaSlovenská republika00000000000000000000000000000000000000000000000000000000000000000000000000028800.0028800.0017280.006000.00923.086000.00923.080010100.00000028800.0017280.0011520.0011520.0020202021202211520.0011520.006000.00923.085076.925076.9211520.004922.820.00180.005102.820.005076.92964.61964.615102.826417.186417.1828800.00962.58962.580.000.001927.191927.191927.191927.19010000407.03.20240000007350.000.000https://ekr.financnasprava.sk/Formulare/xsd/dpfo_b2023.xsdhttps://ekr.financnasprava.sk/Formulare/xslt/dpfo_b2023Plaintext.xsl \ No newline at end of file diff --git a/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc_indented.xml b/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc_indented.xml index 8f04b4be..694f924a 100644 --- a/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc_indented.xml +++ b/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc_indented.xml @@ -1,7 +1,7 @@ + Identifier="https://ekr.financnasprava.sk/Formulare/xsd/dpfo_b2023.xsd/1.0" Version="1.0"> 2120515056 diff --git a/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc_wrong_identifier.asice b/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc_wrong_identifier.asice deleted file mode 100644 index 967d9719..00000000 Binary files a/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc_wrong_identifier.asice and /dev/null differ diff --git a/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc_wrong_identifier.xml b/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc_wrong_identifier.xml deleted file mode 100644 index 88f3e7c3..00000000 --- a/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc_wrong_identifier.xml +++ /dev/null @@ -1 +0,0 @@ -2120515056100202385590Ostatné vzdelávanie i. n.SurnameNameStaré grunty1884104BratislavaSlovenská republika00000000000000000000000000000000000000000000000000000000000000000000000000028800.0028800.0017280.006000.00923.086000.00923.080010100.00000028800.0017280.0011520.0011520.0020202021202211520.0011520.006000.00923.085076.925076.9211520.004922.820.00180.005102.820.005076.92964.61964.615102.826417.186417.1828800.00962.58962.580.000.001927.191927.191927.191927.19010000407.03.20240000007350.000.000https://ekr.financnasprava.sk/Formulare/xsd/dpfo_b2023.xsdhttps://ekr.financnasprava.sk/Formulare/xslt/dpfo_b2023Plaintext.xsl \ No newline at end of file diff --git a/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc_xsd_digest.xml b/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc_xsd_digest.xml index 62441e65..8b5c6dbf 100644 --- a/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc_xsd_digest.xml +++ b/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc_xsd_digest.xml @@ -1,7 +1,7 @@ + Identifier="https://ekr.financnasprava.sk/Formulare/xsd/dpfo_b2023.xsd/1.0" Version="1.0"> 2120515056 diff --git a/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc_xslt_digest.xml b/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc_xslt_digest.xml index 56bff897..1594c8e2 100644 --- a/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc_xslt_digest.xml +++ b/src/test/resources/digital/slovensko/autogram/fs_forms/d_fs792_772_xdc_xslt_digest.xml @@ -1,7 +1,7 @@ + Identifier="https://ekr.financnasprava.sk/Formulare/xsd/dpfo_b2023.xsd/1.0" Version="1.0"> 2120515056 diff --git a/src/test/resources/digital/slovensko/autogram/fs_forms/signed.asice b/src/test/resources/digital/slovensko/autogram/fs_forms/signed.asice index b6c3f839..967d9719 100644 Binary files a/src/test/resources/digital/slovensko/autogram/fs_forms/signed.asice and b/src/test/resources/digital/slovensko/autogram/fs_forms/signed.asice differ diff --git a/src/test/resources/digital/slovensko/autogram/fs_forms/signed_indented.asice b/src/test/resources/digital/slovensko/autogram/fs_forms/signed_indented.asice index 23db2cca..1d0773a9 100644 Binary files a/src/test/resources/digital/slovensko/autogram/fs_forms/signed_indented.asice and b/src/test/resources/digital/slovensko/autogram/fs_forms/signed_indented.asice differ diff --git a/src/test/resources/digital/slovensko/autogram/fs_forms/signed_indented_ts.asice b/src/test/resources/digital/slovensko/autogram/fs_forms/signed_indented_ts.asice index cad8a20f..da3c9955 100644 Binary files a/src/test/resources/digital/slovensko/autogram/fs_forms/signed_indented_ts.asice and b/src/test/resources/digital/slovensko/autogram/fs_forms/signed_indented_ts.asice differ diff --git a/src/test/resources/digital/slovensko/autogram/fs_forms/signed_wrong_identifier.asice b/src/test/resources/digital/slovensko/autogram/fs_forms/signed_wrong_identifier.asice deleted file mode 100644 index 967d9719..00000000 Binary files a/src/test/resources/digital/slovensko/autogram/fs_forms/signed_wrong_identifier.asice and /dev/null differ diff --git a/src/test/resources/digital/slovensko/autogram/fs_forms/signed_xdc_xsd_digest.asice b/src/test/resources/digital/slovensko/autogram/fs_forms/signed_xdc_xsd_digest.asice index 37d0cd47..e7cd9a42 100644 Binary files a/src/test/resources/digital/slovensko/autogram/fs_forms/signed_xdc_xsd_digest.asice and b/src/test/resources/digital/slovensko/autogram/fs_forms/signed_xdc_xsd_digest.asice differ diff --git a/src/test/resources/digital/slovensko/autogram/fs_forms/signed_xdc_xslt_digest.asice b/src/test/resources/digital/slovensko/autogram/fs_forms/signed_xdc_xslt_digest.asice index 990c3301..907bfb1c 100644 Binary files a/src/test/resources/digital/slovensko/autogram/fs_forms/signed_xdc_xslt_digest.asice and b/src/test/resources/digital/slovensko/autogram/fs_forms/signed_xdc_xslt_digest.asice differ diff --git a/src/test/resources/digital/slovensko/autogram/fs_forms/unmarked_xdc_indented.xml b/src/test/resources/digital/slovensko/autogram/fs_forms/unmarked_xdc_indented.xml index 8f04b4be..694f924a 100644 --- a/src/test/resources/digital/slovensko/autogram/fs_forms/unmarked_xdc_indented.xml +++ b/src/test/resources/digital/slovensko/autogram/fs_forms/unmarked_xdc_indented.xml @@ -1,7 +1,7 @@ + Identifier="https://ekr.financnasprava.sk/Formulare/xsd/dpfo_b2023.xsd/1.0" Version="1.0"> 2120515056