-fix
authorSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>
Mon, 4 Dec 2017 16:10:54 +0000 (17:10 +0100)
committerSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>
Mon, 4 Dec 2017 16:10:54 +0000 (17:10 +0100)
src/identity-attribute/identity_attribute.c
src/identity-attribute/plugin_identity_attribute_gnuid.c
src/identity-provider/gnunet-idp.c
src/include/gnunet_identity_attribute_lib.h

index 05cdcdaf02d36ec587ab3a97a7a7ffac79c4ee44..a8aae6ced7593da8382436837fd1cedb80243ddc 100644 (file)
@@ -88,7 +88,7 @@ init()
   if (GNUNET_YES == initialized)
     return;
   initialized = GNUNET_YES;
-  GNUNET_PLUGIN_load_all ("libgnunet_plugin_attribute_", NULL,
+  GNUNET_PLUGIN_load_all ("libgnunet_plugin_identity_attribute_", NULL,
                           &add_plugin, NULL);
 }
 
@@ -151,7 +151,7 @@ GNUNET_IDENTITY_ATTRIBUTE_number_to_typename (uint32_t type)
  * @return #GNUNET_OK on success
  */
 int
-GNUNET_IDENTITY_ATTRIBUTE_string_to_claim (uint32_t type,
+GNUNET_IDENTITY_ATTRIBUTE_string_to_value (uint32_t type,
                                            const char *s,
                                            void **data,
                                            size_t *data_size)
@@ -182,7 +182,7 @@ GNUNET_IDENTITY_ATTRIBUTE_string_to_claim (uint32_t type,
  * @return NULL on error, otherwise human-readable representation of the claim
  */
 char *
-GNUNET_IDENTITY_ATTRIBUTE_claim_to_string (uint32_t type,
+GNUNET_IDENTITY_ATTRIBUTE_value_to_string (uint32_t type,
                                            const void* data,
                                            size_t data_size)
 {
index ba460d0a57eb540d99013e7ae280eb1609ff1332..0ff44d1993f03c978866e0354ca96c8a2d5e3748 100644 (file)
@@ -153,7 +153,7 @@ gnuid_number_to_typename (void *cls,
  * @return the exported block API
  */
 void *
-libgnunet_plugin_attribute_type_gnuid_init (void *cls)
+libgnunet_plugin_identity_attribute_gnuid_init (void *cls)
 {
   struct GNUNET_IDENTITY_ATTRIBUTE_PluginFunctions *api;
 
@@ -173,7 +173,7 @@ libgnunet_plugin_attribute_type_gnuid_init (void *cls)
  * @return NULL
  */
 void *
-libgnunet_plugin_attribute_type_gnuid_done (void *cls)
+libgnunet_plugin_identity_attribute_gnuid_done (void *cls)
 {
   struct GNUNET_IDENTITY_ATTRIBUTE_PluginFunctions *api = cls;
 
index 78da1cb4d10ce0e3347961c9f75a577222c50eab..62f07842b9089d0d919c074102c9f39cee60a907 100644 (file)
@@ -66,6 +66,11 @@ static char* issue_attrs;
  */
 static char* consume_ticket;
 
+/**
+ * Attribute type
+ */
+static char* type_str;
+
 /**
  * Ticket to revoke
  */
@@ -168,7 +173,7 @@ process_attrs (void *cls,
          const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
          const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr)
 {
-  char *claim;
+  char *value_str;
   if (NULL == identity)
   {
     GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
@@ -179,11 +184,11 @@ process_attrs (void *cls,
     ret = 1;
     return;
   }
-  claim = GNUNET_IDENTITY_ATTRIBUTE_claim_to_string (attr->type,
+  value_str = GNUNET_IDENTITY_ATTRIBUTE_value_to_string (attr->type,
                                                      attr->data,
                                                      attr->data_size);
   GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-              "%s: %s\n", attr->name, claim);
+              "%s: %s\n", attr->name, value_str);
 }
 
 
@@ -211,7 +216,10 @@ process_rvk (void *cls, int success, const char* msg)
 static void
 iter_finished (void *cls)
 {
-  struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr;
+  struct GNUNET_IDENTITY_ATTRIBUTE_Claim *claim;
+  char *data;
+  size_t data_size;
+  int type;
 
   attr_iterator = NULL;
   if (list)
@@ -248,13 +256,22 @@ iter_finished (void *cls)
                                                      NULL);
     return;
   }
-  attr = GNUNET_IDENTITY_ATTRIBUTE_claim_new (attr_name,
-                                              GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING,
-                                              attr_value,
-                                              strlen (attr_value) + 1);
+  if (NULL == type_str)
+    type = GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING;
+  else
+    type = GNUNET_IDENTITY_ATTRIBUTE_typename_to_number (type_str);
+
+  GNUNET_assert (GNUNET_SYSERR != GNUNET_IDENTITY_ATTRIBUTE_string_to_value (type,
+                                             attr_value,
+                                             (void**)&data,
+                                             &data_size));
+  claim = GNUNET_IDENTITY_ATTRIBUTE_claim_new (attr_name,
+                                               type,
+                                               data,
+                                               data_size);
   idp_op = GNUNET_IDENTITY_PROVIDER_attribute_store (idp_handle,
                                                      pkey,
-                                                     attr,
+                                                     claim,
                                                      &store_attr_cont,
                                                      NULL);
 
@@ -408,6 +425,11 @@ main(int argc, char *const argv[])
                                  NULL,
                                  gettext_noop ("Revoke a ticket"),
                                  &revoke_ticket),
+    GNUNET_GETOPT_option_string ('t',
+                                 "type",
+                                 NULL,
+                                 gettext_noop ("Type of attribute"),
+                                 &type_str),
     GNUNET_GETOPT_OPTION_END
   };
   GNUNET_PROGRAM_run (argc, argv, "ct",
index 4e32c2ae118eda8c2699d78955b37be0e5d03f94..a43b509da40f6f9941d7a3d0791f097d650c0f63 100644 (file)
@@ -233,7 +233,7 @@ GNUNET_IDENTITY_ATTRIBUTE_typename_to_number (const char *typename);
  * @return #GNUNET_OK on success
  */
 int
-GNUNET_IDENTITY_ATTRIBUTE_string_to_claim (uint32_t type,
+GNUNET_IDENTITY_ATTRIBUTE_string_to_value (uint32_t type,
                                            const char *s,
                                            void **data,
                                            size_t *data_size);
@@ -247,7 +247,7 @@ GNUNET_IDENTITY_ATTRIBUTE_string_to_claim (uint32_t type,
  * @return NULL on error, otherwise human-readable representation of the claim
  */
 char *
-GNUNET_IDENTITY_ATTRIBUTE_claim_to_string (uint32_t type,
+GNUNET_IDENTITY_ATTRIBUTE_value_to_string (uint32_t type,
                                            const void* data,
                                            size_t data_size);