[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-libeufin] 17/25: Check if the message can be handled
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-libeufin] 17/25: Check if the message can be handled by the server. |
Date: |
Fri, 20 Sep 2019 19:32:55 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository libeufin.
commit 944a1417bf697529d6aa2d9a1251fe1a991ce1cd
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Sep 17 17:52:04 2019 +0200
Check if the message can be handled by the server.
---
src/main/java/tech/libeufin/XMLManagement.java | 2 +-
src/main/kotlin/Main.kt | 25 ++++++++++++++++---------
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/src/main/java/tech/libeufin/XMLManagement.java
b/src/main/java/tech/libeufin/XMLManagement.java
index 4576201..e70b05d 100644
--- a/src/main/java/tech/libeufin/XMLManagement.java
+++ b/src/main/java/tech/libeufin/XMLManagement.java
@@ -153,7 +153,7 @@ public class XMLManagement {
/* Make Transformer. */
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer();
- t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ // t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
t.setOutputProperty(OutputKeys.INDENT, "no");
/* Make string writer. */
diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt
index 5f5fc88..4ac446f 100644
--- a/src/main/kotlin/Main.kt
+++ b/src/main/kotlin/Main.kt
@@ -29,7 +29,9 @@ import io.ktor.server.netty.*
import tech.libeufin.XMLManagement;
import java.io.ByteArrayInputStream
import java.io.InputStream
+import org.w3c.dom.Document;
+val knownTypes = arrayOf("ebicsHEVRequest")
fun main(args: Array<String>) {
var xmlProcess = XMLManagement();
@@ -44,21 +46,26 @@ fun main(args: Array<String>) {
val isValid = xmlProcess.validate(body)
call.response.header("Content-Type", "application/xml")
- /*if (!isValid) {
- /* Return "invalid request" */
+ if (!isValid) {
+ call.respond(HttpStatusCode(400, "Invalid request"));
}
- if (!knownType) {
+ val bodyDocument = XMLManagement.parseStringIntoDOM(body)
+ if (null == bodyDocument)
+ {
+ /* Should never happen. */
+ System.out.println("A valid document failed to parse into
DOM!")
+ call.respond(HttpStatusCode(500, "Internal server error"));
+ }
+ if (bodyDocument.documentElement !in knownTypes) {
/* Log to console and return "unknown type" */
+ System.out.println("Unknown message, just logging it!")
+ call.respond(HttpStatusCode(400, "Not found"));
}
- if (isValid){
- call.respond(HttpStatusCode.OK, xmlResponseObject)
- }
- else {
- call.respond(HttpStatusCode.BadRequest, xmlResponseObject)
- }*/
+ /* Generate response here. */
+
}
}
}
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [GNUnet-SVN] [taler-libeufin] 14/25: Test with XML imported from string., (continued)
- [GNUnet-SVN] [taler-libeufin] 14/25: Test with XML imported from string., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 13/25: fix test, gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 15/25: Abstracting string conversion to "stream"., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 16/25: Introducing the converters:, gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 20/25: Server responds with ebicsHEVResponse., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 18/25: method to get (XML) strings from JAXB objects., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 23/25: Translating getLogger() into Kotlin., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 19/25: Importing JAXB scaffolding to reflect ebics "hev" types., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 21/25: Fix resource loading from JAR., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 25/25: Finish translating Java into Kotlin., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 17/25: Check if the message can be handled by the server.,
gnunet <=
- [GNUnet-SVN] [taler-libeufin] 24/25: Move XMLManagement.java to Kotlin., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 22/25: Complete initial setup (#5888)., gnunet, 2019/09/20