gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated (bf264db -> 9f46405)


From: gnunet
Subject: [libeufin] branch master updated (bf264db -> 9f46405)
Date: Fri, 01 Nov 2019 11:17:25 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a change to branch master
in repository libeufin.

    from bf264db  clean up tests and fix annotations
     new 72ca3be  upgrade gradle
     new 9f46405  project structure

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .idea/gradle.xml                                   |  3 +-
 .idea/inspectionProfiles/Project_Default.xml       |  8 ---
 .idea/kotlinc.xml                                  |  6 +++
 .idea/misc.xml                                     |  2 +-
 .idea/modules/libeufin.iml                         |  9 ----
 gradle.properties                                  |  1 -
 gradle/wrapper/gradle-wrapper.properties           |  4 +-
 nexus/build.gradle                                 | 12 ++---
 {resources => nexus/src/resources}/logback.xml     |  0
 sandbox/build.gradle                               | 10 ++--
 sandbox/src/main/kotlin/DB.kt                      |  5 ++
 sandbox/src/main/kotlin/Main.kt                    | 59 ++++++++++++++++++----
 .../libeufin/schema/ebics_h004/EbicsMessages.kt    | 42 +++++++++++++++
 {resources => sandbox/src/resources}/logback.xml   |  0
 sandbox/src/test/kotlin/EbicsMessagesTest.kt       | 24 +++++----
 15 files changed, 132 insertions(+), 53 deletions(-)
 delete mode 100644 .idea/inspectionProfiles/Project_Default.xml
 create mode 100644 .idea/kotlinc.xml
 delete mode 100644 .idea/modules/libeufin.iml
 copy {resources => nexus/src/resources}/logback.xml (100%)
 rename {resources => sandbox/src/resources}/logback.xml (100%)

diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index b8ed810..70bf921 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -9,7 +9,7 @@
         <option name="distributionType" value="DEFAULT_WRAPPED" />
         <option name="externalProjectPath" value="$PROJECT_DIR$" />
         <option name="gradleHome" value="/usr/share/java/gradle" />
-        <option name="gradleJvm" value="#JAVA_INTERNAL" />
+        <option name="gradleJvm" value="11" />
         <option name="modules">
           <set>
             <option value="$PROJECT_DIR$" />
@@ -17,6 +17,7 @@
             <option value="$PROJECT_DIR$/sandbox" />
           </set>
         </option>
+        <option name="useAutoImport" value="true" />
         <option name="useQualifiedModuleNames" value="true" />
       </GradleProjectSettings>
     </option>
diff --git a/.idea/inspectionProfiles/Project_Default.xml 
b/.idea/inspectionProfiles/Project_Default.xml
deleted file mode 100644
index dcb5f6b..0000000
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<component name="InspectionProjectProfileManager">
-  <profile version="1.0">
-    <option name="myName" value="Project Default" />
-    <inspection_tool class="PropertyName" enabled="true" level="WEAK WARNING" 
enabled_by_default="true">
-      <option name="namePattern" value="_?[a-z][A-Za-z\d]*" />
-    </inspection_tool>
-  </profile>
-</component>
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
new file mode 100644
index 0000000..9b02d59
--- /dev/null
+++ b/.idea/kotlinc.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Kotlin2JvmCompilerArguments">
+    <option name="jvmTarget" value="11" />
+  </component>
+</project>
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 4663731..25d34a4 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="ExternalStorageConfigurationManager" enabled="true" />
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_11" 
default="false" project-jdk-name="11" project-jdk-type="JavaSDK" />
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_11" 
project-jdk-name="11" project-jdk-type="JavaSDK" />
 </project>
\ No newline at end of file
diff --git a/.idea/modules/libeufin.iml b/.idea/modules/libeufin.iml
deleted file mode 100644
index 7e86d2c..0000000
--- a/.idea/modules/libeufin.iml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="JAVA_MODULE" version="4">
-  <component name="NewModuleRootManager" inherit-compiler-output="true">
-    <exclude-output />
-    <content url="file://$MODULE_DIR$/../.." />
-    <orderEntry type="inheritedJdk" />
-    <orderEntry type="sourceFolder" forTests="false" />
-  </component>
-</module>
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
index 2381768..7fc6f1f 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,2 +1 @@
 kotlin.code.style=official
-kotlin.incremental=false
diff --git a/gradle/wrapper/gradle-wrapper.properties 
b/gradle/wrapper/gradle-wrapper.properties
index 992f535..eaa2cf0 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
-#Mon Sep 30 09:20:29 CEST 2019
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
+#Fri Nov 01 10:46:40 CET 2019
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-all.zip
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStorePath=wrapper/dists
diff --git a/nexus/build.gradle b/nexus/build.gradle
index 349561c..be00062 100644
--- a/nexus/build.gradle
+++ b/nexus/build.gradle
@@ -4,20 +4,19 @@ plugins {
     id 'application'
 }
 
-
-version '1.0-snapshot'
-sourceCompatibility = 1.8
-targetCompatibility = 1.8
+sourceCompatibility = '11'
+targetCompatibility = '11'
+version = '0.0.1'
 
 compileKotlin {
     kotlinOptions {
-        jvmTarget = "1.8"
+        jvmTarget = '11'
     }
 }
 
 compileTestKotlin {
     kotlinOptions {
-        jvmTarget = "1.8"
+        jvmTarget = '11'
     }
 }
 
@@ -34,7 +33,6 @@ dependencies {
     compile "javax.activation:activation:1.1"
     compile "org.glassfish.jaxb:jaxb-runtime:2.3.1"
     testCompile group: 'junit', name: 'junit', version: '4.12'
-    runtime rootProject.files("resources")
 }
 
 application {
diff --git a/resources/logback.xml b/nexus/src/resources/logback.xml
similarity index 100%
copy from resources/logback.xml
copy to nexus/src/resources/logback.xml
diff --git a/sandbox/build.gradle b/sandbox/build.gradle
index 04cb301..59b4a65 100644
--- a/sandbox/build.gradle
+++ b/sandbox/build.gradle
@@ -4,19 +4,20 @@ plugins {
     id 'application'
 }
 
+
+sourceCompatibility = "11"
+targetCompatibility = "11"
 version '1.0-snapshot'
-sourceCompatibility = 1.8
-targetCompatibility = 1.8
 
 compileKotlin {
     kotlinOptions {
-        jvmTarget = "1.8"
+        jvmTarget = "11"
     }
 }
 
 compileTestKotlin {
     kotlinOptions {
-        jvmTarget = "1.8"
+        jvmTarget = "11"
     }
 }
 
@@ -40,7 +41,6 @@ dependencies {
     testImplementation 'org.jetbrains.kotlin:kotlin-test-junit:1.3.50'
     testImplementation 'org.jetbrains.kotlin:kotlin-test:1.3.50'
     compile 'org.apache.santuario:xmlsec:2.1.4'
-    runtime rootProject.files("resources")
 }
 
 application {
diff --git a/sandbox/src/main/kotlin/DB.kt b/sandbox/src/main/kotlin/DB.kt
index ca95151..e869a58 100644
--- a/sandbox/src/main/kotlin/DB.kt
+++ b/sandbox/src/main/kotlin/DB.kt
@@ -22,6 +22,7 @@ package tech.libeufin.sandbox.db
 import org.jetbrains.exposed.dao.*
 import org.jetbrains.exposed.sql.*
 import org.jetbrains.exposed.sql.transactions.transaction
+import java.sql.Blob
 
 const val CUSTOMER_NAME_MAX_LENGTH = 20
 const val EBICS_HOST_ID_MAX_LENGTH = 10
@@ -81,6 +82,10 @@ enum class KeyState {
     RELEASED
 }
 
+fun Blob.toByteArray(): ByteArray {
+    return this.binaryStream.readAllBytes()
+}
+
 /**
  * This table information *not* related to EBICS, for all
  * its customers.
diff --git a/sandbox/src/main/kotlin/Main.kt b/sandbox/src/main/kotlin/Main.kt
index 6b94078..345593c 100644
--- a/sandbox/src/main/kotlin/Main.kt
+++ b/sandbox/src/main/kotlin/Main.kt
@@ -46,6 +46,7 @@ import org.slf4j.LoggerFactory
 import org.w3c.dom.Document
 import tech.libeufin.sandbox.db.*
 import tech.libeufin.schema.ebics_h004.EbicsKeyManagementResponse
+import tech.libeufin.schema.ebics_h004.EbicsNoPubKeyDigestsRequest
 import tech.libeufin.schema.ebics_h004.EbicsUnsecuredRequest
 import tech.libeufin.schema.ebics_h004.HIARequestOrderDataType
 import tech.libeufin.schema.ebics_hev.HEVResponse
@@ -68,8 +69,8 @@ private suspend fun ApplicationCall.respondEbicsKeyManagement(
     errorText: String,
     errorCode: String,
     statusCode: HttpStatusCode,
-    orderId: String? = null,
-    bankReturnCode: String? = null
+    bankReturnCode: String,
+    orderId: String? = null
 ) {
     val responseXml = EbicsKeyManagementResponse().apply {
         version = "H004"
@@ -85,11 +86,9 @@ private suspend fun 
ApplicationCall.respondEbicsKeyManagement(
             _static = EbicsKeyManagementResponse.Header.EmptyStaticHeader()
         }
         body = EbicsKeyManagementResponse.Body().apply {
-            if (bankReturnCode != null) {
-                this.returnCode = 
EbicsKeyManagementResponse.Body.ReturnCode().apply {
-                    this.authenticate = true
-                    this.value = bankReturnCode
-                }
+            this.returnCode = 
EbicsKeyManagementResponse.Body.ReturnCode().apply {
+                this.authenticate = true
+                this.value = bankReturnCode
             }
         }
     }
@@ -100,7 +99,7 @@ private suspend fun 
ApplicationCall.respondEbicsKeyManagement(
 
 
 private suspend fun ApplicationCall.respondEbicsInvalidXml() {
-    respondEbicsKeyManagement("[EBICS_INVALID_XML]", "091010", 
HttpStatusCode.BadRequest)
+    respondEbicsKeyManagement("[EBICS_INVALID_XML]", "091010", 
HttpStatusCode.BadRequest, "000000")
 }
 
 
@@ -118,6 +117,12 @@ fun findEbicsSubscriber(partnerID: String, userID: String, 
systemID: String?): E
     }.firstOrNull()
 }
 
+data class SubscriberKeys(
+    val authenticationPublicKey: RSAPublicKey,
+    val encryptionPublicKey: RSAPublicKey,
+    val signaturePublicKey: RSAPublicKey
+)
+
 private suspend fun ApplicationCall.ebicsweb() {
     val body: String = receiveText()
     logger.debug("Data received: $body")
@@ -148,7 +153,7 @@ private suspend fun ApplicationCall.ebicsweb() {
 
             if (ebicsHost == null) {
                 logger.warn("client requested unknown HostID")
-                respondEbicsKeyManagement("[EBICS_INVALID_HOST_ID]", "091011", 
HttpStatusCode.NotFound)
+                respondEbicsKeyManagement("[EBICS_INVALID_HOST_ID]", "091011", 
HttpStatusCode.NotFound, "000000")
                 return
             }
 
@@ -294,7 +299,8 @@ private suspend fun ApplicationCall.ebicsweb() {
                             ebicsSubscriber.state = SubscriberState.INITIALIZED
                         }
                     }
-                    respondEbicsKeyManagement("[EBICS_OK]", "000000", 
HttpStatusCode.OK)
+                    respondEbicsKeyManagement("[EBICS_OK]", "000000", 
HttpStatusCode.OK, "000000")
+                    return
                 }
             }
 
@@ -314,6 +320,39 @@ private suspend fun ApplicationCall.ebicsweb() {
             respondText(strResp, ContentType.Application.Xml, 
HttpStatusCode.OK)
             return
         }
+        "ebicsNoPubKeyDigestsRequest" -> {
+            val requestJaxb = 
XMLUtil.convertDomToJaxb(EbicsNoPubKeyDigestsRequest::class.java, bodyDocument)
+            val staticHeader = requestJaxb.value.header.static
+            val orderType = staticHeader.orderDetails.orderType
+            when (orderType) {
+                "HPB" -> {
+                    val subscriberKeys = transaction {
+                        val ebicsSubscriber =
+                            findEbicsSubscriber(staticHeader.partnerID, 
staticHeader.userID, staticHeader.systemID)
+                        if (ebicsSubscriber == null) {
+                            throw 
EbicsRequestError(HttpStatusCode.Unauthorized)
+                        }
+                        if (ebicsSubscriber.state != 
SubscriberState.INITIALIZED) {
+                            throw EbicsRequestError(HttpStatusCode.Forbidden)
+                        }
+                        val authPubBlob = 
ebicsSubscriber.authenticationKey!!.rsaPublicKey
+                        val encPubBlob = 
ebicsSubscriber.encryptionKey!!.rsaPublicKey
+                        val sigPubBlob = 
ebicsSubscriber.signatureKey!!.rsaPublicKey
+                        SubscriberKeys(
+                            
CryptoUtil.loadRsaPublicKey(authPubBlob.toByteArray()),
+                            
CryptoUtil.loadRsaPublicKey(encPubBlob.toByteArray()),
+                            
CryptoUtil.loadRsaPublicKey(sigPubBlob.toByteArray())
+                        )
+                    }
+                    val validationResult = 
XMLUtil.verifyEbicsDocument(bodyDocument, subscriberKeys.signaturePublicKey)
+                    logger.info("validationResult: $validationResult")
+                }
+                else -> {
+                    logger.warn("order type '${orderType}' not supported for 
ebicsNoPubKeyDigestsRequest")
+                    respondEbicsInvalidXml()
+                }
+            }
+        }
         else -> {
             /* Log to console and return "unknown type" */
             logger.info("Unknown message, just logging it!")
diff --git 
a/sandbox/src/main/kotlin/tech/libeufin/schema/ebics_h004/EbicsMessages.kt 
b/sandbox/src/main/kotlin/tech/libeufin/schema/ebics_h004/EbicsMessages.kt
index e964f21..f98d65f 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/schema/ebics_h004/EbicsMessages.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/schema/ebics_h004/EbicsMessages.kt
@@ -540,3 +540,45 @@ class EbicsKeyManagementResponse {
         }
     }
 }
+
+
+@XmlAccessorType(XmlAccessType.NONE)
+@XmlType(name = "", propOrder = ["header", "authSignature", "body"])
+@XmlRootElement(name = "ebicsNoPubKeyDigestsRequest")
+class EbicsNoPubKeyDigestsRequest {
+    @get:XmlAttribute(name = "Version", required = true)
+    @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
+    lateinit var version: String
+
+    @get:XmlAttribute(name = "Revision")
+    var revision: Int? = null
+
+    @get:XmlElement(name = "header", required = true)
+    lateinit var header: Header
+
+    @get:XmlElement(name = "AuthSignature", required = true)
+    lateinit var authSignature: SignatureType
+
+    @get:XmlElement(required = true)
+    lateinit var body: EmptyBody
+
+    @XmlAccessorType(XmlAccessType.NONE)
+    @XmlType(name = "", propOrder = ["static", "mutable"])
+    class Header {
+        @get:XmlAttribute(name = "authenticate", required = true)
+        var authenticate: Boolean = false
+
+        @get:XmlElement(name = "static", required = true)
+        lateinit var static: StaticHeader
+
+        @get:XmlElement(required = true)
+        lateinit var mutable: EmptyMutableHeader
+
+        @XmlAccessorType(XmlAccessType.NONE)
+        @XmlType(name = "")
+        class EmptyMutableHeader
+    }
+
+    @XmlAccessorType(XmlAccessType.NONE)
+    class EmptyBody
+}
\ No newline at end of file
diff --git a/resources/logback.xml b/sandbox/src/resources/logback.xml
similarity index 100%
rename from resources/logback.xml
rename to sandbox/src/resources/logback.xml
diff --git a/sandbox/src/test/kotlin/EbicsMessagesTest.kt 
b/sandbox/src/test/kotlin/EbicsMessagesTest.kt
index afc8f0e..20f7b20 100644
--- a/sandbox/src/test/kotlin/EbicsMessagesTest.kt
+++ b/sandbox/src/test/kotlin/EbicsMessagesTest.kt
@@ -18,7 +18,7 @@ class EbicsMessagesTest {
      * messages.
      */
     @Test
-    fun importNonRoot() {
+    fun testImportNonRoot() {
         val classLoader = ClassLoader.getSystemClassLoader()
         val ini = classLoader.getResource("ebics_ini_inner_key.xml")
         val jaxb = 
XMLUtil.convertStringToJaxb<SignaturePubKeyOrderData>(ini.readText())
@@ -29,7 +29,7 @@ class EbicsMessagesTest {
      * Test string -> JAXB
      */
     @Test
-    fun stringToJaxb() {
+    fun testStringToJaxb() {
         val classLoader = ClassLoader.getSystemClassLoader()
         val ini = classLoader.getResource("ebics_ini_request_sample.xml")
         val jaxb = 
XMLUtil.convertStringToJaxb<EbicsUnsecuredRequest>(ini.readText())
@@ -44,7 +44,7 @@ class EbicsMessagesTest {
      * Test JAXB -> string
      */
     @Test
-    fun jaxbToString() {
+    fun testJaxbToString() {
         val hevResponseJaxb = HEVResponse().apply {
             this.systemReturnCode = SystemReturnCodeType().apply {
                 this.reportText = "[EBICS_OK]"
@@ -55,12 +55,11 @@ class EbicsMessagesTest {
         XMLUtil.convertJaxbToString(hevResponseJaxb)
     }
 
-
     /**
      * Test DOM -> JAXB
      */
     @Test
-    fun domToJaxb() {
+    fun testDomToJaxb() {
         val classLoader = ClassLoader.getSystemClassLoader()
         val ini = classLoader.getResource("ebics_ini_request_sample.xml")!!
         val iniDom = XMLUtil.parseStringIntoDom(ini.readText())
@@ -100,7 +99,7 @@ class EbicsMessagesTest {
     }
 
     @Test
-    fun hiaLoad() {
+    fun testHiaLoad() {
         val classLoader = ClassLoader.getSystemClassLoader()
         val hia = classLoader.getResource("hia_request.xml")!!
         val hiaDom = XMLUtil.parseStringIntoDom(hia.readText())
@@ -122,7 +121,7 @@ class EbicsMessagesTest {
     }
 
     @Test
-    fun loadInnerKey() {
+    fun testLoadInnerKey() {
         val jaxbKey = run {
             val classLoader = ClassLoader.getSystemClassLoader()
             val file = classLoader.getResource(
@@ -138,14 +137,14 @@ class EbicsMessagesTest {
     }
 
     @Test
-    fun loadIniMessage() {
+    fun testLoadIniMessage() {
         val classLoader = ClassLoader.getSystemClassLoader()
         val text = 
classLoader.getResource("ebics_ini_request_sample.xml")!!.readText()
         XMLUtil.convertStringToJaxb<EbicsUnsecuredRequest>(text)
     }
 
     @Test
-    fun loadResponse() {
+    fun testLoadResponse() {
         val response = EbicsResponse().apply {
             version = "H004"
             header = EbicsResponse.Header().apply {
@@ -166,4 +165,11 @@ class EbicsMessagesTest {
         }
         print(XMLUtil.convertJaxbToString(response))
     }
+
+    @Test
+    fun testLoadHpb() {
+        val classLoader = ClassLoader.getSystemClassLoader()
+        val text = classLoader.getResource("hpb_request.xml")!!.readText()
+        XMLUtil.convertStringToJaxb<EbicsNoPubKeyDigestsRequest>(text)
+    }
 }
\ No newline at end of file

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



reply via email to

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