gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated (2152dd2 -> ba8d00d)


From: gnunet
Subject: [libeufin] branch master updated (2152dd2 -> ba8d00d)
Date: Tue, 28 Jan 2020 17:43:05 +0100

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

marcello pushed a change to branch master
in repository libeufin.

    from 2152dd2  template for new restore-backup API endpoint
     new 785563f  New package: tech.libeufin.nexus
     new 4dfbbfa  adjust import
     new ba8d00d  Fix Nexus migration to SQLite3.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../kotlin/{ => tech/libeufin/nexus}/Containers.kt |  0
 .../main/kotlin/{ => tech/libeufin/nexus}/DB.kt    | 12 ++--
 .../kotlin/{ => tech/libeufin/nexus}/Helpers.kt    | 37 ++++++++---
 .../main/kotlin/{ => tech/libeufin/nexus}/JSON.kt  |  3 -
 .../main/kotlin/{ => tech/libeufin/nexus}/Main.kt  | 75 +++++++++++++++++-----
 nexus/src/test/kotlin/LetterFormatTest.kt          |  2 +
 nexus/src/test/kotlin/SignatureDataTest.kt         |  1 +
 sandbox/build.gradle                               |  2 -
 .../src/main/kotlin/tech/libeufin/sandbox/DB.kt    |  1 -
 9 files changed, 97 insertions(+), 36 deletions(-)
 rename nexus/src/main/kotlin/{ => tech/libeufin/nexus}/Containers.kt (100%)
 rename nexus/src/main/kotlin/{ => tech/libeufin/nexus}/DB.kt (83%)
 rename nexus/src/main/kotlin/{ => tech/libeufin/nexus}/Helpers.kt (89%)
 rename nexus/src/main/kotlin/{ => tech/libeufin/nexus}/JSON.kt (91%)
 rename nexus/src/main/kotlin/{ => tech/libeufin/nexus}/Main.kt (92%)

diff --git a/nexus/src/main/kotlin/Containers.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Containers.kt
similarity index 100%
rename from nexus/src/main/kotlin/Containers.kt
rename to nexus/src/main/kotlin/tech/libeufin/nexus/Containers.kt
diff --git a/nexus/src/main/kotlin/DB.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
similarity index 83%
rename from nexus/src/main/kotlin/DB.kt
rename to nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index aba2e5c..f337b95 100644
--- a/nexus/src/main/kotlin/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -4,6 +4,7 @@ import org.jetbrains.exposed.dao.*
 import org.jetbrains.exposed.sql.*
 import org.jetbrains.exposed.sql.transactions.TransactionManager
 import org.jetbrains.exposed.sql.transactions.transaction
+import java.sql.Connection
 
 
 object EbicsSubscribersTable : IntIdTable() {
@@ -20,7 +21,9 @@ object EbicsSubscribersTable : IntIdTable() {
 }
 
 class EbicsSubscriberEntity(id: EntityID<Int>) : IntEntity(id) {
-    companion object : 
IntEntityClass<EbicsSubscriberEntity>(EbicsSubscribersTable)
+    companion object : IntEntityClass<EbicsSubscriberEntity>(
+        EbicsSubscribersTable
+    )
 
     var ebicsURL by EbicsSubscribersTable.ebicsURL
     var hostID by EbicsSubscribersTable.hostID
@@ -35,12 +38,13 @@ class EbicsSubscriberEntity(id: EntityID<Int>) : 
IntEntity(id) {
 }
 
 fun dbCreateTables() {
-    Database.connect("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", driver = 
"org.h2.Driver")
+    Database.connect("jdbc:sqlite:libeufin-nexus.sqlite3", "org.sqlite.JDBC")
+    TransactionManager.manager.defaultIsolationLevel = 
Connection.TRANSACTION_SERIALIZABLE
 
     transaction {
         addLogger(StdOutSqlLogger)
-        SchemaUtils.create(
+         SchemaUtils.create(
             EbicsSubscribersTable
-        )
+         )
     }
 }
\ No newline at end of file
diff --git a/nexus/src/main/kotlin/Helpers.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
similarity index 89%
rename from nexus/src/main/kotlin/Helpers.kt
rename to nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
index f0edd18..79c0cbb 100644
--- a/nexus/src/main/kotlin/Helpers.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
@@ -15,7 +15,6 @@ import java.security.interfaces.RSAPrivateCrtKey
 import java.security.interfaces.RSAPublicKey
 import java.util.*
 import javax.xml.bind.JAXBElement
-import javax.xml.datatype.DatatypeFactory
 import javax.xml.datatype.XMLGregorianCalendar
 
 
@@ -54,8 +53,12 @@ fun createDownloadInitializationPhase(
         subscriberData.hostId,
         nonce,
         date,
-        subscriberData.bankEncPub ?: throw 
BankKeyMissing(HttpStatusCode.PreconditionFailed),
-        subscriberData.bankAuthPub ?: throw 
BankKeyMissing(HttpStatusCode.PreconditionFailed),
+        subscriberData.bankEncPub ?: throw BankKeyMissing(
+            HttpStatusCode.PreconditionFailed
+        ),
+        subscriberData.bankAuthPub ?: throw BankKeyMissing(
+            HttpStatusCode.PreconditionFailed
+        ),
         orderType
     )
 }
@@ -75,8 +78,12 @@ fun createDownloadInitializationPhase(
         subscriberData.hostId,
         nonce,
         date,
-        subscriberData.bankEncPub ?: throw 
BankKeyMissing(HttpStatusCode.PreconditionFailed),
-        subscriberData.bankAuthPub ?: throw 
BankKeyMissing(HttpStatusCode.PreconditionFailed),
+        subscriberData.bankEncPub ?: throw BankKeyMissing(
+            HttpStatusCode.PreconditionFailed
+        ),
+        subscriberData.bankAuthPub ?: throw BankKeyMissing(
+            HttpStatusCode.PreconditionFailed
+        ),
         orderType,
         dateStart,
         dateEnd
@@ -241,7 +248,10 @@ suspend inline fun <reified T, reified S> 
HttpClient.postToBankSignedAndVerify(
         XMLUtil.parseStringIntoDom(response)
     } catch (e: Exception) {
 
-        throw UnparsableResponse(HttpStatusCode.BadRequest, response)
+        throw UnparsableResponse(
+            HttpStatusCode.BadRequest,
+            response
+        )
     }
 
     if (!XMLUtil.verifyEbicsDocument(responseDocument, pub)) {
@@ -254,7 +264,10 @@ suspend inline fun <reified T, reified S> 
HttpClient.postToBankSignedAndVerify(
         return XMLUtil.convertStringToJaxb(response)
     } catch (e: Exception) {
 
-        throw UnparsableResponse(HttpStatusCode.BadRequest, response)
+        throw UnparsableResponse(
+            HttpStatusCode.BadRequest,
+            response
+        )
     }
 }
 
@@ -272,7 +285,10 @@ suspend inline fun <reified T, reified S> 
HttpClient.postToBankSigned(
     try {
         return XMLUtil.convertStringToJaxb(response)
     } catch (e: Exception) {
-        throw UnparsableResponse(HttpStatusCode.BadRequest, response)
+        throw UnparsableResponse(
+            HttpStatusCode.BadRequest,
+            response
+        )
     }
 }
 
@@ -289,7 +305,10 @@ suspend inline fun <reified T, reified S> 
HttpClient.postToBankUnsigned(
     try {
         return XMLUtil.convertStringToJaxb(response)
     } catch (e: Exception) {
-        throw UnparsableResponse(HttpStatusCode.BadRequest, response)
+        throw UnparsableResponse(
+            HttpStatusCode.BadRequest,
+            response
+        )
     }
 }
 
diff --git a/nexus/src/main/kotlin/JSON.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
similarity index 91%
rename from nexus/src/main/kotlin/JSON.kt
rename to nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
index f2dba5c..202548e 100644
--- a/nexus/src/main/kotlin/JSON.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
@@ -1,8 +1,6 @@
 package tech.libeufin.nexus
 
-import com.google.gson.annotations.JsonAdapter
 import com.squareup.moshi.JsonClass
-import org.joda.time.DateTime
 
 
 data class EbicsBackupRequest(
@@ -33,7 +31,6 @@ data class EbicsKeysBackup(
  * This object is POSTed by clients _after_ having created
  * a EBICS subscriber at the sandbox.
  */
-@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/tech/libeufin/nexus/Main.kt
similarity index 92%
rename from nexus/src/main/kotlin/Main.kt
rename to nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 6ec477b..5fadf37 100644
--- a/nexus/src/main/kotlin/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -57,7 +57,6 @@ import java.util.*
 import java.util.zip.DeflaterInputStream
 import javax.crypto.EncryptedPrivateKeyInfo
 
-
 fun testData() {
 
     val pairA = CryptoUtil.generateRsaKeyPair(2048)
@@ -92,7 +91,7 @@ val LOGGER: Logger = 
LoggerFactory.getLogger("tech.libeufin.nexus")
 
 fun main() {
     dbCreateTables()
-    testData() // gets always id == 1
+    // testData()
     val client = HttpClient(){
         expectSuccess = false // this way, it does not throw exceptions on != 
200 responses.
     }
@@ -201,7 +200,13 @@ fun main() {
                 // will throw DateTimeParseException if strings are malformed.
 
                 val subscriberData = transaction {
-                    containerInit(EbicsSubscriberEntity.findById(id) ?: throw 
SubscriberNotFoundError(HttpStatusCode.NotFound))
+                    containerInit(
+                        EbicsSubscriberEntity.findById(
+                            id
+                        ) ?: throw SubscriberNotFoundError(
+                            HttpStatusCode.NotFound
+                        )
+                    )
                 }
 
                 val response = client.postToBankSigned<EbicsRequest, 
EbicsResponse>(
@@ -217,7 +222,11 @@ fun main() {
                     subscriberData.customerAuthPriv
                 )
 
-                val payload: ByteArray = 
decryptAndDecompressResponse(response.value, subscriberData.customerEncPriv)
+                val payload: ByteArray =
+                    decryptAndDecompressResponse(
+                        response.value,
+                        subscriberData.customerEncPriv
+                    )
 
                 call.respondText(
                     payload.toString(Charsets.UTF_8),
@@ -237,7 +246,13 @@ fun main() {
             get("/ebics/subscribers/{id}/sendHtd") {
                 val id = expectId(call.parameters["id"])
                 val subscriberData = transaction {
-                    containerInit(EbicsSubscriberEntity.findById(id) ?: throw 
SubscriberNotFoundError(HttpStatusCode.NotFound))
+                    containerInit(
+                        EbicsSubscriberEntity.findById(
+                            id
+                        ) ?: throw SubscriberNotFoundError(
+                            HttpStatusCode.NotFound
+                        )
+                    )
                 }
 
                 val response = client.postToBankSigned<EbicsRequest, 
EbicsResponse>(
@@ -274,14 +289,18 @@ fun main() {
                 logger.debug("HTD payload is: 
${XMLUtil.convertJaxbToString(data)}")
 
                 val ackRequest = EbicsRequest.createForDownloadReceiptPhase(
-                    response.value.header._static.transactionID ?: throw 
BankInvalidResponse(HttpStatusCode.ExpectationFailed),
+                    response.value.header._static.transactionID ?: throw 
BankInvalidResponse(
+                        HttpStatusCode.ExpectationFailed
+                    ),
                     subscriberData.hostId
                 )
 
                 val ackResponse = 
client.postToBankSignedAndVerify<EbicsRequest, EbicsResponse>(
                     subscriberData.ebicsUrl,
                     ackRequest,
-                    subscriberData.bankAuthPub ?: throw 
BankKeyMissing(HttpStatusCode.PreconditionFailed),
+                    subscriberData.bankAuthPub ?: throw BankKeyMissing(
+                        HttpStatusCode.PreconditionFailed
+                    ),
                     subscriberData.customerAuthPriv
                 )
 
@@ -332,7 +351,9 @@ fun main() {
 
 
                 transaction {
-                    val subscriber = EbicsSubscriberEntity.findById(id) ?: 
throw SubscriberNotFoundError(HttpStatusCode.NotFound)
+                    val subscriber = EbicsSubscriberEntity.findById(id) ?: 
throw SubscriberNotFoundError(
+                        HttpStatusCode.NotFound
+                    )
 
                     val signPubTmp = CryptoUtil.getRsaPublicFromPrivate(
                         
CryptoUtil.loadRsaPrivateKey(subscriber.signaturePrivateKey.toByteArray())
@@ -463,7 +484,9 @@ fun main() {
             get("/ebics/subscribers/{id}") {
                 val id = expectId(call.parameters["id"])
                 val response = transaction {
-                    val tmp = EbicsSubscriberEntity.findById(id) ?: throw 
SubscriberNotFoundError(HttpStatusCode.NotFound)
+                    val tmp = EbicsSubscriberEntity.findById(id) ?: throw 
SubscriberNotFoundError(
+                        HttpStatusCode.NotFound
+                    )
                     EbicsSubscriberInfoResponse(
                         accountID = tmp.id.value,
                         hostID = tmp.hostID,
@@ -511,10 +534,14 @@ fun main() {
 
             post("/ebics/subscribers/{id}/sendIni") {
 
-                val id = expectId(call.parameters["id"]) // caught above
+                val id =
+                    expectId(call.parameters["id"]) // caught above
                 val subscriberData = transaction {
                     containerInit(
-                        EbicsSubscriberEntity.findById(id) ?: throw 
SubscriberNotFoundError(HttpStatusCode.NotFound)
+                        EbicsSubscriberEntity.findById(id)
+                            ?: throw SubscriberNotFoundError(
+                                HttpStatusCode.NotFound
+                            )
                     )
                 }
 
@@ -566,7 +593,9 @@ fun main() {
                 }
 
                 transaction {
-                    val subscriber = EbicsSubscriberEntity.findById(id) ?: 
throw SubscriberNotFoundError(HttpStatusCode.NotFound)
+                    val subscriber = EbicsSubscriberEntity.findById(id) ?: 
throw SubscriberNotFoundError(
+                        HttpStatusCode.NotFound
+                    )
 
                     subscriber.encryptionPrivateKey = 
SerialBlob(encKey.encoded)
                     subscriber.authenticationPrivateKey = 
SerialBlob(authKey.encoded)
@@ -587,7 +616,9 @@ fun main() {
                 val body = call.receive<EbicsBackupRequest>()
 
                 val content = transaction {
-                    val subscriber = EbicsSubscriberEntity.findById(id) ?: 
throw SubscriberNotFoundError(HttpStatusCode.NotFound)
+                    val subscriber = EbicsSubscriberEntity.findById(id) ?: 
throw SubscriberNotFoundError(
+                        HttpStatusCode.NotFound
+                    )
 
 
                     EbicsKeysBackup(
@@ -599,7 +630,8 @@ fun main() {
 
                         encBlob = CryptoUtil.encryptKey(
                             subscriber.encryptionPrivateKey.toByteArray(),
-                            body.passphrase),
+                            body.passphrase
+                        ),
 
                         sigBlob = CryptoUtil.encryptKey(
                             subscriber.signaturePrivateKey.toByteArray(),
@@ -621,7 +653,10 @@ fun main() {
 
                 val subscriberData = transaction {
                     containerInit(
-                        EbicsSubscriberEntity.findById(id) ?: throw 
SubscriberNotFoundError(HttpStatusCode.NotFound)
+                        EbicsSubscriberEntity.findById(id)
+                            ?: throw SubscriberNotFoundError(
+                                HttpStatusCode.NotFound
+                            )
                     )
                 }
                 val payload = "PAYLOAD"
@@ -707,7 +742,10 @@ fun main() {
                 val id = expectId(call.parameters["id"])
                 val bundle = transaction {
                     containerInit(
-                        EbicsSubscriberEntity.findById(id) ?: throw 
SubscriberNotFoundError(HttpStatusCode.NotFound)
+                        EbicsSubscriberEntity.findById(id)
+                            ?: throw SubscriberNotFoundError(
+                                HttpStatusCode.NotFound
+                            )
                     )
                 }
                 val response = client.postToBankSigned<EbicsNpkdRequest, 
EbicsKeyManagementResponse>(
@@ -769,7 +807,10 @@ fun main() {
 
                 val subscriberData = transaction {
                     containerInit(
-                        EbicsSubscriberEntity.findById(id) ?: throw 
SubscriberNotFoundError(HttpStatusCode.NotFound)
+                        EbicsSubscriberEntity.findById(id)
+                            ?: throw SubscriberNotFoundError(
+                                HttpStatusCode.NotFound
+                            )
                     )
                 }
 
diff --git a/nexus/src/test/kotlin/LetterFormatTest.kt 
b/nexus/src/test/kotlin/LetterFormatTest.kt
index f5a455e..ecf9534 100644
--- a/nexus/src/test/kotlin/LetterFormatTest.kt
+++ b/nexus/src/test/kotlin/LetterFormatTest.kt
@@ -1,6 +1,8 @@
 package tech.libeufin.nexus
 
 import org.junit.Test
+import tech.libeufin.nexus.chunkString
+import tech.libeufin.nexus.getNonce
 import tech.libeufin.util.toHexString
 
 class LetterFormatTest {
diff --git a/nexus/src/test/kotlin/SignatureDataTest.kt 
b/nexus/src/test/kotlin/SignatureDataTest.kt
index cb0c1d5..7a81c3f 100644
--- a/nexus/src/test/kotlin/SignatureDataTest.kt
+++ b/nexus/src/test/kotlin/SignatureDataTest.kt
@@ -3,6 +3,7 @@ package tech.libeufin.nexus
 import tech.libeufin.util.XMLUtil
 import org.apache.xml.security.binding.xmldsig.SignatureType
 import org.junit.Test
+import tech.libeufin.nexus.getNonce
 import tech.libeufin.util.CryptoUtil
 import tech.libeufin.util.ebics_h004.EbicsRequest
 import tech.libeufin.util.ebics_h004.EbicsTypes
diff --git a/sandbox/build.gradle b/sandbox/build.gradle
index 573671d..b1fdee3 100644
--- a/sandbox/build.gradle
+++ b/sandbox/build.gradle
@@ -4,12 +4,10 @@ plugins {
     id 'application'
 }
 
-
 sourceCompatibility = "11"
 targetCompatibility = "11"
 version '1.0-snapshot'
 
-
 compileKotlin {
 
     kotlinOptions {
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
index e8853d5..f825491 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
@@ -365,7 +365,6 @@ class EbicsUploadTransactionChunkEntity(id : 
EntityID<String>): Entity<String>(i
 
 fun dbCreateTables() {
     Database.connect("jdbc:sqlite:libeufin-sandbox.sqlite3", "org.sqlite.JDBC")
-    // Database.connect("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", driver = 
"org.h2.Driver")
     TransactionManager.manager.defaultIsolationLevel = 
Connection.TRANSACTION_SERIALIZABLE
 
     transaction {

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



reply via email to

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