gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: main logic to backup keys


From: gnunet
Subject: [libeufin] branch master updated: main logic to backup keys
Date: Wed, 20 Nov 2019 00:50:28 +0100

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

marcello pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 9e3880d  main logic to backup keys
9e3880d is described below

commit 9e3880d39fe2793ee4cd459799a307154f7369c4
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Nov 20 00:49:47 2019 +0100

    main logic to backup keys
    
    no passphrase protection for now
---
 nexus/src/main/kotlin/JSON.kt | 10 +++++++++-
 nexus/src/main/kotlin/Main.kt | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/nexus/src/main/kotlin/JSON.kt b/nexus/src/main/kotlin/JSON.kt
index 8a571fc..5691f58 100644
--- a/nexus/src/main/kotlin/JSON.kt
+++ b/nexus/src/main/kotlin/JSON.kt
@@ -3,11 +3,19 @@ package tech.libeufin.nexus
 import com.google.gson.annotations.JsonAdapter
 import com.squareup.moshi.JsonClass
 
+
+data class EbicsKeysBackup(
+
+    val authBlob: ByteArray,
+    val encBlob: ByteArray,
+    val sigBlob: ByteArray
+)
+
 /**
  * This object is POSTed by clients _after_ having created
  * a EBICS subscriber at the sandbox.
  */
-@JsonClass(generateAdapter = true)
+@JsonClass(generateAdapter = true) // USED?
 data class EbicsSubscriberInfoRequest(
     val ebicsURL: String,
     val hostID: String,
diff --git a/nexus/src/main/kotlin/Main.kt b/nexus/src/main/kotlin/Main.kt
index a7a71b2..9bda6d7 100644
--- a/nexus/src/main/kotlin/Main.kt
+++ b/nexus/src/main/kotlin/Main.kt
@@ -738,7 +738,45 @@ fun main() {
                 return@post
             }
 
+            post("/ebics/subscribers/{id}/restoreBackup") {
 
+                val body = call.receive<EbicsKeysBackup>()
+                val id = expectId(call.parameters["id"])
+
+                transaction {
+                    val subscriber = EbicsSubscriberEntity.findById(id) ?: 
throw SubscriberNotFoundError(HttpStatusCode.NotFound)
+                    subscriber.encryptionPrivateKey = SerialBlob(body.encBlob)
+                    subscriber.authenticationPrivateKey = 
SerialBlob(body.authBlob)
+                    subscriber.signaturePrivateKey = SerialBlob(body.sigBlob)
+                }
+
+                call.respondText(
+                    "Keys successfully restored",
+                    ContentType.Text.Plain,
+                    HttpStatusCode.OK
+                )
+
+            }
+
+            get("/ebics/subscribers/{id}/backup") {
+
+                val id = expectId(call.parameters["id"])
+                val content = transaction {
+                    val subscriber = EbicsSubscriberEntity.findById(id) ?: 
throw SubscriberNotFoundError(HttpStatusCode.NotFound)
+                    EbicsKeysBackup(
+                        authBlob = 
subscriber.authenticationPrivateKey.toByteArray(),
+                        encBlob = 
subscriber.encryptionPrivateKey.toByteArray(),
+                        sigBlob = subscriber.signaturePrivateKey.toByteArray()
+                    )
+                }
+
+                call.response.headers.append("Content-Disposition", 
"attachment")
+                call.respond(
+                    HttpStatusCode.OK,
+                    content
+                )
+
+            }
             post("/ebics/subscribers/{id}/sendTst") {
 
                 val id = expectId(call.parameters["id"])

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



reply via email to

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