aboutsummaryrefslogtreecommitdiff
path: root/src/identity-provider/identity_provider_api.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2017-12-02 22:32:28 +0100
committerSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2017-12-02 22:32:28 +0100
commita9a7ac802811e76e33b54040bf31f00ea9438cea (patch)
tree7f9a22daca2b95e7308d8877c668fc878a39ae4c /src/identity-provider/identity_provider_api.c
parent14c62ed969ace8843154d10b55d4c3571383dc37 (diff)
downloadgnunet-a9a7ac802811e76e33b54040bf31f00ea9438cea.tar.gz
gnunet-a9a7ac802811e76e33b54040bf31f00ea9438cea.zip
-refactored
Diffstat (limited to 'src/identity-provider/identity_provider_api.c')
-rw-r--r--src/identity-provider/identity_provider_api.c49
1 files changed, 15 insertions, 34 deletions
diff --git a/src/identity-provider/identity_provider_api.c b/src/identity-provider/identity_provider_api.c
index 6d28709df..6fc8d228a 100644
--- a/src/identity-provider/identity_provider_api.c
+++ b/src/identity-provider/identity_provider_api.c
@@ -29,13 +29,12 @@
29#include "gnunet_protocols.h" 29#include "gnunet_protocols.h"
30#include "gnunet_mq_lib.h" 30#include "gnunet_mq_lib.h"
31#include "gnunet_identity_provider_service.h" 31#include "gnunet_identity_provider_service.h"
32#include "gnunet_identity_attribute_lib.h"
32#include "identity_provider.h" 33#include "identity_provider.h"
33#include "identity_attribute.h"
34 34
35#define LOG(kind,...) GNUNET_log_from (kind, "identity-api",__VA_ARGS__) 35#define LOG(kind,...) GNUNET_log_from (kind, "identity-api",__VA_ARGS__)
36 36
37 37
38
39/** 38/**
40 * Handle for an operation with the service. 39 * Handle for an operation with the service.
41 */ 40 */
@@ -495,9 +494,9 @@ handle_consume_ticket_result (void *cls,
495 return; 494 return;
496 495
497 { 496 {
498 struct GNUNET_IDENTITY_PROVIDER_AttributeList *attrs; 497 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs;
499 struct GNUNET_IDENTITY_PROVIDER_AttributeListEntry *le; 498 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le;
500 attrs = attribute_list_deserialize ((char*)&msg[1], 499 attrs = GNUNET_IDENTITY_ATTRIBUTE_list_deserialize ((char*)&msg[1],
501 attrs_len); 500 attrs_len);
502 if (NULL != op->ar_cb) 501 if (NULL != op->ar_cb)
503 { 502 {
@@ -512,8 +511,8 @@ handle_consume_ticket_result (void *cls,
512 for (le = attrs->list_head; NULL != le; le = le->next) 511 for (le = attrs->list_head; NULL != le; le = le->next)
513 op->ar_cb (op->cls, 512 op->ar_cb (op->cls,
514 &msg->identity, 513 &msg->identity,
515 le->attribute); 514 le->claim);
516 attribute_list_destroy (attrs); 515 GNUNET_IDENTITY_ATTRIBUTE_list_destroy (attrs);
517 } 516 }
518 } 517 }
519 op->ar_cb (op->cls, 518 op->ar_cb (op->cls,
@@ -619,9 +618,9 @@ handle_attribute_result (void *cls,
619 } 618 }
620 619
621 { 620 {
622 struct GNUNET_IDENTITY_PROVIDER_Attribute *attr; 621 struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr;
623 attr = attribute_deserialize ((char*)&msg[1], 622 attr = GNUNET_IDENTITY_ATTRIBUTE_deserialize ((char*)&msg[1],
624 attr_len); 623 attr_len);
625 if (NULL != it) 624 if (NULL != it)
626 { 625 {
627 if (NULL != it->proc) 626 if (NULL != it->proc)
@@ -905,7 +904,7 @@ GNUNET_IDENTITY_PROVIDER_disconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h)
905struct GNUNET_IDENTITY_PROVIDER_Operation * 904struct GNUNET_IDENTITY_PROVIDER_Operation *
906GNUNET_IDENTITY_PROVIDER_attribute_store (struct GNUNET_IDENTITY_PROVIDER_Handle *h, 905GNUNET_IDENTITY_PROVIDER_attribute_store (struct GNUNET_IDENTITY_PROVIDER_Handle *h,
907 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, 906 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
908 const struct GNUNET_IDENTITY_PROVIDER_Attribute *attr, 907 const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr,
909 GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus cont, 908 GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus cont,
910 void *cont_cls) 909 void *cont_cls)
911{ 910{
@@ -921,14 +920,14 @@ GNUNET_IDENTITY_PROVIDER_attribute_store (struct GNUNET_IDENTITY_PROVIDER_Handle
921 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, 920 GNUNET_CONTAINER_DLL_insert_tail (h->op_head,
922 h->op_tail, 921 h->op_tail,
923 op); 922 op);
924 attr_len = attribute_serialize_get_size (attr); 923 attr_len = GNUNET_IDENTITY_ATTRIBUTE_serialize_get_size (attr);
925 op->env = GNUNET_MQ_msg_extra (sam, 924 op->env = GNUNET_MQ_msg_extra (sam,
926 attr_len, 925 attr_len,
927 GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_STORE); 926 GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_STORE);
928 sam->identity = *pkey; 927 sam->identity = *pkey;
929 sam->id = htonl (op->r_id); 928 sam->id = htonl (op->r_id);
930 929
931 attribute_serialize (attr, 930 GNUNET_IDENTITY_ATTRIBUTE_serialize (attr,
932 (char*)&sam[1]); 931 (char*)&sam[1]);
933 932
934 sam->attr_len = htons (attr_len); 933 sam->attr_len = htons (attr_len);
@@ -941,24 +940,6 @@ GNUNET_IDENTITY_PROVIDER_attribute_store (struct GNUNET_IDENTITY_PROVIDER_Handle
941 940
942 941
943/** 942/**
944 * Create a new attribute.
945 *
946 * @param name the attribute name
947 * @param type the attribute type
948 * @param data the attribute value
949 * @param data_size the attribute value size
950 * @return the new attribute
951 */
952struct GNUNET_IDENTITY_PROVIDER_Attribute *
953GNUNET_IDENTITY_PROVIDER_attribute_new (const char* attr_name,
954 uint32_t attr_type,
955 const void* data,
956 size_t data_size)
957{
958 return attribute_new (attr_name, attr_type, data, data_size);
959}
960
961/**
962 * List all attributes for a local identity. 943 * List all attributes for a local identity.
963 * This MUST lock the `struct GNUNET_IDENTITY_PROVIDER_Handle` 944 * This MUST lock the `struct GNUNET_IDENTITY_PROVIDER_Handle`
964 * for any other calls than #GNUNET_IDENTITY_PROVIDER_get_attributes_next() and 945 * for any other calls than #GNUNET_IDENTITY_PROVIDER_get_attributes_next() and
@@ -1089,7 +1070,7 @@ struct GNUNET_IDENTITY_PROVIDER_Operation *
1089GNUNET_IDENTITY_PROVIDER_ticket_issue (struct GNUNET_IDENTITY_PROVIDER_Handle *h, 1070GNUNET_IDENTITY_PROVIDER_ticket_issue (struct GNUNET_IDENTITY_PROVIDER_Handle *h,
1090 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, 1071 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
1091 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, 1072 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
1092 const struct GNUNET_IDENTITY_PROVIDER_AttributeList *attrs, 1073 const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs,
1093 GNUNET_IDENTITY_PROVIDER_TicketCallback cb, 1074 GNUNET_IDENTITY_PROVIDER_TicketCallback cb,
1094 void *cb_cls) 1075 void *cb_cls)
1095{ 1076{
@@ -1105,7 +1086,7 @@ GNUNET_IDENTITY_PROVIDER_ticket_issue (struct GNUNET_IDENTITY_PROVIDER_Handle *h
1105 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, 1086 GNUNET_CONTAINER_DLL_insert_tail (h->op_head,
1106 h->op_tail, 1087 h->op_tail,
1107 op); 1088 op);
1108 attr_len = attribute_list_serialize_get_size (attrs); 1089 attr_len = GNUNET_IDENTITY_ATTRIBUTE_list_serialize_get_size (attrs);
1109 op->env = GNUNET_MQ_msg_extra (tim, 1090 op->env = GNUNET_MQ_msg_extra (tim,
1110 attr_len, 1091 attr_len,
1111 GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ISSUE_TICKET); 1092 GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ISSUE_TICKET);
@@ -1113,7 +1094,7 @@ GNUNET_IDENTITY_PROVIDER_ticket_issue (struct GNUNET_IDENTITY_PROVIDER_Handle *h
1113 tim->rp = *rp; 1094 tim->rp = *rp;
1114 tim->id = htonl (op->r_id); 1095 tim->id = htonl (op->r_id);
1115 1096
1116 attribute_list_serialize (attrs, 1097 GNUNET_IDENTITY_ATTRIBUTE_list_serialize (attrs,
1117 (char*)&tim[1]); 1098 (char*)&tim[1]);
1118 1099
1119 tim->attr_len = htons (attr_len); 1100 tim->attr_len = htons (attr_len);