diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-06-13 13:51:47 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-06-13 13:51:47 +0530 |
commit | f324a2dc77a0bdc833a016576558ef9bc0eeac9c (patch) | |
tree | 20a3f8668ae5f7be85bccc0f7c3bb9433d97450a /nexus/src/main/kotlin/tech/libeufin | |
parent | 0e0cc5586eef6fbe8827d5b19067bbbf6324f7ba (diff) | |
download | libeufin-f324a2dc77a0bdc833a016576558ef9bc0eeac9c.tar.gz libeufin-f324a2dc77a0bdc833a016576558ef9bc0eeac9c.tar.bz2 libeufin-f324a2dc77a0bdc833a016576558ef9bc0eeac9c.zip |
formatting / headers
Diffstat (limited to 'nexus/src/main/kotlin/tech/libeufin')
-rw-r--r-- | nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 19 | ||||
-rw-r--r-- | nexus/src/main/kotlin/tech/libeufin/nexus/EbicsClient.kt | 19 | ||||
-rw-r--r-- | nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt | 19 | ||||
-rw-r--r-- | nexus/src/main/kotlin/tech/libeufin/nexus/Iso20022.kt | 10 | ||||
-rw-r--r-- | nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt | 19 | ||||
-rw-r--r-- | nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 33 | ||||
-rw-r--r-- | nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt | 19 |
7 files changed, 121 insertions, 17 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt index 58cbc9bf..1f1b57fd 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt @@ -1,3 +1,22 @@ +/* + * This file is part of LibEuFin. + * Copyright (C) 2020 Taler Systems S.A. + * + * LibEuFin is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3, or + * (at your option) any later version. + * + * LibEuFin is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General + * Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with LibEuFin; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/> + */ + package tech.libeufin.nexus import org.jetbrains.exposed.dao.* diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsClient.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsClient.kt index 1e3ffa22..830fc520 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsClient.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsClient.kt @@ -1,3 +1,22 @@ +/* + * This file is part of LibEuFin. + * Copyright (C) 2020 Taler Systems S.A. + * + * LibEuFin is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3, or + * (at your option) any later version. + * + * LibEuFin is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General + * Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with LibEuFin; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/> + */ + /** * High-level interface for the EBICS protocol. */ diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt index 062f1d3f..ec02eeb9 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt @@ -1,3 +1,22 @@ +/* + * This file is part of LibEuFin. + * Copyright (C) 2020 Taler Systems S.A. + * + * LibEuFin is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3, or + * (at your option) any later version. + * + * LibEuFin is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General + * Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with LibEuFin; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/> + */ + package tech.libeufin.nexus import io.ktor.client.HttpClient diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Iso20022.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Iso20022.kt index 5f226895..95cbae85 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/Iso20022.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Iso20022.kt @@ -1,17 +1,17 @@ /* * This file is part of LibEuFin. * Copyright (C) 2020 Taler Systems S.A. - + * * LibEuFin is free software; you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3, or * (at your option) any later version. - + * * LibEuFin is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General * Public License for more details. - + * * You should have received a copy of the GNU Affero General Public * License along with LibEuFin; see the file COPYING. If not, see * <http://www.gnu.org/licenses/> @@ -37,10 +37,12 @@ enum class TransactionStatus { * Booked */ BOOK, + /** * Pending */ PDNG, + /** * Informational */ @@ -280,7 +282,7 @@ private fun XmlElementDestructor.extractPartiesAndAgents(): RelatedParties { private fun XmlElementDestructor.extractAmountAndCurrencyExchangeDetails(): AmountAndCurrencyExchangeDetails { return AmountAndCurrencyExchangeDetails( - amount = requireUniqueChildNamed("Amt") { it.textContent}, + amount = requireUniqueChildNamed("Amt") { it.textContent }, currency = requireUniqueChildNamed("Amt") { it.getAttribute("Ccy") } ) } diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt index 88cb19b1..da38273a 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt @@ -1,3 +1,22 @@ +/* + * This file is part of LibEuFin. + * Copyright (C) 2020 Taler Systems S.A. + * + * LibEuFin is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3, or + * (at your option) any later version. + * + * LibEuFin is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General + * Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with LibEuFin; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/> + */ + package tech.libeufin.nexus import com.fasterxml.jackson.annotation.JsonAutoDetect diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt index 17f45199..875d19d3 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -50,13 +50,17 @@ import io.ktor.request.* import io.ktor.response.respond import io.ktor.response.respondBytes import io.ktor.response.respondText -import io.ktor.routing.* +import io.ktor.routing.get +import io.ktor.routing.post +import io.ktor.routing.route +import io.ktor.routing.routing import io.ktor.server.engine.embeddedServer import io.ktor.server.netty.Netty import io.ktor.utils.io.ByteReadChannel import io.ktor.utils.io.jvm.javaio.toByteReadChannel import io.ktor.utils.io.jvm.javaio.toInputStream -import kotlinx.coroutines.* +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch import kotlinx.coroutines.time.delay import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.statements.api.ExposedBlob @@ -69,13 +73,12 @@ import tech.libeufin.util.CryptoUtil.hashpw import tech.libeufin.util.ebics_h004.HTDResponseOrderData import java.io.PrintWriter import java.io.StringWriter -import java.lang.NumberFormatException import java.net.URLEncoder import java.time.Duration +import java.time.LocalDateTime import java.util.* import java.util.zip.InflaterInputStream import javax.crypto.EncryptedPrivateKeyInfo -import java.time.LocalDateTime data class NexusError(val statusCode: HttpStatusCode, val reason: String) : Exception("${reason} (HTTP status $statusCode)") @@ -199,7 +202,7 @@ fun createLoopbackBankConnection(bankConnectionName: String, user: NexusUserEnti type = "loopback" } val bankAccount = jacksonObjectMapper().treeToValue(data, BankAccount::class.java) - NexusBankAccountEntity.new(bankAccount.account){ + NexusBankAccountEntity.new(bankAccount.account) { iban = bankAccount.iban bankCode = bankAccount.bic accountHolder = bankAccount.holder @@ -267,7 +270,7 @@ fun moreFrequentBackgroundTasks(httpClient: HttpClient) { ingestTalerTransactions() submitPreparedPaymentsViaEbics() try { - downloadTalerFacadesTransactions(httpClient,"C52") + downloadTalerFacadesTransactions(httpClient, "C52") } catch (e: Exception) { val sw = StringWriter() val pw = PrintWriter(sw) @@ -284,7 +287,7 @@ fun lessFrequentBackgroundTasks(httpClient: HttpClient) { while (true) { logger.debug("Less frequent background job") try { - downloadTalerFacadesTransactions(httpClient,"C53") + downloadTalerFacadesTransactions(httpClient, "C53") } catch (e: Exception) { val sw = StringWriter() val pw = PrintWriter(sw) @@ -316,7 +319,7 @@ suspend fun downloadTalerFacadesTransactions(httpClient: HttpClient, type: Strin } } -fun <T>expectNonNull(param: T?): T { +fun <T> expectNonNull(param: T?): T { return param ?: throw EbicsProtocolError( HttpStatusCode.BadRequest, "Non-null value expected." @@ -757,13 +760,16 @@ fun serverMain(dbName: String) { } else -> { - throw NexusError(HttpStatusCode.BadRequest, "connection type ${body.type} not supported") + throw NexusError( + HttpStatusCode.BadRequest, + "connection type ${body.type} not supported" + ) } } } } } - call.respond(object {}) + call.respond(object {}) } get("/bank-connections") { @@ -905,7 +911,8 @@ fun serverMain(dbName: String) { subscriberEntity.ebicsHiaState = EbicsInitState.SENT } if (hpbData != null) { - subscriberEntity.bankAuthenticationPublicKey = ExposedBlob((hpbData.authenticationPubKey.encoded)) + subscriberEntity.bankAuthenticationPublicKey = + ExposedBlob((hpbData.authenticationPubKey.encoded)) subscriberEntity.bankEncryptionPublicKey = ExposedBlob((hpbData.encryptionPubKey.encoded)) } } @@ -930,7 +937,7 @@ fun serverMain(dbName: String) { if (msgid == null || msgid == "") { throw NexusError(HttpStatusCode.BadRequest, "missing or invalid message ID") } - val msg = NexusBankMessageEntity.find { NexusBankMessagesTable.messageId eq msgid}.firstOrNull() + val msg = NexusBankMessageEntity.find { NexusBankMessagesTable.messageId eq msgid }.firstOrNull() if (msg == null) { throw NexusError(HttpStatusCode.NotFound, "bank message not found") } @@ -1174,4 +1181,4 @@ fun serverMain(dbName: String) { } logger.info("Up and running") server.start(wait = true) -}
\ No newline at end of file +} diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt index 16c30ed3..7513e120 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt @@ -1,3 +1,22 @@ +/* + * This file is part of LibEuFin. + * Copyright (C) 2020 Taler Systems S.A. + * + * LibEuFin is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3, or + * (at your option) any later version. + * + * LibEuFin is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General + * Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with LibEuFin; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/> + */ + package tech.libeufin.nexus import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper |