libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit c6fba2461569e999c3cda20f6186db750621420e
parent ee8a2b27060b7db55e7bbb4a0ff7cad9b0022ed6
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date:   Thu, 19 Dec 2019 15:58:59 +0100

fix #5990

Diffstat:
A.idea/runConfigurations/test_nexus.xml | 22++++++++++++++++++++++
Mutil/src/main/kotlin/XMLUtil.kt | 12+++++++++++-
2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/.idea/runConfigurations/test_nexus.xml b/.idea/runConfigurations/test_nexus.xml @@ -0,0 +1,21 @@ +<component name="ProjectRunConfigurationManager"> + <configuration default="false" name="test-nexus" type="GradleRunConfiguration" factoryName="Gradle"> + <ExternalSystemSettings> + <option name="executionName" /> + <option name="externalProjectPath" value="$PROJECT_DIR$/nexus" /> + <option name="externalSystemIdString" value="GRADLE" /> + <option name="scriptParameters" value="" /> + <option name="taskDescriptions"> + <list /> + </option> + <option name="taskNames"> + <list> + <option value="test" /> + </list> + </option> + <option name="vmOptions" value="" /> + </ExternalSystemSettings> + <GradleScriptDebugEnabled>true</GradleScriptDebugEnabled> + <method v="2" /> + </configuration> +</component> +\ No newline at end of file diff --git a/util/src/main/kotlin/XMLUtil.kt b/util/src/main/kotlin/XMLUtil.kt @@ -20,6 +20,7 @@ package tech.libeufin.util import com.sun.org.apache.xerces.internal.dom.DOMInputImpl +import com.sun.xml.bind.marshaller.NamespacePrefixMapper import org.w3c.dom.Document import org.w3c.dom.Node import org.w3c.dom.NodeList @@ -57,6 +58,14 @@ import javax.xml.xpath.XPath import javax.xml.xpath.XPathConstants import javax.xml.xpath.XPathFactory +class DefaultNamespaces : NamespacePrefixMapper() { + override fun getPreferredPrefix(namespaceUri: String?, suggestion: String?, requirePrefix: Boolean): String? { + if (namespaceUri == "http://www.w3.org/2000/09/xmldsig#") return "ds" + return null + } +} + + /** * Helpers for dealing with XML in EBICS. */ @@ -89,7 +98,6 @@ class XMLUtil private constructor() { return NodeSetData { nodeList.iterator() } } } - /** * Validator for EBICS messages. */ @@ -198,6 +206,7 @@ class XMLUtil private constructor() { val jc = JAXBContext.newInstance(T::class.java) val m = jc.createMarshaller() m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true) + m.setProperty("com.sun.xml.bind.namespacePrefixMapper", DefaultNamespaces()) m.marshal(obj, sw) return sw.toString() } @@ -209,6 +218,7 @@ class XMLUtil private constructor() { val jc = JAXBContext.newInstance(T::class.java) val m = jc.createMarshaller() m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true) + m.setProperty("com.sun.xml.bind.namespacePrefixMapper", DefaultNamespaces()) m.marshal(obj, doc) return doc }