[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: Worked on policy handling
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: Worked on policy handling |
Date: |
Wed, 20 Nov 2019 21:31:09 +0100 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new ef178f9 Worked on policy handling
ef178f9 is described below
commit ef178f97a3aa2bb1f6cbc9d84a191d2e25313fd4
Author: Dennis Neufeld <address@hidden>
AuthorDate: Wed Nov 20 20:30:54 2019 +0000
Worked on policy handling
---
src/backend/Makefile.am | 4 +-
src/backend/anastasis-httpd.c | 11 +++++-
src/backend/anastasis-httpd_policy.c | 39 ++++++++++++-------
src/backend/anastasis-httpd_policy.h | 10 ++---
...asis-httpd_policy.h => anastasis-httpd_truth.c} | 45 +++++++++++++---------
...asis-httpd_policy.h => anastasis-httpd_truth.h} | 24 ++++++------
src/lib/anastasis_api_policy.c | 6 +--
7 files changed, 83 insertions(+), 56 deletions(-)
diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am
index df0b27e..852c758 100644
--- a/src/backend/Makefile.am
+++ b/src/backend/Makefile.am
@@ -16,7 +16,8 @@ anastasis_httpd_SOURCES = \
anastasis-httpd_parsing.c anastasis-httpd_parsing.h \
anastasis-httpd_responses.c anastasis-httpd_responses.h \
anastasis-httpd_mhd.c anastasis-httpd_mhd.h \
- anastasis-httpd_policy.c anastasis-httpd_policy.h
+ anastasis-httpd_policy.c anastasis-httpd_policy.h \
+ anastasis-httpd_truth.c anastasis-httpd_truth.h
anastasis_httpd_LDADD = \
$(top_builddir)/src/util/libanastasisutil.la \
@@ -24,6 +25,7 @@ anastasis_httpd_LDADD = \
-lmicrohttpd \
-ljansson \
-lgnunetcurl \
+ -lgnunetrest \
-lgnunetjson \
-lgnunetutil
diff --git a/src/backend/anastasis-httpd.c b/src/backend/anastasis-httpd.c
index 2bb8f31..5aca436 100644
--- a/src/backend/anastasis-httpd.c
+++ b/src/backend/anastasis-httpd.c
@@ -27,6 +27,7 @@
#include "anastasis-httpd_mhd.h"
#include "anastasis_database_lib.h"
#include "anastasis-httpd_policy.h"
+#include "anastasis-httpd_truth.h"
/**
* Backlog for listen operation on unix-domain sockets.
@@ -224,11 +225,17 @@ url_handler (void *cls,
// return handle_truth (...);
if (0 == strcmp (method, MHD_HTTP_METHOD_GET))
{
-
+ return AH_handler_truth_GET (connection,
+ url,
+ con_cls);
}
if (0 == strcmp (method, MHD_HTTP_METHOD_POST))
{
-
+ return AH_handler_truth_POST (connection,
+ con_cls,
+ url,
+ upload_data,
+ upload_data_size);
}
}
for (unsigned int i = 0; NULL != handlers[i].url; i++)
diff --git a/src/backend/anastasis-httpd_policy.c
b/src/backend/anastasis-httpd_policy.c
index 457e0d7..3f23208 100644
--- a/src/backend/anastasis-httpd_policy.c
+++ b/src/backend/anastasis-httpd_policy.c
@@ -83,9 +83,9 @@ AH_handler_policy_GET (struct MHD_Connection *connection,
res_recovery_data_size,
res_recovery_data);
if (NULL == res_recovery_data_size)
- return TMH_RESPONSE_reply_internal_error(connection,
- 42 /*FIXME*/,
- "recovery data size not
available");
+ return TMH_RESPONSE_reply_internal_error (connection,
+ 42 /*FIXME*/,
+ "recovery data size not
available");
}
else
{
@@ -101,7 +101,12 @@ AH_handler_policy_GET (struct MHD_Connection *connection,
// binary reply
{
struct MHD_Response *response;
-
+
+ /*FIXME: header must contain:
+ * - version of returned encrypted recovery document
+ * - Etag if Status 200 OK
+ */
+ //FIXME: Find correct create_response
response = MHD_create_response_from_buffer (sizeof (res_recovery_data),
res_recovery_data,
MHD_RESPMEM_MUST_FREE);
@@ -120,9 +125,10 @@ AH_handler_policy_GET (struct MHD_Connection *connection,
/**
* @param connection the MHD connection to handle
- * @param[in,out] connection_cls the connection's closure (can be updated)
+ * @param con_cls the connection's closure
+ * @param url handles a URL of the format "/policy/$ACCOUNT_PUB"
* @param upload_data upload data
- * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param upload_data_size number of bytes (left) in @a upload_data
* @return MHD result code
*/
int
@@ -140,6 +146,11 @@ AH_handler_policy_POST (struct MHD_Connection *connection,
unsigned int version;
int ret;
+ GNUNET_STRINGS_string_to_data (upload_data,
+ strlen (upload_data),
+ &recovery_data,
+ sizeof (recovery_data));
+
GNUNET_assert (0 == strncmp (url,
"/policy/",
strlen ("/policy/")));
@@ -158,27 +169,27 @@ AH_handler_policy_POST (struct MHD_Connection *connection,
}
paymentIdentifier_str = MHD_lookup_connection_value (connection,
- MHD_HEADER_KIND,
- "Payment-Identifier");
-
- memcpy (&paymentIdentifier,
+ MHD_HEADER_KIND,
+ "Payment-Identifier");
+
+ memcpy (&paymentIdentifier,
paymentIdentifier_str,
strlen (paymentIdentifier_str) + 1);
-
+
db->store_recovery_document (db->cls,
&accountPubP,
recovery_data,
sizeof (recovery_data),
paymentIdentifier,
&version);
-
+
}
// BUILD reply
{
struct MHD_Response *response;
-
- //FIXME: find correct create response
+
+ // FIXME: find correct create response
response = GNUNET_REST_create_response ("Irgendwas");
TMH_RESPONSE_add_global_headers (response);
diff --git a/src/backend/anastasis-httpd_policy.h
b/src/backend/anastasis-httpd_policy.h
index e947b2e..13a955e 100644
--- a/src/backend/anastasis-httpd_policy.h
+++ b/src/backend/anastasis-httpd_policy.h
@@ -26,9 +26,8 @@
/**
* @param connection the MHD connection to handle
- * @param[in,out] connection_cls the connection's closure (can be updated)
- * @param upload_data upload data
- * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param url handles a URL of the format
"/policy/$ACCOUNT_PUB[&version=$NUMBER]"
+ * @param con_cls
* @return MHD result code
*/
int
@@ -38,9 +37,10 @@ AH_handler_policy_GET (struct MHD_Connection *connection,
/**
* @param connection the MHD connection to handle
- * @param[in,out] connection_cls the connection's closure (can be updated)
+ * @param con_cls the connection's closure
+ * @param url handles a URL of the format "/policy/$ACCOUNT_PUB"
* @param upload_data upload data
- * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param upload_data_size number of bytes (left) in @a upload_data
* @return MHD result code
*/
int
diff --git a/src/backend/anastasis-httpd_policy.h
b/src/backend/anastasis-httpd_truth.c
similarity index 55%
copy from src/backend/anastasis-httpd_policy.h
copy to src/backend/anastasis-httpd_truth.c
index e947b2e..bdfc03d 100644
--- a/src/backend/anastasis-httpd_policy.h
+++ b/src/backend/anastasis-httpd_truth.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014, 2015, 2016 GNUnet e.V.
+ Copyright (C) 2019 GNUnet e.V.
TALER 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
@@ -14,41 +14,48 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file anastasis-httpd_policy.h
- * @brief functions to handle incoming requests on /policy/
+ * @file anastasis-httpd_truth.c
+ * @brief functions to handle incoming requests on /truth
* @author Dennis Neufeld
* @author Dominik Meister
* @author Christian Grothoff
*/
-#ifndef ANASTASIS_HTTPD_POLICY_H
-#define ANASTASIS_HTTPD_POLICY_H
-#include <microhttpd.h>
+#include "platform.h"
+#include "anastasis-httpd.h"
+#include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_rest_lib.h>
+#include "anastasis-httpd_responses.h"
/**
* @param connection the MHD connection to handle
- * @param[in,out] connection_cls the connection's closure (can be updated)
- * @param upload_data upload data
- * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param url handles a URL of the format "/truth/$UUID[&response=$RESPONSE]"
+ * @param con_cls
* @return MHD result code
*/
int
-AH_handler_policy_GET (struct MHD_Connection *connection,
+AH_handler_truth_GET (struct MHD_Connection *connection,
const char *url,
- void **con_cls);
+ void **con_cls)
+{
+ //FIXME: Handle truth get
+ return MHD_NO;
+}
/**
* @param connection the MHD connection to handle
- * @param[in,out] connection_cls the connection's closure (can be updated)
- * @param upload_data upload data
- * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param con_cls the connection's closure
+ * @param url handles a URL of the format "/truth/$UUID"
+ * @param upload_data upload data (truth)
+ * @param upload_data_size number of bytes (left) in @a upload_data
* @return MHD result code
*/
int
-AH_handler_policy_POST (struct MHD_Connection *connection,
+AH_handler_truth_POST (struct MHD_Connection *connection,
void **con_cls,
const char *url,
const char *upload_data,
- size_t *upload_data_size);
-
-
-#endif
\ No newline at end of file
+ size_t *upload_data_size)
+{
+ //FIXME: Handle truth get
+ return MHD_NO;
+}
diff --git a/src/backend/anastasis-httpd_policy.h
b/src/backend/anastasis-httpd_truth.h
similarity index 66%
copy from src/backend/anastasis-httpd_policy.h
copy to src/backend/anastasis-httpd_truth.h
index e947b2e..96f93ac 100644
--- a/src/backend/anastasis-httpd_policy.h
+++ b/src/backend/anastasis-httpd_truth.h
@@ -14,37 +14,37 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file anastasis-httpd_policy.h
- * @brief functions to handle incoming requests on /policy/
+ * @file anastasis-httpd_truth.h
+ * @brief functions to handle incoming requests on /truth
* @author Dennis Neufeld
* @author Dominik Meister
* @author Christian Grothoff
*/
-#ifndef ANASTASIS_HTTPD_POLICY_H
-#define ANASTASIS_HTTPD_POLICY_H
+#ifndef ANASTASIS_HTTPD_TRUTH_H
+#define ANASTASIS_HTTPD_TRUTH_H
#include <microhttpd.h>
/**
* @param connection the MHD connection to handle
- * @param[in,out] connection_cls the connection's closure (can be updated)
- * @param upload_data upload data
- * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param url handles a URL of the format "/truth/$UUID[&response=$RESPONSE]"
+ * @param con_cls
* @return MHD result code
*/
int
-AH_handler_policy_GET (struct MHD_Connection *connection,
+AH_handler_truth_GET (struct MHD_Connection *connection,
const char *url,
void **con_cls);
/**
* @param connection the MHD connection to handle
- * @param[in,out] connection_cls the connection's closure (can be updated)
- * @param upload_data upload data
- * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param con_cls the connection's closure
+ * @param url handles a URL of the format "/truth/$UUID"
+ * @param upload_data upload data (truth)
+ * @param upload_data_size number of bytes (left) in @a upload_data
* @return MHD result code
*/
int
-AH_handler_policy_POST (struct MHD_Connection *connection,
+AH_handler_truth_POST (struct MHD_Connection *connection,
void **con_cls,
const char *url,
const char *upload_data,
diff --git a/src/lib/anastasis_api_policy.c b/src/lib/anastasis_api_policy.c
index c397957..010f26f 100644
--- a/src/lib/anastasis_api_policy.c
+++ b/src/lib/anastasis_api_policy.c
@@ -496,9 +496,9 @@ ANASTASIS_policy_store_cancel (struct
*/
int
ANASTASIS_curl_easy_post (struct TEAH_PostContext *ctx,
- CURL *eh,
- const void *body,
- size_t body_size)
+ CURL *eh,
+ const void *body,
+ size_t body_size)
{
size_t slen;
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: Worked on policy handling,
gnunet <=