summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-11-26 13:41:59 +0100
committerChristian Grothoff <christian@grothoff.org>2015-11-26 13:41:59 +0100
commit9ac12f14e9d2272b67877525c076824ff4b813f5 (patch)
tree4a30bda0bfe1e2e321a76a12b9698eb3141d2522
parent7c94fa50d13de092b80c78d66c5e91637209e64f (diff)
downloadmerchant-9ac12f14e9d2272b67877525c076824ff4b813f5.tar.gz
merchant-9ac12f14e9d2272b67877525c076824ff4b813f5.tar.bz2
merchant-9ac12f14e9d2272b67877525c076824ff4b813f5.zip
modify auditor logic to include public keys and URI, also now matches latest API spec
-rw-r--r--src/backend/merchant.conf37
-rw-r--r--src/backend/taler-merchant-httpd_auditors.c147
2 files changed, 128 insertions, 56 deletions
diff --git a/src/backend/merchant.conf b/src/backend/merchant.conf
index 4515fd41..6b9c3cbf 100644
--- a/src/backend/merchant.conf
+++ b/src/backend/merchant.conf
@@ -1,21 +1,50 @@
+# Sample configuration file for a merchant.
[merchant]
+
+# Which port do we run the backend on? (HTTP server)
PORT = 9966
+
+# FIXME: is this one used?
HOSTNAME = localhost
-TRUSTED_MINTS = taler
+
+# Where is our private key?
KEYFILE = merchant.priv
+
+# What currency does this backend accept?
CURRENCY = KUDOS
+
+# FIXME: to be revised
+TRUSTED_MINTS = taler
+
+# How quickly do we want the mint to send us our money?
+# Used only if the frontend does not specify a value.
+# FIXME: EDATE is a bit short, 'execution_delay'?
EDATE = 3 week
-AUDITORS = france
[mint-taler]
HOSTNAME = mint.demo.taler.net
-[auditor-france]
-NAME = Charles De Gaulle
+# Auditors must be in sections "auditor-", the rest of the section
+# name could be anything.
+[auditor-ezb]
+# Informal name of the auditor. Just for the user.
+NAME = European Central Bank
+
+# URI of the auditor (especially for in the future, when the
+# auditor offers an automated issue reporting system).
+# Not really used today.
+URI = http://taler.ezb.eu/
+# This is the important bit: the signing key of the auditor.
+PUBLIC_KEY = 9QXF7XY7E9VPV47B5Z806NDFSX2VJ79SVHHD29QEQ3BG31ANHZ60
+
+# This specifies which database we use.
+# FIXME: should be in a section that has 'postgres' in the name!
[merchant-db]
CONFIG = postgres:///talerdemo
+
+# "wire-" sections include wire details, here for SEPA.
[wire-sepa]
IBAN = DE67830654080004822650
NAME = GNUNET E.V
diff --git a/src/backend/taler-merchant-httpd_auditors.c b/src/backend/taler-merchant-httpd_auditors.c
index 7edcdb9e..84fbb344 100644
--- a/src/backend/taler-merchant-httpd_auditors.c
+++ b/src/backend/taler-merchant-httpd_auditors.c
@@ -28,10 +28,20 @@
struct Auditor
{
/**
- * Auditor's legal name (FIXME: this is not what we really want.)
+ * Auditor's legal name.
*/
char *name;
+ /**
+ * Auditor's URI.
+ */
+ char *uri;
+
+ /**
+ * Public key of the auditor.
+ */
+ struct TALER_AuditorPublicKeyP public_key;
+
};
@@ -52,6 +62,81 @@ json_t *j_auditors;
/**
+ * Function called on each configuration section. Finds sections
+ * about auditors and parses the entries.
+ *
+ * @param cls closure
+ * @param section name of the section
+ */
+static void
+parse_auditors (void *cls,
+ const char *section)
+{
+ char *pks;
+ struct Auditor auditor;
+
+ if (0 != strncasecmp (section,
+ "auditor-",
+ strlen ("auditor-")))
+ return;
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ section,
+ "NAME",
+ &auditor.name))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ section,
+ "NAME");
+ return;
+ }
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ section,
+ "URI",
+ &auditor.uri))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ section,
+ "URI");
+ GNUNET_free (auditor.name);
+ return;
+ }
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ section,
+ "PUBLIC_KEY",
+ &pks))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ section,
+ "PUBLIC_KEY");
+ GNUNET_free (auditor.name);
+ GNUNET_free (auditor.uri);
+ return;
+ }
+ if (GNUNET_OK !=
+ GNUNET_CRYPTO_eddsa_public_key_from_string (pks,
+ strlen (pks),
+ &auditor.public_key.eddsa_pub))
+ {
+ GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
+ section,
+ "PUBLIC_KEY",
+ "valid public key");
+ GNUNET_free (auditor.name);
+ GNUNET_free (auditor.uri);
+ GNUNET_free (pks);
+ return;
+ }
+ GNUNET_free (pks);
+ GNUNET_array_append (auditors,
+ nauditors,
+ auditor);
+}
+
+
+/**
* Parses auditor information from the configuration.
*
* @param cfg the configuration
@@ -61,65 +146,22 @@ json_t *j_auditors;
int
TMH_AUDITORS_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- char *auditors_str;
- char *token_nf; /* do no free (nf) */
- char *auditor_section;
- char *auditor_name;
- struct Auditor *r_auditors;
- struct Auditor auditor;
unsigned int cnt;
int ok;
- ok = 0;
- auditors_str = NULL;
- token_nf = NULL;
- auditor_section = NULL;
- auditor_name = NULL;
- r_auditors = NULL;
- cnt = 0;
- EXITIF (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- "merchant",
- "AUDITORS",
- &auditors_str));
- for (token_nf = strtok (auditors_str, " ");
- NULL != token_nf;
- token_nf = strtok (NULL, " "))
- {
- GNUNET_assert (0 < GNUNET_asprintf (&auditor_section,
- "auditor-%s", token_nf));
- EXITIF (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- auditor_section,
- "NAME",
- &auditor_name));
- auditor.name = auditor_name;
- GNUNET_array_append (r_auditors, cnt, auditor);
- auditor_name = NULL;
- GNUNET_free (auditor_section);
- auditor_section = NULL;
- }
- ok = 1;
-
- EXITIF_exit:
- GNUNET_free_non_null (auditors_str);
- GNUNET_free_non_null (auditor_section);
- GNUNET_free_non_null (auditor_name);
- if (! ok)
- {
- GNUNET_free_non_null (r_auditors);
- return GNUNET_SYSERR;
- }
-
- auditors = r_auditors;
- nauditors = cnt;
+ GNUNET_CONFIGURATION_iterate_sections (cfg,
+ &parse_auditors,
+ NULL);
/* Generate preferred mint(s) array. */
j_auditors = json_array ();
for (cnt = 0; cnt < nauditors; cnt++)
json_array_append_new (j_auditors,
- json_pack ("{s:s}",
- "name", auditors[cnt].name));
+ json_pack ("{s:s, s:o, s:s}",
+ "name", auditors[cnt].name,
+ "auditor_pub", TALER_json_from_data (&auditors[cnt].public_key,
+ sizeof (struct TALER_AuditorPublicKeyP)),
+ "uri", auditors[cnt].uri));
return nauditors;
}
@@ -137,6 +179,7 @@ TMH_AUDITORS_done ()
for (i=0;i<nauditors;i++)
{
GNUNET_free (auditors[i].name);
+ GNUNET_free (auditors[i].uri);
}
GNUNET_free (auditors);
auditors = NULL;