-minor fixed, start consume
authorSchanzenbach, Martin <mschanzenbach@posteo.de>
Sun, 17 Sep 2017 19:44:35 +0000 (21:44 +0200)
committerSchanzenbach, Martin <mschanzenbach@posteo.de>
Sun, 17 Sep 2017 19:44:35 +0000 (21:44 +0200)
src/identity-provider/gnunet-idp.c
src/identity-provider/gnunet-service-identity-provider.c
src/identity-provider/identity_provider.h
src/identity-provider/identity_provider_api.c
src/identity-provider/plugin_gnsrecord_identity_provider.c
src/include/gnunet_identity_provider_service.h

index fdd4720e07a59f963ef9c1c16848503d471a16a5..f85ede7aa0b95b1d28dc48efe13d849ae9dcb926 100644 (file)
@@ -138,9 +138,6 @@ store_attr_cont (void *cls,
                  int32_t success,
                  const char*emsg)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-              "Store continuation\n");
-
   if (GNUNET_SYSERR == success) {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "%s\n", emsg);
@@ -166,8 +163,6 @@ iter_finished (void *cls)
 {
   struct GNUNET_IDENTITY_PROVIDER_Attribute *attr;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-              "Attribute collection finished!\n");
   attr_iterator = NULL;
   if (list) {
     GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
@@ -187,9 +182,6 @@ iter_finished (void *cls)
                                                  GNUNET_IDENTITY_PROVIDER_AT_STRING,
                                                  attr_value,
                                                  strlen (attr_value));
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-              "Adding attribute\n");
-
   idp_op = GNUNET_IDENTITY_PROVIDER_attribute_store (idp_handle,
                                                      pkey,
                                                      attr,
index b481c00c07108ad64ca056d4aabc55d6a76d4176..0eb6599e64cc8f0683a2d90cc52df120902c7f54 100644 (file)
@@ -620,7 +620,7 @@ bootstrap_store_task (void *cls)
   rd[0].data_size = GNUNET_CRYPTO_cpabe_serialize_master_key (abh->abe_key,
                                                               (void**)&rd[0].data);
   rd[0].record_type = GNUNET_GNSRECORD_TYPE_ABE_MASTER;
-  rd[0].flags = GNUNET_GNSRECORD_RF_NONE | GNUNET_GNSRECORD_RF_PRIVATE;
+  rd[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE;
   rd[0].expiration_time = GNUNET_TIME_UNIT_HOURS.rel_value_us; //TODO sane?
   abh->ns_qe = GNUNET_NAMESTORE_records_store (ns_handle,
                                                &abh->identity,
@@ -1869,7 +1869,7 @@ attr_store_cont (void *cls,
     return;
   }
 
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Sending ATTRIBUTE_STORE_RESPONSE message\n");
   env = GNUNET_MQ_msg (acr_msg,
                        GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_STORE_RESPONSE);
@@ -1888,7 +1888,7 @@ attr_store_task (void *cls)
   char* buf;
   size_t buf_size;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Storing attribute\n");
   buf_size = attribute_serialize_get_size (as_handle->attribute);
   buf = GNUNET_malloc (buf_size);
@@ -1924,7 +1924,7 @@ static void
 store_after_abe_bootstrap (void *cls,
                            struct GNUNET_CRYPTO_AbeMasterKey *abe_key)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Finished ABE bootstrap\n");
   struct AttributeStoreHandle *ash = cls;
   ash->abe_key = abe_key;
@@ -1969,7 +1969,7 @@ handle_attribute_store_message (void *cls,
   struct AttributeStoreHandle *as_handle;
   struct IdpClient *idp = cls;
   size_t data_len;
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received ATTRIBUTE_STORE message\n");
 
   data_len = ntohs (sam->attr_len);
@@ -2059,7 +2059,7 @@ attr_iter_cb (void *cls,
                                                key,
                                                (void**)&attr_ser);
   GNUNET_CRYPTO_cpabe_delete_key (key);
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Found attribute: %s\n", label);
   env = GNUNET_MQ_msg_extra (arm,
                              msg_extra_len,
index 098885e3c0e14b4fa46e6064498571d179b13d1c..9b6fe6237d350fc3196275decd74c7b6702c8230 100644 (file)
@@ -367,6 +367,31 @@ struct TicketResultMessage
   uint32_t id GNUNET_PACKED;
 
 };
+
+/**
+ * Ticket consume message
+ */
+struct ConsumeTicketMessage
+{
+  /**
+   * Type will be #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ISSUE
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * Unique identifier for this request (for key collisions).
+   */
+  uint32_t id GNUNET_PACKED;
+
+  /**
+   * Identity.
+   */
+  struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
+
+  //Followed by a serialized ticket
+};
+
+
 GNUNET_NETWORK_STRUCT_END
 
 #endif
index 74d15bbe0be07b364c8327ba1746f66ac948ea05..25c14793da9e6452a1e5355829a1a92f648b7431 100644 (file)
@@ -80,6 +80,11 @@ struct GNUNET_IDENTITY_PROVIDER_Operation
    */
   GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus as_cb;
 
+  /**
+   * Attribute result callback
+   */
+  GNUNET_IDENTITY_PROVIDER_AttributeResult ar_cb;
+
   /**
    * Ticket result callback
    */
@@ -1188,6 +1193,52 @@ GNUNET_IDENTITY_PROVIDER_idp_ticket_issue (struct GNUNET_IDENTITY_PROVIDER_Handl
   return op;
 }
 
+/**
+ * Consumes an issued ticket. The ticket is persisted
+ * and used to retrieve identity information from the issuer
+ *
+ * @param id the identity provider to use
+ * @param identity the identity that is the subject of the issued ticket (the relying party)
+ * @param ticket the issued ticket to consume
+ * @param cb the callback to call
+ * @param cb_cls the callback closure
+ * @return handle to abort the operation
+ */
+struct GNUNET_IDENTITY_PROVIDER_Operation *
+GNUNET_IDENTITY_PROVIDER_rp_ticket_consume (struct GNUNET_IDENTITY_PROVIDER_Handle *h,
+                                            const struct GNUNET_CRYPTO_EcdsaPrivateKey * identity,
+                                            const struct GNUNET_IDENTITY_PROVIDER_Ticket2 *ticket,
+                                            GNUNET_IDENTITY_PROVIDER_AttributeResult cb,
+                                            void *cb_cls)
+{
+  struct GNUNET_IDENTITY_PROVIDER_Operation *op;
+  struct ConsumeTicketMessage *ctm;
+
+  op = GNUNET_new (struct GNUNET_IDENTITY_PROVIDER_Operation);
+  op->h = h;
+  op->ar_cb = cb;
+  op->cls = cb_cls;
+  op->r_id = h->r_id_gen++;
+  GNUNET_CONTAINER_DLL_insert_tail (h->op_head,
+                                    h->op_tail,
+                                    op);
+  op->env = GNUNET_MQ_msg_extra (ctm,
+                                 sizeof (const struct GNUNET_IDENTITY_PROVIDER_Ticket2),
+                                 GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ISSUE);
+  ctm->identity = *identity;
+  ctm->id = htonl (op->r_id);
+
+  GNUNET_memcpy ((char*)&ctm[1],
+                 ticket,
+                 sizeof (const struct GNUNET_IDENTITY_PROVIDER_Ticket2));
+
+  if (NULL != h->mq)
+    GNUNET_MQ_send_copy (h->mq,
+                         op->env);
+  return op;
+
+}
+
 
 
 
index 1f197378345569fbcef7c1cddaa2a924264cff27..cee0a95065b9f3c0a03d01e4b24fe8cb0611e412 100644 (file)
@@ -175,6 +175,8 @@ static struct {
 } name_map[] = {
   { "ID_ATTR", GNUNET_GNSRECORD_TYPE_ID_ATTR },
   { "ID_TOKEN", GNUNET_GNSRECORD_TYPE_ID_TOKEN },
+  { "ABE_KEY", GNUNET_GNSRECORD_TYPE_ABE_KEY },
+  { "ABE_MASTER", GNUNET_GNSRECORD_TYPE_ABE_MASTER },
   { "ID_TOKEN_METADATA", GNUNET_GNSRECORD_TYPE_ID_TOKEN_METADATA },
   { NULL, UINT32_MAX }
 };
@@ -229,7 +231,7 @@ number_to_typename (void *cls,
  * @return the exported block API
  */
 void *
-libgnunet_plugin_gnsrecord_identity_init (void *cls)
+libgnunet_plugin_gnsrecord_identity_provider_init (void *cls)
 {
   struct GNUNET_GNSRECORD_PluginFunctions *api;
 
@@ -249,7 +251,7 @@ libgnunet_plugin_gnsrecord_identity_init (void *cls)
  * @return NULL
  */
 void *
-libgnunet_plugin_gnsrecord_identity_done (void *cls)
+libgnunet_plugin_gnsrecord_identity_provider_done (void *cls)
 {
   struct GNUNET_GNSRECORD_PluginFunctions *api = cls;
 
index 7aaae2e85f25a68823e16f5f04c024078c7234b8..4b1dcd641358d745b6cebf480d8d5bc6328e4897 100644 (file)
@@ -403,7 +403,7 @@ GNUNET_IDENTITY_PROVIDER_idp_ticket_revoke (struct GNUNET_IDENTITY_PROVIDER_Hand
 struct GNUNET_IDENTITY_PROVIDER_Operation *
 GNUNET_IDENTITY_PROVIDER_rp_ticket_consume (struct GNUNET_IDENTITY_PROVIDER_Handle *id,
                                             const struct GNUNET_CRYPTO_EcdsaPrivateKey * identity,
-                                            const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
+                                            const struct GNUNET_IDENTITY_PROVIDER_Ticket2 *ticket,
                                             GNUNET_IDENTITY_PROVIDER_AttributeResult cb,
                                             void *cb_cls);