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_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 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 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)
 
static void attr_collect (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
 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_finished_cb (void *cls, int32_t success, const char *emsg)
 
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)
 
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 44 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_IDENTITY_TICKETS

#define GNUNET_REST_API_NS_IDENTITY_TICKETS   "/reclaim/tickets"

Ticket namespace.

Definition at line 54 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 59 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 64 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 69 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 74 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 244 of file plugin_rest_reclaim.c.

References 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, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::next, EgoEntry::next, RequestHandle::resp_object, RequestHandle::ticket_it, RequestHandle::timeout_task, and RequestHandle::url.

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

245 {
246  struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_entry;
247  struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_tmp;
248  struct EgoEntry *ego_entry;
249  struct EgoEntry *ego_tmp;
250 
251  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
252  if (NULL != handle->resp_object)
253  json_decref (handle->resp_object);
254  if (NULL != handle->timeout_task)
256  if (NULL != handle->identity_handle)
258  if (NULL != handle->attr_it)
260  if (NULL != handle->ticket_it)
262  if (NULL != handle->idp)
263  GNUNET_RECLAIM_disconnect (handle->idp);
264  if (NULL != handle->url)
265  GNUNET_free (handle->url);
266  if (NULL != handle->emsg)
267  GNUNET_free (handle->emsg);
268  if (NULL != handle->attr_list)
269  {
270  for (claim_entry = handle->attr_list->list_head; NULL != claim_entry;)
271  {
272  claim_tmp = claim_entry;
273  claim_entry = claim_entry->next;
274  GNUNET_free (claim_tmp->claim);
275  GNUNET_free (claim_tmp);
276  }
277  GNUNET_free (handle->attr_list);
278  }
279  for (ego_entry = handle->ego_head; NULL != ego_entry;)
280  {
281  ego_tmp = ego_entry;
282  ego_entry = ego_entry->next;
283  GNUNET_free (ego_tmp->identifier);
284  GNUNET_free (ego_tmp->keystring);
285  GNUNET_free (ego_tmp);
286  }
287  GNUNET_free (handle);
288 }
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute claim.
struct GNUNET_RECLAIM_AttributeIterator * attr_it
Attribute iterator.
void GNUNET_RECLAIM_disconnect(struct GNUNET_RECLAIM_Handle *h)
Disconnect from identity provider service.
Definition: reclaim_api.c:819
void GNUNET_RECLAIM_ticket_iteration_stop(struct GNUNET_RECLAIM_TicketIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1209
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:1021
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 292 of file plugin_rest_reclaim.c.

References cleanup_handle().

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

293 {
294  cleanup_handle (cls);
295 }
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 304 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_attribute_cont(), collect_error_cb(), consume_ticket_cont(), delete_attribute_cont(), delete_finished_cb(), do_timeout(), finished_cont(), init_cont(), list_attribute_cont(), list_tickets_cont(), and revoke_ticket_cont().

305 {
306  struct RequestHandle *handle = cls;
307  struct MHD_Response *resp;
308  char *json_error;
309 
310  GNUNET_asprintf (&json_error, "{ \"error\" : \"%s\" }", handle->emsg);
311  if (0 == handle->response_code)
312  {
313  handle->response_code = MHD_HTTP_BAD_REQUEST;
314  }
315  resp = GNUNET_REST_create_response (json_error);
316  MHD_add_response_header (resp, "Content-Type", "application/json");
317  handle->proc (handle->proc_cls, resp, handle->response_code);
319  GNUNET_free (json_error);
320 }
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 329 of file plugin_rest_reclaim.c.

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

Referenced by rest_identity_process_request().

330 {
331  struct RequestHandle *handle = cls;
332 
333  handle->timeout_task = NULL;
334  do_error (handle);
335 }
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 339 of file plugin_rest_reclaim.c.

References do_error(), and handle.

Referenced by list_attribute_cont(), and list_tickets_cont().

340 {
341  struct RequestHandle *handle = cls;
342 
343  do_error (handle);
344 }
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 348 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_attribute_cont(), and revoke_ticket_cont().

349 {
350  struct RequestHandle *handle = cls;
351  struct MHD_Response *resp;
352 
353  resp = GNUNET_REST_create_response (emsg);
354  if (GNUNET_OK != success)
355  {
357  return;
358  }
359  handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
361 }
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:75
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 370 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_attribute_cont(), list_attribute_cont(), and list_tickets_cont().

371 {
372  char *result_str;
373  struct RequestHandle *handle = cls;
374  struct MHD_Response *resp;
375 
376  result_str = json_dumps (handle->resp_object, 0);
377  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
378  resp = GNUNET_REST_create_response (result_str);
379  handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
380  GNUNET_free (result_str);
381  cleanup_handle (handle);
382 }
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 386 of file plugin_rest_reclaim.c.

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

Referenced by list_attribute_cont(), and list_tickets_cont().

387 {
388  struct RequestHandle *handle = cls;
389 
390  // Done
391  handle->attr_it = NULL;
392  handle->ticket_it = NULL;
394 }
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 402 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().

403 {
404  json_t *json_resource;
405  struct RequestHandle *handle = cls;
406  json_t *value;
407  char *tmp;
408 
409  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding ticket\n");
410  tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t));
411  json_resource = json_object ();
412  GNUNET_free (tmp);
413  json_array_append (handle->resp_object, json_resource);
414 
415  tmp =
417  sizeof(struct
419  value = json_string (tmp);
420  json_object_set_new (json_resource, "issuer", value);
421  GNUNET_free (tmp);
422  tmp =
424  sizeof(struct
426  value = json_string (tmp);
427  json_object_set_new (json_resource, "audience", value);
428  GNUNET_free (tmp);
429  tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t));
430  value = json_string (tmp);
431  json_object_set_new (json_resource, "rnd", value);
432  GNUNET_free (tmp);
434 }
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:1189
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:

◆ 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 445 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().

448 {
449  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
450  struct RequestHandle *handle = cls;
451  struct EgoEntry *ego_entry;
452  char *identity;
453 
455  "Getting tickets for %s.\n",
456  handle->url);
457  if (strlen (GNUNET_REST_API_NS_IDENTITY_TICKETS) >= strlen (handle->url))
458  {
459  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
461  return;
462  }
463  identity = handle->url + strlen (GNUNET_REST_API_NS_IDENTITY_TICKETS) + 1;
464 
465  for (ego_entry = handle->ego_head; NULL != ego_entry;
466  ego_entry = ego_entry->next)
467  if (0 == strcmp (identity, ego_entry->identifier))
468  break;
469  handle->resp_object = json_array ();
470 
471  if (NULL == ego_entry)
472  {
473  // Done
474  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
476  return;
477  }
478  priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
479  handle->idp = GNUNET_RECLAIM_connect (cfg);
480  handle->ticket_it =
482  priv_key,
484  handle,
486  handle,
488  handle);
489 }
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:1145
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:779
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 493 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().

496 {
497  const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
498  const char *identity;
499  struct RequestHandle *handle = cls;
500  struct EgoEntry *ego_entry;
501  struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attribute;
502  struct GNUNET_TIME_Relative exp;
503  char term_data[handle->rest_handle->data_size + 1];
504  json_t *data_json;
505  json_error_t err;
506  struct GNUNET_JSON_Specification attrspec[] =
508 
510  "Adding an attribute for %s.\n",
511  handle->url);
512  if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
513  {
514  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
516  return;
517  }
518  identity = handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1;
519 
520  for (ego_entry = handle->ego_head; NULL != ego_entry;
521  ego_entry = ego_entry->next)
522  if (0 == strcmp (identity, ego_entry->identifier))
523  break;
524 
525  if (NULL == ego_entry)
526  {
527  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity);
528  return;
529  }
530  identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
531 
532  if (0 >= handle->rest_handle->data_size)
533  {
535  return;
536  }
537 
538  term_data[handle->rest_handle->data_size] = '\0';
539  GNUNET_memcpy (term_data,
540  handle->rest_handle->data,
541  handle->rest_handle->data_size);
542  data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
544  GNUNET_JSON_parse (data_json, attrspec, NULL, NULL));
545  json_decref (data_json);
546  if (NULL == attribute)
547  {
549  "Unable to parse attribute from %s\n",
550  term_data);
552  return;
553  }
557  if (0 == attribute->id)
558  attribute->id =
560  handle->idp = GNUNET_RECLAIM_connect (cfg);
562  handle->idp_op = GNUNET_RECLAIM_attribute_store (handle->idp,
563  identity_priv,
564  attribute,
565  &exp,
566  &finished_cont,
567  handle);
568  GNUNET_JSON_parse_free (attrspec);
569 }
#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:850
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:75
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:133
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:779
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:

◆ attr_collect()

static void attr_collect ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey identity,
const struct GNUNET_RECLAIM_ATTRIBUTE_Claim attr 
)
static

Collect all attributes for an ego.

Definition at line 577 of file plugin_rest_reclaim.c.

References RequestHandle::attr_it, GNUNET_RECLAIM_ATTRIBUTE_Claim::data, GNUNET_RECLAIM_ATTRIBUTE_Claim::data_size, 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, RequestHandle::resp_object, GNUNET_RECLAIM_ATTRIBUTE_Claim::type, and type.

Referenced by list_attribute_cont().

580 {
581  struct RequestHandle *handle = cls;
582  json_t *attr_obj;
583  const char *type;
584  char *tmp_value;
585  char *id_str;
586 
587  if ((NULL == attr->name) || (NULL == attr->data))
588  {
590  return;
591  }
592 
593  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name);
594 
596  attr->data,
597  attr->data_size);
598 
599  attr_obj = json_object ();
600  json_object_set_new (attr_obj, "value", json_string (tmp_value));
601  json_object_set_new (attr_obj, "name", json_string (attr->name));
603  json_object_set_new (attr_obj, "type", json_string (type));
604  id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t));
605  json_object_set_new (attr_obj, "id", json_string (id_str));
606  json_array_append (handle->resp_object, attr_obj);
607  json_decref (attr_obj);
608  GNUNET_free (tmp_value);
610 }
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.
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:1000
The request handle.
const void * data
Binary value stored as attribute value.
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.
#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 621 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().

624 {
625  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
626  struct RequestHandle *handle = cls;
627  struct EgoEntry *ego_entry;
628  char *identity;
629 
631  "Getting attributes for %s.\n",
632  handle->url);
633  if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
634  {
635  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
637  return;
638  }
639  identity = handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1;
640 
641  for (ego_entry = handle->ego_head; NULL != ego_entry;
642  ego_entry = ego_entry->next)
643  if (0 == strcmp (identity, ego_entry->identifier))
644  break;
645  handle->resp_object = json_array ();
646 
647 
648  if (NULL == ego_entry)
649  {
650  // Done
651  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
653  return;
654  }
655  priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
656  handle->idp = GNUNET_RECLAIM_connect (cfg);
658  priv_key,
660  handle,
661  &attr_collect,
662  handle,
664  handle);
665 }
#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES
Attribute namespace.
static void attr_collect(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
Collect all attributes for an ego.
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:954
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,...)
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:779
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_finished_cb()

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

Definition at line 669 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_attribute_cont().

670 {
671  struct RequestHandle *handle = cls;
672  struct MHD_Response *resp;
673 
674  resp = GNUNET_REST_create_response (emsg);
675  if (GNUNET_OK != success)
676  {
678  return;
679  }
680  handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
682 }
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:75
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_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 693 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().

696 {
697  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
698  struct RequestHandle *handle = cls;
699  struct GNUNET_RECLAIM_ATTRIBUTE_Claim attr;
700  struct EgoEntry *ego_entry;
701  char *identity_id_str;
702  char *identity;
703  char *id;
704 
705  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attributes.\n");
706  if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
707  {
708  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
710  return;
711  }
712  identity_id_str =
713  strdup (handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1);
714  identity = strtok (identity_id_str, "/");
715  id = strtok (NULL, "/");
716  if ((NULL == identity) || (NULL == id))
717  {
718  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n");
719  GNUNET_free (identity_id_str);
721  return;
722  }
723 
724  for (ego_entry = handle->ego_head; NULL != ego_entry;
725  ego_entry = ego_entry->next)
726  if (0 == strcmp (identity, ego_entry->identifier))
727  break;
728  handle->resp_object = json_array ();
729  if (NULL == ego_entry)
730  {
731  // Done
732  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
733  GNUNET_free (identity_id_str);
735  return;
736  }
737  priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
738  handle->idp = GNUNET_RECLAIM_connect (cfg);
739  memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim));
740  GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(uint64_t));
741  attr.name = "";
742  handle->idp_op = GNUNET_RECLAIM_attribute_delete (handle->idp,
743  priv_key,
744  &attr,
746  handle);
747  GNUNET_free (identity_id_str);
748 }
#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:897
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:779
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 752 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().

755 {
756  const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
757  struct RequestHandle *handle = cls;
758  struct EgoEntry *ego_entry;
759  struct GNUNET_RECLAIM_Ticket *ticket = NULL;
760  struct GNUNET_CRYPTO_EcdsaPublicKey tmp_pk;
761  char term_data[handle->rest_handle->data_size + 1];
762  json_t *data_json;
763  json_error_t err;
764  struct GNUNET_JSON_Specification tktspec[] =
766 
767  if (0 >= handle->rest_handle->data_size)
768  {
770  return;
771  }
772 
773  term_data[handle->rest_handle->data_size] = '\0';
774  GNUNET_memcpy (term_data,
775  handle->rest_handle->data,
776  handle->rest_handle->data_size);
777  data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
778  if ((NULL == data_json) ||
779  (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL)))
780  {
781  handle->emsg = GNUNET_strdup ("Not a ticket!\n");
783  GNUNET_JSON_parse_free (tktspec);
784  if (NULL != data_json)
785  json_decref (data_json);
786  return;
787  }
788  json_decref (data_json);
789  if (NULL == ticket)
790  {
792  "Unable to parse ticket from %s\n",
793  term_data);
795  return;
796  }
797 
798  for (ego_entry = handle->ego_head; NULL != ego_entry;
799  ego_entry = ego_entry->next)
800  {
801  GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk);
802  if (0 == memcmp (&ticket->identity,
803  &tmp_pk,
804  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
805  break;
806  }
807  if (NULL == ego_entry)
808  {
809  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n");
810  GNUNET_JSON_parse_free (tktspec);
811  return;
812  }
813  identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
814 
815  handle->idp = GNUNET_RECLAIM_connect (cfg);
816  handle->idp_op = GNUNET_RECLAIM_ticket_revoke (handle->idp,
817  identity_priv,
818  ticket,
819  &finished_cont,
820  handle);
821  GNUNET_JSON_parse_free (tktspec);
822 }
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:75
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:1240
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:779
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:254
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 
)
static

Definition at line 826 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().

829 {
830  struct RequestHandle *handle = cls;
831  char *val_str;
832  json_t *value;
833 
834  if (NULL == identity)
835  {
837  return;
838  }
839 
840  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name);
842  attr->data,
843  attr->data_size);
844  if (NULL == val_str)
845  {
847  "Failed to parse value for: %s\n",
848  attr->name);
849  return;
850  }
851  value = json_string (val_str);
852  json_object_set_new (handle->resp_object, attr->name, value);
853  json_decref (value);
854  GNUNET_free (val_str);
855 }
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 859 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().

862 {
863  const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
864  struct RequestHandle *handle = cls;
865  struct EgoEntry *ego_entry;
867  struct GNUNET_CRYPTO_EcdsaPublicKey tmp_pk;
868  char term_data[handle->rest_handle->data_size + 1];
869  json_t *data_json;
870  json_error_t err;
871  struct GNUNET_JSON_Specification tktspec[] =
873 
874  if (0 >= handle->rest_handle->data_size)
875  {
877  return;
878  }
879 
880  term_data[handle->rest_handle->data_size] = '\0';
881  GNUNET_memcpy (term_data,
882  handle->rest_handle->data,
883  handle->rest_handle->data_size);
884  data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
885  if (NULL == data_json)
886  {
888  "Unable to parse JSON Object from %s\n",
889  term_data);
891  return;
892  }
893  if (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL))
894  {
895  handle->emsg = GNUNET_strdup ("Not a ticket!\n");
897  GNUNET_JSON_parse_free (tktspec);
898  json_decref (data_json);
899  return;
900  }
901  for (ego_entry = handle->ego_head; NULL != ego_entry;
902  ego_entry = ego_entry->next)
903  {
904  GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk);
905  if (0 == memcmp (&ticket->audience,
906  &tmp_pk,
907  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
908  break;
909  }
910  if (NULL == ego_entry)
911  {
912  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n");
913  GNUNET_JSON_parse_free (tktspec);
914  return;
915  }
916  identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
917  handle->resp_object = json_object ();
918  handle->idp = GNUNET_RECLAIM_connect (cfg);
919  handle->idp_op = GNUNET_RECLAIM_ticket_consume (handle->idp,
920  identity_priv,
921  ticket,
922  &consume_cont,
923  handle);
924  GNUNET_JSON_parse_free (tktspec);
925 }
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
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:75
Private ECC key encoded for transmission.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static void consume_cont(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
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:1101
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:779
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:254
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 936 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().

939 {
940  struct MHD_Response *resp;
941  struct RequestHandle *handle = cls;
942 
943  // For now, independent of path return all options
944  resp = GNUNET_REST_create_response (NULL);
945  MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods);
946  handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
947  cleanup_handle (handle);
948  return;
949 }
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 958 of file plugin_rest_reclaim.c.

References add_attribute_cont(), consume_ticket_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_ATTRIBUTES, GNUNET_REST_handle_request(), GNUNET_REST_HANDLER_END, GNUNET_SCHEDULER_add_now(), list_attribute_cont(), list_tickets_cont(), options_cont(), RequestHandle::response_code, RequestHandle::rest_handle, and revoke_ticket_cont().

Referenced by list_ego().

959 {
961  static const struct GNUNET_REST_RequestHandler handlers[] =
962  { { MHD_HTTP_METHOD_GET,
965  { MHD_HTTP_METHOD_POST,
968  { MHD_HTTP_METHOD_DELETE,
971  { MHD_HTTP_METHOD_GET,
974  { MHD_HTTP_METHOD_POST,
977  { MHD_HTTP_METHOD_POST,
980  { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont },
982 
983  if (GNUNET_NO ==
984  GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle))
985  {
986  handle->response_code = err.error_code;
988  }
989 }
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:78
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 do_error(void *cls)
Task run on error, sends error message.
static void revoke_ticket_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
#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 1026 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().

1030 {
1031  struct RequestHandle *handle = cls;
1032  struct EgoEntry *ego_entry;
1034 
1035  if ((NULL == ego) && (ID_REST_STATE_INIT == handle->state))
1036  {
1037  handle->state = ID_REST_STATE_POST_INIT;
1038  init_cont (handle);
1039  return;
1040  }
1041  if (ID_REST_STATE_INIT == handle->state)
1042  {
1043  ego_entry = GNUNET_new (struct EgoEntry);
1046  ego_entry->ego = ego;
1047  ego_entry->identifier = GNUNET_strdup (identifier);
1049  handle->ego_tail,
1050  ego_entry);
1051  }
1052 }
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:332
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 1056 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().

1059 {
1060  struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
1061 
1062  handle->response_code = 0;
1064  handle->proc_cls = proc_cls;
1065  handle->proc = proc;
1066  handle->state = ID_REST_STATE_INIT;
1067  handle->rest_handle = rest_handle;
1068 
1069  handle->url = GNUNET_strdup (rest_handle->url);
1070  if (handle->url[strlen (handle->url) - 1] == '/')
1071  handle->url[strlen (handle->url) - 1] = '\0';
1072  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n");
1073  handle->identity_handle = GNUNET_IDENTITY_connect (cfg, &list_ego, handle);
1074  handle->timeout_task =
1075  GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle);
1076  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n");
1077 }
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 1087 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().

1088 {
1089  static struct Plugin plugin;
1090  struct GNUNET_REST_Plugin *api;
1091 
1092  cfg = cls;
1093  if (NULL != plugin.cfg)
1094  return NULL; /* can only initialize once! */
1095  memset (&plugin, 0, sizeof(struct Plugin));
1096  plugin.cfg = cfg;
1097  api = GNUNET_new (struct GNUNET_REST_Plugin);
1098  api->cls = &plugin;
1102  "%s, %s, %s, %s, %s",
1103  MHD_HTTP_METHOD_GET,
1104  MHD_HTTP_METHOD_POST,
1105  MHD_HTTP_METHOD_PUT,
1106  MHD_HTTP_METHOD_DELETE,
1107  MHD_HTTP_METHOD_OPTIONS);
1108 
1110  _ ("Identity Provider REST API initialized\n"));
1111  return api;
1112 }
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:181
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 1122 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.

1123 {
1124  struct GNUNET_REST_Plugin *api = cls;
1125  struct Plugin *plugin = api->cls;
1126 
1127  plugin->cfg = NULL;
1128 
1130  GNUNET_free (api);
1132  "Identity Provider REST plugin is finished\n");
1133  return NULL;
1134 }
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 79 of file plugin_rest_reclaim.c.

◆ allow_methods

char* allow_methods
static

HTTP methods allows for this plugin.

Definition at line 84 of file plugin_rest_reclaim.c.

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