[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: Getting HTTP requests logged.
From: |
gnunet |
Subject: |
[libeufin] branch master updated: Getting HTTP requests logged. |
Date: |
Mon, 09 Dec 2019 22:14:22 +0100 |
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 0c04014 Getting HTTP requests logged.
0c04014 is described below
commit 0c0401461d642c74331d5b76fe4e79d5e327ec86
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Dec 9 22:13:39 2019 +0100
Getting HTTP requests logged.
---
.../kotlin/tech/libeufin/sandbox/CryptoUtil.kt | 2 +-
.../src/main/kotlin/tech/libeufin/sandbox/DB.kt | 2 +-
.../tech/libeufin/sandbox/EbicsProtocolBackend.kt | 20 ++++++-------
.../src/main/kotlin/tech/libeufin/sandbox/Main.kt | 34 +++++++++++++++-------
.../main/kotlin/tech/libeufin/sandbox/XMLUtil.kt | 2 +-
5 files changed, 36 insertions(+), 24 deletions(-)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/CryptoUtil.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/CryptoUtil.kt
index 4bf0c7a..00690ce 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/CryptoUtil.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/CryptoUtil.kt
@@ -173,7 +173,7 @@ object CryptoUtil {
val symmetricCipher = Cipher.getInstance("AES/CBC/X9.23Padding",
bouncyCastleProvider)
val ivParameterSpec = IvParameterSpec(ByteArray(16))
symmetricCipher.init(Cipher.DECRYPT_MODE, secretKeySpec,
ivParameterSpec)
- logger.debug("decrypting: ${encryptedData.toHexString()}")
+ LOGGER.debug("decrypting: ${encryptedData.toHexString()}")
val data = symmetricCipher.doFinal(encryptedData)
return data
}
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
index fcdb36e..9a43896 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
@@ -140,7 +140,7 @@ open class IntIdTableWithAmount : IntIdTable() {
}
if ((value as BigDecimal).compareTo(BigDecimal.ZERO) == 0) {
- logger.error("Cannot have transactions of ZERO amount")
+ LOGGER.error("Cannot have transactions of ZERO amount")
throw BadAmount(value)
}
return super.valueToDB(value)
diff --git
a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
index 0f43d9b..34950eb 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
@@ -104,7 +104,7 @@ private suspend fun
ApplicationCall.respondEbicsKeyManagement(
}
}
val text = XMLUtil.convertJaxbToString(responseXml)
- logger.info("responding with:\n${text}")
+ LOGGER.info("responding with:\n${text}")
respondText(text, ContentType.Application.Xml, HttpStatusCode.OK)
}
@@ -124,7 +124,7 @@ private suspend fun ApplicationCall.handleEbicsHia(header:
EbicsUnsecuredRequest
transaction {
val ebicsSubscriber = findEbicsSubscriber(header.static.partnerID,
header.static.userID, header.static.systemID)
if (ebicsSubscriber == null) {
- logger.warn("ebics subscriber not found")
+ LOGGER.warn("ebics subscriber not found")
throw EbicsInvalidRequestError()
}
ebicsSubscriber.authenticationKey = EbicsSubscriberPublicKeyEntity.new
{
@@ -159,7 +159,7 @@ private suspend fun ApplicationCall.handleEbicsIni(header:
EbicsUnsecuredRequest
val ebicsSubscriber =
findEbicsSubscriber(header.static.partnerID, header.static.userID,
header.static.systemID)
if (ebicsSubscriber == null) {
- logger.warn("ebics subscriber ('${header.static.partnerID}' /
'${header.static.userID}' / '${header.static.systemID}') not found")
+ LOGGER.warn("ebics subscriber ('${header.static.partnerID}' /
'${header.static.userID}' / '${header.static.systemID}') not found")
throw EbicsInvalidRequestError()
}
ebicsSubscriber.signatureKey = EbicsSubscriberPublicKeyEntity.new {
@@ -172,7 +172,7 @@ private suspend fun ApplicationCall.handleEbicsIni(header:
EbicsUnsecuredRequest
else -> ebicsSubscriber.state
}
}
- logger.info("Signature key inserted in database _and_ subscriber state
changed accordingly")
+ LOGGER.info("Signature key inserted in database _and_ subscriber state
changed accordingly")
respondEbicsKeyManagement("[EBICS_OK]", "000000", bankReturnCode =
"000000", orderId = "OR01")
}
@@ -201,7 +201,7 @@ private suspend fun ApplicationCall.handleEbicsHpb(
}
val validationResult =
XMLUtil.verifyEbicsDocument(requestDocument,
subscriberKeys.authenticationPublicKey)
- logger.info("validationResult: $validationResult")
+ LOGGER.info("validationResult: $validationResult")
if (!validationResult) {
throw EbicsKeyManagementError("invalid signature", "90000");
}
@@ -242,7 +242,7 @@ private fun ApplicationCall.ensureEbicsHost(requestHostID:
String): EbicsHostPub
val ebicsHost =
EbicsHostEntity.find { EbicsHostsTable.hostID.upperCase() eq
requestHostID.toUpperCase() }.firstOrNull()
if (ebicsHost == null) {
- logger.warn("client requested unknown HostID")
+ LOGGER.warn("client requested unknown HostID")
throw EbicsKeyManagementError("[EBICS_INVALID_HOST_ID]", "091011")
}
val encryptionPrivateKey =
CryptoUtil.loadRsaPrivateKey(ebicsHost.encryptionPrivateKey.toByteArray())
@@ -258,7 +258,7 @@ private fun ApplicationCall.ensureEbicsHost(requestHostID:
String): EbicsHostPub
private suspend fun ApplicationCall.receiveEbicsXml(): Document {
val body: String = receiveText()
- logger.debug("Data received: $body")
+ LOGGER.debug("Data received: $body")
val requestDocument: Document? = XMLUtil.parseStringIntoDom(body)
if (requestDocument == null ||
(!XMLUtil.validateFromDom(requestDocument))) {
throw EbicsInvalidXmlError()
@@ -458,12 +458,12 @@ fun queryEbicsTransactionDetails(ebicsRequest:
EbicsRequest): EbicsTransactionDe
suspend fun ApplicationCall.ebicsweb() {
val requestDocument = receiveEbicsXml()
- logger.info("Processing ${requestDocument.documentElement.localName}")
+ LOGGER.info("Processing ${requestDocument.documentElement.localName}")
when (requestDocument.documentElement.localName) {
"ebicsUnsecuredRequest" -> {
val requestObject =
requestDocument.toObject<EbicsUnsecuredRequest>()
- logger.info("Serving a
${requestObject.header.static.orderDetails.orderType} request")
+ LOGGER.info("Serving a
${requestObject.header.static.orderDetails.orderType} request")
val orderData = requestObject.body.dataTransfer.orderData.value
val header = requestObject.header
@@ -719,7 +719,7 @@ suspend fun ApplicationCall.ebicsweb() {
}
else -> {
/* Log to console and return "unknown type" */
- logger.info("Unknown message, just logging it!")
+ LOGGER.info("Unknown message, just logging it!")
respond(
HttpStatusCode.NotImplemented,
SandboxError("Not Implemented")
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index af29f39..7f1e8dc 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -46,6 +46,7 @@ import org.jetbrains.exposed.sql.transactions.transaction
import org.joda.time.DateTime
import org.slf4j.Logger
import org.slf4j.LoggerFactory
+import org.slf4j.event.Level
import org.w3c.dom.Document
import java.lang.ArithmeticException
import java.math.BigDecimal
@@ -55,8 +56,6 @@ import javax.sql.rowset.serial.SerialBlob
import javax.xml.bind.JAXBContext
-val logger: Logger = LoggerFactory.getLogger("tech.libeufin.sandbox")
-
class CustomerNotFound(id: String?) : Exception("Customer ${id} not found")
class BadInputData(inputData: String?) : Exception("Customer provided invalid
input data: ${inputData}")
class BadAmount(badValue: Any?) : Exception("Value '${badValue}' is not a
valid amount")
@@ -128,8 +127,7 @@ fun BigDecimal.signToString(): String {
// minus sign is added by default already.
}
-fun main() {
- dbCreateTables()
+fun sampleData() {
transaction {
val pairA = CryptoUtil.generateRsaKeyPair(2048)
@@ -146,7 +144,7 @@ fun main() {
val customerEntity = BankCustomerEntity.new {
name = "Mina"
- }
+ }
EbicsSubscriberEntity.new {
partnerId = "PARTNER1"
@@ -169,8 +167,22 @@ fun main() {
}
}
+
+}
+
+val LOGGER: Logger = LoggerFactory.getLogger("tech.libeufin.sandbox")
+
+fun main() {
+
+ dbCreateTables()
+ sampleData()
+
val server = embeddedServer(Netty, port = 5000) {
- install(CallLogging)
+ install(CallLogging) {
+ this.level = Level.DEBUG
+ this.logger = LOGGER
+
+ }
install(ContentNegotiation) {
gson {
setDateFormat(DateFormat.LONG)
@@ -179,11 +191,11 @@ fun main() {
}
install(StatusPages) {
exception<Throwable> { cause ->
- logger.error("Exception while handling '${call.request.uri}'",
cause)
+ LOGGER.error("Exception while handling '${call.request.uri}'",
cause)
call.respondText("Internal server error.",
ContentType.Text.Plain, HttpStatusCode.InternalServerError)
}
exception<ArithmeticException> { cause ->
- logger.error("Exception while handling '${call.request.uri}'",
cause)
+ LOGGER.error("Exception while handling '${call.request.uri}'",
cause)
call.respondText("Invalid arithmetic attempted.",
ContentType.Text.Plain, HttpStatusCode.InternalServerError)
}
}
@@ -198,13 +210,13 @@ fun main() {
post("/{id}/history") {
- logger.debug("/history fired up")
+ LOGGER.debug("/history fired up")
val req = call.receive<CustomerHistoryRequest>()
val startDate = DateTime.parse(req.start)
val endDate = DateTime.parse(req.end)
- logger.debug("Fetching history from ${startDate.toString()},
to ${endDate.toString()}")
+ LOGGER.debug("Fetching history from ${startDate.toString()},
to ${endDate.toString()}")
val ret = CustomerHistoryResponse()
@@ -309,6 +321,6 @@ fun main() {
}
}
}
- logger.info("Up and running")
+ LOGGER.info("Up and running")
server.start(wait = true)
}
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/XMLUtil.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/XMLUtil.kt
index 2ed6a2f..6f49d95 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/XMLUtil.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/XMLUtil.kt
@@ -160,7 +160,7 @@ class XMLUtil private constructor() {
try {
getEbicsValidator().validate(xmlDoc)
} catch (e: Exception) {
- logger.warn("Validation failed: ${e}")
+ LOGGER.warn("Validation failed: ${e}")
return false
}
return true;
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: Getting HTTP requests logged.,
gnunet <=