diff options
author | Antoine A <> | 2024-03-12 10:57:23 +0100 |
---|---|---|
committer | Antoine A <> | 2024-03-12 10:57:23 +0100 |
commit | 0cc7f2a61b17f2870d1c8f9c45d0eb754a60a27b (patch) | |
tree | 2fb49d578202c0956c07f0d0d676cc0de8bf75cb /nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsKeyMng.kt | |
parent | 0d62875dd2287857c5da172dcb3301062880810a (diff) | |
download | libeufin-0cc7f2a61b17f2870d1c8f9c45d0eb754a60a27b.tar.gz libeufin-0cc7f2a61b17f2870d1c8f9c45d0eb754a60a27b.tar.bz2 libeufin-0cc7f2a61b17f2870d1c8f9c45d0eb754a60a27b.zip |
Clean code and fix tests
Diffstat (limited to 'nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsKeyMng.kt')
-rw-r--r-- | nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsKeyMng.kt | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsKeyMng.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsKeyMng.kt index 1847beec..a6d965e5 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsKeyMng.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsKeyMng.kt @@ -45,11 +45,7 @@ class Ebics3KeyMng( el("ns2:SignatureVersion", "A006") } } - val doc = XmlBuilder.toDom("ebicsUnsecuredRequest", "urn:org:ebics:H004") { - attr("http://www.w3.org/2000/xmlns/", "xmlns", "urn:org:ebics:H004") - attr("http://www.w3.org/2000/xmlns/", "xmlns:ds", "http://www.w3.org/2000/09/xmldsig#") - attr("Version", "H004") - attr("Revision", "1") + val doc = request("ebicsUnsecuredRequest") { el("header") { attr("authenticate", "true") el("static") { @@ -80,11 +76,7 @@ class Ebics3KeyMng( el("ns2:EncryptionVersion", "E002") } } - val doc = XmlBuilder.toDom("ebicsUnsecuredRequest", "urn:org:ebics:H004") { - attr("http://www.w3.org/2000/xmlns/", "xmlns", "urn:org:ebics:H004") - attr("http://www.w3.org/2000/xmlns/", "xmlns:ds", "http://www.w3.org/2000/09/xmldsig#") - attr("Version", "H004") - attr("Revision", "1") + val doc = request("ebicsUnsecuredRequest") { el("header") { attr("authenticate", "true") el("static") { @@ -106,11 +98,7 @@ class Ebics3KeyMng( fun HPB(): ByteArray { val nonce = getNonce(128) - val doc = XmlBuilder.toDom("ebicsNoPubKeyDigestsRequest", "urn:org:ebics:H004") { - attr("http://www.w3.org/2000/xmlns/", "xmlns", "urn:org:ebics:H004") - attr("http://www.w3.org/2000/xmlns/", "xmlns:ds", "http://www.w3.org/2000/09/xmldsig#") - attr("Version", "H004") - attr("Revision", "1") + val doc = request("ebicsNoPubKeyDigestsRequest") { el("header") { attr("authenticate", "true") el("static") { @@ -136,6 +124,16 @@ class Ebics3KeyMng( /* ----- Helpers ----- */ + private fun request(name: String, build: XmlBuilder.() -> Unit): Document { + return XmlBuilder.toDom(name, "urn:org:ebics:H004") { + attr("http://www.w3.org/2000/xmlns/", "xmlns", "urn:org:ebics:H004") + attr("http://www.w3.org/2000/xmlns/", "xmlns:ds", "http://www.w3.org/2000/09/xmldsig#") + attr("Version", "H004") + attr("Revision", "1") + build() + } + } + private fun XmlBuilder.RSAKeyXml(key: RSAPrivateCrtKey) { el("ns2:PubKeyValue") { el("ds:RSAKeyValue") { |