gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: better naming of database-related stuf


From: gnunet
Subject: [libeufin] branch master updated: better naming of database-related stuff
Date: Tue, 05 Nov 2019 12:23:59 +0100

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 2e65c07  better naming of database-related stuff
2e65c07 is described below

commit 2e65c079376542d1eb68622dd8c133bde3af898f
Author: Florian Dold <address@hidden>
AuthorDate: Tue Nov 5 12:23:56 2019 +0100

    better naming of database-related stuff
---
 .../src/main/kotlin/tech/libeufin/sandbox/DB.kt    | 72 +++++++++++-----------
 .../src/main/kotlin/tech/libeufin/sandbox/Main.kt  | 36 +++++------
 2 files changed, 54 insertions(+), 54 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
index b594dcb..ad02887 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
@@ -90,40 +90,40 @@ fun Blob.toByteArray(): ByteArray {
  * This table information *not* related to EBICS, for all
  * its customers.
  */
-object BankCustomers: IntIdTable() {
+object BankCustomersTable: IntIdTable() {
     // Customer ID is the default 'id' field provided by the constructor.
     val name = varchar("name", CUSTOMER_NAME_MAX_LENGTH).primaryKey()
-    val ebicsSubscriber = reference("ebicsSubscriber", EbicsSubscribers)
+    val ebicsSubscriber = reference("ebicsSubscriber", EbicsSubscribersTable)
 }
 
-class BankCustomer(id: EntityID<Int>) : IntEntity(id) {
-    companion object : IntEntityClass<BankCustomer>(BankCustomers)
+class BankCustomerEntity(id: EntityID<Int>) : IntEntity(id) {
+    companion object : IntEntityClass<BankCustomerEntity>(BankCustomersTable)
 
-    var name by BankCustomers.name
-    var ebicsSubscriber by EbicsSubscriber referencedOn 
BankCustomers.ebicsSubscriber
+    var name by BankCustomersTable.name
+    var ebicsSubscriber by EbicsSubscriberEntity referencedOn 
BankCustomersTable.ebicsSubscriber
 }
 
 
 /**
  * This table stores RSA public keys of subscribers.
  */
-object EbicsPublicKeys : IntIdTable() {
+object EbicsSubscriberPublicKeysTable : IntIdTable() {
     val rsaPublicKey = blob("rsaPublicKey")
     val state = enumeration("state", KeyState::class)
 }
 
 
 /**
- * Definition of a row in the [EbicsPublicKey] table
+ * Definition of a row in the [EbicsSubscriberPublicKeyEntity] table
  */
-class EbicsPublicKey(id: EntityID<Int>) : IntEntity(id) {
-    companion object : IntEntityClass<EbicsPublicKey>(EbicsPublicKeys)
-    var rsaPublicKey by EbicsPublicKeys.rsaPublicKey
-    var state by EbicsPublicKeys.state
+class EbicsSubscriberPublicKeyEntity(id: EntityID<Int>) : IntEntity(id) {
+    companion object : 
IntEntityClass<EbicsSubscriberPublicKeyEntity>(EbicsSubscriberPublicKeysTable)
+    var rsaPublicKey by EbicsSubscriberPublicKeysTable.rsaPublicKey
+    var state by EbicsSubscriberPublicKeysTable.state
 }
 
 
-object EbicsHosts : IntIdTable() {
+object EbicsHostsTable : IntIdTable() {
     val hostID = text("hostID")
     val ebicsVersion = text("ebicsVersion")
     val signaturePrivateKey = blob("signaturePrivateKey")
@@ -132,43 +132,43 @@ object EbicsHosts : IntIdTable() {
 }
 
 
-class EbicsHost(id: EntityID<Int>) : IntEntity(id) {
-    companion object : IntEntityClass<EbicsHost>(EbicsHosts)
-    var hostId by EbicsHosts.hostID
-    var ebicsVersion by EbicsHosts.ebicsVersion
-    var signaturePrivateKey by EbicsHosts.signaturePrivateKey
-    var encryptionPrivateKey by EbicsHosts.encryptionPrivateKey
-    var authenticationPrivateKey by EbicsHosts.authenticationPrivateKey
+class EbicsHostEntity(id: EntityID<Int>) : IntEntity(id) {
+    companion object : IntEntityClass<EbicsHostEntity>(EbicsHostsTable)
+    var hostId by EbicsHostsTable.hostID
+    var ebicsVersion by EbicsHostsTable.ebicsVersion
+    var signaturePrivateKey by EbicsHostsTable.signaturePrivateKey
+    var encryptionPrivateKey by EbicsHostsTable.encryptionPrivateKey
+    var authenticationPrivateKey by EbicsHostsTable.authenticationPrivateKey
 }
 
 /**
  * Subscribers table.  This table associates users with partners
  * and systems.  Each value can appear multiple times in the same column.
  */
-object EbicsSubscribers: IntIdTable() {
+object EbicsSubscribersTable: IntIdTable() {
     val userId = text("userID")
     val partnerId = text("partnerID")
     val systemId = text("systemID").nullable()
 
-    val signatureKey = reference("signatureKey", EbicsPublicKeys).nullable()
-    val encryptionKey = reference("encryptionKey", EbicsPublicKeys).nullable()
-    val authenticationKey = reference("authorizationKey", 
EbicsPublicKeys).nullable()
+    val signatureKey = reference("signatureKey", 
EbicsSubscriberPublicKeysTable).nullable()
+    val encryptionKey = reference("encryptionKey", 
EbicsSubscriberPublicKeysTable).nullable()
+    val authenticationKey = reference("authorizationKey", 
EbicsSubscriberPublicKeysTable).nullable()
 
     val state = enumeration("state", SubscriberState::class)
 }
 
-class EbicsSubscriber(id: EntityID<Int>) : IntEntity(id) {
-    companion object : IntEntityClass<EbicsSubscriber>(EbicsSubscribers)
+class EbicsSubscriberEntity(id: EntityID<Int>) : IntEntity(id) {
+    companion object : 
IntEntityClass<EbicsSubscriberEntity>(EbicsSubscribersTable)
 
-    var userId by EbicsSubscribers.userId
-    var partnerId by EbicsSubscribers.partnerId
-    var systemId by EbicsSubscribers.systemId
+    var userId by EbicsSubscribersTable.userId
+    var partnerId by EbicsSubscribersTable.partnerId
+    var systemId by EbicsSubscribersTable.systemId
 
-    var signatureKey by EbicsPublicKey optionalReferencedOn 
EbicsSubscribers.signatureKey
-    var encryptionKey by EbicsPublicKey optionalReferencedOn 
EbicsSubscribers.encryptionKey
-    var authenticationKey by EbicsPublicKey optionalReferencedOn 
EbicsSubscribers.authenticationKey
+    var signatureKey by EbicsSubscriberPublicKeyEntity optionalReferencedOn 
EbicsSubscribersTable.signatureKey
+    var encryptionKey by EbicsSubscriberPublicKeyEntity optionalReferencedOn 
EbicsSubscribersTable.encryptionKey
+    var authenticationKey by EbicsSubscriberPublicKeyEntity 
optionalReferencedOn EbicsSubscribersTable.authenticationKey
 
-    var state by EbicsSubscribers.state
+    var state by EbicsSubscribersTable.state
 }
 
 
@@ -179,9 +179,9 @@ fun dbCreateTables() {
         // addLogger(StdOutSqlLogger)
 
         SchemaUtils.create(
-            BankCustomers,
-            EbicsSubscribers,
-            EbicsHosts
+            BankCustomersTable,
+            EbicsSubscribersTable,
+            EbicsHostsTable
         )
     }
 }
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 16635bb..85376ad 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -113,16 +113,16 @@ private suspend fun 
ApplicationCall.respondEbicsKeyManagement(
 }
 
 
-fun findEbicsSubscriber(partnerID: String, userID: String, systemID: String?): 
EbicsSubscriber? {
+fun findEbicsSubscriber(partnerID: String, userID: String, systemID: String?): 
EbicsSubscriberEntity? {
     return if (systemID == null) {
-        EbicsSubscriber.find {
-            (EbicsSubscribers.partnerId eq partnerID) and 
(EbicsSubscribers.userId eq userID)
+        EbicsSubscriberEntity.find {
+            (EbicsSubscribersTable.partnerId eq partnerID) and 
(EbicsSubscribersTable.userId eq userID)
         }
     } else {
-        EbicsSubscriber.find {
-            (EbicsSubscribers.partnerId eq partnerID) and
-                    (EbicsSubscribers.userId eq userID) and
-                    (EbicsSubscribers.systemId eq systemID)
+        EbicsSubscriberEntity.find {
+            (EbicsSubscribersTable.partnerId eq partnerID) and
+                    (EbicsSubscribersTable.userId eq userID) and
+                    (EbicsSubscribersTable.systemId eq systemID)
         }
     }.firstOrNull()
 }
@@ -161,11 +161,11 @@ private suspend fun 
ApplicationCall.handleEbicsHia(header: EbicsUnsecuredRequest
             logger.warn("ebics subscriber not found")
             throw EbicsRequestError(HttpStatusCode.NotFound)
         }
-        ebicsSubscriber.authenticationKey = EbicsPublicKey.new {
+        ebicsSubscriber.authenticationKey = EbicsSubscriberPublicKeyEntity.new 
{
             this.rsaPublicKey = SerialBlob(authPub.encoded)
             state = KeyState.NEW
         }
-        ebicsSubscriber.encryptionKey = EbicsPublicKey.new {
+        ebicsSubscriber.encryptionKey = EbicsSubscriberPublicKeyEntity.new {
             this.rsaPublicKey = SerialBlob(encPub.encoded)
             state = KeyState.NEW
         }
@@ -191,7 +191,7 @@ private suspend fun ApplicationCall.handleEbicsIni(header: 
EbicsUnsecuredRequest
             logger.warn("ebics subscriber ('${header.static.partnerID}' / 
'${header.static.userID}' / '${header.static.systemID}') not found")
             throw EbicsRequestError(HttpStatusCode.NotFound)
         }
-        ebicsSubscriber.signatureKey = EbicsPublicKey.new {
+        ebicsSubscriber.signatureKey = EbicsSubscriberPublicKeyEntity.new {
             this.rsaPublicKey = SerialBlob(sigPub.encoded)
             state = KeyState.NEW
         }
@@ -268,7 +268,7 @@ private suspend fun ApplicationCall.handleEbicsHpb(
  */
 private fun ApplicationCall.ensureEbicsHost(requestHostID: String): 
EbicsHostInfo {
     return transaction {
-        val ebicsHost = EbicsHost.find { EbicsHosts.hostID eq requestHostID 
}.firstOrNull()
+        val ebicsHost = EbicsHostEntity.find { EbicsHostsTable.hostID eq 
requestHostID }.firstOrNull()
         if (ebicsHost == null) {
             logger.warn("client requested unknown HostID")
             throw EbicsKeyManagementError("[EBICS_INVALID_HOST_ID]", "091011")
@@ -362,7 +362,7 @@ fun main() {
         val pairA = CryptoUtil.generateRsaKeyPair(2048)
         val pairB = CryptoUtil.generateRsaKeyPair(2048)
         val pairC = CryptoUtil.generateRsaKeyPair(2048)
-        EbicsHost.new {
+        EbicsHostEntity.new {
             hostId = "host01"
             ebicsVersion = "H004"
             authenticationPrivateKey = SerialBlob(pairA.private.encoded)
@@ -370,7 +370,7 @@ fun main() {
             signaturePrivateKey = SerialBlob(pairC.private.encoded)
         }
 
-        EbicsSubscriber.new {
+        EbicsSubscriberEntity.new {
             partnerId = "PARTNER1"
             userId = "USER1"
             systemId = null
@@ -405,14 +405,14 @@ fun main() {
             }
             get("/ebics/hosts") {
                 val ebicsHosts = transaction {
-                    EbicsHost.all().map { it.hostId }
+                    EbicsHostEntity.all().map { it.hostId }
                 }
                 call.respond(EbicsHostsResponse(ebicsHosts))
             }
             post("/ebics/hosts") {
                 val req = call.receive<EbicsHostCreateRequest>()
                 transaction {
-                    EbicsHost.new {
+                    EbicsHostEntity.new {
                         this.ebicsVersion = req.ebicsVersion
                         this.hostId = hostId
                     }
@@ -420,7 +420,7 @@ fun main() {
             }
             get("/ebics/hosts/{id}") {
                 val resp = transaction {
-                    val host = EbicsHost.find { EbicsHosts.hostID eq 
call.parameters["id"]!! }.firstOrNull()
+                    val host = EbicsHostEntity.find { EbicsHostsTable.hostID 
eq call.parameters["id"]!! }.firstOrNull()
                     if (host == null) null
                     else EbicsHostResponse(host.hostId, host.ebicsVersion)
                 }
@@ -432,14 +432,14 @@ fun main() {
             }
             get("/ebics/subscribers") {
                 val subscribers = transaction {
-                    EbicsSubscriber.all().map { it.id.value.toString() }
+                    EbicsSubscriberEntity.all().map { it.id.value.toString() }
                 }
                 call.respond(EbicsSubscribersResponse(subscribers))
             }
             get("/ebics/subscribers/{id}") {
                 val resp = transaction {
                     val id = call.parameters["id"]!!
-                    val subscriber = EbicsSubscriber.findById(id.toInt())!!
+                    val subscriber = 
EbicsSubscriberEntity.findById(id.toInt())!!
                     EbicsSubscriberResponse(
                         id,
                         subscriber.partnerId,

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



reply via email to

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