GNUnet  0.11.x
Data Structures | Macros | Functions | Variables
plugin_rest_reclaim.c File Reference

GNUnet reclaim REST plugin. More...

#include "platform.h"
#include "microhttpd.h"
#include <inttypes.h>
#include <jansson.h>
#include "gnunet_gns_service.h"
#include "gnunet_gnsrecord_lib.h"
#include "gnunet_identity_service.h"
#include "gnunet_reclaim_attribute_lib.h"
#include "gnunet_reclaim_service.h"
#include "gnunet_rest_lib.h"
#include "gnunet_rest_plugin.h"
#include "gnunet_signatures.h"
#include "json_reclaim.h"
Include dependency graph for plugin_rest_reclaim.c:

Go to the source code of this file.

Data Structures

struct  Plugin
 Handle for a plugin. More...
 
struct  EgoEntry
 The ego list. More...
 
struct  RequestHandle
 The request handle. More...
 

Macros

#define GNUNET_REST_API_NS_RECLAIM   "/reclaim"
 REST root namespace. More...
 
#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES   "/reclaim/attributes"
 Attribute namespace. More...
 
#define GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE   "/reclaim/attestation"
 Attestation namespace. More...
 
#define GNUNET_REST_API_NS_IDENTITY_TICKETS   "/reclaim/tickets"
 Ticket namespace. More...
 
#define GNUNET_REST_API_NS_IDENTITY_REVOKE   "/reclaim/revoke"
 Revoke namespace. More...
 
#define GNUNET_REST_API_NS_IDENTITY_CONSUME   "/reclaim/consume"
 Revoke namespace. More...
 
#define ID_REST_STATE_INIT   0
 State while collecting all egos. More...
 
#define ID_REST_STATE_POST_INIT   1
 Done collecting egos. More...
 

Functions

static void cleanup_handle (struct RequestHandle *handle)
 Cleanup lookup handle. More...
 
static void cleanup_handle_delayed (void *cls)
 
static void do_error (void *cls)
 Task run on error, sends error message. More...
 
static void do_timeout (void *cls)
 Task run on timeout, sends error message. More...
 
static void collect_error_cb (void *cls)
 
static void finished_cont (void *cls, int32_t success, const char *emsg)
 
static void delete_finished_cb (void *cls, int32_t success, const char *emsg)
 
static void return_response (void *cls)
 Return attributes for identity. More...
 
static void collect_finished_cb (void *cls)
 
static void ticket_collect (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
 Collect all attributes for an ego. More...
 
static void add_attestation_ref_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 
static void parse_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 
static void add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 
static void ref_collect (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
 Collect all references for an ego. More...
 
static void list_reference_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 Lists references for identity request. More...
 
static void attest_collect (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
 Collect all attestations for an ego. More...
 
static void list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 Lists attestation for identity request. More...
 
static void delete_attestation_ref_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 Deletes reference from an identity. More...
 
static void delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 Deletes attestation from an identity. More...
 
static void list_tickets_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 List tickets for identity request. More...
 
static void add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 
struct GNUNET_RECLAIM_ATTRIBUTE_Claimparse_jwt (const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, const char *claim)
 Parse a JWT and return the respective claim value as Attribute. More...
 
static void attr_collect (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
 Collect all attributes for an ego. More...
 
static void list_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 List attributes for identity request. More...
 
static void delete_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 List attributes for identity request. More...
 
static void revoke_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 
static void consume_cont (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
 
static void consume_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 
static void options_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 Respond to OPTIONS request. More...
 
static void init_cont (struct RequestHandle *handle)
 Handle rest request. More...
 
static void list_ego (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *identifier)
 If listing is enabled, prints information about the egos. More...
 
static void rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle, GNUNET_REST_ResultProcessor proc, void *proc_cls)
 
void * libgnunet_plugin_rest_reclaim_init (void *cls)
 Entry point for the plugin. More...
 
void * libgnunet_plugin_rest_reclaim_done (void *cls)
 Exit point from the plugin. More...
 

Variables

const struct GNUNET_CONFIGURATION_Handlecfg
 The configuration handle. More...
 
static char * allow_methods
 HTTP methods allows for this plugin. More...
 

Detailed Description

GNUnet reclaim REST plugin.

Author
Martin Schanzenbach
Philippe Buschmann

Definition in file plugin_rest_reclaim.c.

Macro Definition Documentation

◆ GNUNET_REST_API_NS_RECLAIM

#define GNUNET_REST_API_NS_RECLAIM   "/reclaim"

REST root namespace.

Definition at line 43 of file plugin_rest_reclaim.c.

Referenced by init_cont(), and libgnunet_plugin_rest_reclaim_init().

◆ GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES

#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES   "/reclaim/attributes"

◆ GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE

#define GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE   "/reclaim/attestation"

◆ GNUNET_REST_API_NS_IDENTITY_TICKETS

#define GNUNET_REST_API_NS_IDENTITY_TICKETS   "/reclaim/tickets"

Ticket namespace.

Definition at line 58 of file plugin_rest_reclaim.c.

Referenced by init_cont(), and list_tickets_cont().

◆ GNUNET_REST_API_NS_IDENTITY_REVOKE

#define GNUNET_REST_API_NS_IDENTITY_REVOKE   "/reclaim/revoke"

Revoke namespace.

Definition at line 63 of file plugin_rest_reclaim.c.

Referenced by init_cont().

◆ GNUNET_REST_API_NS_IDENTITY_CONSUME

#define GNUNET_REST_API_NS_IDENTITY_CONSUME   "/reclaim/consume"

Revoke namespace.

Definition at line 68 of file plugin_rest_reclaim.c.

Referenced by init_cont().

◆ ID_REST_STATE_INIT

#define ID_REST_STATE_INIT   0

State while collecting all egos.

Definition at line 73 of file plugin_rest_reclaim.c.

Referenced by list_ego(), and rest_identity_process_request().

◆ ID_REST_STATE_POST_INIT

#define ID_REST_STATE_POST_INIT   1

Done collecting egos.

Definition at line 78 of file plugin_rest_reclaim.c.

Referenced by list_ego().

Function Documentation

◆ cleanup_handle()

static void cleanup_handle ( struct RequestHandle handle)
static

Cleanup lookup handle.

Parameters
handleHandle to clean up

Definition at line 248 of file plugin_rest_reclaim.c.

References GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::attest, RequestHandle::attr_it, RequestHandle::attr_list, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::claim, RequestHandle::ego_head, RequestHandle::emsg, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_IDENTITY_disconnect(), GNUNET_log, GNUNET_RECLAIM_disconnect(), GNUNET_RECLAIM_get_attributes_stop(), GNUNET_RECLAIM_ticket_iteration_stop(), GNUNET_SCHEDULER_cancel(), EgoEntry::identifier, RequestHandle::identity_handle, RequestHandle::idp, EgoEntry::keystring, GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_head, EgoEntry::next, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::next, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::reference, RequestHandle::resp_object, RequestHandle::ticket_it, RequestHandle::timeout_task, and RequestHandle::url.

Referenced by cleanup_handle_delayed(), options_cont(), parse_attestation_cont(), and return_response().

249 {
250  struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_entry;
251  struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_tmp;
252  struct EgoEntry *ego_entry;
253  struct EgoEntry *ego_tmp;
254 
255  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
256  if (NULL != handle->resp_object)
257  json_decref (handle->resp_object);
258  if (NULL != handle->timeout_task)
260  if (NULL != handle->identity_handle)
262  if (NULL != handle->attr_it)
264  if (NULL != handle->ticket_it)
266  if (NULL != handle->idp)
267  GNUNET_RECLAIM_disconnect (handle->idp);
268  if (NULL != handle->url)
269  GNUNET_free (handle->url);
270  if (NULL != handle->emsg)
271  GNUNET_free (handle->emsg);
272  if (NULL != handle->attr_list)
273  {
274  for (claim_entry = handle->attr_list->list_head; NULL != claim_entry;)
275  {
276  claim_tmp = claim_entry;
277  claim_entry = claim_entry->next;
278  GNUNET_free (claim_tmp->claim);
279  GNUNET_free (claim_tmp->attest);
280  GNUNET_free (claim_tmp->reference);
281  GNUNET_free (claim_tmp);
282  }
283  GNUNET_free (handle->attr_list);
284  }
285  for (ego_entry = handle->ego_head; NULL != ego_entry;)
286  {
287  ego_tmp = ego_entry;
288  ego_entry = ego_entry->next;
289  GNUNET_free (ego_tmp->identifier);
290  GNUNET_free (ego_tmp->keystring);
291  GNUNET_free (ego_tmp);
292  }
293  GNUNET_free (handle);
294 }
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute claim.
struct GNUNET_RECLAIM_AttributeIterator * attr_it
Attribute iterator.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * reference
The reference.
void GNUNET_RECLAIM_disconnect(struct GNUNET_RECLAIM_Handle *h)
Disconnect from identity provider service.
Definition: reclaim_api.c:1044
void GNUNET_RECLAIM_ticket_iteration_stop(struct GNUNET_RECLAIM_TicketIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1613
struct GNUNET_RECLAIM_ATTESTATION_Claim * attest
The attestation claim.
The ego list.
json_t * resp_object
Response object.
char * emsg
Error response message.
struct GNUNET_RECLAIM_TicketIterator * ticket_it
Ticket iterator.
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:837
char * keystring
Public key string.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * attr_list
Attribute claim list.
char * identifier
Ego Identifier.
struct EgoEntry * ego_head
Ego list.
void GNUNET_RECLAIM_get_attributes_stop(struct GNUNET_RECLAIM_AttributeIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1425
struct GNUNET_SCHEDULER_Task * timeout_task
ID of a task associated with the resolution process.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * next
DLL.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_head
List head.
struct EgoEntry * next
DLL.
struct GNUNET_IDENTITY_Handle * identity_handle
Handle to Identity service.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
char * url
The url.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_handle_delayed()

static void cleanup_handle_delayed ( void *  cls)
static

Definition at line 298 of file plugin_rest_reclaim.c.

References cleanup_handle().

Referenced by delete_finished_cb(), do_error(), and finished_cont().

299 {
300  cleanup_handle (cls);
301 }
static void cleanup_handle(struct RequestHandle *handle)
Cleanup lookup handle.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_error()

static void do_error ( void *  cls)
static

Task run on error, sends error message.

Cleans up everything.

Parameters
clsthe struct RequestHandle

Definition at line 310 of file plugin_rest_reclaim.c.

References cleanup_handle_delayed(), RequestHandle::emsg, GNUNET_asprintf(), GNUNET_free, GNUNET_REST_create_response(), GNUNET_SCHEDULER_add_now(), handle, RequestHandle::proc, RequestHandle::proc_cls, and RequestHandle::response_code.

Referenced by add_attestation_cont(), add_attestation_ref_cont(), add_attribute_cont(), collect_error_cb(), consume_ticket_cont(), delete_attestation_cont(), delete_attestation_ref_cont(), delete_attribute_cont(), delete_finished_cb(), do_timeout(), finished_cont(), init_cont(), list_attestation_cont(), list_attribute_cont(), list_reference_cont(), list_tickets_cont(), parse_attestation_cont(), and revoke_ticket_cont().

311 {
312  struct RequestHandle *handle = cls;
313  struct MHD_Response *resp;
314  char *json_error;
315 
316  GNUNET_asprintf (&json_error, "{ \"error\" : \"%s\" }", handle->emsg);
317  if (0 == handle->response_code)
318  {
319  handle->response_code = MHD_HTTP_BAD_REQUEST;
320  }
321  resp = GNUNET_REST_create_response (json_error);
322  MHD_add_response_header (resp, "Content-Type", "application/json");
323  handle->proc (handle->proc_cls, resp, handle->response_code);
325  GNUNET_free (json_error);
326 }
static void cleanup_handle_delayed(void *cls)
GNUNET_REST_ResultProcessor proc
The plugin result processor.
void * proc_cls
The closure of the result processor.
The request handle.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
char * emsg
Error response message.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
int response_code
Response code.
struct MHD_Response * GNUNET_REST_create_response(const char *data)
Create REST MHD response.
Definition: rest.c:57
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_timeout()

static void do_timeout ( void *  cls)
static

Task run on timeout, sends error message.

Cleans up everything.

Parameters
clsthe struct RequestHandle

Definition at line 335 of file plugin_rest_reclaim.c.

References do_error(), handle, and RequestHandle::timeout_task.

Referenced by rest_identity_process_request().

336 {
337  struct RequestHandle *handle = cls;
338 
339  handle->timeout_task = NULL;
340  do_error (handle);
341 }
The request handle.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static void do_error(void *cls)
Task run on error, sends error message.
struct GNUNET_SCHEDULER_Task * timeout_task
ID of a task associated with the resolution process.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ collect_error_cb()

static void collect_error_cb ( void *  cls)
static

Definition at line 345 of file plugin_rest_reclaim.c.

References do_error(), and handle.

Referenced by list_attestation_cont(), list_attribute_cont(), list_reference_cont(), and list_tickets_cont().

346 {
347  struct RequestHandle *handle = cls;
348 
349  do_error (handle);
350 }
The request handle.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static void do_error(void *cls)
Task run on error, sends error message.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ finished_cont()

static void finished_cont ( void *  cls,
int32_t  success,
const char *  emsg 
)
static

Definition at line 354 of file plugin_rest_reclaim.c.

References cleanup_handle_delayed(), do_error(), GNUNET_OK, GNUNET_REST_create_response(), GNUNET_SCHEDULER_add_now(), handle, RequestHandle::proc, and RequestHandle::proc_cls.

Referenced by add_attestation_cont(), add_attestation_ref_cont(), add_attribute_cont(), and revoke_ticket_cont().

355 {
356  struct RequestHandle *handle = cls;
357  struct MHD_Response *resp;
358 
359  resp = GNUNET_REST_create_response (emsg);
360  if (GNUNET_OK != success)
361  {
363  return;
364  }
365  handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
367 }
static void cleanup_handle_delayed(void *cls)
GNUNET_REST_ResultProcessor proc
The plugin result processor.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
void * proc_cls
The closure of the result processor.
The request handle.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static void do_error(void *cls)
Task run on error, sends error message.
struct MHD_Response * GNUNET_REST_create_response(const char *data)
Create REST MHD response.
Definition: rest.c:57
Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_finished_cb()

static void delete_finished_cb ( void *  cls,
int32_t  success,
const char *  emsg 
)
static

Definition at line 370 of file plugin_rest_reclaim.c.

References cleanup_handle_delayed(), do_error(), GNUNET_OK, GNUNET_REST_create_response(), GNUNET_SCHEDULER_add_now(), handle, RequestHandle::proc, and RequestHandle::proc_cls.

Referenced by delete_attestation_cont(), delete_attestation_ref_cont(), and delete_attribute_cont().

371 {
372  struct RequestHandle *handle = cls;
373  struct MHD_Response *resp;
374 
375  resp = GNUNET_REST_create_response (emsg);
376  if (GNUNET_OK != success)
377  {
379  return;
380  }
381  handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
383 }
static void cleanup_handle_delayed(void *cls)
GNUNET_REST_ResultProcessor proc
The plugin result processor.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
void * proc_cls
The closure of the result processor.
The request handle.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static void do_error(void *cls)
Task run on error, sends error message.
struct MHD_Response * GNUNET_REST_create_response(const char *data)
Create REST MHD response.
Definition: rest.c:57
Here is the call graph for this function:
Here is the caller graph for this function:

◆ return_response()

static void return_response ( void *  cls)
static

Return attributes for identity.

Parameters
clsthe request handle

Definition at line 391 of file plugin_rest_reclaim.c.

References cleanup_handle(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_REST_create_response(), handle, RequestHandle::proc, RequestHandle::proc_cls, and RequestHandle::resp_object.

Referenced by collect_finished_cb(), consume_cont(), delete_attestation_cont(), delete_attestation_ref_cont(), delete_attribute_cont(), list_attestation_cont(), list_attribute_cont(), list_reference_cont(), and list_tickets_cont().

392 {
393  char *result_str;
394  struct RequestHandle *handle = cls;
395  struct MHD_Response *resp;
396 
397  result_str = json_dumps (handle->resp_object, 0);
398  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
399  resp = GNUNET_REST_create_response (result_str);
400  handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
401  GNUNET_free (result_str);
402  cleanup_handle (handle);
403 }
GNUNET_REST_ResultProcessor proc
The plugin result processor.
void * proc_cls
The closure of the result processor.
The request handle.
json_t * resp_object
Response object.
static void cleanup_handle(struct RequestHandle *handle)
Cleanup lookup handle.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct MHD_Response * GNUNET_REST_create_response(const char *data)
Create REST MHD response.
Definition: rest.c:57
#define GNUNET_log(kind,...)
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ collect_finished_cb()

static void collect_finished_cb ( void *  cls)
static

Definition at line 407 of file plugin_rest_reclaim.c.

References RequestHandle::attr_it, GNUNET_SCHEDULER_add_now(), handle, return_response(), and RequestHandle::ticket_it.

Referenced by list_attestation_cont(), list_attribute_cont(), list_reference_cont(), and list_tickets_cont().

408 {
409  struct RequestHandle *handle = cls;
410 
411  // Done
412  handle->attr_it = NULL;
413  handle->ticket_it = NULL;
415 }
struct GNUNET_RECLAIM_AttributeIterator * attr_it
Attribute iterator.
The request handle.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
struct GNUNET_RECLAIM_TicketIterator * ticket_it
Ticket iterator.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static void return_response(void *cls)
Return attributes for identity.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ticket_collect()

static void ticket_collect ( void *  cls,
const struct GNUNET_RECLAIM_Ticket ticket 
)
static

Collect all attributes for an ego.

Definition at line 423 of file plugin_rest_reclaim.c.

References GNUNET_RECLAIM_Ticket::audience, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_RECLAIM_ticket_iteration_next(), GNUNET_STRINGS_data_to_string_alloc(), handle, GNUNET_RECLAIM_Ticket::identity, RequestHandle::resp_object, GNUNET_RECLAIM_Ticket::rnd, RequestHandle::ticket_it, and value.

Referenced by list_tickets_cont().

424 {
425  json_t *json_resource;
426  struct RequestHandle *handle = cls;
427  json_t *value;
428  char *tmp;
429 
430  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding ticket\n");
431  tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t));
432  json_resource = json_object ();
433  GNUNET_free (tmp);
434  json_array_append (handle->resp_object, json_resource);
435 
436  tmp =
438  sizeof(struct
440  value = json_string (tmp);
441  json_object_set_new (json_resource, "issuer", value);
442  GNUNET_free (tmp);
443  tmp =
445  sizeof(struct
447  value = json_string (tmp);
448  json_object_set_new (json_resource, "audience", value);
449  GNUNET_free (tmp);
450  tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t));
451  value = json_string (tmp);
452  json_object_set_new (json_resource, "rnd", value);
453  GNUNET_free (tmp);
455 }
void GNUNET_RECLAIM_ticket_iteration_next(struct GNUNET_RECLAIM_TicketIterator *it)
Calls the ticket processor specified in GNUNET_RECLAIM_ticket_iteration_start for the next record...
Definition: reclaim_api.c:1593
The request handle.
json_t * resp_object
Response object.
static char * value
Value of the record to add/remove.
struct GNUNET_RECLAIM_TicketIterator * ticket_it
Ticket iterator.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The ticket issuer (= the user)
uint64_t rnd
The ticket random (NBO)
struct GNUNET_CRYPTO_EcdsaPublicKey audience
The ticket audience (= relying party)
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
#define GNUNET_log(kind,...)
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:920
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_attestation_ref_cont()

static void add_attestation_ref_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

New ID for attribute

Definition at line 459 of file plugin_rest_reclaim.c.

References GNUNET_REST_RequestHandle::data, GNUNET_REST_RequestHandle::data_size, do_error(), EgoEntry::ego, RequestHandle::ego_head, finished_cont(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_JSON_parse(), GNUNET_JSON_parse_free(), GNUNET_JSON_spec_end(), GNUNET_log, GNUNET_memcpy, GNUNET_OK, GNUNET_RECLAIM_attestation_reference_store(), GNUNET_RECLAIM_connect(), GNUNET_RECLAIM_JSON_spec_claim_attest_ref(), GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE, GNUNET_SCHEDULER_add_now(), GNUNET_TIME_UNIT_HOURS, handle, GNUNET_RECLAIM_ATTESTATION_REFERENCE::id, GNUNET_RECLAIM_ATTESTATION_REFERENCE::id_attest, EgoEntry::identifier, identity, RequestHandle::idp, RequestHandle::idp_op, EgoEntry::next, RequestHandle::rest_handle, and RequestHandle::url.

Referenced by add_attestation_cont().

462 {
463  struct RequestHandle *handle = cls;
464  const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
465  const char *identity;
466  struct EgoEntry *ego_entry;
467  struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attribute;
468  struct GNUNET_TIME_Relative exp;
469  char term_data[handle->rest_handle->data_size + 1];
470  json_t *data_json;
471  json_error_t err;
472  struct GNUNET_JSON_Specification attrspec[] =
476  "Adding an attestation reference for %s.\n",
477  handle->url);
479  "reference/") + 1 >= strlen (
480  handle->url))
481  {
482  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
484  return;
485  }
486  identity = handle->url + strlen (
487  GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + strlen ("reference/")
488  + 1;
489  for (ego_entry = handle->ego_head; NULL != ego_entry;
490  ego_entry = ego_entry->next)
491  if (0 == strcmp (identity, ego_entry->identifier))
492  break;
493  if (NULL == ego_entry)
494  {
495  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity);
496  return;
497  }
498  identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
499  if (0 >= handle->rest_handle->data_size)
500  {
502  return;
503  }
504 
505  term_data[handle->rest_handle->data_size] = '\0';
506  GNUNET_memcpy (term_data,
507  handle->rest_handle->data,
508  handle->rest_handle->data_size);
509  data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
511  GNUNET_JSON_parse (data_json, attrspec, NULL, NULL));
512  json_decref (data_json);
513  if (NULL == attribute)
514  {
516  "Unable to parse attestation reference from %s\n",
517  term_data);
519  return;
520  }
524  if (0 == attribute->id)
525  attribute->id = attribute->id_attest;
526  handle->idp = GNUNET_RECLAIM_connect (cfg);
529  identity_priv,
530  attribute,
531  &exp,
532  &finished_cont,
533  handle);
534  GNUNET_JSON_parse_free (attrspec);
535 }
#define GNUNET_TIME_UNIT_HOURS
One hour.
size_t data_size
The POST data size.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_JSON_parse_free(struct GNUNET_JSON_Specification *spec)
Frees all elements allocated during a GNUNET_JSON_parse() operation.
Definition: json.c:100
static void finished_cont(void *cls, int32_t success, const char *emsg)
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Entry in parser specification for GNUNET_JSON_parse().
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
Private ECC key encoded for transmission.
uint64_t id_attest
Referenced ID of Attestation.
struct GNUNET_JSON_Specification GNUNET_RECLAIM_JSON_spec_claim_attest_ref(struct GNUNET_RECLAIM_ATTESTATION_REFERENCE **attr)
JSON Specification for Reclaim attestation references.
Definition: json_reclaim.c:469
The request handle.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
int GNUNET_JSON_parse(const json_t *root, struct GNUNET_JSON_Specification *spec, const char **error_json_name, unsigned int *error_line)
Navigate and parse data in a JSON tree.
Definition: json.c:45
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
struct GNUNET_REST_RequestHandle * rest_handle
Rest connection.
const char * data
The POST data.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static void do_error(void *cls)
Task run on error, sends error message.
char * identifier
Ego Identifier.
struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end(void)
End of a parser specification.
Definition: json_helper.c:35
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1004
#define GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE
Attestation namespace.
struct EgoEntry * next
DLL.
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attestation_reference_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Store an attestation reference.
Definition: reclaim_api.c:1256
char * url
The url.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_attestation_cont()

static void parse_attestation_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

Definition at line 538 of file plugin_rest_reclaim.c.

References cleanup_handle(), GNUNET_REST_RequestHandle::data, GNUNET_REST_RequestHandle::data_size, do_error(), GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_memcpy, GNUNET_REST_create_response(), GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_base64_decode(), handle, RequestHandle::proc, RequestHandle::proc_cls, RequestHandle::rest_handle, and type_str.

Referenced by add_attestation_cont().

541 {
542  struct RequestHandle *handle = cls;
543 
544  char term_data[handle->rest_handle->data_size + 1];
545  json_t *data_json;
546  json_error_t err;
547  int unpack_state;
548  struct MHD_Response *resp;
549  char *val_str = NULL;
550  const char *type_str = NULL;
551  term_data[handle->rest_handle->data_size] = '\0';
552  GNUNET_memcpy (term_data,
553  handle->rest_handle->data,
554  handle->rest_handle->data_size);
555  data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
556  GNUNET_assert (NULL != data_json);
557  if (! json_is_object (data_json))
558  {
560  "Error json is not array nor object!\n");
562  return;
563  }
564  unpack_state = json_unpack (data_json,
565  "{s:s, s:s!}",
566  "value",
567  &val_str,
568  "type",
569  &type_str);
570  if ((0 != unpack_state) || (NULL == val_str) || (NULL == type_str))
571  {
573  "Error json object has a wrong format!\n");
575  return;
576  }
577  if (0 == strcmp (type_str, "JWT"))
578  {
579  // The value is a JWT
580  char *decoded_jwt;
581  char delim[] = ".";
582  char *jwt_body = strtok (val_str, delim);
583  jwt_body = strtok (NULL, delim);
584  GNUNET_STRINGS_base64_decode (jwt_body, strlen (jwt_body),
585  (void **) &decoded_jwt);
586  resp = GNUNET_REST_create_response (decoded_jwt);
587  handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
588  GNUNET_free (decoded_jwt);
589  }
590  else
591  {
593  "Error requested parsing type not supported!\n");
595  return;
596  }
597  cleanup_handle (handle);
598  json_decref (data_json);
599 }
size_t data_size
The POST data size.
GNUNET_REST_ResultProcessor proc
The plugin result processor.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
void * proc_cls
The closure of the result processor.
The request handle.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static void cleanup_handle(struct RequestHandle *handle)
Cleanup lookup handle.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_REST_RequestHandle * rest_handle
Rest connection.
size_t GNUNET_STRINGS_base64_decode(const char *data, size_t len, void **output)
Decode from Base64.
Definition: strings.c:1920
const char * data
The POST data.
static char * type_str
Attribute type.
static void do_error(void *cls)
Task run on error, sends error message.
struct MHD_Response * GNUNET_REST_create_response(const char *data)
Create REST MHD response.
Definition: rest.c:57
#define GNUNET_log(kind,...)
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_attestation_cont()

static void add_attestation_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

New ID for attribute

Definition at line 602 of file plugin_rest_reclaim.c.

References add_attestation_ref_cont(), GNUNET_REST_RequestHandle::data, GNUNET_REST_RequestHandle::data_size, do_error(), EgoEntry::ego, RequestHandle::ego_head, finished_cont(), GNUNET_assert, GNUNET_CRYPTO_QUALITY_STRONG, GNUNET_CRYPTO_random_u64(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_JSON_parse(), GNUNET_JSON_parse_free(), GNUNET_JSON_spec_end(), GNUNET_log, GNUNET_memcpy, GNUNET_OK, GNUNET_RECLAIM_attestation_store(), GNUNET_RECLAIM_connect(), GNUNET_RECLAIM_JSON_spec_claim_attest(), GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE, GNUNET_SCHEDULER_add_now(), GNUNET_TIME_UNIT_HOURS, handle, GNUNET_RECLAIM_ATTESTATION_Claim::id, EgoEntry::identifier, identity, RequestHandle::idp, RequestHandle::idp_op, EgoEntry::next, parse_attestation_cont(), RequestHandle::rest_handle, and RequestHandle::url.

Referenced by init_cont().

605 {
606  struct RequestHandle *handle = cls;
607  /* Check for substring "reference" */
609  handle->url))
610  {
611  if ( strncmp ("reference/", (handle->url + strlen (
613  + 1), strlen (
614  "reference/")) == 0)
615  {
616  add_attestation_ref_cont (con_handle,url,cls);
617  return;
618  }
619  }
620  /* Check for substring "parse" */
622  handle->url))
623  {
624  if ( strncmp ("parse", (handle->url + strlen (
626  + 1), strlen (
627  "parse")) == 0)
628  {
629  parse_attestation_cont (con_handle,url,cls);
630  return;
631  }
632  }
633  const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
634  const char *identity;
635  struct EgoEntry *ego_entry;
636  struct GNUNET_RECLAIM_ATTESTATION_Claim *attribute;
637  struct GNUNET_TIME_Relative exp;
638  char term_data[handle->rest_handle->data_size + 1];
639  json_t *data_json;
640  json_error_t err;
641  struct GNUNET_JSON_Specification attrspec[] =
644 
646  "Adding an attestation for %s.\n",
647  handle->url);
648  if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) >= strlen (
649  handle->url))
650  {
651  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
653  return;
654  }
655  identity = handle->url + strlen (
657 
658  for (ego_entry = handle->ego_head; NULL != ego_entry;
659  ego_entry = ego_entry->next)
660  if (0 == strcmp (identity, ego_entry->identifier))
661  break;
662 
663  if (NULL == ego_entry)
664  {
665  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity);
666  return;
667  }
668  identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
669 
670  if (0 >= handle->rest_handle->data_size)
671  {
673  return;
674  }
675 
676  term_data[handle->rest_handle->data_size] = '\0';
677  GNUNET_memcpy (term_data,
678  handle->rest_handle->data,
679  handle->rest_handle->data_size);
680  data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
682  GNUNET_JSON_parse (data_json, attrspec, NULL, NULL));
683  json_decref (data_json);
684  if (NULL == attribute)
685  {
687  "Unable to parse attestation from %s\n",
688  term_data);
690  return;
691  }
695  if (0 == attribute->id)
696  attribute->id =
698  handle->idp = GNUNET_RECLAIM_connect (cfg);
700  handle->idp_op = GNUNET_RECLAIM_attestation_store (handle->idp,
701  identity_priv,
702  attribute,
703  &exp,
704  &finished_cont,
705  handle);
706  GNUNET_JSON_parse_free (attrspec);
707 }
#define GNUNET_TIME_UNIT_HOURS
One hour.
size_t data_size
The POST data size.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_JSON_parse_free(struct GNUNET_JSON_Specification *spec)
Frees all elements allocated during a GNUNET_JSON_parse() operation.
Definition: json.c:100
static void finished_cont(void *cls, int32_t success, const char *emsg)
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Entry in parser specification for GNUNET_JSON_parse().
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
Private ECC key encoded for transmission.
The request handle.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
static void add_attestation_ref_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
int GNUNET_JSON_parse(const json_t *root, struct GNUNET_JSON_Specification *spec, const char **error_json_name, unsigned int *error_line)
Navigate and parse data in a JSON tree.
Definition: json.c:45
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
struct GNUNET_REST_RequestHandle * rest_handle
Rest connection.
const char * data
The POST data.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static void do_error(void *cls)
Task run on error, sends error message.
char * identifier
Ego Identifier.
struct EgoEntry * ego_head
Ego list.
static void parse_attestation_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
struct GNUNET_JSON_Specification GNUNET_RECLAIM_JSON_spec_claim_attest(struct GNUNET_RECLAIM_ATTESTATION_Claim **attr)
JSON Specification for Reclaim attestation claims.
Definition: json_reclaim.c:366
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end(void)
End of a parser specification.
Definition: json_helper.c:35
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1004
#define GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE
Attestation namespace.
struct EgoEntry * next
DLL.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attestation_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Store an attestation.
Definition: reclaim_api.c:1166
Time for relative time used by GNUnet, in microseconds.
High-quality operations are desired.
char * url
The url.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ref_collect()

static void ref_collect ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey identity,
const struct GNUNET_RECLAIM_ATTRIBUTE_Claim attr,
const struct GNUNET_RECLAIM_ATTESTATION_Claim attest,
const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE reference 
)
static

Collect all references for an ego.

Definition at line 714 of file plugin_rest_reclaim.c.

References RequestHandle::attr_it, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_RECLAIM_get_attributes_next(), GNUNET_STRINGS_data_to_string_alloc(), handle, GNUNET_RECLAIM_ATTESTATION_REFERENCE::id, GNUNET_RECLAIM_ATTESTATION_REFERENCE::id_attest, GNUNET_RECLAIM_ATTESTATION_REFERENCE::name, GNUNET_RECLAIM_ATTESTATION_REFERENCE::reference_value, and RequestHandle::resp_object.

Referenced by list_reference_cont().

719 {
720  struct RequestHandle *handle = cls;
721  json_t *attr_obj;
722  char *id_str;
723  char *id_attest_str;
724 
725  if (NULL == reference)
726  {
728  return;
729  }
730 
731  if ((NULL == reference->name) || (NULL == reference->reference_value))
732  {
733  return;
734  }
735 
736  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding reference: %s\n",
737  reference->name);
738  attr_obj = json_object ();
739  json_object_set_new (attr_obj, "name", json_string (reference->name));
740  json_object_set_new (attr_obj, "ref_value", json_string (
741  reference->reference_value));
742  id_str = GNUNET_STRINGS_data_to_string_alloc (&reference->id,
743  sizeof(uint64_t));
744  id_attest_str = GNUNET_STRINGS_data_to_string_alloc (&reference->id_attest,
745  sizeof(uint64_t));
746  json_object_set_new (attr_obj, "id", json_string (id_str));
747  json_object_set_new (attr_obj, "ref_id", json_string (id_attest_str));
748  json_array_append (handle->resp_object, attr_obj);
749  json_decref (attr_obj);
750 }
struct GNUNET_RECLAIM_AttributeIterator * attr_it
Attribute iterator.
const char * reference_value
The name of the attribute/attestation reference value.
void GNUNET_RECLAIM_get_attributes_next(struct GNUNET_RECLAIM_AttributeIterator *it)
Calls the record processor specified in GNUNET_RECLAIM_get_attributes_start for the next record...
Definition: reclaim_api.c:1404
uint64_t id_attest
Referenced ID of Attestation.
The request handle.
json_t * resp_object
Response object.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const char * name
The name of the attribute/attestation reference value.
#define GNUNET_log(kind,...)
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:920
Here is the call graph for this function:
Here is the caller graph for this function:

◆ list_reference_cont()

static void list_reference_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

Lists references for identity request.

Parameters
con_handlethe connection handle
urlthe url
clsthe RequestHandle

Definition at line 760 of file plugin_rest_reclaim.c.

References RequestHandle::attr_it, collect_error_cb(), collect_finished_cb(), do_error(), EgoEntry::ego, RequestHandle::ego_head, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_log, GNUNET_RECLAIM_connect(), GNUNET_RECLAIM_get_attributes_start(), GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE, GNUNET_SCHEDULER_add_now(), handle, EgoEntry::identifier, identity, RequestHandle::idp, EgoEntry::next, ref_collect(), RequestHandle::resp_object, return_response(), and RequestHandle::url.

Referenced by list_attestation_cont().

763 {
764  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
765  struct RequestHandle *handle = cls;
766  struct EgoEntry *ego_entry;
767  char *identity;
768 
770  "Getting references for %s.\n",
771  handle->url);
773  "reference/") + 1 >= strlen (
774  handle->url))
775  {
776  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
778  return;
779  }
780  identity = handle->url + strlen (
781  GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + strlen ("reference/")
782  + 1;
783  for (ego_entry = handle->ego_head; NULL != ego_entry;
784  ego_entry = ego_entry->next)
785  if (0 == strcmp (identity, ego_entry->identifier))
786  break;
787  handle->resp_object = json_array ();
788 
789  if (NULL == ego_entry)
790  {
791  // Done
792  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
794  return;
795  }
796  priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
797  handle->idp = GNUNET_RECLAIM_connect (cfg);
799  priv_key,
801  handle,
802  &ref_collect,
803  handle,
805  handle);
806 }
struct GNUNET_RECLAIM_AttributeIterator * GNUNET_RECLAIM_get_attributes_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_AttributeResult proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
List all attributes for a local identity.
Definition: reclaim_api.c:1358
static void collect_error_cb(void *cls)
struct GNUNET_RECLAIM_AttributeIterator * attr_it
Attribute iterator.
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
Private ECC key encoded for transmission.
static void collect_finished_cb(void *cls)
The request handle.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
json_t * resp_object
Response object.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
static void return_response(void *cls)
Return attributes for identity.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static void do_error(void *cls)
Task run on error, sends error message.
char * identifier
Ego Identifier.
struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
static void ref_collect(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
Collect all references for an ego.
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1004
#define GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE
Attestation namespace.
struct EgoEntry * next
DLL.
char * url
The url.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ attest_collect()

static void attest_collect ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey identity,
const struct GNUNET_RECLAIM_ATTRIBUTE_Claim attr,
const struct GNUNET_RECLAIM_ATTESTATION_Claim attest,
const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE reference 
)
static

Collect all attestations for an ego.

Definition at line 813 of file plugin_rest_reclaim.c.

References RequestHandle::attr_it, GNUNET_RECLAIM_ATTESTATION_Claim::data, GNUNET_RECLAIM_ATTESTATION_Claim::data_size, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_RECLAIM_ATTESTATION_number_to_typename(), GNUNET_RECLAIM_ATTESTATION_value_to_string(), GNUNET_RECLAIM_get_attributes_next(), GNUNET_STRINGS_data_to_string_alloc(), handle, GNUNET_RECLAIM_ATTESTATION_Claim::id, GNUNET_RECLAIM_ATTESTATION_Claim::name, RequestHandle::resp_object, GNUNET_RECLAIM_ATTESTATION_Claim::type, and type.

Referenced by list_attestation_cont().

818 {
819  struct RequestHandle *handle = cls;
820  json_t *attr_obj;
821  const char *type;
822  char *tmp_value;
823  char *id_str;
824 
825 
826  if (NULL != reference)
827  {
829  "Attestation Collection with Reference\n");
830  return;
831  }
832  if (NULL == attest)
833  {
835  "Attestation Collection with empty Attestation\n");
837  return;
838  }
839 
840  if ((NULL == attest->name) || (NULL == attest->data))
841  {
843  "Attestation Collection with empty Name/Value\n");
845  return;
846  }
847 
848  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation: %s\n",
849  attest->name);
850 
852  attest->data,
853  attest->data_size);
854  attr_obj = json_object ();
855  json_object_set_new (attr_obj, "value", json_string (tmp_value));
856  json_object_set_new (attr_obj, "name", json_string (attest->name));
858  json_object_set_new (attr_obj, "type", json_string (type));
859  id_str = GNUNET_STRINGS_data_to_string_alloc (&attest->id, sizeof(uint64_t));
860  json_object_set_new (attr_obj, "id", json_string (id_str));
861  json_array_append (handle->resp_object, attr_obj);
862  json_decref (attr_obj);
863  GNUNET_free (tmp_value);
865 }
struct GNUNET_RECLAIM_AttributeIterator * attr_it
Attribute iterator.
void GNUNET_RECLAIM_get_attributes_next(struct GNUNET_RECLAIM_AttributeIterator *it)
Calls the record processor specified in GNUNET_RECLAIM_get_attributes_start for the next record...
Definition: reclaim_api.c:1404
The request handle.
json_t * resp_object
Response object.
const char * GNUNET_RECLAIM_ATTESTATION_number_to_typename(uint32_t type)
Convert an attestation type number to the corresponding attestation type string.
size_t data_size
Number of bytes in data.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
char * GNUNET_RECLAIM_ATTESTATION_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;claim&#39; of an attestation to a string.
const char * name
The name of the attribute.
#define GNUNET_log(kind,...)
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:920
#define GNUNET_free(ptr)
Wrapper around free.
const void * data
Binary value stored as attribute value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ list_attestation_cont()

static void list_attestation_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

Lists attestation for identity request.

Parameters
con_handlethe connection handle
urlthe url
clsthe RequestHandle

Definition at line 876 of file plugin_rest_reclaim.c.

References attest_collect(), RequestHandle::attr_it, collect_error_cb(), collect_finished_cb(), do_error(), EgoEntry::ego, RequestHandle::ego_head, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_log, GNUNET_RECLAIM_connect(), GNUNET_RECLAIM_get_attributes_start(), GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE, GNUNET_SCHEDULER_add_now(), handle, EgoEntry::identifier, identity, RequestHandle::idp, list_reference_cont(), EgoEntry::next, RequestHandle::resp_object, return_response(), and RequestHandle::url.

Referenced by init_cont().

879 {
880  struct RequestHandle *handle = cls;
881  /* Check for substring "reference" */
883  handle->url))
884  {
885  if ( strncmp ("reference/", (handle->url + strlen (
887  + 1), strlen (
888  "reference/")) == 0)
889  {
890  list_reference_cont (con_handle,url,cls);
891  return;
892  }
893  }
894  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
895  struct EgoEntry *ego_entry;
896  char *identity;
897 
899  "Getting attestations for %s.\n",
900  handle->url);
901  if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) >= strlen (
902  handle->url))
903  {
904  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
906  return;
907  }
908  identity = handle->url + strlen (
910 
911  for (ego_entry = handle->ego_head; NULL != ego_entry;
912  ego_entry = ego_entry->next)
913  if (0 == strcmp (identity, ego_entry->identifier))
914  break;
915  handle->resp_object = json_array ();
916 
917 
918  if (NULL == ego_entry)
919  {
920  // Done
921  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
923  return;
924  }
925  priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
926  handle->idp = GNUNET_RECLAIM_connect (cfg);
928  priv_key,
930  handle,
932  handle,
934  handle);
935 }
struct GNUNET_RECLAIM_AttributeIterator * GNUNET_RECLAIM_get_attributes_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_AttributeResult proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
List all attributes for a local identity.
Definition: reclaim_api.c:1358
static void collect_error_cb(void *cls)
struct GNUNET_RECLAIM_AttributeIterator * attr_it
Attribute iterator.
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
Private ECC key encoded for transmission.
static void attest_collect(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
Collect all attestations for an ego.
static void collect_finished_cb(void *cls)
The request handle.
The ego list.
static void list_reference_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Lists references for identity request.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
json_t * resp_object
Response object.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
static void return_response(void *cls)
Return attributes for identity.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static void do_error(void *cls)
Task run on error, sends error message.
char * identifier
Ego Identifier.
struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1004
#define GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE
Attestation namespace.
struct EgoEntry * next
DLL.
char * url
The url.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_attestation_ref_cont()

static void delete_attestation_ref_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

Deletes reference from an identity.

Parameters
con_handlethe connection handle
urlthe url
clsthe RequestHandle

Definition at line 945 of file plugin_rest_reclaim.c.

References GNUNET_REST_RequestHandle::data, GNUNET_REST_RequestHandle::data_size, delete_finished_cb(), do_error(), EgoEntry::ego, RequestHandle::ego_head, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_JSON_parse(), GNUNET_JSON_parse_free(), GNUNET_JSON_spec_end(), GNUNET_log, GNUNET_memcpy, GNUNET_OK, GNUNET_RECLAIM_attestation_reference_delete(), GNUNET_RECLAIM_connect(), GNUNET_RECLAIM_JSON_spec_claim_attest_ref(), GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE, GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_string_to_data(), handle, GNUNET_RECLAIM_ATTESTATION_REFERENCE::id, id, EgoEntry::identifier, identity, RequestHandle::idp, RequestHandle::idp_op, EgoEntry::next, RequestHandle::resp_object, RequestHandle::rest_handle, return_response(), and RequestHandle::url.

Referenced by delete_attestation_cont().

948 {
949  struct RequestHandle *handle = cls;
950  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
952  struct EgoEntry *ego_entry;
953  char *identity;
954  char *identity_id_str;
955  char *id;
956  char term_data[handle->rest_handle->data_size + 1];
957  json_t *data_json;
958  json_error_t err;
959 
960  struct GNUNET_JSON_Specification attrspec[] =
964  "Deleting attestation reference.\n");
966  "reference/") + 1 >= strlen (
967  handle->url))
968  {
969  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
971  return;
972  }
973  identity_id_str = strdup (handle->url + strlen (
975  + strlen ("reference/")
976  + 1);
977  identity = strtok (identity_id_str, "/");
978  id = strtok (NULL, "/");
979 
980  if ((NULL == identity) || (NULL == id))
981  {
982  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n");
984  return;
985  }
986  for (ego_entry = handle->ego_head; NULL != ego_entry;
987  ego_entry = ego_entry->next)
988  if (0 == strcmp (identity, ego_entry->identifier))
989  break;
990  handle->resp_object = json_array ();
991  if (NULL == ego_entry)
992  {
993  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
995  return;
996  }
997  priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
998  if (0 >= handle->rest_handle->data_size)
999  {
1001  return;
1002  }
1003 
1004  term_data[handle->rest_handle->data_size] = '\0';
1005  GNUNET_memcpy (term_data,
1006  handle->rest_handle->data,
1007  handle->rest_handle->data_size);
1008  data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
1010  GNUNET_JSON_parse (data_json, attrspec, NULL, NULL));
1011  json_decref (data_json);
1012  if (NULL == attr)
1013  {
1015  "Unable to parse attestation reference from %s\n",
1016  term_data);
1018  return;
1019  }
1020  GNUNET_STRINGS_string_to_data (id, strlen (id), &attr->id, sizeof(uint64_t));
1021 
1022  handle->idp = GNUNET_RECLAIM_connect (cfg);
1024  priv_key,
1025  attr,
1026  &
1028  handle);
1029  GNUNET_JSON_parse_free (attrspec);
1030 }
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attestation_reference_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete an attestation reference.
Definition: reclaim_api.c:1301
size_t data_size
The POST data size.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_JSON_parse_free(struct GNUNET_JSON_Specification *spec)
Frees all elements allocated during a GNUNET_JSON_parse() operation.
Definition: json.c:100
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
Entry in parser specification for GNUNET_JSON_parse().
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
Private ECC key encoded for transmission.
struct GNUNET_JSON_Specification GNUNET_RECLAIM_JSON_spec_claim_attest_ref(struct GNUNET_RECLAIM_ATTESTATION_REFERENCE **attr)
JSON Specification for Reclaim attestation references.
Definition: json_reclaim.c:469
The request handle.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
json_t * resp_object
Response object.
int GNUNET_JSON_parse(const json_t *root, struct GNUNET_JSON_Specification *spec, const char **error_json_name, unsigned int *error_line)
Navigate and parse data in a JSON tree.
Definition: json.c:45
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
struct GNUNET_REST_RequestHandle * rest_handle
Rest connection.
static void return_response(void *cls)
Return attributes for identity.
const char * data
The POST data.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static void delete_finished_cb(void *cls, int32_t success, const char *emsg)
static void do_error(void *cls)
Task run on error, sends error message.
char * identifier
Ego Identifier.
struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end(void)
End of a parser specification.
Definition: json_helper.c:35
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1004
#define GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE
Attestation namespace.
struct EgoEntry * next
DLL.
int GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:952
char * url
The url.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_attestation_cont()

static void delete_attestation_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

Deletes attestation from an identity.

Parameters
con_handlethe connection handle
urlthe url
clsthe RequestHandle

Definition at line 1041 of file plugin_rest_reclaim.c.

References delete_attestation_ref_cont(), delete_finished_cb(), do_error(), EgoEntry::ego, RequestHandle::ego_head, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_log, GNUNET_RECLAIM_attestation_delete(), GNUNET_RECLAIM_connect(), GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE, GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_string_to_data(), handle, GNUNET_RECLAIM_ATTESTATION_Claim::id, id, EgoEntry::identifier, identity, RequestHandle::idp, RequestHandle::idp_op, GNUNET_RECLAIM_ATTESTATION_Claim::name, EgoEntry::next, RequestHandle::resp_object, return_response(), and RequestHandle::url.

Referenced by init_cont().

1044 {
1045  struct RequestHandle *handle = cls;
1046  /* Check for substring "reference" */
1047  if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) < strlen (
1048  handle->url))
1049  {
1050  if ( strncmp ("reference", (handle->url + strlen (
1052  + 1), strlen (
1053  "reference")) == 0)
1054  {
1055  delete_attestation_ref_cont (con_handle,url,cls);
1056  return;
1057  }
1058  }
1059  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
1061  struct EgoEntry *ego_entry;
1062  char *identity_id_str;
1063  char *identity;
1064  char *id;
1065 
1066  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attestation.\n");
1067  if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) >= strlen (
1068  handle->url))
1069  {
1070  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
1072  return;
1073  }
1074  identity_id_str =
1075  strdup (handle->url + strlen (
1077  identity = strtok (identity_id_str, "/");
1078  id = strtok (NULL, "/");
1079  if ((NULL == identity) || (NULL == id))
1080  {
1081  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n");
1082  GNUNET_free (identity_id_str);
1084  return;
1085  }
1086 
1087  for (ego_entry = handle->ego_head; NULL != ego_entry;
1088  ego_entry = ego_entry->next)
1089  if (0 == strcmp (identity, ego_entry->identifier))
1090  break;
1091  handle->resp_object = json_array ();
1092  if (NULL == ego_entry)
1093  {
1094  // Done
1095  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
1096  GNUNET_free (identity_id_str);
1098  return;
1099  }
1100  priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1101  handle->idp = GNUNET_RECLAIM_connect (cfg);
1102  memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_ATTESTATION_Claim));
1103  GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(uint64_t));
1104  attr.name = "";
1105  handle->idp_op = GNUNET_RECLAIM_attestation_delete (handle->idp,
1106  priv_key,
1107  &attr,
1109  handle);
1110  GNUNET_free (identity_id_str);
1111 }
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
Private ECC key encoded for transmission.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attestation_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete an attestation.
Definition: reclaim_api.c:1212
The request handle.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
json_t * resp_object
Response object.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
static void delete_attestation_ref_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Deletes reference from an identity.
static void return_response(void *cls)
Return attributes for identity.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static void delete_finished_cb(void *cls, int32_t success, const char *emsg)
static void do_error(void *cls)
Task run on error, sends error message.
char * identifier
Ego Identifier.
struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1004
#define GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE
Attestation namespace.
struct EgoEntry * next
DLL.
int GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:952
#define GNUNET_free(ptr)
Wrapper around free.
char * url
The url.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ list_tickets_cont()

static void list_tickets_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

List tickets for identity request.

Parameters
con_handlethe connection handle
urlthe url
clsthe RequestHandle

Definition at line 1121 of file plugin_rest_reclaim.c.

References collect_error_cb(), collect_finished_cb(), do_error(), EgoEntry::ego, RequestHandle::ego_head, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_log, GNUNET_RECLAIM_connect(), GNUNET_RECLAIM_ticket_iteration_start(), GNUNET_REST_API_NS_IDENTITY_TICKETS, GNUNET_SCHEDULER_add_now(), handle, EgoEntry::identifier, identity, RequestHandle::idp, EgoEntry::next, RequestHandle::resp_object, return_response(), ticket_collect(), RequestHandle::ticket_it, and RequestHandle::url.

Referenced by init_cont().

1124 {
1125  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
1126  struct RequestHandle *handle = cls;
1127  struct EgoEntry *ego_entry;
1128  char *identity;
1129 
1131  "Getting tickets for %s.\n",
1132  handle->url);
1133  if (strlen (GNUNET_REST_API_NS_IDENTITY_TICKETS) >= strlen (handle->url))
1134  {
1135  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
1137  return;
1138  }
1139  identity = handle->url + strlen (GNUNET_REST_API_NS_IDENTITY_TICKETS) + 1;
1140 
1141  for (ego_entry = handle->ego_head; NULL != ego_entry;
1142  ego_entry = ego_entry->next)
1143  if (0 == strcmp (identity, ego_entry->identifier))
1144  break;
1145  handle->resp_object = json_array ();
1146 
1147  if (NULL == ego_entry)
1148  {
1149  // Done
1150  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
1152  return;
1153  }
1154  priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1155  handle->idp = GNUNET_RECLAIM_connect (cfg);
1156  handle->ticket_it =
1158  priv_key,
1160  handle,
1161  &ticket_collect,
1162  handle,
1164  handle);
1165 }
struct GNUNET_RECLAIM_TicketIterator * GNUNET_RECLAIM_ticket_iteration_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_TicketCallback proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
Lists all tickets that have been issued to remote identites (relying parties)
Definition: reclaim_api.c:1549
static void collect_error_cb(void *cls)
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
Private ECC key encoded for transmission.
static void collect_finished_cb(void *cls)
The request handle.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
json_t * resp_object
Response object.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
struct GNUNET_RECLAIM_TicketIterator * ticket_it
Ticket iterator.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
static void ticket_collect(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
Collect all attributes for an ego.
static void return_response(void *cls)
Return attributes for identity.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static void do_error(void *cls)
Task run on error, sends error message.
char * identifier
Ego Identifier.
struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1004
struct EgoEntry * next
DLL.
#define GNUNET_REST_API_NS_IDENTITY_TICKETS
Ticket namespace.
char * url
The url.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_attribute_cont()

static void add_attribute_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

New ID for attribute

Definition at line 1169 of file plugin_rest_reclaim.c.

References GNUNET_REST_RequestHandle::data, GNUNET_REST_RequestHandle::data_size, do_error(), EgoEntry::ego, RequestHandle::ego_head, finished_cont(), GNUNET_assert, GNUNET_CRYPTO_QUALITY_STRONG, GNUNET_CRYPTO_random_u64(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_JSON_parse(), GNUNET_JSON_parse_free(), GNUNET_JSON_spec_end(), GNUNET_log, GNUNET_memcpy, GNUNET_OK, GNUNET_RECLAIM_attribute_store(), GNUNET_RECLAIM_connect(), GNUNET_RECLAIM_JSON_spec_claim(), GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, GNUNET_SCHEDULER_add_now(), GNUNET_TIME_UNIT_HOURS, handle, GNUNET_RECLAIM_ATTRIBUTE_Claim::id, EgoEntry::identifier, identity, RequestHandle::idp, RequestHandle::idp_op, EgoEntry::next, RequestHandle::rest_handle, and RequestHandle::url.

Referenced by init_cont().

1172 {
1173  const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
1174  const char *identity;
1175  struct RequestHandle *handle = cls;
1176  struct EgoEntry *ego_entry;
1177  struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attribute;
1178  struct GNUNET_TIME_Relative exp;
1179  char term_data[handle->rest_handle->data_size + 1];
1180  json_t *data_json;
1181  json_error_t err;
1182  struct GNUNET_JSON_Specification attrspec[] =
1184 
1186  "Adding an attribute for %s.\n",
1187  handle->url);
1188  if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
1189  {
1190  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
1192  return;
1193  }
1194  identity = handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1;
1195 
1196  for (ego_entry = handle->ego_head; NULL != ego_entry;
1197  ego_entry = ego_entry->next)
1198  if (0 == strcmp (identity, ego_entry->identifier))
1199  break;
1200 
1201  if (NULL == ego_entry)
1202  {
1203  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity);
1204  return;
1205  }
1206  identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1207 
1208  if (0 >= handle->rest_handle->data_size)
1209  {
1211  return;
1212  }
1213 
1214  term_data[handle->rest_handle->data_size] = '\0';
1215  GNUNET_memcpy (term_data,
1216  handle->rest_handle->data,
1217  handle->rest_handle->data_size);
1218  data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
1220  GNUNET_JSON_parse (data_json, attrspec, NULL, NULL));
1221  json_decref (data_json);
1222  if (NULL == attribute)
1223  {
1225  "Unable to parse attribute from %s\n",
1226  term_data);
1228  return;
1229  }
1233  if (0 == attribute->id)
1234  attribute->id =
1236  handle->idp = GNUNET_RECLAIM_connect (cfg);
1237  exp = GNUNET_TIME_UNIT_HOURS;
1238  handle->idp_op = GNUNET_RECLAIM_attribute_store (handle->idp,
1239  identity_priv,
1240  attribute,
1241  &exp,
1242  &finished_cont,
1243  handle);
1244  GNUNET_JSON_parse_free (attrspec);
1245 }
#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES
Attribute namespace.
#define GNUNET_TIME_UNIT_HOURS
One hour.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Store an attribute.
Definition: reclaim_api.c:1075
size_t data_size
The POST data size.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_JSON_parse_free(struct GNUNET_JSON_Specification *spec)
Frees all elements allocated during a GNUNET_JSON_parse() operation.
Definition: json.c:100
static void finished_cont(void *cls, int32_t success, const char *emsg)
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Entry in parser specification for GNUNET_JSON_parse().
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
Private ECC key encoded for transmission.
The request handle.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
int GNUNET_JSON_parse(const json_t *root, struct GNUNET_JSON_Specification *spec, const char **error_json_name, unsigned int *error_line)
Navigate and parse data in a JSON tree.
Definition: json.c:45
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
struct GNUNET_REST_RequestHandle * rest_handle
Rest connection.
const char * data
The POST data.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static void do_error(void *cls)
Task run on error, sends error message.
char * identifier
Ego Identifier.
struct GNUNET_JSON_Specification GNUNET_RECLAIM_JSON_spec_claim(struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr)
JSON Specification for Reclaim claims.
Definition: json_reclaim.c:136
struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end(void)
End of a parser specification.
Definition: json_helper.c:35
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1004
struct EgoEntry * next
DLL.
Time for relative time used by GNUnet, in microseconds.
High-quality operations are desired.
char * url
The url.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_jwt()

struct GNUNET_RECLAIM_ATTRIBUTE_Claim* parse_jwt ( const struct GNUNET_RECLAIM_ATTESTATION_Claim attest,
const char *  claim 
)

Parse a JWT and return the respective claim value as Attribute.

Parameters
attestthe jwt attestation
claimthe name of the claim in the JWT
Returns
a GNUNET_RECLAIM_ATTRIBUTE_Claim, containing the new value

Definition at line 1256 of file plugin_rest_reclaim.c.

References data, GNUNET_RECLAIM_ATTESTATION_Claim::data, GNUNET_RECLAIM_ATTESTATION_Claim::data_size, data_size, GNUNET_RECLAIM_ATTRIBUTE_Claim::flag, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_RECLAIM_ATTESTATION_value_to_string(), GNUNET_RECLAIM_ATTRIBUTE_claim_new(), GNUNET_RECLAIM_ATTRIBUTE_string_to_value(), GNUNET_RECLAIM_ATTRIBUTE_typename_to_number(), GNUNET_STRINGS_base64_decode(), GNUNET_SYSERR, GNUNET_RECLAIM_ATTRIBUTE_Claim::id, GNUNET_RECLAIM_ATTESTATION_Claim::id, Plugin::key, GNUNET_RECLAIM_ATTESTATION_Claim::type, type, type_str, and value.

Referenced by attr_collect().

1258 {
1259  char *jwt_string;
1260  struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
1261  char delim[] = ".";
1262  const char *type_str = NULL;
1263  const char *val_str = NULL;
1264  char *data;
1265  size_t data_size;
1266  uint32_t type;
1267  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Parsing JWT attributes.\n");
1268  char *decoded_jwt;
1269  json_t *json_val;
1270  json_error_t *json_err = NULL;
1271 
1272  jwt_string = GNUNET_RECLAIM_ATTESTATION_value_to_string (attest->type,
1273  attest->data,
1274  attest->data_size);
1275  char *jwt_body = strtok (jwt_string, delim);
1276  jwt_body = strtok (NULL, delim);
1277  GNUNET_STRINGS_base64_decode (jwt_body, strlen (jwt_body),
1278  (void **) &decoded_jwt);
1279  json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err);
1280  const char *key;
1281  json_t *value;
1282  json_object_foreach (json_val, key, value) {
1283  if (0 == strcasecmp (key,claim))
1284  {
1285  val_str = json_dumps (value, JSON_ENCODE_ANY);
1286  }
1287  }
1288  type_str = "String";
1291  (void **) &data,
1292  &data_size)))
1293  {
1295  "Attribute value from JWT Parser invalid!\n");
1297  "Error: Referenced Claim Name not Found",
1298  (void **) &data,
1299  &data_size);
1300  attr = GNUNET_RECLAIM_ATTRIBUTE_claim_new (claim, type, data, data_size);
1301  attr->id = attest->id;
1302  attr->flag = 1;
1303  }
1304  else
1305  {
1306  attr = GNUNET_RECLAIM_ATTRIBUTE_claim_new (claim, type, data, data_size);
1307  attr->id = attest->id;
1308  attr->flag = 1;
1309  }
1310  return attr;
1311 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
uint32_t GNUNET_RECLAIM_ATTRIBUTE_typename_to_number(const char *typename)
Convert a type name to the corresponding number.
int GNUNET_RECLAIM_ATTRIBUTE_string_to_value(uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of a &#39;claim&#39; of an attribute to the binary representation.
static char * value
Value of the record to add/remove.
size_t data_size
Number of bytes in data.
size_t GNUNET_STRINGS_base64_decode(const char *data, size_t len, void **output)
Decode from Base64.
Definition: strings.c:1920
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
static char * type_str
Attribute type.
char * GNUNET_RECLAIM_ATTESTATION_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;claim&#39; of an attestation to a string.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * GNUNET_RECLAIM_ATTRIBUTE_claim_new(const char *attr_name, uint32_t type, const void *data, size_t data_size)
Create a new attribute claim.
#define GNUNET_log(kind,...)
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
Claim to store.
uint32_t data
The data value.
const void * data
Binary value stored as attribute value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ attr_collect()

static void attr_collect ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey identity,
const struct GNUNET_RECLAIM_ATTRIBUTE_Claim attr,
const struct GNUNET_RECLAIM_ATTESTATION_Claim attest,
const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE reference 
)
static

Collect all attributes for an ego.

Definition at line 1319 of file plugin_rest_reclaim.c.

References RequestHandle::attr_it, GNUNET_RECLAIM_ATTRIBUTE_Claim::data, GNUNET_RECLAIM_ATTRIBUTE_Claim::data_size, GNUNET_RECLAIM_ATTRIBUTE_Claim::flag, GNUNET_asprintf(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_RECLAIM_ATTRIBUTE_number_to_typename(), GNUNET_RECLAIM_ATTRIBUTE_value_to_string(), GNUNET_RECLAIM_get_attributes_next(), GNUNET_STRINGS_data_to_string_alloc(), handle, GNUNET_RECLAIM_ATTRIBUTE_Claim::id, GNUNET_RECLAIM_ATTRIBUTE_Claim::name, GNUNET_RECLAIM_ATTESTATION_REFERENCE::name, parse_jwt(), GNUNET_RECLAIM_ATTESTATION_REFERENCE::reference_value, RequestHandle::resp_object, GNUNET_RECLAIM_ATTRIBUTE_Claim::type, and type.

Referenced by list_attribute_cont().

1324 {
1325  struct RequestHandle *handle = cls;
1326  json_t *attr_obj;
1327  const char *type;
1328  char *id_str;
1329 
1330  if ((NULL == attr) && (NULL == reference))
1331  {
1333  "Attribute Collection with empty Attribute/Reference\n");
1335  return;
1336  }
1337 
1338  if (NULL == attr)
1339  {
1340 
1341  if ((NULL == reference->name) || (NULL == reference->reference_value))
1342  {
1344  "Attribute Collection with empty Reference Name/Value\n");
1345  return;
1346  }
1347  struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr2;
1348  attr2 = parse_jwt (attest, reference->reference_value);
1349  if (NULL == attr2)
1350  {
1352  "Attribute Collection with unparsed Attestation\n");
1353  return;
1354  }
1355  attr2->name = reference->name;
1356  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding reference as attribute: %s\n",
1357  reference->name);
1358  char *tmp_value;
1359  tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr2->type,
1360  attr2->data,
1361  attr2->data_size);
1362  attr_obj = json_object ();
1363 
1364  json_object_set_new (attr_obj, "value", json_string (tmp_value));
1365  json_object_set_new (attr_obj, "name", json_string (attr2->name));
1366  json_object_set_new (attr_obj, "flag", json_string ("1"));
1368  json_object_set_new (attr_obj, "type", json_string (type));
1369  id_str = GNUNET_STRINGS_data_to_string_alloc (&attr2->id, sizeof(uint64_t));
1370  json_object_set_new (attr_obj, "id", json_string (id_str));
1371  json_array_append (handle->resp_object, attr_obj);
1372  json_decref (attr_obj);
1373  GNUNET_free (tmp_value);
1374  }
1375  else
1376  {
1377  if ((NULL == attr->name) || (NULL == attr->data))
1378  {
1380  "Attribute Collection with empty Attribute Name/Value\n");
1382  return;
1383  }
1384  char *tmp_value;
1385  char *flag_str;
1386  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name);
1387 
1389  attr->data,
1390  attr->data_size);
1391 
1392  attr_obj = json_object ();
1393  json_object_set_new (attr_obj, "value", json_string (tmp_value));
1394  json_object_set_new (attr_obj, "name", json_string (attr->name));
1395  GNUNET_asprintf (&flag_str,"%d",attr->flag);
1396  json_object_set_new (attr_obj, "flag", json_string (flag_str));
1398  json_object_set_new (attr_obj, "type", json_string (type));
1399  id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t));
1400  json_object_set_new (attr_obj, "id", json_string (id_str));
1401  json_array_append (handle->resp_object, attr_obj);
1402  json_decref (attr_obj);
1403  GNUNET_free (tmp_value);
1405  }
1406 }
const char * name
The name of the attribute.
char * GNUNET_RECLAIM_ATTRIBUTE_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;claim&#39; of an attribute to a string.
size_t data_size
Number of bytes in data.
struct GNUNET_RECLAIM_AttributeIterator * attr_it
Attribute iterator.
const char * reference_value
The name of the attribute/attestation reference value.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * parse_jwt(const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, const char *claim)
Parse a JWT and return the respective claim value as Attribute.
void GNUNET_RECLAIM_get_attributes_next(struct GNUNET_RECLAIM_AttributeIterator *it)
Calls the record processor specified in GNUNET_RECLAIM_get_attributes_start for the next record...
Definition: reclaim_api.c:1404
The request handle.
const void * data
Binary value stored as attribute value.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
json_t * resp_object
Response object.
const char * GNUNET_RECLAIM_ATTRIBUTE_number_to_typename(uint32_t type)
Convert a type number to the corresponding type string.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const char * name
The name of the attribute/attestation reference value.
#define GNUNET_log(kind,...)
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:920
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ list_attribute_cont()

static void list_attribute_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

List attributes for identity request.

Parameters
con_handlethe connection handle
urlthe url
clsthe RequestHandle

Definition at line 1416 of file plugin_rest_reclaim.c.

References attr_collect(), RequestHandle::attr_it, collect_error_cb(), collect_finished_cb(), do_error(), EgoEntry::ego, RequestHandle::ego_head, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_log, GNUNET_RECLAIM_connect(), GNUNET_RECLAIM_get_attributes_start(), GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, GNUNET_SCHEDULER_add_now(), handle, EgoEntry::identifier, identity, RequestHandle::idp, EgoEntry::next, RequestHandle::resp_object, return_response(), and RequestHandle::url.

Referenced by init_cont().

1419 {
1420  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
1421  struct RequestHandle *handle = cls;
1422  struct EgoEntry *ego_entry;
1423  char *identity;
1424 
1426  "Getting attributes for %s.\n",
1427  handle->url);
1428  if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
1429  {
1430  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
1432  return;
1433  }
1434  identity = handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1;
1435 
1436  for (ego_entry = handle->ego_head; NULL != ego_entry;
1437  ego_entry = ego_entry->next)
1438  if (0 == strcmp (identity, ego_entry->identifier))
1439  break;
1440  handle->resp_object = json_array ();
1441 
1442 
1443  if (NULL == ego_entry)
1444  {
1445  // Done
1446  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
1448  return;
1449  }
1450  priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1451  handle->idp = GNUNET_RECLAIM_connect (cfg);
1452  handle->attr_it = GNUNET_RECLAIM_get_attributes_start (handle->idp,
1453  priv_key,
1455  handle,
1456  &attr_collect,
1457  handle,
1459  handle);
1460 }
#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES
Attribute namespace.
struct GNUNET_RECLAIM_AttributeIterator * GNUNET_RECLAIM_get_attributes_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_AttributeResult proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
List all attributes for a local identity.
Definition: reclaim_api.c:1358
static void collect_error_cb(void *cls)
struct GNUNET_RECLAIM_AttributeIterator * attr_it
Attribute iterator.
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
static void attr_collect(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
Collect all attributes for an ego.
Private ECC key encoded for transmission.
static void collect_finished_cb(void *cls)
The request handle.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
json_t * resp_object
Response object.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
static void return_response(void *cls)
Return attributes for identity.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static void do_error(void *cls)
Task run on error, sends error message.
char * identifier
Ego Identifier.
struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1004
struct EgoEntry * next
DLL.
char * url
The url.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_attribute_cont()

static void delete_attribute_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

List attributes for identity request.

Parameters
con_handlethe connection handle
urlthe url
clsthe RequestHandle

Definition at line 1471 of file plugin_rest_reclaim.c.

References delete_finished_cb(), do_error(), EgoEntry::ego, RequestHandle::ego_head, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_log, GNUNET_RECLAIM_attribute_delete(), GNUNET_RECLAIM_connect(), GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_string_to_data(), handle, GNUNET_RECLAIM_ATTRIBUTE_Claim::id, id, EgoEntry::identifier, identity, RequestHandle::idp, RequestHandle::idp_op, GNUNET_RECLAIM_ATTRIBUTE_Claim::name, EgoEntry::next, RequestHandle::resp_object, return_response(), and RequestHandle::url.

Referenced by init_cont().

1474 {
1475  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
1476  struct RequestHandle *handle = cls;
1477  struct GNUNET_RECLAIM_ATTRIBUTE_Claim attr;
1478  struct EgoEntry *ego_entry;
1479  char *identity_id_str;
1480  char *identity;
1481  char *id;
1482 
1483  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attributes.\n");
1484  if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
1485  {
1486  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
1488  return;
1489  }
1490  identity_id_str =
1491  strdup (handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1);
1492  identity = strtok (identity_id_str, "/");
1493  id = strtok (NULL, "/");
1494  if ((NULL == identity) || (NULL == id))
1495  {
1496  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n");
1497  GNUNET_free (identity_id_str);
1499  return;
1500  }
1501 
1502  for (ego_entry = handle->ego_head; NULL != ego_entry;
1503  ego_entry = ego_entry->next)
1504  if (0 == strcmp (identity, ego_entry->identifier))
1505  break;
1506  handle->resp_object = json_array ();
1507  if (NULL == ego_entry)
1508  {
1509  // Done
1510  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
1511  GNUNET_free (identity_id_str);
1513  return;
1514  }
1515  priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1516  handle->idp = GNUNET_RECLAIM_connect (cfg);
1517  memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim));
1518  GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(uint64_t));
1519  attr.name = "";
1520  handle->idp_op = GNUNET_RECLAIM_attribute_delete (handle->idp,
1521  priv_key,
1522  &attr,
1524  handle);
1525  GNUNET_free (identity_id_str);
1526 }
#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES
Attribute namespace.
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
Private ECC key encoded for transmission.
The request handle.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
json_t * resp_object
Response object.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete an attribute.
Definition: reclaim_api.c:1122
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
static void return_response(void *cls)
Return attributes for identity.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static void delete_finished_cb(void *cls, int32_t success, const char *emsg)
static void do_error(void *cls)
Task run on error, sends error message.
char * identifier
Ego Identifier.
struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1004
struct EgoEntry * next
DLL.
int GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:952
#define GNUNET_free(ptr)
Wrapper around free.
char * url
The url.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ revoke_ticket_cont()

static void revoke_ticket_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

Definition at line 1530 of file plugin_rest_reclaim.c.

References GNUNET_REST_RequestHandle::data, GNUNET_REST_RequestHandle::data_size, do_error(), EgoEntry::ego, RequestHandle::ego_head, RequestHandle::emsg, finished_cont(), GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_IDENTITY_ego_get_public_key(), GNUNET_JSON_parse(), GNUNET_JSON_parse_free(), GNUNET_JSON_spec_end(), GNUNET_log, GNUNET_memcpy, GNUNET_OK, GNUNET_RECLAIM_connect(), GNUNET_RECLAIM_JSON_spec_ticket(), GNUNET_RECLAIM_ticket_revoke(), GNUNET_SCHEDULER_add_now(), GNUNET_strdup, handle, GNUNET_RECLAIM_Ticket::identity, RequestHandle::idp, RequestHandle::idp_op, EgoEntry::next, RequestHandle::rest_handle, and ticket.

Referenced by init_cont().

1533 {
1534  const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
1535  struct RequestHandle *handle = cls;
1536  struct EgoEntry *ego_entry;
1537  struct GNUNET_RECLAIM_Ticket *ticket = NULL;
1538  struct GNUNET_CRYPTO_EcdsaPublicKey tmp_pk;
1539  char term_data[handle->rest_handle->data_size + 1];
1540  json_t *data_json;
1541  json_error_t err;
1542  struct GNUNET_JSON_Specification tktspec[] =
1544 
1545  if (0 >= handle->rest_handle->data_size)
1546  {
1548  return;
1549  }
1550 
1551  term_data[handle->rest_handle->data_size] = '\0';
1552  GNUNET_memcpy (term_data,
1553  handle->rest_handle->data,
1554  handle->rest_handle->data_size);
1555  data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
1556  if ((NULL == data_json) ||
1557  (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL)))
1558  {
1559  handle->emsg = GNUNET_strdup ("Not a ticket!\n");
1561  GNUNET_JSON_parse_free (tktspec);
1562  if (NULL != data_json)
1563  json_decref (data_json);
1564  return;
1565  }
1566  json_decref (data_json);
1567  if (NULL == ticket)
1568  {
1570  "Unable to parse ticket from %s\n",
1571  term_data);
1573  return;
1574  }
1575 
1576  for (ego_entry = handle->ego_head; NULL != ego_entry;
1577  ego_entry = ego_entry->next)
1578  {
1579  GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk);
1580  if (0 == memcmp (&ticket->identity,
1581  &tmp_pk,
1582  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
1583  break;
1584  }
1585  if (NULL == ego_entry)
1586  {
1587  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n");
1588  GNUNET_JSON_parse_free (tktspec);
1589  return;
1590  }
1591  identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1592 
1593  handle->idp = GNUNET_RECLAIM_connect (cfg);
1594  handle->idp_op = GNUNET_RECLAIM_ticket_revoke (handle->idp,
1595  identity_priv,
1596  ticket,
1597  &finished_cont,
1598  handle);
1599  GNUNET_JSON_parse_free (tktspec);
1600 }
The authorization ticket.
size_t data_size
The POST data size.
void GNUNET_JSON_parse_free(struct GNUNET_JSON_Specification *spec)
Frees all elements allocated during a GNUNET_JSON_parse() operation.
Definition: json.c:100
static void finished_cont(void *cls, int32_t success, const char *emsg)
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Entry in parser specification for GNUNET_JSON_parse().
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
Private ECC key encoded for transmission.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
The request handle.
The ego list.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_revoke(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, const struct GNUNET_RECLAIM_Ticket *ticket, GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls)
Revoked an issued ticket.
Definition: reclaim_api.c:1644
char * emsg
Error response message.
int GNUNET_JSON_parse(const json_t *root, struct GNUNET_JSON_Specification *spec, const char **error_json_name, unsigned int *error_line)
Navigate and parse data in a JSON tree.
Definition: json.c:45
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
struct GNUNET_REST_RequestHandle * rest_handle
Rest connection.
const char * data
The POST data.
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The ticket issuer (= the user)
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
void GNUNET_IDENTITY_ego_get_public_key(const struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_CRYPTO_EcdsaPublicKey *pk)
Get the identifier (public key) of an ego.
Definition: identity_api.c:568
static void do_error(void *cls)
Task run on error, sends error message.
struct EgoEntry * ego_head
Ego list.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end(void)
End of a parser specification.
Definition: json_helper.c:35
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1004
struct EgoEntry * next
DLL.
struct GNUNET_JSON_Specification GNUNET_RECLAIM_JSON_spec_ticket(struct GNUNET_RECLAIM_Ticket **ticket)
JSON Specification for Reclaim tickets.
Definition: json_reclaim.c:257
Here is the call graph for this function:
Here is the caller graph for this function:

◆ consume_cont()

static void consume_cont ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey identity,
const struct GNUNET_RECLAIM_ATTRIBUTE_Claim attr,
const struct GNUNET_RECLAIM_ATTESTATION_Claim attest,
const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE reference 
)
static

Definition at line 1604 of file plugin_rest_reclaim.c.

References GNUNET_RECLAIM_ATTRIBUTE_Claim::data, GNUNET_RECLAIM_ATTRIBUTE_Claim::data_size, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_RECLAIM_ATTRIBUTE_value_to_string(), GNUNET_SCHEDULER_add_now(), handle, GNUNET_RECLAIM_ATTRIBUTE_Claim::name, RequestHandle::resp_object, return_response(), GNUNET_RECLAIM_ATTRIBUTE_Claim::type, and value.

Referenced by consume_ticket_cont().

1609 {
1610  struct RequestHandle *handle = cls;
1611  char *val_str;
1612  json_t *value;
1613 
1614  if (NULL == identity)
1615  {
1617  return;
1618  }
1619 
1620  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name);
1622  attr->data,
1623  attr->data_size);
1624  if (NULL == val_str)
1625  {
1627  "Failed to parse value for: %s\n",
1628  attr->name);
1629  return;
1630  }
1631  value = json_string (val_str);
1632  json_object_set_new (handle->resp_object, attr->name, value);
1633  json_decref (value);
1634  GNUNET_free (val_str);
1635 }
const char * name
The name of the attribute.
char * GNUNET_RECLAIM_ATTRIBUTE_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;claim&#39; of an attribute to a string.
size_t data_size
Number of bytes in data.
The request handle.
const void * data
Binary value stored as attribute value.
json_t * resp_object
Response object.
static char * value
Value of the record to add/remove.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static void return_response(void *cls)
Return attributes for identity.
#define GNUNET_log(kind,...)
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ consume_ticket_cont()

static void consume_ticket_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

Definition at line 1639 of file plugin_rest_reclaim.c.

References GNUNET_RECLAIM_Ticket::audience, consume_cont(), GNUNET_REST_RequestHandle::data, GNUNET_REST_RequestHandle::data_size, do_error(), EgoEntry::ego, RequestHandle::ego_head, RequestHandle::emsg, GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_IDENTITY_ego_get_public_key(), GNUNET_JSON_parse(), GNUNET_JSON_parse_free(), GNUNET_JSON_spec_end(), GNUNET_log, GNUNET_memcpy, GNUNET_OK, GNUNET_RECLAIM_connect(), GNUNET_RECLAIM_JSON_spec_ticket(), GNUNET_RECLAIM_ticket_consume(), GNUNET_SCHEDULER_add_now(), GNUNET_strdup, handle, RequestHandle::idp, RequestHandle::idp_op, EgoEntry::next, RequestHandle::resp_object, RequestHandle::rest_handle, and ticket.

Referenced by init_cont().

1642 {
1643  const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
1644  struct RequestHandle *handle = cls;
1645  struct EgoEntry *ego_entry;
1646  struct GNUNET_RECLAIM_Ticket *ticket;
1647  struct GNUNET_CRYPTO_EcdsaPublicKey tmp_pk;
1648  char term_data[handle->rest_handle->data_size + 1];
1649  json_t *data_json;
1650  json_error_t err;
1651  struct GNUNET_JSON_Specification tktspec[] =
1653 
1654  if (0 >= handle->rest_handle->data_size)
1655  {
1657  return;
1658  }
1659 
1660  term_data[handle->rest_handle->data_size] = '\0';
1661  GNUNET_memcpy (term_data,
1662  handle->rest_handle->data,
1663  handle->rest_handle->data_size);
1664  data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
1665  if (NULL == data_json)
1666  {
1668  "Unable to parse JSON Object from %s\n",
1669  term_data);
1671  return;
1672  }
1673  if (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL))
1674  {
1675  handle->emsg = GNUNET_strdup ("Not a ticket!\n");
1677  GNUNET_JSON_parse_free (tktspec);
1678  json_decref (data_json);
1679  return;
1680  }
1681  for (ego_entry = handle->ego_head; NULL != ego_entry;
1682  ego_entry = ego_entry->next)
1683  {
1684  GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk);
1685  if (0 == memcmp (&ticket->audience,
1686  &tmp_pk,
1687  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
1688  break;
1689  }
1690  if (NULL == ego_entry)
1691  {
1692  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n");
1693  GNUNET_JSON_parse_free (tktspec);
1694  return;
1695  }
1696  identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1697  handle->resp_object = json_object ();
1698  handle->idp = GNUNET_RECLAIM_connect (cfg);
1699  handle->idp_op = GNUNET_RECLAIM_ticket_consume (handle->idp,
1700  identity_priv,
1701  ticket,
1702  &consume_cont,
1703  handle);
1704  GNUNET_JSON_parse_free (tktspec);
1705 }
The authorization ticket.
size_t data_size
The POST data size.
static void consume_cont(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
void GNUNET_JSON_parse_free(struct GNUNET_JSON_Specification *spec)
Frees all elements allocated during a GNUNET_JSON_parse() operation.
Definition: json.c:100
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Entry in parser specification for GNUNET_JSON_parse().
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
Private ECC key encoded for transmission.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
The request handle.
The ego list.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
json_t * resp_object
Response object.
char * emsg
Error response message.
int GNUNET_JSON_parse(const json_t *root, struct GNUNET_JSON_Specification *spec, const char **error_json_name, unsigned int *error_line)
Navigate and parse data in a JSON tree.
Definition: json.c:45
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
struct GNUNET_REST_RequestHandle * rest_handle
Rest connection.
const char * data
The POST data.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
void GNUNET_IDENTITY_ego_get_public_key(const struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_CRYPTO_EcdsaPublicKey *pk)
Get the identifier (public key) of an ego.
Definition: identity_api.c:568
static void do_error(void *cls)
Task run on error, sends error message.
struct EgoEntry * ego_head
Ego list.
struct GNUNET_CRYPTO_EcdsaPublicKey audience
The ticket audience (= relying party)
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_consume(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, const struct GNUNET_RECLAIM_Ticket *ticket, GNUNET_RECLAIM_AttributeResult cb, void *cb_cls)
Consumes an issued ticket.
Definition: reclaim_api.c:1505
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end(void)
End of a parser specification.
Definition: json_helper.c:35
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1004
struct EgoEntry * next
DLL.
struct GNUNET_JSON_Specification GNUNET_RECLAIM_JSON_spec_ticket(struct GNUNET_RECLAIM_Ticket **ticket)
JSON Specification for Reclaim tickets.
Definition: json_reclaim.c:257
Here is the call graph for this function:
Here is the caller graph for this function:

◆ options_cont()

static void options_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

Respond to OPTIONS request.

Parameters
con_handlethe connection handle
urlthe url
clsthe RequestHandle

Definition at line 1716 of file plugin_rest_reclaim.c.

References allow_methods, cleanup_handle(), GNUNET_REST_create_response(), handle, RequestHandle::proc, and RequestHandle::proc_cls.

Referenced by init_cont().

1719 {
1720  struct MHD_Response *resp;
1721  struct RequestHandle *handle = cls;
1722 
1723  // For now, independent of path return all options
1724  resp = GNUNET_REST_create_response (NULL);
1725  MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods);
1726  handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
1727  cleanup_handle (handle);
1728  return;
1729 }
GNUNET_REST_ResultProcessor proc
The plugin result processor.
void * proc_cls
The closure of the result processor.
The request handle.
static char * allow_methods
HTTP methods allows for this plugin.
static void cleanup_handle(struct RequestHandle *handle)
Cleanup lookup handle.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct MHD_Response * GNUNET_REST_create_response(const char *data)
Create REST MHD response.
Definition: rest.c:57
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_cont()

static void init_cont ( struct RequestHandle handle)
static

Handle rest request.

Parameters
handlethe request handle

Definition at line 1738 of file plugin_rest_reclaim.c.

References add_attestation_cont(), add_attribute_cont(), consume_ticket_cont(), delete_attestation_cont(), delete_attribute_cont(), do_error(), GNUNET_REST_RequestHandlerError::error_code, GNUNET_NO, GNUNET_REST_API_NS_IDENTITY_CONSUME, GNUNET_REST_API_NS_IDENTITY_REVOKE, GNUNET_REST_API_NS_IDENTITY_TICKETS, GNUNET_REST_API_NS_RECLAIM, GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE, GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, GNUNET_REST_handle_request(), GNUNET_REST_HANDLER_END, GNUNET_SCHEDULER_add_now(), list_attestation_cont(), list_attribute_cont(), list_tickets_cont(), options_cont(), RequestHandle::response_code, RequestHandle::rest_handle, and revoke_ticket_cont().

Referenced by list_ego().

1739 {
1741  static const struct GNUNET_REST_RequestHandler handlers[] =
1742  { { MHD_HTTP_METHOD_GET,
1745  { MHD_HTTP_METHOD_POST,
1747  &add_attribute_cont },
1748  { MHD_HTTP_METHOD_DELETE,
1751  { MHD_HTTP_METHOD_GET,
1754  { MHD_HTTP_METHOD_POST,
1757  { MHD_HTTP_METHOD_DELETE,
1760  { MHD_HTTP_METHOD_GET,
1762  &list_tickets_cont },
1763  { MHD_HTTP_METHOD_POST,
1765  &revoke_ticket_cont },
1766  { MHD_HTTP_METHOD_POST,
1769  { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont },
1771 
1772  if (GNUNET_NO ==
1773  GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle))
1774  {
1775  handle->response_code = err.error_code;
1777  }
1778 }
static void list_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
List attributes for identity request.
#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES
Attribute namespace.
static void consume_ticket_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
static void add_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
#define GNUNET_REST_API_NS_IDENTITY_CONSUME
Revoke namespace.
#define GNUNET_NO
Definition: gnunet_common.h:86
static void add_attestation_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
static void options_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Respond to OPTIONS request.
#define GNUNET_REST_HANDLER_END
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static void list_tickets_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
List tickets for identity request.
int GNUNET_REST_handle_request(struct GNUNET_REST_RequestHandle *conn, const struct GNUNET_REST_RequestHandler *handlers, struct GNUNET_REST_RequestHandlerError *err, void *cls)
Definition: rest.c:77
struct GNUNET_REST_RequestHandle * rest_handle
Rest connection.
int response_code
Response code.
#define GNUNET_REST_API_NS_RECLAIM
REST root namespace.
static void delete_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
List attributes for identity request.
#define GNUNET_REST_API_NS_IDENTITY_REVOKE
Revoke namespace.
static void delete_attestation_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Deletes attestation from an identity.
static void do_error(void *cls)
Task run on error, sends error message.
static void list_attestation_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Lists attestation for identity request.
static void revoke_ticket_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
#define GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE
Attestation namespace.
#define GNUNET_REST_API_NS_IDENTITY_TICKETS
Ticket namespace.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ list_ego()

static void list_ego ( void *  cls,
struct GNUNET_IDENTITY_Ego ego,
void **  ctx,
const char *  identifier 
)
static

If listing is enabled, prints information about the egos.

This function is initially called for all egos and then again whenever a ego's identifier changes or if it is deleted. At the end of the initial pass over all egos, the function is once called with 'NULL' for 'ego'. That does NOT mean that the callback won't be invoked in the future or that there was an error.

When used with 'GNUNET_IDENTITY_create' or 'GNUNET_IDENTITY_get', this function is only called ONCE, and 'NULL' being passed in 'ego' does indicate an error (i.e. name is taken or no default value is known). If 'ego' is non-NULL and if '*ctx' is set in those callbacks, the value WILL be passed to a subsequent call to the identity callback of 'GNUNET_IDENTITY_connect' (if that one was not NULL).

When an identity is renamed, this function is called with the (known) ego but the NEW identifier.

When an identity is deleted, this function is called with the (known) ego and "NULL" for the 'identifier'. In this case, the 'ego' is henceforth invalid (and the 'ctx' should also be cleaned up).

Parameters
clsclosure
egoego handle
ctxcontext for application to store data for this ego (during the lifetime of this process, initially NULL)
identifieridentifier assigned by the user for this ego, NULL if the user just deleted the ego and it must thus no longer be used

Definition at line 1815 of file plugin_rest_reclaim.c.

References EgoEntry::ego, RequestHandle::ego_head, RequestHandle::ego_tail, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CRYPTO_ecdsa_public_key_to_string(), GNUNET_IDENTITY_ego_get_public_key(), GNUNET_new, GNUNET_strdup, handle, ID_REST_STATE_INIT, ID_REST_STATE_POST_INIT, EgoEntry::identifier, init_cont(), EgoEntry::keystring, and RequestHandle::state.

Referenced by rest_identity_process_request().

1819 {
1820  struct RequestHandle *handle = cls;
1821  struct EgoEntry *ego_entry;
1823 
1824  if ((NULL == ego) && (ID_REST_STATE_INIT == handle->state))
1825  {
1826  handle->state = ID_REST_STATE_POST_INIT;
1827  init_cont (handle);
1828  return;
1829  }
1830  if (ID_REST_STATE_INIT == handle->state)
1831  {
1832  ego_entry = GNUNET_new (struct EgoEntry);
1835  ego_entry->ego = ego;
1836  ego_entry->identifier = GNUNET_strdup (identifier);
1838  handle->ego_tail,
1839  ego_entry);
1840  }
1841 }
static struct GNUNET_CRYPTO_EddsaPrivateKey * pk
Private key of this peer.
struct EgoEntry * ego_tail
Ego list.
static void init_cont(struct RequestHandle *handle)
Handle rest request.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
The request handle.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
#define ID_REST_STATE_INIT
State while collecting all egos.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
#define ID_REST_STATE_POST_INIT
Done collecting egos.
int state
The processing state.
char * GNUNET_CRYPTO_ecdsa_public_key_to_string(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Convert a public key to a string.
Definition: crypto_ecc.c:223
char * keystring
Public key string.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
void GNUNET_IDENTITY_ego_get_public_key(const struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_CRYPTO_EcdsaPublicKey *pk)
Get the identifier (public key) of an ego.
Definition: identity_api.c:568
char * identifier
Ego Identifier.
struct EgoEntry * ego_head
Ego list.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rest_identity_process_request()

static void rest_identity_process_request ( struct GNUNET_REST_RequestHandle rest_handle,
GNUNET_REST_ResultProcessor  proc,
void *  proc_cls 
)
static

Definition at line 1845 of file plugin_rest_reclaim.c.

References do_timeout(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_IDENTITY_connect(), GNUNET_log, GNUNET_new, GNUNET_SCHEDULER_add_delayed(), GNUNET_strdup, GNUNET_TIME_UNIT_FOREVER_REL, handle, ID_REST_STATE_INIT, RequestHandle::identity_handle, list_ego(), RequestHandle::proc, RequestHandle::proc_cls, RequestHandle::response_code, RequestHandle::rest_handle, RequestHandle::state, RequestHandle::timeout, RequestHandle::timeout_task, GNUNET_REST_RequestHandle::url, and RequestHandle::url.

Referenced by libgnunet_plugin_rest_reclaim_init().

1848 {
1849  struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
1850 
1851  handle->response_code = 0;
1853  handle->proc_cls = proc_cls;
1854  handle->proc = proc;
1855  handle->state = ID_REST_STATE_INIT;
1856  handle->rest_handle = rest_handle;
1857 
1858  handle->url = GNUNET_strdup (rest_handle->url);
1859  if (handle->url[strlen (handle->url) - 1] == '/')
1860  handle->url[strlen (handle->url) - 1] = '\0';
1861  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n");
1862  handle->identity_handle = GNUNET_IDENTITY_connect (cfg, &list_ego, handle);
1863  handle->timeout_task =
1864  GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle);
1865  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n");
1866 }
struct GNUNET_IDENTITY_Handle * GNUNET_IDENTITY_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Connect to the identity service.
Definition: identity_api.c:527
static void list_ego(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *identifier)
If listing is enabled, prints information about the egos.
GNUNET_REST_ResultProcessor proc
The plugin result processor.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
void * proc_cls
The closure of the result processor.
The request handle.
#define ID_REST_STATE_INIT
State while collecting all egos.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1253
const char * url
The url as string.
struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
struct GNUNET_REST_RequestHandle * rest_handle
Rest connection.
int response_code
Response code.
int state
The processing state.
struct GNUNET_SCHEDULER_Task * timeout_task
ID of a task associated with the resolution process.
static void do_timeout(void *cls)
Task run on timeout, sends error message.
#define GNUNET_log(kind,...)
struct GNUNET_IDENTITY_Handle * identity_handle
Handle to Identity service.
char * url
The url.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ libgnunet_plugin_rest_reclaim_init()

void* libgnunet_plugin_rest_reclaim_init ( void *  cls)

Entry point for the plugin.

Parameters
clsConfig info
Returns
NULL on error, otherwise the plugin context

Definition at line 1876 of file plugin_rest_reclaim.c.

References _, allow_methods, Plugin::api, Plugin::cfg, GNUNET_REST_Plugin::cls, GNUNET_asprintf(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_REST_API_NS_RECLAIM, GNUNET_REST_Plugin::name, plugin, GNUNET_REST_Plugin::process_request, and rest_identity_process_request().

1877 {
1878  static struct Plugin plugin;
1879  struct GNUNET_REST_Plugin *api;
1880 
1881  cfg = cls;
1882  if (NULL != plugin.cfg)
1883  return NULL; /* can only initialize once! */
1884  memset (&plugin, 0, sizeof(struct Plugin));
1885  plugin.cfg = cfg;
1886  api = GNUNET_new (struct GNUNET_REST_Plugin);
1887  api->cls = &plugin;
1891  "%s, %s, %s, %s, %s",
1892  MHD_HTTP_METHOD_GET,
1893  MHD_HTTP_METHOD_POST,
1894  MHD_HTTP_METHOD_PUT,
1895  MHD_HTTP_METHOD_DELETE,
1896  MHD_HTTP_METHOD_OPTIONS);
1897 
1899  _ ("Identity Provider REST API initialized\n"));
1900  return api;
1901 }
void * cls
The closure of the plugin.
struct returned by the initialization function of the plugin
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void(* process_request)(struct GNUNET_REST_RequestHandle *handle, GNUNET_REST_ResultProcessor proc, void *proc_cls)
Function to process a REST call.
#define _(String)
GNU gettext support macro.
Definition: platform.h:180
static void rest_identity_process_request(struct GNUNET_REST_RequestHandle *rest_handle, GNUNET_REST_ResultProcessor proc, void *proc_cls)
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
static char * allow_methods
HTTP methods allows for this plugin.
char * name
Plugin name.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
#define GNUNET_REST_API_NS_RECLAIM
REST root namespace.
static char * plugin
Solver plugin name as string.
Handle for a plugin.
Definition: block.c:37
#define GNUNET_log(kind,...)
Here is the call graph for this function:

◆ libgnunet_plugin_rest_reclaim_done()

void* libgnunet_plugin_rest_reclaim_done ( void *  cls)

Exit point from the plugin.

Parameters
clsthe plugin context (as returned by "init")
Returns
always NULL

Definition at line 1911 of file plugin_rest_reclaim.c.

References allow_methods, Plugin::api, Plugin::cfg, GNUNET_REST_Plugin::cls, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_free_non_null, GNUNET_log, and plugin.

1912 {
1913  struct GNUNET_REST_Plugin *api = cls;
1914  struct Plugin *plugin = api->cls;
1915 
1916  plugin->cfg = NULL;
1917 
1919  GNUNET_free (api);
1921  "Identity Provider REST plugin is finished\n");
1922  return NULL;
1923 }
void * cls
The closure of the plugin.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
struct returned by the initialization function of the plugin
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static char * allow_methods
HTTP methods allows for this plugin.
static char * plugin
Solver plugin name as string.
Handle for a plugin.
Definition: block.c:37
#define GNUNET_log(kind,...)
#define GNUNET_free(ptr)
Wrapper around free.

Variable Documentation

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg

The configuration handle.

Handle to our configuration.

Definition at line 83 of file plugin_rest_reclaim.c.

◆ allow_methods

char* allow_methods
static

HTTP methods allows for this plugin.

Definition at line 88 of file plugin_rest_reclaim.c.

Referenced by libgnunet_plugin_rest_reclaim_done(), libgnunet_plugin_rest_reclaim_init(), and options_cont().