gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: re-enable backup, this time generic


From: gnunet
Subject: [libeufin] branch master updated: re-enable backup, this time generic
Date: Sun, 24 May 2020 14:24:19 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new d14f334  re-enable backup, this time generic
d14f334 is described below

commit d14f334378b16f5df9a2d16cda69baf5eb72a878
Author: Florian Dold <address@hidden>
AuthorDate: Sun May 24 17:54:14 2020 +0530

    re-enable backup, this time generic
---
 nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 49 ++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 2 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 17074d7..9916978 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -591,7 +591,7 @@ fun serverMain() {
                     when (body) {
                         is CreateBankConnectionFromBackupRequestJson -> {
                             val type = body.data.get("type")
-                            if (type == null || !type.isTextual()) {
+                            if (type == null || !type.isTextual) {
                                 throw NexusError(HttpStatusCode.BadRequest, 
"backup needs type")
                             }
                             when (type.textValue()) {
@@ -655,7 +655,52 @@ fun serverMain() {
             }
 
             post("/bank-connections/{connid}/export-backup") {
-                throw NotImplementedError()
+                val body = call.receive<EbicsBackupRequestJson>()
+                val response = transaction {
+                    val user = authenticateRequest(call.request)
+                    val conn = requireBankConnection(call, "connid")
+                    when (conn.type) {
+                        "ebics" -> {
+                            val subscriber = 
getEbicsSubscriberDetails(user.id.value, conn.id.value)
+                            EbicsKeysBackupJson(
+                                type = "ebics",
+                                userID = subscriber.userId,
+                                hostID = subscriber.hostId,
+                                partnerID = subscriber.partnerId,
+                                ebicsURL = subscriber.ebicsUrl,
+                                authBlob = bytesToBase64(
+                                    CryptoUtil.encryptKey(
+                                        subscriber.customerAuthPriv.encoded,
+                                        body.passphrase
+                                    )
+                                ),
+                                encBlob = bytesToBase64(
+                                    CryptoUtil.encryptKey(
+                                        subscriber.customerEncPriv.encoded,
+                                        body.passphrase
+                                    )
+                                ),
+                                sigBlob = bytesToBase64(
+                                    CryptoUtil.encryptKey(
+                                        subscriber.customerSignPriv.encoded,
+                                        body.passphrase
+                                    )
+                                )
+                            )
+                        }
+                        else -> {
+                            throw NexusError(
+                                HttpStatusCode.BadRequest,
+                                "bank connection is not of type 'ebics' (but 
'${conn.type}')"
+                            )
+                        }
+                    }
+                }
+                call.response.headers.append("Content-Disposition", 
"attachment")
+                call.respond(
+                    HttpStatusCode.OK,
+                    response
+                )
             }
 
             post("/bank-connections/{connid}/connect") {

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]