commit e9ab70b4e0e598baeb4b4033f407640d5236c95c
parent 3c7ff7037a26de936f19754e8427e9d9fb95e6f3
Author: Florian Dold <florian.dold@gmail.com>
Date: Thu, 30 Jan 2020 15:43:57 +0100
letter tweaks / fix key confusion
Diffstat:
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
@@ -133,7 +133,7 @@ fun containerInit(subscriber: EbicsSubscriberEntity): EbicsContainer {
customerSignPriv = CryptoUtil.loadRsaPrivateKey(subscriber.signaturePrivateKey.toByteArray()),
customerAuthPriv = CryptoUtil.loadRsaPrivateKey(subscriber.authenticationPrivateKey.toByteArray()),
- customerEncPriv = CryptoUtil.loadRsaPrivateKey(subscriber.authenticationPrivateKey.toByteArray())
+ customerEncPriv = CryptoUtil.loadRsaPrivateKey(subscriber.encryptionPrivateKey.toByteArray())
)
}
@@ -145,7 +145,7 @@ fun chunkString(input: String): String {
var columns = 0
for (i in input.indices) {
if ((i + 1).rem(2) == 0) {
- if (columns == 7) {
+ if (columns == 15) {
ret.append(input[i] + "\n")
columns = 0
continue
@@ -156,7 +156,7 @@ fun chunkString(input: String): String {
}
ret.append(input[i])
}
- return ret.toString()
+ return ret.toString().toUpperCase()
}
fun expectId(param: String?): String {
@@ -247,6 +247,7 @@ suspend inline fun <reified T, reified S> HttpClient.postToBankSigned(
val doc = XMLUtil.convertJaxbToDocument(body)
XMLUtil.signEbicsDocument(doc, priv)
val response: String = this.postToBank(url, XMLUtil.convertDomToString(doc))
+ println("bank response: $response")
try {
return XMLUtil.convertStringToJaxb(response)
} catch (e: Exception) {
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -315,9 +315,10 @@ fun main() {
val encVersionLine = "E002"
val now = Date()
val dateFormat = SimpleDateFormat("DD.MM.YYYY")
- val timeFormat = SimpleDateFormat("HH.mm.ss")
- var dateLine = dateFormat.format(now)
- var timeLine = timeFormat.format(now)
+ val timeFormat = SimpleDateFormat("HH:mm:ss")
+ val dateLine = dateFormat.format(now)
+ val timeLine = timeFormat.format(now)
+ var hostID = ""
transaction {
val subscriber = EbicsSubscriberEntity.findById(id) ?: throw SubscriberNotFoundError(
HttpStatusCode.NotFound
@@ -331,6 +332,7 @@ fun main() {
val encPubTmp = CryptoUtil.getRsaPublicFromPrivate(
CryptoUtil.loadRsaPrivateKey(subscriber.encryptionPrivateKey.toByteArray())
)
+ hostID = subscriber.hostID
userIdLine = subscriber.userID
esExponentLine = signPubTmp.publicExponent.toByteArray().toHexString()
esModulusLine = signPubTmp.modulus.toByteArray().toHexString()
@@ -347,8 +349,9 @@ fun main() {
|Date: ${dateLine}
|Time: ${timeLine}
|Recipient: ${recipientLine}
+ |Host ID: ${hostID}
|User ID: ${userIdLine}
- |Customer ID: ${customerIdLine}
+ |Partner ID: ${customerIdLine}
|ES version: ${esVersionLine}
|Public key for the electronic signature:
@@ -369,6 +372,7 @@ fun main() {
|__________
|Signature
+ |
""".trimMargin()
val hiaLetter = """
@@ -376,8 +380,9 @@ fun main() {
|Date: ${dateLine}
|Time: ${timeLine}
|Recipient: ${recipientLine}
+ |Host ID: ${hostID}
|User ID: ${userIdLine}
- |Customer ID: ${customerIdLine}
+ |Partner ID: ${customerIdLine}
|Identification and authentication signature version: ${authVersionLine}
|Encryption version: ${encVersionLine}
@@ -410,6 +415,7 @@ fun main() {
|__________
|Signature
+ |
""".trimMargin()
call.respondText(
@@ -682,7 +688,7 @@ fun main() {
usd_encrypted
),
subscriberData.bankAuthPub!!,
- subscriberData.customerEncPriv
+ subscriberData.customerAuthPriv
)
if (response.value.body.returnCode.value != "000000") {
throw EbicsError(response.value.body.returnCode.value)