gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated (26875f2 -> 9c36aa1)


From: gnunet
Subject: [libeufin] branch master updated (26875f2 -> 9c36aa1)
Date: Wed, 20 May 2020 13:21:51 +0200

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

dold pushed a change to branch master
in repository libeufin.

    from 26875f2  formatting via black
     new d795c43  update deps
     new 9c36aa1  use jackson

The 2 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:
 build.gradle                                       |  2 +-
 integration-tests/test-ebics.py                    |  2 +-
 nexus/build.gradle                                 | 23 +++++++-----
 nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt    | 39 ++++++++++++++++----
 .../src/main/kotlin/tech/libeufin/nexus/Helpers.kt | 11 +++---
 nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt  | 42 ++++++++++++----------
 util/build.gradle                                  |  2 --
 7 files changed, 77 insertions(+), 44 deletions(-)

diff --git a/build.gradle b/build.gradle
index cf6cc8a..e304305 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,5 @@
 plugins {
-    id 'org.jetbrains.kotlin.jvm' version '1.3.50'
+    id 'org.jetbrains.kotlin.jvm' version '1.3.72'
 }
 allprojects {
     repositories {
diff --git a/integration-tests/test-ebics.py b/integration-tests/test-ebics.py
index d640e4a..ac633aa 100755
--- a/integration-tests/test-ebics.py
+++ b/integration-tests/test-ebics.py
@@ -231,7 +231,7 @@ assertResponse(
 assertResponse(
     post(
         "http://localhost:5001/bank-accounts/collected-transactions";,
-        json=dict(type="ebics", name="my-ebics"),
+        json=dict(transport=dict(type="ebics", name="my-ebics")),
         headers=dict(Authorization=USER_AUTHORIZATION_HEADER),
     )
 )
diff --git a/nexus/build.gradle b/nexus/build.gradle
index 2c6f3b2..b109726 100644
--- a/nexus/build.gradle
+++ b/nexus/build.gradle
@@ -52,13 +52,13 @@ compileTestKotlin {
     }
 }
 
+
+def ktor_version = "1.3.2"
+
+
 dependencies {
     implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
-    implementation "io.ktor:ktor-gson:1.1.5"
-    implementation group: 'io.ktor', name: 'ktor-gson', version: '0.9.0'
     implementation "org.jetbrains.exposed:exposed:0.17.6"
-    implementation "io.ktor:ktor-server-netty:1.2.4"
-    implementation "io.ktor:ktor-auth:1.2.4"
     implementation "ch.qos.logback:logback-classic:1.2.3"
     implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
     implementation "javax.xml.bind:jaxb-api:2.3.0"
@@ -70,12 +70,17 @@ dependencies {
 
     implementation("com.github.ajalt:clikt:2.7.0")
 
-    testImplementation group: 'junit', name: 'junit', version: '4.12'
-}
-
-dependencies {
     implementation project(":util")
-    compile "io.ktor:ktor-client-apache:1.2.4"
+
+    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7'
+
+    implementation "io.ktor:ktor-server-core:$ktor_version"
+    implementation "io.ktor:ktor-client-apache:$ktor_version"
+    implementation "io.ktor:ktor-server-netty:$ktor_version"
+    implementation "io.ktor:ktor-auth:$ktor_version"
+    implementation "io.ktor:ktor-jackson:$ktor_version"
+
+    testImplementation group: 'junit', name: 'junit', version: '4.12'
 }
 
 application {
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index 89d55e2..d44a514 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -2,9 +2,16 @@ package tech.libeufin.nexus
 
 import io.ktor.http.HttpStatusCode
 import org.jetbrains.exposed.dao.*
-import org.jetbrains.exposed.sql.*
+import org.jetbrains.exposed.sql.Database
+import org.jetbrains.exposed.sql.SchemaUtils
+import org.jetbrains.exposed.sql.StdOutSqlLogger
+import org.jetbrains.exposed.sql.addLogger
 import org.jetbrains.exposed.sql.transactions.TransactionManager
 import org.jetbrains.exposed.sql.transactions.transaction
+import tech.libeufin.nexus.EbicsSubscribersTable.entityId
+import tech.libeufin.nexus.EbicsSubscribersTable.primaryKey
+import tech.libeufin.nexus.NexusUsersTable.entityId
+import tech.libeufin.nexus.NexusUsersTable.primaryKey
 import tech.libeufin.util.amount
 import java.sql.Connection
 
@@ -16,13 +23,14 @@ const val ID_MAX_LENGTH = 50
  * whether a pain.001 document was sent or not to the bank is indicated
  * in the PAIN-table.
  */
-object TalerRequestedPayments: LongIdTable() {
+object TalerRequestedPayments : LongIdTable() {
     val preparedPayment = reference("payment", PreparedPaymentsTable)
     val requestUId = text("request_uid")
     val amount = text("amount")
     val exchangeBaseUrl = text("exchange_base_url")
     val wtid = text("wtid")
     val creditAccount = text("credit_account")
+
     /**
      * This column gets a value only after the bank acknowledges the payment 
via
      * a camt.05x entry.  The "crunch" logic is responsible for assigning such 
value.
@@ -32,6 +40,7 @@ object TalerRequestedPayments: LongIdTable() {
 
 class TalerRequestedPaymentEntity(id: EntityID<Long>) : LongEntity(id) {
     companion object : 
LongEntityClass<TalerRequestedPaymentEntity>(TalerRequestedPayments)
+
     var preparedPayment by PreparedPaymentEntity referencedOn 
TalerRequestedPayments.preparedPayment
     var requestUId by TalerRequestedPayments.requestUId
     var amount by TalerRequestedPayments.amount
@@ -45,9 +54,10 @@ class TalerRequestedPaymentEntity(id: EntityID<Long>) : 
LongEntity(id) {
  * This is the table of the incoming payments.  Entries are merely "pointers" 
to the
  * entries from the raw payments table.  Fixme: name should end with "-table".
  */
-object TalerIncomingPayments: LongIdTable() {
+object TalerIncomingPayments : LongIdTable() {
     val payment = reference("payment", RawBankTransactionsTable)
     val valid = bool("valid")
+
     // avoid refunding twice!
     val refunded = bool("refunded").default(false)
 }
@@ -73,6 +83,7 @@ class TalerIncomingPaymentEntity(id: EntityID<Long>) : 
LongEntity(id) {
             return newRow
         }
     }
+
     var payment by RawBankTransactionEntity referencedOn 
TalerIncomingPayments.payment
     var valid by TalerIncomingPayments.valid
     var refunded by TalerIncomingPayments.refunded
@@ -99,6 +110,7 @@ object RawBankTransactionsTable : LongIdTable() {
 
 class RawBankTransactionEntity(id: EntityID<Long>) : LongEntity(id) {
     companion object : 
LongEntityClass<RawBankTransactionEntity>(RawBankTransactionsTable)
+
     var sourceFileName by RawBankTransactionsTable.sourceFileName
     var unstructuredRemittanceInformation by 
RawBankTransactionsTable.unstructuredRemittanceInformation
     var transactionType by RawBankTransactionsTable.transactionType
@@ -112,6 +124,7 @@ class RawBankTransactionEntity(id: EntityID<Long>) : 
LongEntity(id) {
     var status by RawBankTransactionsTable.status
     var bankAccount by BankAccountEntity referencedOn 
RawBankTransactionsTable.bankAccount
 }
+
 /**
  * Represents a prepared payment.
  */
@@ -131,18 +144,22 @@ object PreparedPaymentsTable : IdTable<String>() {
     val debitorIban = text("debitorIban")
     val debitorBic = text("debitorBic")
     val debitorName = text("debitorName").nullable()
+
     /* Indicates whether the PAIN message was sent to the bank. */
     val submitted = bool("submitted").default(false)
+
     /* Indicates whether the bank didn't perform the payment: note that
      * this state can be reached when the payment gets listed in a CRZ
      * response OR when the payment doesn't show up in a C52/C53 response */
     val invalid = bool("invalid").default(false)
+
     /** never really used, but it makes sure the user always exists  */
     val nexusUser = reference("nexusUser", NexusUsersTable)
 }
 
 class PreparedPaymentEntity(id: EntityID<String>) : Entity<String>(id) {
     companion object : EntityClass<String, 
PreparedPaymentEntity>(PreparedPaymentsTable)
+
     var paymentId by PreparedPaymentsTable.paymentId
     var preparationDate by PreparedPaymentsTable.preparationDate
     var submissionDate by PreparedPaymentsTable.submissionDate
@@ -168,11 +185,12 @@ object BankAccountsTable : IdTable<String>() {
     override val id = varchar("id", ID_MAX_LENGTH).primaryKey().entityId()
     val accountHolder = text("accountHolder")
     val iban = text("iban")
-    val bankCode = text("bankCode") 
+    val bankCode = text("bankCode")
 }
 
 class BankAccountEntity(id: EntityID<String>) : Entity<String>(id) {
     companion object : EntityClass<String, 
BankAccountEntity>(BankAccountsTable)
+
     var accountHolder by BankAccountsTable.accountHolder
     var iban by BankAccountsTable.iban
     var bankCode by BankAccountsTable.bankCode
@@ -195,6 +213,7 @@ object EbicsSubscribersTable : IdTable<String>() {
 
 class EbicsSubscriberEntity(id: EntityID<String>) : Entity<String>(id) {
     companion object : EntityClass<String, 
EbicsSubscriberEntity>(EbicsSubscribersTable)
+
     var ebicsURL by EbicsSubscribersTable.ebicsURL
     var hostID by EbicsSubscribersTable.hostID
     var partnerID by EbicsSubscribersTable.partnerID
@@ -216,6 +235,7 @@ object NexusUsersTable : IdTable<String>() {
 
 class NexusUserEntity(id: EntityID<String>) : Entity<String>(id) {
     companion object : EntityClass<String, NexusUserEntity>(NexusUsersTable)
+
     var passwordHash by NexusUsersTable.passwordHash
     var superuser by NexusUsersTable.superuser
 }
@@ -225,13 +245,20 @@ object BankAccountMapsTable : IntIdTable() {
     val bankAccount = reference("bankAccount", BankAccountsTable)
     val nexusUser = reference("nexusUser", NexusUsersTable)
 }
-class BankAccountMapEntity(id: EntityID<Int>): IntEntity(id) {
+
+class BankAccountMapEntity(id: EntityID<Int>) : IntEntity(id) {
     companion object : 
IntEntityClass<BankAccountMapEntity>(BankAccountMapsTable)
+
     var ebicsSubscriber by EbicsSubscriberEntity referencedOn 
BankAccountMapsTable.ebicsSubscriber
     var bankAccount by BankAccountEntity referencedOn 
BankAccountMapsTable.bankAccount
     var nexusUser by NexusUserEntity referencedOn 
BankAccountMapsTable.nexusUser
 }
 
+object NexusBankConnectionsTable : IdTable<String>() {
+    override val id = EbicsSubscribersTable.text("id").entityId().primaryKey()
+    
+}
+
 fun dbCreateTables() {
     Database.connect("jdbc:sqlite:libeufin-nexus.sqlite3", "org.sqlite.JDBC")
     TransactionManager.manager.defaultIsolationLevel = 
Connection.TRANSACTION_SERIALIZABLE
@@ -246,6 +273,6 @@ fun dbCreateTables() {
             TalerIncomingPayments,
             TalerRequestedPayments,
             BankAccountMapsTable
-         )
+        )
     }
 }
\ No newline at end of file
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
index 6258679..5967af0 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
@@ -1,7 +1,8 @@
 package tech.libeufin.nexus
 
-import com.google.gson.Gson
-import com.google.gson.JsonObject
+import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
+import com.fasterxml.jackson.module.kotlin.treeToValue
 import io.ktor.client.HttpClient
 import io.ktor.http.HttpStatusCode
 import org.jetbrains.exposed.sql.and
@@ -57,10 +58,8 @@ fun extractFirstBic(bankCodes: 
List<EbicsTypes.AbstractBankCode>?): String? {
     return null
 }
 
-fun getTransportFromJsonObject(jo: JsonObject): Transport {
-    return Gson().fromJson(
-        expectNonNull(jo.get("transport")).asJsonObject, Transport::class.java
-    )
+fun getTransportFromJsonObject(jo: JsonNode): Transport {
+    return jacksonObjectMapper().treeToValue(jo.get("transport"), 
Transport::class.java)
 }
 
 /**
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 5bcf100..ea7a91c 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -19,22 +19,25 @@
 
 package tech.libeufin.nexus
 
+import com.fasterxml.jackson.core.util.DefaultIndenter
+import com.fasterxml.jackson.core.util.DefaultPrettyPrinter
+import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.SerializationFeature
+import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
 import com.github.ajalt.clikt.core.CliktCommand
 import com.github.ajalt.clikt.core.ProgramResult
 import com.github.ajalt.clikt.core.subcommands
 import com.github.ajalt.clikt.parameters.arguments.argument
 import com.github.ajalt.clikt.parameters.options.option
 import com.github.ajalt.clikt.parameters.options.prompt
-import com.google.gson.Gson
-import com.google.gson.JsonObject
 import io.ktor.application.ApplicationCallPipeline
 import io.ktor.application.call
 import io.ktor.application.install
 import io.ktor.client.HttpClient
 import io.ktor.features.*
-import io.ktor.gson.gson
 import io.ktor.http.ContentType
 import io.ktor.http.HttpStatusCode
+import io.ktor.jackson.jackson
 import io.ktor.request.ApplicationReceivePipeline
 import io.ktor.request.ApplicationReceiveRequest
 import io.ktor.request.receive
@@ -47,10 +50,10 @@ import io.ktor.routing.routing
 import io.ktor.server.engine.embeddedServer
 import io.ktor.server.netty.Netty
 import io.ktor.util.KtorExperimentalAPI
-import kotlinx.coroutines.io.ByteReadChannel
-import kotlinx.coroutines.io.jvm.javaio.toByteReadChannel
-import kotlinx.coroutines.io.jvm.javaio.toInputStream
-import kotlinx.io.core.ExperimentalIoApi
+import io.ktor.utils.io.ByteReadChannel
+import io.ktor.utils.io.core.ExperimentalIoApi
+import io.ktor.utils.io.jvm.javaio.toByteReadChannel
+import io.ktor.utils.io.jvm.javaio.toInputStream
 import org.jetbrains.exposed.sql.and
 import org.jetbrains.exposed.sql.transactions.transaction
 import org.joda.time.DateTime
@@ -218,9 +221,13 @@ fun serverMain() {
             this.logger = tech.libeufin.nexus.logger
         }
         install(ContentNegotiation) {
-            gson {
-                setDateFormat(DateFormat.LONG)
-                setPrettyPrinting()
+            jackson {
+                enable(SerializationFeature.INDENT_OUTPUT)
+                setDefaultPrettyPrinter(DefaultPrettyPrinter().apply {
+                    
indentArraysWith(DefaultPrettyPrinter.FixedSpaceIndenter.instance)
+                    indentObjectsWith(DefaultIndenter("  ", "\n"))
+                })
+                //registerModule(JavaTimeModule())
             }
         }
         install(StatusPages) {
@@ -318,6 +325,9 @@ fun serverMain() {
                 )
                 return@post
             }
+            get("/bank-connection-protocols")  {
+                return@get
+            }
             /**
              * Shows the bank accounts belonging to the requesting user.
              */
@@ -513,15 +523,12 @@ fun serverMain() {
             post("/bank-transports") {
                 val userId = transaction { 
authenticateRequest(call.request.headers["Authorization"]).id.value }
                 // user exists and is authenticated.
-                val body = call.receive<JsonObject>()
+                val body = call.receive<JsonNode>()
                 val transport: Transport = getTransportFromJsonObject(body)
                 when (transport.type) {
                     "ebics" -> {
                         if (body.get("backup") != null) {
-                            val backup = Gson().fromJson(
-                                body.get("backup").asJsonObject,
-                                EbicsKeysBackupJson::class.java
-                            )
+                            val backup = 
jacksonObjectMapper().treeToValue(body,EbicsKeysBackupJson::class.java)
                             val (authKey, encKey, sigKey) = try {
                                 Triple(
                                     CryptoUtil.decryptKey(
@@ -571,10 +578,7 @@ fun serverMain() {
                             return@post
                         }
                         if (body.get("data") != null) {
-                            val data = Gson().fromJson(
-                                body.get("data"),
-                                EbicsNewTransport::class.java
-                            )
+                            val data = 
jacksonObjectMapper().treeToValue((body.get("data")), 
EbicsNewTransport::class.java)
                             val pairA = CryptoUtil.generateRsaKeyPair(2048)
                             val pairB = CryptoUtil.generateRsaKeyPair(2048)
                             val pairC = CryptoUtil.generateRsaKeyPair(2048)
diff --git a/util/build.gradle b/util/build.gradle
index c53b544..d06ff1b 100644
--- a/util/build.gradle
+++ b/util/build.gradle
@@ -28,8 +28,6 @@ sourceSets {
 
 dependencies {
     implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
-    implementation "io.ktor:ktor-gson:1.1.5"
-    implementation group: 'io.ktor', name: 'ktor-gson', version: '0.9.0'
     implementation "org.jetbrains.exposed:exposed:0.17.6"
     implementation "io.ktor:ktor-server-netty:1.2.4"
     implementation "ch.qos.logback:logback-classic:1.2.3"

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



reply via email to

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