summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2021-04-20 19:03:41 +0200
committerMartin Schanzenbach <mschanzenbach@posteo.de>2021-04-20 19:03:41 +0200
commit22d8a6445a1807e9a9e032d85c0503ed08e70bf7 (patch)
treee9f9d6020e1f294c7fcbb31340d425f1158bf04e
parent5faab5da8337e5060002cba8cf5c4c1d8bc89a1e (diff)
- towards pabc fixing
-rw-r--r--contrib/Makefile.inc3
-rw-r--r--po/POTFILES.in125
-rw-r--r--src/reclaim/pabc_helper.c3
-rw-r--r--src/reclaim/plugin_reclaim_credential_pabc.c169
-rw-r--r--src/reclaim/plugin_rest_pabc.c32
5 files changed, 155 insertions, 177 deletions
diff --git a/contrib/Makefile.inc b/contrib/Makefile.inc
index c737a07f8..a563ef4a1 100644
--- a/contrib/Makefile.inc
+++ b/contrib/Makefile.inc
@@ -8,7 +8,8 @@ BUILDCOMMON_SHLIB_FILES = \
build-common/sh/lib.sh/existence_python.sh \
build-common/sh/lib.sh/msg.sh \
build-common/sh/lib.sh/progname.sh \
- build-common/sh/lib.sh/version_gnunet.sh
+ build-common/sh/lib.sh/version_gnunet.sh \
+ build-common/LICENSE
BUILDCOMMON_CONF_FILES = \
build-common/conf/.dir-locals.el \
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 9d1e3427c..dd36b7411 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -10,13 +10,21 @@ src/arm/arm_monitor_api.c
src/arm/gnunet-arm.c
src/arm/gnunet-service-arm.c
src/arm/mockup-service.c
+src/ats-tests/ats-testing-experiment.c
+src/ats-tests/ats-testing-log.c
+src/ats-tests/ats-testing-preferences.c
+src/ats-tests/ats-testing-traffic.c
+src/ats-tests/ats-testing.c
+src/ats-tests/gnunet-ats-sim.c
+src/ats-tests/gnunet-solver-eval.c
+src/ats-tool/gnunet-ats.c
src/ats/ats_api_connectivity.c
src/ats/ats_api_performance.c
src/ats/ats_api_scanner.c
src/ats/ats_api_scheduling.c
src/ats/gnunet-ats-solver-eval.c
-src/ats/gnunet-service-ats_addresses.c
src/ats/gnunet-service-ats.c
+src/ats/gnunet-service-ats_addresses.c
src/ats/gnunet-service-ats_connectivity.c
src/ats/gnunet-service-ats_normalization.c
src/ats/gnunet-service-ats_performance.c
@@ -25,14 +33,6 @@ src/ats/gnunet-service-ats_preferences.c
src/ats/gnunet-service-ats_reservations.c
src/ats/gnunet-service-ats_scheduling.c
src/ats/plugin_ats_proportional.c
-src/ats-tests/ats-testing.c
-src/ats-tests/ats-testing-experiment.c
-src/ats-tests/ats-testing-log.c
-src/ats-tests/ats-testing-preferences.c
-src/ats-tests/ats-testing-traffic.c
-src/ats-tests/gnunet-ats-sim.c
-src/ats-tests/gnunet-solver-eval.c
-src/ats-tool/gnunet-ats.c
src/auction/gnunet-auction-create.c
src/auction/gnunet-auction-info.c
src/auction/gnunet-auction-join.c
@@ -50,8 +50,8 @@ src/cadet/cadet_api_list_peers.c
src/cadet/cadet_api_list_tunnels.c
src/cadet/cadet_test_lib.c
src/cadet/desirability_table.c
-src/cadet/gnunet-cadet.c
src/cadet/gnunet-cadet-profiler.c
+src/cadet/gnunet-cadet.c
src/cadet/gnunet-service-cadet.c
src/cadet/gnunet-service-cadet_channel.c
src/cadet/gnunet-service-cadet_connection.c
@@ -67,15 +67,15 @@ src/consensus/gnunet-service-consensus.c
src/consensus/plugin_block_consensus.c
src/conversation/conversation_api.c
src/conversation/conversation_api_call.c
-src/conversation/gnunet-conversation.c
src/conversation/gnunet-conversation-test.c
-src/conversation/gnunet_gst.c
-src/conversation/gnunet_gst_test.c
-src/conversation/gnunet-helper-audio-playback.c
+src/conversation/gnunet-conversation.c
src/conversation/gnunet-helper-audio-playback-gst.c
-src/conversation/gnunet-helper-audio-record.c
+src/conversation/gnunet-helper-audio-playback.c
src/conversation/gnunet-helper-audio-record-gst.c
+src/conversation/gnunet-helper-audio-record.c
src/conversation/gnunet-service-conversation.c
+src/conversation/gnunet_gst.c
+src/conversation/gnunet_gst_test.c
src/conversation/microphone.c
src/conversation/plugin_gnsrecord_conversation.c
src/conversation/speaker.c
@@ -105,7 +105,6 @@ src/dht/dht_api.c
src/dht/dht_test_lib.c
src/dht/gnunet-dht-get.c
src/dht/gnunet-dht-monitor.c
-src/dht/gnunet_dht_profiler.c
src/dht/gnunet-dht-put.c
src/dht/gnunet-service-dht.c
src/dht/gnunet-service-dht_clients.c
@@ -114,6 +113,7 @@ src/dht/gnunet-service-dht_hello.c
src/dht/gnunet-service-dht_neighbours.c
src/dht/gnunet-service-dht_nse.c
src/dht/gnunet-service-dht_routing.c
+src/dht/gnunet_dht_profiler.c
src/dht/plugin_block_dht.c
src/dns/dns_api.c
src/dns/gnunet-dns-monitor.c
@@ -148,8 +148,8 @@ src/fs/gnunet-auto-share.c
src/fs/gnunet-daemon-fsprofiler.c
src/fs/gnunet-directory.c
src/fs/gnunet-download.c
-src/fs/gnunet-fs.c
src/fs/gnunet-fs-profiler.c
+src/fs/gnunet-fs.c
src/fs/gnunet-helper-fs-publish.c
src/fs/gnunet-publish.c
src/fs/gnunet-search.c
@@ -169,9 +169,9 @@ src/gns/gns_tld_api.c
src/gns/gnunet-bcd.c
src/gns/gnunet-dns2gns.c
src/gns/gnunet-gns-benchmark.c
-src/gns/gnunet-gns.c
src/gns/gnunet-gns-import.c
src/gns/gnunet-gns-proxy.c
+src/gns/gnunet-gns.c
src/gns/gnunet-service-gns.c
src/gns/gnunet-service-gns_interceptor.c
src/gns/gnunet-service-gns_resolver.c
@@ -189,8 +189,8 @@ src/gnsrecord/json_gnsrecord.c
src/gnsrecord/plugin_gnsrecord_dns.c
src/hello/address.c
src/hello/gnunet-hello.c
-src/hello/hello.c
src/hello/hello-ng.c
+src/hello/hello.c
src/hostlist/gnunet-daemon-hostlist.c
src/hostlist/gnunet-daemon-hostlist_client.c
src/hostlist/gnunet-daemon-hostlist_server.c
@@ -205,8 +205,8 @@ src/json/json_generator.c
src/json/json_helper.c
src/json/json_mhd.c
src/messenger/gnunet-messenger.c
-src/messenger/gnunet-service-messenger_basement.c
src/messenger/gnunet-service-messenger.c
+src/messenger/gnunet-service-messenger_basement.c
src/messenger/gnunet-service-messenger_ego_store.c
src/messenger/gnunet-service-messenger_handle.c
src/messenger/gnunet-service-messenger_list_handles.c
@@ -245,8 +245,8 @@ src/namecache/namecache_api.c
src/namecache/plugin_namecache_flat.c
src/namecache/plugin_namecache_postgres.c
src/namecache/plugin_namecache_sqlite.c
-src/namestore/gnunet-namestore.c
src/namestore/gnunet-namestore-fcfsd.c
+src/namestore/gnunet-namestore.c
src/namestore/gnunet-service-namestore.c
src/namestore/gnunet-zoneimport.c
src/namestore/namestore_api.c
@@ -272,17 +272,17 @@ src/nat/gnunet-service-nat_mini.c
src/nat/gnunet-service-nat_stun.c
src/nat/nat_api.c
src/nat/nat_api_stun.c
-src/nse/gnunet-nse.c
src/nse/gnunet-nse-profiler.c
+src/nse/gnunet-nse.c
src/nse/gnunet-service-nse.c
src/nse/nse_api.c
src/nt/nt.c
-src/peerinfo/gnunet-service-peerinfo.c
-src/peerinfo/peerinfo_api.c
-src/peerinfo/peerinfo_api_notify.c
src/peerinfo-tool/gnunet-peerinfo.c
src/peerinfo-tool/gnunet-peerinfo_plugins.c
src/peerinfo-tool/plugin_rest_peerinfo.c
+src/peerinfo/gnunet-service-peerinfo.c
+src/peerinfo/peerinfo_api.c
+src/peerinfo/peerinfo_api_notify.c
src/peerstore/gnunet-peerstore.c
src/peerstore/gnunet-service-peerstore.c
src/peerstore/peerstore_api.c
@@ -302,10 +302,13 @@ src/reclaim/gnunet-service-reclaim.c
src/reclaim/gnunet-service-reclaim_tickets.c
src/reclaim/json_reclaim.c
src/reclaim/oidc_helper.c
+src/reclaim/pabc_helper.c
src/reclaim/plugin_gnsrecord_reclaim.c
src/reclaim/plugin_reclaim_attribute_basic.c
src/reclaim/plugin_reclaim_credential_jwt.c
+src/reclaim/plugin_reclaim_credential_pabc.c
src/reclaim/plugin_rest_openid_connect.c
+src/reclaim/plugin_rest_pabc.c
src/reclaim/plugin_rest_reclaim.c
src/reclaim/reclaim_api.c
src/reclaim/reclaim_attribute.c
@@ -328,27 +331,27 @@ src/rest/gnunet-rest-server.c
src/rest/plugin_rest_config.c
src/rest/plugin_rest_copying.c
src/rest/rest.c
-src/revocation/gnunet-revocation.c
src/revocation/gnunet-revocation-tvg.c
+src/revocation/gnunet-revocation.c
src/revocation/gnunet-service-revocation.c
src/revocation/plugin_block_revocation.c
src/revocation/revocation_api.c
-src/rps/gnunet-rps.c
src/rps/gnunet-rps-profiler.c
+src/rps/gnunet-rps.c
src/rps/gnunet-service-rps.c
src/rps/gnunet-service-rps_custommap.c
src/rps/gnunet-service-rps_sampler.c
src/rps/gnunet-service-rps_sampler_elem.c
src/rps/gnunet-service-rps_view.c
-src/rps/rps_api.c
src/rps/rps-sampler_client.c
src/rps/rps-sampler_common.c
src/rps/rps-test_util.c
+src/rps/rps_api.c
src/scalarproduct/gnunet-scalarproduct.c
-src/scalarproduct/gnunet-service-scalarproduct_alice.c
-src/scalarproduct/gnunet-service-scalarproduct_bob.c
src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c
src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c
+src/scalarproduct/gnunet-service-scalarproduct_alice.c
+src/scalarproduct/gnunet-service-scalarproduct_bob.c
src/scalarproduct/scalarproduct_api.c
src/secretsharing/gnunet-secretsharing-profiler.c
src/secretsharing/gnunet-service-secretsharing.c
@@ -362,12 +365,12 @@ src/set/gnunet-set-ibf-profiler.c
src/set/gnunet-set-profiler.c
src/set/ibf.c
src/set/ibf_sim.c
+src/set/plugin_block_set_test.c
+src/set/set_api.c
src/seti/gnunet-service-seti.c
src/seti/gnunet-seti-profiler.c
src/seti/plugin_block_seti_test.c
src/seti/seti_api.c
-src/set/plugin_block_set_test.c
-src/set/set_api.c
src/setu/gnunet-service-setu.c
src/setu/gnunet-service-setu_strata_estimator.c
src/setu/gnunet-setu-ibf-profiler.c
@@ -386,15 +389,16 @@ src/statistics/gnunet-statistics.c
src/statistics/statistics_api.c
src/template/gnunet-service-template.c
src/template/gnunet-template.c
+src/testbed-logger/gnunet-service-testbed-logger.c
+src/testbed-logger/testbed_logger_api.c
src/testbed/generate-underlay-topology.c
src/testbed/gnunet-daemon-latency-logger.c
src/testbed/gnunet-daemon-testbed-blacklist.c
src/testbed/gnunet-daemon-testbed-underlay.c
src/testbed/gnunet-helper-testbed.c
-src/testbed/gnunet_mpi_test.c
src/testbed/gnunet-service-test-barriers.c
-src/testbed/gnunet-service-testbed_barriers.c
src/testbed/gnunet-service-testbed.c
+src/testbed/gnunet-service-testbed_barriers.c
src/testbed/gnunet-service-testbed_cache.c
src/testbed/gnunet-service-testbed_connectionpool.c
src/testbed/gnunet-service-testbed_cpustatus.c
@@ -402,69 +406,81 @@ src/testbed/gnunet-service-testbed_links.c
src/testbed/gnunet-service-testbed_meminfo.c
src/testbed/gnunet-service-testbed_oc.c
src/testbed/gnunet-service-testbed_peers.c
-src/testbed/gnunet_testbed_mpi_spawn.c
src/testbed/gnunet-testbed-profiler.c
-src/testbed-logger/gnunet-service-testbed-logger.c
-src/testbed-logger/testbed_logger_api.c
-src/testbed/testbed_api_barriers.c
+src/testbed/gnunet_mpi_test.c
+src/testbed/gnunet_testbed_mpi_spawn.c
src/testbed/testbed_api.c
+src/testbed/testbed_api_barriers.c
src/testbed/testbed_api_cmd_controller.c
src/testbed/testbed_api_cmd_peer.c
-src/testbed/testbed_api_cmd_service.c
+src/testbed/testbed_api_cmd_peer_store.c
+src/testbed/testbed_api_cmd_tng_connect.c
+src/testbed/testbed_api_cmd_tng_service.c
src/testbed/testbed_api_hosts.c
src/testbed/testbed_api_operations.c
src/testbed/testbed_api_peers.c
src/testbed/testbed_api_sd.c
src/testbed/testbed_api_services.c
src/testbed/testbed_api_statistics.c
-src/testbed/testbed_api_testbed.c
src/testbed/testbed_api_test.c
+src/testbed/testbed_api_testbed.c
src/testbed/testbed_api_topology.c
src/testbed/testbed_api_underlay.c
src/testing/gnunet-testing.c
src/testing/list-keys.c
+src/testing/testing.c
src/testing/testing_api_cmd_batch.c
-src/testing/testing_api_cmd_hello_world_birth.c
src/testing/testing_api_cmd_hello_world.c
+src/testing/testing_api_cmd_hello_world_birth.c
src/testing/testing_api_loop.c
src/testing/testing_api_trait_cmd.c
src/testing/testing_api_trait_process.c
src/testing/testing_api_traits.c
-src/testing/testing.c
src/topology/friends.c
src/topology/gnunet-daemon-topology.c
src/transport/gnunet-communicator-tcp.c
src/transport/gnunet-communicator-udp.c
src/transport/gnunet-communicator-unix.c
src/transport/gnunet-helper-transport-bluetooth.c
-src/transport/gnunet-helper-transport-wlan.c
src/transport/gnunet-helper-transport-wlan-dummy.c
+src/transport/gnunet-helper-transport-wlan.c
src/transport/gnunet-service-tng.c
-src/transport/gnunet-service-transport_ats.c
src/transport/gnunet-service-transport.c
+src/transport/gnunet-service-transport_ats.c
src/transport/gnunet-service-transport_hello.c
src/transport/gnunet-service-transport_manipulation.c
src/transport/gnunet-service-transport_neighbours.c
src/transport/gnunet-service-transport_plugins.c
src/transport/gnunet-service-transport_validation.c
-src/transport/gnunet-transport.c
src/transport/gnunet-transport-profiler.c
src/transport/gnunet-transport-wlan-receiver.c
src/transport/gnunet-transport-wlan-sender.c
+src/transport/gnunet-transport.c
src/transport/plugin_transport_http_client.c
src/transport/plugin_transport_http_common.c
src/transport/plugin_transport_http_server.c
src/transport/plugin_transport_smtp.c
src/transport/plugin_transport_tcp.c
src/transport/plugin_transport_template.c
-src/transport/plugin_transport_udp_broadcasting.c
src/transport/plugin_transport_udp.c
+src/transport/plugin_transport_udp_broadcasting.c
src/transport/plugin_transport_unix.c
src/transport/plugin_transport_wlan.c
src/transport/tcp_connection_legacy.c
src/transport/tcp_server_legacy.c
src/transport/tcp_server_mst_legacy.c
src/transport/tcp_service_legacy.c
+src/transport/transport-testing-communicator.c
+src/transport/transport-testing-filenames.c
+src/transport/transport-testing-filenames2.c
+src/transport/transport-testing-loggers.c
+src/transport/transport-testing-loggers2.c
+src/transport/transport-testing-main.c
+src/transport/transport-testing-main2.c
+src/transport/transport-testing-send.c
+src/transport/transport-testing-send2.c
+src/transport/transport-testing.c
+src/transport/transport-testing2.c
src/transport/transport_api2_application.c
src/transport/transport_api2_communication.c
src/transport/transport_api2_core.c
@@ -477,17 +493,6 @@ src/transport/transport_api_manipulation.c
src/transport/transport_api_monitor_peers.c
src/transport/transport_api_monitor_plugins.c
src/transport/transport_api_offer_hello.c
-src/transport/transport-testing2.c
-src/transport/transport-testing.c
-src/transport/transport-testing-communicator.c
-src/transport/transport-testing-filenames2.c
-src/transport/transport-testing-filenames.c
-src/transport/transport-testing-loggers2.c
-src/transport/transport-testing-loggers.c
-src/transport/transport-testing-main2.c
-src/transport/transport-testing-main.c
-src/transport/transport-testing-send2.c
-src/transport/transport-testing-send.c
src/util/bandwidth.c
src/util/benchmark.c
src/util/bio.c
@@ -502,8 +507,8 @@ src/util/consttime_memcmp.c
src/util/container_bloomfilter.c
src/util/container_heap.c
src/util/container_meta_data.c
-src/util/container_multihashmap32.c
src/util/container_multihashmap.c
+src/util/container_multihashmap32.c
src/util/container_multipeermap.c
src/util/container_multishortmap.c
src/util/container_multiuuidmap.c
@@ -528,8 +533,8 @@ src/util/dnsstub.c
src/util/getopt.c
src/util/getopt_helpers.c
src/util/gnunet-base32.c
-src/util/gnunet-config.c
src/util/gnunet-config-diff.c
+src/util/gnunet-config.c
src/util/gnunet-crypto-tvg.c
src/util/gnunet-ecc.c
src/util/gnunet-qr.c
@@ -567,8 +572,8 @@ src/vpn/gnunet-helper-vpn.c
src/vpn/gnunet-service-vpn.c
src/vpn/gnunet-vpn.c
src/vpn/vpn_api.c
-src/zonemaster/gnunet-service-zonemaster.c
src/zonemaster/gnunet-service-zonemaster-monitor.c
+src/zonemaster/gnunet-service-zonemaster.c
src/fs/fs_api.h
src/testbed/testbed_api.h
src/testbed/testbed_api_operations.h
diff --git a/src/reclaim/pabc_helper.c b/src/reclaim/pabc_helper.c
index e76977d03..c435ad5b3 100644
--- a/src/reclaim/pabc_helper.c
+++ b/src/reclaim/pabc_helper.c
@@ -29,7 +29,8 @@ write_file (char const *const filename, const char *buffer)
struct GNUNET_DISK_FileHandle *fh;
fh = GNUNET_DISK_file_open (filename,
GNUNET_DISK_OPEN_WRITE
- | GNUNET_DISK_OPEN_TRUNCATE,
+ | GNUNET_DISK_OPEN_TRUNCATE
+ | GNUNET_DISK_OPEN_CREATE,
GNUNET_DISK_PERM_USER_WRITE);
if (fh == NULL)
return GNUNET_SYSERR;
diff --git a/src/reclaim/plugin_reclaim_credential_pabc.c b/src/reclaim/plugin_reclaim_credential_pabc.c
index 148cfec13..e17520528 100644
--- a/src/reclaim/plugin_reclaim_credential_pabc.c
+++ b/src/reclaim/plugin_reclaim_credential_pabc.c
@@ -144,6 +144,22 @@ pabc_number_to_typename (void *cls, uint32_t type)
}
+static void
+inspect_attrs (char const *const key,
+ char const *const value,
+ void *ctx)
+{
+ struct GNUNET_RECLAIM_AttributeList *attrs = ctx;
+
+ GNUNET_RECLAIM_attribute_list_add (attrs,
+ key,
+ NULL,
+ GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING,
+ value,
+ strlen (value));
+}
+
+
/**
* Parse a pabc and return the respective claim value as Attribute
*
@@ -156,14 +172,9 @@ pabc_parse_attributes (void *cls,
const char *data,
size_t data_size)
{
- const char *key;
struct GNUNET_RECLAIM_AttributeList *attrs;
- char *val_str = NULL;
- char *tmp;
- json_t *value;
- json_t *attr;
- json_t *json_attrs;
json_t *json_root;
+ json_t *json_attrs;
json_error_t *json_err = NULL;
json_root = json_loads (data, JSON_DECODE_ANY, json_err);
@@ -177,55 +188,20 @@ pabc_parse_attributes (void *cls,
json_decref (json_root);
return NULL;
}
- json_attrs = json_object_get (json_root, "attributes");
+ json_attrs = json_object_get (json_root, PABC_JSON_PLAIN_ATTRS_KEY);
if ((NULL == json_attrs) ||
- (! json_is_array (json_attrs)))
+ (! json_is_object (json_attrs)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%s is not a valid pabc credentials (attributes not an array)\n",
+ "%s is not a valid pabc credentials (attributes not an object)\n",
data);
json_decref (json_root);
return NULL;
}
attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
- for (int i = 0; i < json_array_size (json_attrs); i++)
- {
- attr = json_array_get (json_attrs, i);
- if (! json_is_object (attr))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Found json entry is not an object!\n");
- GNUNET_RECLAIM_attribute_list_destroy (attrs);
- json_decref (json_root);
- return NULL;
- }
- /**
- * This *should* only contain a single pair.
- */
- json_object_foreach (attr, key, value)
- {
- if ((0 == strcmp ("issuer", key)) ||
- (0 == strcmp ("expiration", key)) ||
- (0 == strcmp ("subject", key)))
- continue;
- val_str = json_dumps (value, JSON_ENCODE_ANY);
- tmp = val_str;
- // Remove leading " from jasson conversion
- if (tmp[0] == '"')
- tmp++;
- // Remove trailing " from jansson conversion
- if (tmp[strlen (tmp) - 1] == '"')
- tmp[strlen (tmp) - 1] = '\0';
- GNUNET_RECLAIM_attribute_list_add (attrs,
- key,
- NULL,
- GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING,
- tmp,
- strlen (tmp));
- GNUNET_free (val_str);
- }
- }
+ char *attr_str = json_dumps (json_attrs, JSON_DECODE_ANY);
+ pabc_cred_inspect_credential (attr_str, &inspect_attrs, attrs);
json_decref (json_root);
return attrs;
}
@@ -260,6 +236,23 @@ pabc_parse_attributes_p (void *cls,
return pabc_parse_attributes (cls, cred->data, cred->data_size);
}
+struct Finder
+{
+ const char* target;
+ char *result;
+};
+
+static void
+find_attr (char const *const key,
+ char const *const value,
+ void *ctx)
+{
+ struct Finder *fdr = ctx;
+ if (0 == strcmp (key, fdr->target))
+ fdr->result = GNUNET_strdup (value);
+}
+
+
/**
* Parse a pabc and return an attribute value.
@@ -267,7 +260,7 @@ pabc_parse_attributes_p (void *cls,
* @param cls the plugin
* @param data the pabc credential data
* @param data_size the pabc credential size
- * @param key the attribute key to look for.
+ * @param skey the attribute key to look for.
* @return a string, containing the isser
*/
char *
@@ -276,13 +269,8 @@ pabc_get_attribute (void *cls,
size_t data_size,
const char *skey)
{
- const char *key;
- char *val_str = NULL;
- char *tmp;
json_t *json_root;
json_t *json_attrs;
- json_t *value;
- json_t *attr;
json_error_t *json_err = NULL;
json_root = json_loads (data, JSON_DECODE_ANY, json_err);
@@ -290,50 +278,29 @@ pabc_get_attribute (void *cls,
(! json_is_object (json_root)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%s is not a valid pabc credentials (not an object)\n",
+ "%s is not a valid pabc credential (not an object)\n",
data);
if (NULL != json_root)
json_decref (json_root);
return NULL;
}
- json_attrs = json_object_get (json_root, "attributes");
+ json_attrs = json_object_get (json_root, PABC_JSON_PLAIN_ATTRS_KEY);
if ((NULL == json_attrs) ||
- (! json_is_array (json_attrs)))
+ (! json_is_object (json_attrs)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%s is not a valid pabc credentials (attributes not an array)\n",
+ "%s is not a valid pabc credential (attributes not an object)\n",
data);
json_decref (json_root);
return NULL;
}
-
- for (int i = 0; i < json_array_size (json_attrs); i++)
- {
- attr = json_array_get (json_attrs, i);
- if (! json_is_object (attr))
- continue;
- /**
- * This *should* only contain a single pair.
- */
- json_object_foreach (attr, key, value)
- {
- if (0 != strcmp (skey, key))
- continue;
- val_str = json_dumps (value, JSON_ENCODE_ANY);
- tmp = val_str;
- // Remove leading " from jasson conversion
- if (tmp[0] == '"')
- tmp++;
- // Remove trailing " from jansson conversion
- if (tmp[strlen (tmp) - 1] == '"')
- tmp[strlen (tmp) - 1] = '\0';
- GNUNET_free (val_str);
- json_decref (json_root);
- return tmp;
- }
- }
+ char *attr_str = json_dumps (json_attrs, JSON_DECODE_ANY);
json_decref (json_root);
- return NULL;
+ struct Finder fdr;
+ memset (&fdr, 0, sizeof (fdr));
+ fdr.target = skey;
+ pabc_cred_inspect_credential (attr_str, &find_attr, &fdr);
+ return fdr.result;
}
@@ -403,9 +370,8 @@ pabc_get_expiration (void *cls,
json_t *json_root;
json_t *json_attrs;
json_t *value;
- json_t *attr;
+ json_t *exp_j;
json_error_t *json_err = NULL;
- const char*key;
json_root = json_loads (data, JSON_DECODE_ANY, json_err);
if ((NULL == json_root) ||
@@ -418,24 +384,23 @@ pabc_get_expiration (void *cls,
json_decref (json_root);
return GNUNET_SYSERR;
}
- for (int i = 0; i < json_array_size (json_attrs); i++)
+ json_attrs = json_object_get (json_root, PABC_JSON_PLAIN_ATTRS_KEY);
+ if ((NULL == json_attrs) ||
+ (! json_is_object (json_attrs)))
{
- attr = json_array_get (json_attrs, i);
- if (! json_is_object (attr))
- continue;
- /**
- * This *should* only contain a single pair.
- */
- json_object_foreach (attr, key, value)
- {
- if (0 != strcmp ("expiration", key))
- continue;
- if (! json_is_integer (value))
- continue;
- exp->abs_value_us = json_integer_value (value) * 1000 * 1000;
- json_decref (json_root);
- return GNUNET_OK;
- }
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "%s is not a valid pabc credential (attributes not an object)\n",
+ data);
+ json_decref (json_root);
+ return GNUNET_SYSERR;
+ }
+ exp_j = json_object_get (json_attrs, "expiration");
+ if ((NULL != exp_j) &&
+ json_is_integer (exp_j))
+ {
+ exp->abs_value_us = json_integer_value (value) * 1000 * 1000;
+ json_decref (json_root);
+ return GNUNET_OK;
}
json_decref (json_root);
return GNUNET_SYSERR;
diff --git a/src/reclaim/plugin_rest_pabc.c b/src/reclaim/plugin_rest_pabc.c
index 1c766a716..9c1ac3c47 100644
--- a/src/reclaim/plugin_rest_pabc.c
+++ b/src/reclaim/plugin_rest_pabc.c
@@ -264,9 +264,8 @@ set_attributes_from_idtoken (const struct pabc_context *ctx,
json_string_value (value));
if (PABC_OK != status)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to set attribute.\n");
- return PABC_FAILURE;
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Failed to set attribute `%s'.\n", key);
}
}
return PABC_OK;
@@ -370,7 +369,7 @@ cr_cont (struct GNUNET_REST_RequestHandle *con_handle,
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
- idtoken_json = json_object_get (idtoken_json, "id_token");
+ idtoken_json = json_object_get (data_json, "id_token");
if (NULL == idtoken_json)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -390,13 +389,18 @@ cr_cont (struct GNUNET_REST_RequestHandle *con_handle,
}
PABC_ASSERT (pabc_new_ctx (&ctx));
- // FIXME jansson does stupid escaping here maybe expect ecoded?
+ char *pp_str = json_dumps (pp_json, JSON_ENCODE_ANY);
status = pabc_decode_and_new_public_parameters (ctx,
&pp,
- json_string_value (pp_json));
+ pp_str);
+ char *ppid;
+ GNUNET_assert (PABC_OK == pabc_cred_get_ppid_from_pp (pp_str, &ppid));
+ GNUNET_free (pp_str);
if (status != PABC_OK)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to read public parameters.\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to read public parameters: %s\n",
+ pp_str);
json_decref (data_json);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
@@ -457,8 +461,8 @@ cr_cont (struct GNUNET_REST_RequestHandle *con_handle,
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
- // FIXME: where does this come from???
- status = pabc_decode_nonce (ctx, nonce, json_string_value (nonce_json));
+ char *nonce_str = json_dumps (nonce_json, JSON_ENCODE_ANY);
+ status = pabc_decode_nonce (ctx, nonce, nonce_str);
if (status != PABC_OK)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to decode nonce.\n");
@@ -496,7 +500,9 @@ cr_cont (struct GNUNET_REST_RequestHandle *con_handle,
return;
}
handle->resp_object = json_object ();
- pabc_encode_credential_request (ctx, pp, cr, &response_str);
+ GNUNET_assert (PABC_OK == pabc_cred_encode_cr (ctx, pp, cr,
+ json_string_value (identity_json),
+ ppid, &response_str));
if (PABC_OK != status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to serialize cr.\n");
@@ -508,9 +514,9 @@ cr_cont (struct GNUNET_REST_RequestHandle *con_handle,
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
+ json_decref (handle->resp_object);
+ handle->resp_object = json_loads (response_str, JSON_DECODE_ANY, &err);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s\n", response_str);
- json_object_set_new (handle->resp_object, "cr",
- json_string (response_str));
GNUNET_free (response_str);
// clean up
@@ -593,7 +599,7 @@ rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
* @return NULL on error, otherwise the plugin context
*/
void *
-libgnunet_plugin_rest_reclaim_init (void *cls)
+libgnunet_plugin_rest_pabc_init (void *cls)
{
static struct Plugin plugin;
struct GNUNET_REST_Plugin *api;