summaryrefslogtreecommitdiff
path: root/nexus
diff options
context:
space:
mode:
Diffstat (limited to 'nexus')
-rw-r--r--nexus/build.gradle3
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/ebics/Ebics2.kt4
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsCommon.kt25
-rw-r--r--nexus/src/test/kotlin/Ebics.kt24
4 files changed, 10 insertions, 46 deletions
diff --git a/nexus/build.gradle b/nexus/build.gradle
index be202f45..58e7858f 100644
--- a/nexus/build.gradle
+++ b/nexus/build.gradle
@@ -24,9 +24,6 @@ dependencies {
implementation(project(":common"))
implementation(project(":ebics"))
- // XML parsing/binding and encryption
- implementation("jakarta.xml.bind:jakarta.xml.bind-api:2.3.3")
-
// Command line parsing
implementation("com.github.ajalt.clikt:clikt:$clikt_version")
implementation("org.postgresql:postgresql:$postgres_version")
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/Ebics2.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/Ebics2.kt
index 3de5632e..1fdb4b26 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/Ebics2.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/Ebics2.kt
@@ -27,10 +27,6 @@ import org.slf4j.Logger
import org.slf4j.LoggerFactory
import tech.libeufin.common.*
import tech.libeufin.ebics.*
-import tech.libeufin.ebics.ebics_h004.EbicsKeyManagementResponse
-import tech.libeufin.ebics.ebics_h004.EbicsNpkdRequest
-import tech.libeufin.ebics.ebics_h004.EbicsRequest
-import tech.libeufin.ebics.ebics_h004.EbicsUnsecuredRequest
import tech.libeufin.nexus.BankPublicKeysFile
import tech.libeufin.nexus.ClientPrivateKeysFile
import tech.libeufin.nexus.EbicsSetupConfig
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsCommon.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsCommon.kt
index 157e53b2..496006e2 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsCommon.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsCommon.kt
@@ -215,8 +215,7 @@ suspend fun postEbics(
client: HttpClient,
cfg: EbicsSetupConfig,
bankKeys: BankPublicKeysFile,
- xmlReq: ByteArray,
- isEbics3: Boolean
+ xmlReq: ByteArray
): EbicsResponseContent {
val respXml = try {
client.postToBank(cfg.hostBaseUrl, xmlReq)
@@ -241,16 +240,15 @@ suspend fun postEbics(
if (!XMLUtil.verifyEbicsDocument(
doc,
bankKeys.bank_authentication_public_key,
- isEbics3
+ true
)) {
throw EbicsSideException(
"Bank signature did not verify",
sideEc = EbicsSideError.BANK_SIGNATURE_DIDNT_VERIFY
)
}
- if (isEbics3)
- return ebics3toInternalRepr(doc)
- return ebics25toInternalRepr(doc)
+
+ return ebics3toInternalRepr(doc)
}
/**
@@ -296,7 +294,7 @@ suspend fun ebicsDownload(
// error loop until the pending transaction timeout.
// TODO find a way to cancel the pending transaction ?
withContext(NonCancellable) {
- val initResp = postEbics(client, cfg, bankKeys, reqXml, true)
+ val initResp = postEbics(client, cfg, bankKeys, reqXml)
logger.debug("Download init phase done. EBICS- and bank-technical codes are: ${initResp.technicalReturnCode}, ${initResp.bankReturnCode}")
if (initResp.technicalReturnCode != EbicsReturnCode.EBICS_OK) {
throw Exception("Download init phase has EBICS-technical error: ${initResp.technicalReturnCode}")
@@ -337,7 +335,7 @@ suspend fun ebicsDownload(
// request segment number x.
val transReq = impl.downloadTransfer(x, howManySegments, tId)
- val transResp = postEbics(client, cfg, bankKeys, transReq, true)
+ val transResp = postEbics(client, cfg, bankKeys, transReq)
if (!areCodesOk(transResp)) {
throw EbicsSideException(
"EBICS transfer segment #$x failed.",
@@ -358,8 +356,7 @@ suspend fun ebicsDownload(
client,
cfg,
bankKeys,
- receiptXml,
- true
+ receiptXml
)
}
if (scope.isActive) {
@@ -440,7 +437,7 @@ fun prepareUploadPayload(
cfg.ebicsUserId
)
val encryptionResult = CryptoUtil.encryptEbicsE002(
- EbicsOrderUtil.encodeOrderDataXml(innerSignedEbicsXml),
+ innerSignedEbicsXml.inputStream().deflate().readAllBytes(),
bankKeys.bank_encryption_public_key
)
val plainTransactionKey = encryptionResult.plainTransactionKey
@@ -517,8 +514,7 @@ suspend fun doEbicsUpload(
client,
cfg,
bankKeys,
- initXml,
- isEbics3 = true
+ initXml
)
if (!areCodesOk(initResp)) throw EbicsUploadException(
"EBICS upload init failed",
@@ -537,8 +533,7 @@ suspend fun doEbicsUpload(
client,
cfg,
bankKeys,
- transferXml,
- isEbics3 = true
+ transferXml
)
logger.debug("Download init phase done. EBICS- and bank-technical codes are: ${transferResp.technicalReturnCode}, ${transferResp.bankReturnCode}")
if (!areCodesOk(transferResp)) throw EbicsUploadException(
diff --git a/nexus/src/test/kotlin/Ebics.kt b/nexus/src/test/kotlin/Ebics.kt
index a1c86f20..7bd05fa7 100644
--- a/nexus/src/test/kotlin/Ebics.kt
+++ b/nexus/src/test/kotlin/Ebics.kt
@@ -21,36 +21,12 @@ import io.ktor.client.engine.mock.*
import io.ktor.http.*
import org.junit.Test
import tech.libeufin.ebics.XMLUtil
-import tech.libeufin.ebics.ebics_h004.EbicsUnsecuredRequest
import tech.libeufin.nexus.ebics.*
import kotlin.io.path.Path
import kotlin.io.path.writeBytes
import kotlin.test.assertEquals
class Ebics {
- // Checks XML is valid and INI.
- @Test
- fun iniMessage() = conf { config ->
- val msg = generateIniMessage(config, clientKeys)
- val ini = XMLUtil.convertToJaxb<EbicsUnsecuredRequest>(msg.inputStream()) // ensures is valid
- assertEquals(ini.value.header.static.orderDetails.orderType, "INI") // ensures is INI
- }
-
- // Checks XML is valid and HIA.
- @Test
- fun hiaMessage() = conf { config ->
- val msg = generateHiaMessage(config, clientKeys)
- val ini = XMLUtil.convertToJaxb<EbicsUnsecuredRequest>(msg.inputStream()) // ensures is valid
- assertEquals(ini.value.header.static.orderDetails.orderType, "HIA") // ensures is HIA
- }
-
- // Checks XML is valid and HPB.
- @Test
- fun hpbMessage() = conf { config ->
- val msg = generateHpbMessage(config, clientKeys)
- val ini = XMLUtil.convertToJaxb<EbicsUnsecuredRequest>(msg.inputStream()) // ensures is valid
- assertEquals(ini.value.header.static.orderDetails.orderType, "HPB") // ensures is HPB
- }
// POSTs an EBICS message to the mock bank. Tests
// the main branches: unreachable bank, non-200 status
// code, and 200.