struct GNUNET_CRYPTO_EcdsaPublicKey identity_pub;
/**
- * ParallelLookups DLL
+ * Lookup DLL
*/
struct ParallelLookup2 *parallel_lookups_head;
+
+ /**
+ * Lookup DLL
+ */
struct ParallelLookup2 *parallel_lookups_tail;
+ /**
+ * Kill task
+ */
struct GNUNET_SCHEDULER_Task *kill_task;
+
+ /**
+ * The ABE key
+ */
struct GNUNET_CRYPTO_AbeKey *key;
+ /**
+ * Attributes
+ */
+ struct GNUNET_IDENTITY_PROVIDER_AttributeList *attrs;
+
/**
* request id
*/
"Parallel lookup finished (count=%u)\n", rd_count);
struct ParallelLookup2 *parallel_lookup = cls;
struct ConsumeTicketHandle *handle = parallel_lookup->handle;
- struct AttributeResultMessage *arm;
+ struct ConsumeTicketResultMessage *crm;
struct GNUNET_MQ_Envelope *env;
+ struct GNUNET_IDENTITY_PROVIDER_AttributeListEntry *attr_le;
char *data;
char *data_tmp;
- size_t msg_extra_len;
+ size_t attr_len;
+ size_t attrs_len;
GNUNET_CONTAINER_DLL_remove (handle->parallel_lookups_head,
handle->parallel_lookups_tail,
GNUNET_break(0);//TODO
if (rd->record_type == GNUNET_GNSRECORD_TYPE_ID_ATTR)
{
- msg_extra_len = GNUNET_CRYPTO_cpabe_decrypt (rd->data,
- rd->data_size,
- handle->key,
- (void**)&data);
- env = GNUNET_MQ_msg_extra (arm,
- msg_extra_len,
- GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_RESULT);
- arm->id = htonl (handle->r_id);
- arm->attr_len = htons (msg_extra_len);
- arm->identity = handle->ticket.identity;
- data_tmp = (char *) &arm[1];
- GNUNET_memcpy (data_tmp,
- data,
- msg_extra_len);
- GNUNET_MQ_send (handle->client->mq, env);
+ attr_len = GNUNET_CRYPTO_cpabe_decrypt (rd->data,
+ rd->data_size,
+ handle->key,
+ (void**)&data);
+ attr_le = GNUNET_new (struct GNUNET_IDENTITY_PROVIDER_AttributeListEntry);
+ attr_le->attribute = attribute_deserialize (data,
+ attr_len);
+ GNUNET_CONTAINER_DLL_insert (handle->attrs->list_head,
+ handle->attrs->list_tail,
+ attr_le);
GNUNET_free (data);
}
if (NULL != handle->parallel_lookups_head)
return; //Wait for more
//Else we are done
GNUNET_SCHEDULER_cancel (handle->kill_task);
- env = GNUNET_MQ_msg (arm,
- GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_RESULT);
- arm->id = htonl (handle->r_id);
- arm->attr_len = htons (0);
+ attrs_len = attribute_list_serialize_get_size (handle->attrs);
+ env = GNUNET_MQ_msg_extra (crm,
+ attrs_len,
+ GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET_RESULT);
+ crm->id = htonl (handle->r_id);
+ crm->attrs_len = htons (attrs_len);
+ crm->identity = handle->ticket.identity;
+ data_tmp = (char *) &crm[1];
+ attribute_list_serialize (handle->attrs,
+ data_tmp);
GNUNET_MQ_send (handle->client->mq, env);
}
ch->r_id = ntohl (cm->id);
ch->client = idp;
ch->identity = cm->identity;
+ ch->attrs = GNUNET_new (struct GNUNET_IDENTITY_PROVIDER_AttributeList);
GNUNET_CRYPTO_ecdsa_key_get_public (&ch->identity,
&ch->identity_pub);
ch->ticket = *((struct GNUNET_IDENTITY_PROVIDER_Ticket2*)&cm[1]);
*/
static void
handle_ticket_iteration_start (void *cls,
- const struct TicketIterationStartMessage *tis_msg)
+ const struct TicketIterationStartMessage *tis_msg)
{
struct IdpClient *client = cls;
struct TicketIteration *ti;
*/
static void
handle_ticket_iteration_stop (void *cls,
- const struct TicketIterationStopMessage *tis_msg)
+ const struct TicketIterationStopMessage *tis_msg)
{
struct IdpClient *client = cls;
struct TicketIteration *ti;
*/
static void
handle_ticket_iteration_next (void *cls,
- const struct TicketIterationNextMessage *tis_msg)
+ const struct TicketIterationNextMessage *tis_msg)
{
struct IdpClient *client = cls;
struct TicketIteration *ti;
UNIX_MATCH_UID = NO
UNIX_MATCH_GID = YES
TOKEN_EXPIRATION_INTERVAL = 30 m
+DATABASE = sqlite
[identity-provider-sqlite]
FILENAME = $GNUNET_DATA_HOME/identity-provider/sqlite.db
//Followed by a serialized ticket
};
+/**
+ * Attribute list is returned from the idp.
+ */
+struct ConsumeTicketResultMessage
+{
+ /**
+ * Message header
+ */
+ struct GNUNET_MessageHeader header;
+
+ /**
+ * Unique identifier for this request (for key collisions).
+ */
+ uint32_t id GNUNET_PACKED;
+
+ /**
+ * Length of serialized attribute data
+ */
+ uint16_t attrs_len GNUNET_PACKED;
+
+ /**
+ * always zero (for alignment)
+ */
+ uint16_t reserved GNUNET_PACKED;
+
+ /**
+ * The public key of the identity.
+ */
+ struct GNUNET_CRYPTO_EcdsaPublicKey identity;
+
+ /* followed by:
+ * serialized attributes data
+ */
+};
+
+
GNUNET_NETWORK_STRUCT_END
}
+
+/**
+ * Handle an incoming message of type
+ * #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET_RESULT
+ *
+ * @param cls
+ * @param msg the message we received
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
+ */
+static int
+check_consume_ticket_result (void *cls,
+ const struct ConsumeTicketResultMessage *msg)
+{
+ size_t msg_len;
+ size_t attrs_len;
+
+ msg_len = ntohs (msg->header.size);
+ attrs_len = ntohs (msg->attrs_len);
+ if (msg_len != sizeof (struct ConsumeTicketResultMessage) + attrs_len)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+
+/**
+ * Handle an incoming message of type
+ * #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET_RESULT
+ *
+ * @param cls
+ * @param msg the message we received
+ */
+static void
+handle_consume_ticket_result (void *cls,
+ const struct ConsumeTicketResultMessage *msg)
+{
+ struct GNUNET_IDENTITY_PROVIDER_Handle *h = cls;
+ struct GNUNET_IDENTITY_PROVIDER_Operation *op;
+ size_t attrs_len;
+ uint32_t r_id = ntohl (msg->id);
+
+ attrs_len = ntohs (msg->attrs_len);
+ LOG (GNUNET_ERROR_TYPE_MESSAGE,
+ "Processing attribute result.\n");
+
+
+ for (op = h->op_head; NULL != op; op = op->next)
+ if (op->r_id == r_id)
+ break;
+ if (NULL == op)
+ return;
+
+ {
+ struct GNUNET_IDENTITY_PROVIDER_AttributeList *attrs;
+ struct GNUNET_IDENTITY_PROVIDER_AttributeListEntry *le;
+ attrs = attribute_list_deserialize ((char*)&msg[1],
+ attrs_len);
+ if (NULL != op->ar_cb)
+ {
+ for (le = attrs->list_head; NULL != le; le = le->next)
+ op->ar_cb (op->cls,
+ &msg->identity,
+ le->attribute);
+ }
+ attribute_list_destroy (attrs);
+ op->ar_cb (op->cls,
+ NULL,
+ NULL);
+ GNUNET_CONTAINER_DLL_remove (h->op_head,
+ h->op_tail,
+ op);
+ GNUNET_free (op);
+ return;
+ }
+ GNUNET_assert (0);
+}
+
+
/**
* Handle an incoming message of type
* #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_RESULT
*/
static void
handle_attribute_result (void *cls,
- const struct AttributeResultMessage *msg)
+ const struct AttributeResultMessage *msg)
{
static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
struct GNUNET_IDENTITY_PROVIDER_Handle *h = cls;
GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_RESULT,
struct TicketResultMessage,
h),
+ GNUNET_MQ_hd_var_size (consume_ticket_result,
+ GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET_RESULT,
+ struct ConsumeTicketResultMessage,
+ h),
GNUNET_MQ_handler_end ()
};
struct GNUNET_IDENTITY_PROVIDER_Operation *op;
* a failure of the command 'cmd' on file 'filename'
* with the message given by strerror(errno).
*/
-#define LOG_SQLITE(db, level, cmd) do { GNUNET_log_from (level, "namestore-identity-provider", _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, sqlite3_errmsg(db->dbh)); } while(0)
+#define LOG_SQLITE(db, level, cmd) do { GNUNET_log_from (level, "identity-provider", _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, sqlite3_errmsg(db->dbh)); } while(0)
-#define LOG(kind,...) GNUNET_log_from (kind, "namestore-sqlite", __VA_ARGS__)
+#define LOG(kind,...) GNUNET_log_from (kind, "identity-provider-sqlite", __VA_ARGS__)
/**
sqlite3_finalize (plugin->delete_ticket);
if (NULL != plugin->iterate_tickets)
sqlite3_finalize (plugin->iterate_tickets);
+ if (NULL != plugin->iterate_tickets_by_audience)
+ sqlite3_finalize (plugin->iterate_tickets_by_audience);
result = sqlite3_close (plugin->dbh);
if (result == SQLITE_BUSY)
{
* @return always NULL
*/
void *
-libgnunet_plugin_namestore_sqlite_done (void *cls)
+libgnunet_plugin_identity_provider_sqlite_done (void *cls)
{
struct GNUNET_IDENTITY_PROVIDER_PluginFunctions *api = cls;
struct Plugin *plugin = api->cls;
#!/bin/bash
-trap "gnunet-arm -e -c test_idp_lookup.conf" SIGINT
+trap "gnunet-arm -e -c test_idp.conf" SIGINT
LOCATION=$(which gnunet-config)
if [ -z $LOCATION ]
#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET 973
-#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_START 974
+#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET_RESULT 974
-#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_STOP 975
+#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_START 975
-#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_NEXT 976
+#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_STOP 976
+
+#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_NEXT 977
/**************************************************
*