aboutsummaryrefslogtreecommitdiff
path: root/src/identity-provider/identity_provider_api.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2017-09-17 21:06:42 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2017-09-17 21:06:42 +0200
commit0469377fd49450c1d7853c5ceecf08be9ce8df75 (patch)
tree847fd99b23035611d0dbb6a12e548a9a1b196bf6 /src/identity-provider/identity_provider_api.c
parent67e0d73709ef557b52ba0527291d68c17fd6c60a (diff)
downloadgnunet-0469377fd49450c1d7853c5ceecf08be9ce8df75.tar.gz
gnunet-0469377fd49450c1d7853c5ceecf08be9ce8df75.zip
- rework issue api
Diffstat (limited to 'src/identity-provider/identity_provider_api.c')
-rw-r--r--src/identity-provider/identity_provider_api.c118
1 files changed, 117 insertions, 1 deletions
diff --git a/src/identity-provider/identity_provider_api.c b/src/identity-provider/identity_provider_api.c
index c806735f6..74d15bbe0 100644
--- a/src/identity-provider/identity_provider_api.c
+++ b/src/identity-provider/identity_provider_api.c
@@ -81,6 +81,11 @@ struct GNUNET_IDENTITY_PROVIDER_Operation
81 GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus as_cb; 81 GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus as_cb;
82 82
83 /** 83 /**
84 * Ticket result callback
85 */
86 GNUNET_IDENTITY_PROVIDER_TicketCallback tr_cb;
87
88 /**
84 * Envelope with the message for this queue entry. 89 * Envelope with the message for this queue entry.
85 */ 90 */
86 struct GNUNET_MQ_Envelope *env; 91 struct GNUNET_MQ_Envelope *env;
@@ -590,6 +595,62 @@ handle_attribute_result (void *cls,
590 GNUNET_assert (0); 595 GNUNET_assert (0);
591} 596}
592 597
598/**
599 * Handle an incoming message of type
600 * #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_RESULT
601 *
602 * @param cls
603 * @param msg the message we received
604 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
605 */
606static int
607check_ticket_result (void *cls,
608 const struct TicketResultMessage *msg)
609{
610 size_t msg_len;
611
612 msg_len = ntohs (msg->header.size);
613 if (msg_len < sizeof (struct TicketResultMessage))
614 {
615 GNUNET_break (0);
616 return GNUNET_SYSERR;
617 }
618 return GNUNET_OK;
619}
620
621
622
623/**
624 * Handle an incoming message of type
625 * #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_RESULT
626 *
627 * @param cls
628 * @param msg the message we received
629 */
630static void
631handle_ticket_result (void *cls,
632 const struct TicketResultMessage *msg)
633{
634 struct GNUNET_IDENTITY_PROVIDER_Handle *handle = cls;
635 struct GNUNET_IDENTITY_PROVIDER_Operation *op;
636 const struct GNUNET_IDENTITY_PROVIDER_Ticket2 *ticket;
637 uint32_t r_id = ntohl (msg->id);
638
639 for (op = handle->op_head; NULL != op; op = op->next)
640 if (op->r_id == r_id)
641 break;
642 if (NULL == op)
643 return;
644 GNUNET_CONTAINER_DLL_remove (handle->op_head,
645 handle->op_tail,
646 op);
647 ticket = (struct GNUNET_IDENTITY_PROVIDER_Ticket2 *)&msg[1];
648 if (NULL != op->tr_cb)
649 op->tr_cb (op->cls, ticket);
650 GNUNET_free (op);
651
652}
653
593 654
594 655
595/** 656/**
@@ -617,6 +678,10 @@ reconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h)
617 GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_RESULT, 678 GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_RESULT,
618 struct AttributeResultMessage, 679 struct AttributeResultMessage,
619 h), 680 h),
681 GNUNET_MQ_hd_var_size (ticket_result,
682 GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_RESULT,
683 struct TicketResultMessage,
684 h),
620 GNUNET_MQ_handler_end () 685 GNUNET_MQ_handler_end ()
621 }; 686 };
622 struct GNUNET_IDENTITY_PROVIDER_Operation *op; 687 struct GNUNET_IDENTITY_PROVIDER_Operation *op;
@@ -1072,7 +1137,58 @@ GNUNET_IDENTITY_PROVIDER_get_attributes_stop (struct GNUNET_IDENTITY_PROVIDER_At
1072} 1137}
1073 1138
1074 1139
1140/** TODO
1141 * Issues a ticket to another identity. The identity may use
1142 * @GNUNET_IDENTITY_PROVIDER_authorization_ticket_consume to consume the ticket
1143 * and retrieve the attributes specified in the AttributeList.
1144 *
1145 * @param h the identity provider to use
1146 * @param iss the issuing identity
1147 * @param rp the subject of the ticket (the relying party)
1148 * @param attr the attributes that the relying party is given access to
1149 * @param cb the callback
1150 * @param cb_cls the callback closure
1151 * @return handle to abort the operation
1152 */
1153struct GNUNET_IDENTITY_PROVIDER_Operation *
1154GNUNET_IDENTITY_PROVIDER_idp_ticket_issue (struct GNUNET_IDENTITY_PROVIDER_Handle *h,
1155 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
1156 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
1157 const struct GNUNET_IDENTITY_PROVIDER_AttributeList *attrs,
1158 GNUNET_IDENTITY_PROVIDER_TicketCallback cb,
1159 void *cb_cls)
1160{
1161 struct GNUNET_IDENTITY_PROVIDER_Operation *op;
1162 struct TicketIssueMessage *tim;
1163 size_t attr_len;
1164
1165 op = GNUNET_new (struct GNUNET_IDENTITY_PROVIDER_Operation);
1166 op->h = h;
1167 op->tr_cb = cb;
1168 op->cls = cb_cls;
1169 op->r_id = h->r_id_gen++;
1170 GNUNET_CONTAINER_DLL_insert_tail (h->op_head,
1171 h->op_tail,
1172 op);
1173 attr_len = attribute_list_serialize_get_size (attrs);
1174 op->env = GNUNET_MQ_msg_extra (tim,
1175 attr_len,
1176 GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ISSUE);
1177 tim->identity = *iss;
1178 tim->rp = *rp;
1179 tim->id = htonl (op->r_id);
1180
1181 attribute_list_serialize (attrs,
1182 (char*)&tim[1]);
1183
1184 tim->attr_len = htons (attr_len);
1185 if (NULL != h->mq)
1186 GNUNET_MQ_send_copy (h->mq,
1187 op->env);
1188 return op;
1189}
1190
1075 1191
1076 1192
1077 1193
1078 /* end of identity_provider_api.c */ 1194/* end of identity_provider_api.c */