gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libeufin] branch master updated: Transparently create (EBI


From: gnunet
Subject: [GNUnet-SVN] [libeufin] branch master updated: Transparently create (EBICS) user/partner/system IDs columns.
Date: Thu, 03 Oct 2019 18:45:17 +0200

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 15ae048  Transparently create (EBICS) user/partner/system IDs columns.
15ae048 is described below

commit 15ae0483272dfcdb6245443631c37b91223bb795
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Oct 3 18:44:17 2019 +0200

    Transparently create (EBICS) user/partner/system IDs columns.
---
 src/main/kotlin/tech/libeufin/DB.kt   | 46 +++++++++++++++++++++++++++--------
 src/main/kotlin/tech/libeufin/JSON.kt |  2 +-
 src/main/kotlin/tech/libeufin/Main.kt |  6 ++---
 src/main/python/libeufin-cli          |  7 +++++-
 4 files changed, 45 insertions(+), 16 deletions(-)

diff --git a/src/main/kotlin/tech/libeufin/DB.kt 
b/src/main/kotlin/tech/libeufin/DB.kt
index d901808..339f869 100644
--- a/src/main/kotlin/tech/libeufin/DB.kt
+++ b/src/main/kotlin/tech/libeufin/DB.kt
@@ -5,7 +5,9 @@ import org.jetbrains.exposed.sql.*
 import org.jetbrains.exposed.sql.transactions.transaction
 
 const val CUSTOMER_NAME_MAX_LENGTH = 20
-const val SUBSCRIBER_ID_MAX_LENGTH = 10
+const val EBICS_USER_ID_MAX_LENGTH = 10
+const val EBICS_PARTNER_ID_MAX_LENGTH = 10
+const val EBICS_SYSTEM_ID_MAX_LENGTH = 10
 const val PUBLIC_KEY_MAX_LENGTH = 256 // FIXME review this value!
 const val PRIV_KEY_MAX_LENGTH = 512 // FIXME review this value!
 const val SQL_ENUM_SUBSCRIBER_STATES = "ENUM('NEW', 
'PARTIALLI_INITIALIZED_INI', 'PARTIALLY_INITIALIZED_HIA', 'INITIALIZED', 
'READY')"
@@ -89,16 +91,23 @@ class BankCustomer(id: EntityID<Int>) : IntEntity(id) {
  * - SystemID, (optional) the machine that is handling the EBICS task on 
behalf of the UserID.
  */
 
-/**
- * Table for UserID.
- */
 object EbicsUsers: IntIdTable() {
-    // For simplicity, this entity is implemented by the
-    // 'id' field provided by the table constructor by default.
+    /* EBICS user ID in the string form. */
+    val userId = varchar("userId", EBICS_USER_ID_MAX_LENGTH).nullable()
+
 }
 
-class EbicsUser(id: EntityID<Int>) : IntEntity(id) {
-    companion object : IntEntityClass<EbicsUser>(EbicsUsers)
+class EbicsUser(id: EntityID<Int>) : IntEntity(id){
+    companion object : IntEntityClass<EbicsUser>(EbicsUsers) {
+        fun newUser() : EbicsUser {
+            var row = Companion.new {
+            }
+            row.userId = "u${row.id}"
+            return row
+        }
+    }
+
+    var userId by EbicsUsers.userId
 }
 
 /**
@@ -107,11 +116,19 @@ class EbicsUser(id: EntityID<Int>) : IntEntity(id) {
 object EbicsPartners: IntIdTable() {
     // For simplicity, this entity is implemented by the
     // 'id' field provided by the table constructor by default.
+    val partnerId = varchar("partnerId", 
EBICS_PARTNER_ID_MAX_LENGTH).nullable()
 }
 
 
 class EbicsPartner(id: EntityID<Int>) : IntEntity(id) {
-    companion object : IntEntityClass<EbicsPartner>(EbicsPartners)
+    companion object : IntEntityClass<EbicsPartner>(EbicsPartners) {
+        fun newUser(): EbicsPartner {
+            var row = EbicsPartner.new { }
+            row.partnerId = "p${row.id}"
+            return row
+        }
+    }
+    var partnerId by EbicsPartners.partnerId
 }
 
 
@@ -121,10 +138,19 @@ class EbicsPartner(id: EntityID<Int>) : IntEntity(id) {
 object EbicsSystems: IntIdTable() {
     // For simplicity, this entity is implemented by the
     // 'id' field provided by the table constructor by default.
+    val systemId = EbicsPartners.varchar("systemId", 
EBICS_SYSTEM_ID_MAX_LENGTH).nullable()
 }
 
 class EbicsSystem(id: EntityID<Int>) : IntEntity(id) {
-    companion object : IntEntityClass<EbicsSystem>(EbicsSystems)
+    companion object : IntEntityClass<EbicsSystem>(EbicsSystems) {
+        fun newUser(): EbicsSystem {
+            var row = EbicsSystem.new { }
+            row.systemId = "s${row.id}"
+            return row
+        }
+    }
+
+    var systemId by EbicsSystems.systemId
 }
 
 /**
diff --git a/src/main/kotlin/tech/libeufin/JSON.kt 
b/src/main/kotlin/tech/libeufin/JSON.kt
index e294322..b20951a 100644
--- a/src/main/kotlin/tech/libeufin/JSON.kt
+++ b/src/main/kotlin/tech/libeufin/JSON.kt
@@ -28,7 +28,7 @@ data class CustomerInfo(
 )
 
 data class CustomerEbicsInfo(
-    val userId: Int
+    val userId: String
 )
 
 /**
diff --git a/src/main/kotlin/tech/libeufin/Main.kt 
b/src/main/kotlin/tech/libeufin/Main.kt
index 3dc1059..a6ca473 100644
--- a/src/main/kotlin/tech/libeufin/Main.kt
+++ b/src/main/kotlin/tech/libeufin/Main.kt
@@ -77,7 +77,7 @@ fun main() {
                 logger.info(body.toString())
 
                 val returnId = transaction {
-                    val myUserId = EbicsUser.new { }
+                    var myUserId = EbicsUser.newUser()
                     val myPartnerId = EbicsPartner.new { }
                     val mySystemId = EbicsSystem.new { }
                     val subscriber = EbicsSubscriber.new {
@@ -115,14 +115,12 @@ fun main() {
                     return@get
                 }
 
-                logger.info("Querying ID: $id")
-
                 val customerInfo = transaction {
                     val customer = BankCustomer.findById(id) ?: 
return@transaction null
                     CustomerInfo(
                         customer.name,
                         ebicsInfo = CustomerEbicsInfo(
-                            customer.ebicsSubscriber.userId.id.value
+                            customer.ebicsSubscriber.userId.userId!!
                         )
                     )
                 }
diff --git a/src/main/python/libeufin-cli b/src/main/python/libeufin-cli
index c18b542..03af95f 100755
--- a/src/main/python/libeufin-cli
+++ b/src/main/python/libeufin-cli
@@ -3,6 +3,7 @@
 import os
 import click
 import hashlib
+import errno
 from datetime import datetime
 from requests import post, get
 from Crypto.PublicKey import RSA 
@@ -63,7 +64,11 @@ def customers(obj):
         keyfile.write(pem)
         keyfile.write("\n")
         keyfile.close()
-    print("Customer and private keys ({}) correctly 
generated.".format(customer_path))
+    print(
+        "Customer (id == {}) and private keys ({}) correctly 
generated.".format(
+            customer_id, customer_path
+        )
+    )
 
 @admin.command(help="Ask details about a customer")
 @click.option(

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



reply via email to

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