gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libfints] branch master updated: INI: fill header and payl


From: gnunet
Subject: [GNUnet-SVN] [libfints] branch master updated: INI: fill header and payload, and join them.
Date: Mon, 15 Oct 2018 16:49:18 +0200

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

marcello pushed a commit to branch master
in repository libfints.

The following commit(s) were added to refs/heads/master by this push:
     new 5e3933a  INI: fill header and payload, and join them.
5e3933a is described below

commit 5e3933ac1be7397371f436a65061402400eff038
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Oct 15 16:48:29 2018 +0200

    INI: fill header and payload, and join them.
---
 src/libebics.c    | 15 ++++++-----
 src/libebics.h    |  4 +--
 src/xmlmessages.c | 79 ++++++++++++++++++++++++++++++++++++++++---------------
 src/xmlproto.c    | 59 ++++++++++++++++++++++++++++-------------
 4 files changed, 109 insertions(+), 48 deletions(-)

diff --git a/src/libebics.c b/src/libebics.c
index a37e579..fdae8dc 100644
--- a/src/libebics.c
+++ b/src/libebics.c
@@ -1,7 +1,7 @@
 /**
  * This file is part of libebics
  *
- * libfints is free software; you can redistribute it and/or
+ * libebics is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 3,
  * or (at your option) any later version.
@@ -732,7 +732,7 @@ EBICS_close_library ()
  * @return pointer to a freshly allocated copy of
  * the base document; to be freed by the caller.
  */
-static struct EBICS_genex_document *
+struct EBICS_genex_document *
 get_genex_instance (unsigned int type_index)
 {
   struct EBICS_genex_document *ret;
@@ -762,12 +762,15 @@ EBICS_generate_message_ini
   struct EBICS_genex_document *instance;
 
   if (NULL == (instance = get_genex_instance
-    (EBICS_INI_BASE_DOCUMENT)))
+    (EBICS_INI_WRAPPER_TEMPLATE)))
   {
     LOG (EBICS_ERROR,
          "Could not allocate genex instance\n");
     return NULL;
   }
+  LOG (EBICS_LOGLEVEL_DEBUG,
+       "Picked base document %s\n",
+       instance->name);
 
   struct EBICS_MSG_Spec spec[] = {
 
@@ -806,7 +809,7 @@ EBICS_generate_message_hia (struct EBICS_ARGS_build_header 
*header_args,
   struct EBICS_genex_document *instance;
 
   if (NULL == (instance = get_genex_instance
-    (EBICS_INI_BASE_DOCUMENT)))
+    (0))) // FIXME
   {
     LOG (EBICS_ERROR,
          "Could not allocate genex instance\n");
@@ -844,7 +847,7 @@ EBICS_generate_message_hpb (struct EBICS_ARGS_build_header 
*header_args,
   struct EBICS_genex_document *instance;
 
   if (NULL == (instance = get_genex_instance
-    (EBICS_INI_BASE_DOCUMENT)))
+    (0))) // FIXME
   {
     LOG (EBICS_ERROR,
          "Could not allocate genex instance\n");
@@ -885,7 +888,7 @@ EBICS_generate_message_camt053 (struct 
EBICS_ARGS_build_header *header_args,
   struct EBICS_genex_document *instance;
 
   if (NULL == (instance = get_genex_instance
-    (EBICS_INI_BASE_DOCUMENT)))
+    (0))) //FIXME
   {
     LOG (EBICS_ERROR,
          "Could not allocate genex instance\n");
diff --git a/src/libebics.h b/src/libebics.h
index 6e10c75..d24b831 100644
--- a/src/libebics.h
+++ b/src/libebics.h
@@ -36,8 +36,8 @@
 #define EBICS_KEY_MAX_NAME 128
 
 
-/* FIXME verify that this is _actually_ it! */
-#define EBICS_INI_BASE_DOCUMENT 0
+#define EBICS_INI_WRAPPER_TEMPLATE 3
+#define EBICS_INI_PAYLOAD_TEMPLATE 1
 
 /**
  * Those indexes point inside the keyList global object.
diff --git a/src/xmlmessages.c b/src/xmlmessages.c
index df8e28a..9e375a2 100644
--- a/src/xmlmessages.c
+++ b/src/xmlmessages.c
@@ -39,6 +39,13 @@
 extern struct EBICS_Key keyList[];
 
 /**
+ * Needed to get payload's templates
+ */
+extern struct EBICS_genex_document *
+get_genex_instance (unsigned int type_index);
+
+
+/**
  * Dump a EBICS_genex_document to LOG_DEBUG.
  *
  */
@@ -153,27 +160,49 @@ util_extract_public_RSAKeyValue (gnutls_pubkey_t pubkey,
   return EBICS_SUCCESS;
 } 
 
+
+/**
+ * Fill header with always-needed values.
+ *
+ * @param cls closure, tipically contains
+ *        data to put in the document.
+ * @param document the base document to fill.
+ */
 void
 EBICS_build_header_generic (void *cls,
                             struct EBICS_genex_document *document)
 {
   char *sigAttribute[] = {"DZHNN", "OZHNN"};
-  struct EBICS_ARGS_build_header *data = (struct EBICS_ARGS_build_header*) cls;
+  struct EBICS_ARGS_build_header *data = (
+    struct EBICS_ARGS_build_header*) cls;
+
   struct EBICS_MSG_Spec header[] = {
-    EBICS_MSG_op_unique_choice("//ebics:static"),
-    EBICS_MSG_op_set_string("//ebics:static//ebics:HostID", data->hostID),
-    EBICS_MSG_op_set_string("//ebics:static//ebics:PartnerID", 
data->partnerID),
-    EBICS_MSG_op_set_string("//ebics:static//ebics:UserID", data->userID),
-    EBICS_MSG_op_set_string("//ebics:static//ebics:Product", 
data->productName),
-    EBICS_MSG_op_set_string("//ebics:static//ebics:SecurityMedium", "0000"),
-    EBICS_MSG_op_set_attribute("//ebics:static//ebics:Product/@Language", 
data->languageCode),
-    EBICS_MSG_op_unique_choice("//ebics:OrderDetails"),
-    EBICS_MSG_op_set_string("//ebics:OrderDetails/ebics:OrderAttribute", 
sigAttribute[data->requestBankSignature]),
-    EBICS_MSG_op_end()
+    EBICS_MSG_op_unique_choice ("//ebics:static"),
+    EBICS_MSG_op_set_string ("//ebics:static//ebics:HostID",
+                            data->hostID),
+    EBICS_MSG_op_set_string ("//ebics:static//ebics:PartnerID",
+                            data->partnerID),
+    EBICS_MSG_op_set_string ("//ebics:static//ebics:UserID",
+                            data->userID),
+    EBICS_MSG_op_set_string ("//ebics:static//ebics:Product",
+                             data->productName),
+    EBICS_MSG_op_set_string ("//ebics:static//ebics:SecurityMedium",
+                            "0000"),
+    EBICS_MSG_op_set_attribute ("//ebics:static//ebics:Product/@Language",
+                               data->languageCode),
+    EBICS_MSG_op_unique_choice ("//ebics:OrderDetails"),
+    EBICS_MSG_op_set_string ("//ebics:OrderDetails/ebics:OrderAttribute",
+                            sigAttribute[data->requestBankSignature]),
+    EBICS_MSG_op_end ()
   };
-  EBICS_MSG_parse_spec(header, document);
+  EBICS_MSG_parse_spec (header,
+                       document);
 }
 
+
+/**
+ * 
+ */
 void
 EBICS_build_header_ebicsRequest (void *cls,
                                  struct EBICS_genex_document *document)
@@ -197,7 +226,8 @@ EBICS_build_header_ebicsRequest (void *cls,
     EBICS_MSG_op_end ()
   };
 
-  EBICS_MSG_parse_spec (header, document);
+  EBICS_MSG_parse_spec (header,
+                       document);
 }
 
 
@@ -215,7 +245,8 @@ EBICS_build_header_ebicsUnsecuredRequest (void *cls,
     EBICS_MSG_op_end ()
   };
 
-  EBICS_MSG_parse_spec (header, document);
+  EBICS_MSG_parse_spec (header,
+                       document);
 }
 
 void
@@ -246,6 +277,7 @@ EBICS_build_content_ini (void *cls,
   char *exponent;
   char date[DATE_STR_SIZE];
   struct EBICS_ARGS_build_content_ini *data;
+  struct EBICS_genex_document *payload;
 
   xmlChar *iniContent;
   char *base64content;
@@ -264,7 +296,10 @@ EBICS_build_content_ini (void *cls,
      &exponent,
      &modulus);
 
-  struct EBICS_MSG_Spec content[] = {
+  /* Fills the SignaturePubKeyOrderData sub-tree,
+   * that will be appended to the OrderData node.  */
+
+  struct EBICS_MSG_Spec payload_spec[] = {
     EBICS_MSG_op_unique_choice ("//esig:SignatureVersion"),
     EBICS_MSG_op_del_node ("//ds:X509Data"),
     EBICS_MSG_op_set_string ("//esig:SignatureVersion",
@@ -278,13 +313,14 @@ EBICS_build_content_ini (void *cls,
     EBICS_MSG_op_set_string ("//esig:UserID",
                              data->userID),
     EBICS_MSG_op_del_node ("//schema:ANY"),
-    EBICS_MSG_op_set_string
-      ("//esig:PubKeyValue//ds:Exponent",
-       exponent),
+    EBICS_MSG_op_set_string ("//esig:PubKeyValue//ds:Exponent",
+                             exponent),
     EBICS_MSG_op_end ()
   };
-  EBICS_MSG_parse_spec (content,
-                        document);
+
+  payload = get_genex_instance (EBICS_INI_PAYLOAD_TEMPLATE);
+  EBICS_MSG_parse_spec (payload_spec,
+                        payload);
   GNUNET_free (modulus);
   GNUNET_free (exponent);
   
@@ -292,7 +328,7 @@ EBICS_build_content_ini (void *cls,
   LOG (EBICS_LOGLEVEL_DEBUG,
        "DUMPING CONTENT!");
   dump_message (document);
-  xmlDocDumpMemoryEnc (document->document,
+  xmlDocDumpMemoryEnc (payload->document,
                        &iniContent,
                        &xLen,
                        "utf-8");
@@ -339,6 +375,7 @@ EBICS_build_content_ini (void *cls,
   EBICS_MSG_parse_spec (body,
                         document);
   xmlFree (iniContent);
+  GNUNET_free (payload);
   GNUNET_free (base64content);
   GNUNET_free (zData);
 }
diff --git a/src/xmlproto.c b/src/xmlproto.c
index 431e5dc..66fb7cb 100644
--- a/src/xmlproto.c
+++ b/src/xmlproto.c
@@ -360,19 +360,22 @@ relink_choice(xmlNodePtr choice, xmlDocPtr doc)
  * @param doc Document pointer.
  */
 static void
-remove_opt_attribute(xmlNodePtr node, xmlDocPtr doc)
+remove_opt_attribute (xmlNodePtr node,
+                     xmlDocPtr doc)
 {
   xmlNodePtr current;
 
   for (current = node;
-       current && current != xmlDocGetRootElement(doc);
+       current && current != xmlDocGetRootElement (doc);
        current = current->parent)
   {
-    LOG(EBICS_LOGLEVEL_INFO,"Looking at %s",current->name);
-    if (xmlUnsetProp(current, BAD_CAST "lfts_optional") >= 0)
-    {
-      LOG(EBICS_LOGLEVEL_INFO,"Found opt, removing");
-    }
+    LOG (EBICS_LOGLEVEL_INFO,
+        "Looking at %s\n",
+        current->name);
+    if (0 <= xmlUnsetProp (current,
+                           BAD_CAST "lfts_optional"))
+      LOG (EBICS_LOGLEVEL_INFO,
+           "Found opt, removing\n");
   }
 }
 
@@ -387,23 +390,41 @@ remove_opt_attribute(xmlNodePtr node, xmlDocPtr doc)
 static void
 remove_lfts_optional_nodes (struct EBICS_genex_document *document)
 {
-  xmlXPathContextPtr xpathCtxPtr = document->xpath;
-  xmlNodePtr node;
-  xmlXPathObjectPtr xpathObjPtr = xmlXPathEvalExpression(BAD_CAST 
"//address@hidden'True']", xpathCtxPtr);
-  assert(NULL != xpathObjPtr);
-  assert(NULL != xpathObjPtr->nodesetval);
-  xmlNodeSetPtr nodeset = xpathObjPtr->nodesetval;
-  LOG(EBICS_LOGLEVEL_INFO,"remove_lfts_opt: Number of Nodes found: 
%d",nodeset->nodeNr);
   int i;
-  for (i = (nodeset->nodeNr); i > 0; i--)
+  xmlNodePtr node;
+  xmlXPathContextPtr xpathCtxPtr;
+  xmlXPathObjectPtr xpathObjPtr;
+  xmlNodeSetPtr nodeset;
+
+  xpathCtxPtr = document->xpath;
+  xpathObjPtr = xmlXPathEvalExpression
+    (BAD_CAST "//address@hidden'True']",
+     xpathCtxPtr);
+
+  assert (NULL != xpathObjPtr);
+  assert (NULL != xpathObjPtr->nodesetval);
+  nodeset = xpathObjPtr->nodesetval;
+
+  LOG (EBICS_LOGLEVEL_INFO,
+       "remove_lfts_opt: Number of Nodes found: %d\n",
+       nodeset->nodeNr);
+
+  for (i = (nodeset->nodeNr);
+       i > 0;
+       i--)
   {
     node = nodeset->nodeTab[i-1];
-    LOG(EBICS_LOGLEVEL_INFO,"\tFound: %s", node->name);
-    xmlUnlinkNode(node);
-    xmlFreeNode(node);
+
+    LOG (EBICS_LOGLEVEL_INFO,
+         "\tFound: %s\n",
+         node->name);
+
+    xmlUnlinkNode (node);
+    xmlFreeNode (node);
     nodeset->nodeTab[i-1] = NULL;
   }
-  xmlXPathFreeObject(xpathObjPtr);
+
+  xmlXPathFreeObject (xpathObjPtr);
 }
 
 /**

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



reply via email to

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