aboutsummaryrefslogtreecommitdiff
path: root/src/identity-provider/identity_provider_api.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2017-10-07 11:08:04 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2017-10-07 11:08:04 +0200
commitf12a22a2a9b6d71f0fc9d24940e77d84d6568da0 (patch)
treeb9febded7bcf40b6590249b78814630180f3786b /src/identity-provider/identity_provider_api.c
parentbada12fb79c54aa1151e86b0284e8b6f38fd020c (diff)
downloadgnunet-f12a22a2a9b6d71f0fc9d24940e77d84d6568da0.tar.gz
gnunet-f12a22a2a9b6d71f0fc9d24940e77d84d6568da0.zip
-add api impl for revocation
Diffstat (limited to 'src/identity-provider/identity_provider_api.c')
-rw-r--r--src/identity-provider/identity_provider_api.c107
1 files changed, 101 insertions, 6 deletions
diff --git a/src/identity-provider/identity_provider_api.c b/src/identity-provider/identity_provider_api.c
index 97ecc691c..fb9926a2c 100644
--- a/src/identity-provider/identity_provider_api.c
+++ b/src/identity-provider/identity_provider_api.c
@@ -72,6 +72,11 @@ struct GNUNET_IDENTITY_PROVIDER_Operation
72 * Attribute result callback 72 * Attribute result callback
73 */ 73 */
74 GNUNET_IDENTITY_PROVIDER_AttributeResult ar_cb; 74 GNUNET_IDENTITY_PROVIDER_AttributeResult ar_cb;
75
76 /**
77 * Revocation result callback
78 */
79 GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus rvk_cb;
75 80
76 /** 81 /**
77 * Ticket result callback 82 * Ticket result callback
@@ -400,7 +405,7 @@ mq_error_handler (void *cls,
400 */ 405 */
401static void 406static void
402handle_attribute_store_response (void *cls, 407handle_attribute_store_response (void *cls,
403 const struct AttributeStoreResponseMessage *msg) 408 const struct AttributeStoreResultMessage *msg)
404{ 409{
405 struct GNUNET_IDENTITY_PROVIDER_Handle *h = cls; 410 struct GNUNET_IDENTITY_PROVIDER_Handle *h = cls;
406 struct GNUNET_IDENTITY_PROVIDER_Operation *op; 411 struct GNUNET_IDENTITY_PROVIDER_Operation *op;
@@ -716,6 +721,48 @@ handle_ticket_result (void *cls,
716 GNUNET_break (0); 721 GNUNET_break (0);
717} 722}
718 723
724/**
725 * Handle an incoming message of type
726 * #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_REVOKE_TICKET_RESULT
727 *
728 * @param cls
729 * @param msg the message we received
730 */
731static void
732handle_revoke_ticket_result (void *cls,
733 const struct RevokeTicketResultMessage *msg)
734{
735 struct GNUNET_IDENTITY_PROVIDER_Handle *h = cls;
736 struct GNUNET_IDENTITY_PROVIDER_Operation *op;
737 uint32_t r_id = ntohl (msg->id);
738 int32_t success;
739
740 LOG (GNUNET_ERROR_TYPE_DEBUG,
741 "Processing revocation result.\n");
742
743
744 for (op = h->op_head; NULL != op; op = op->next)
745 if (op->r_id == r_id)
746 break;
747 if (NULL == op)
748 return;
749 success = ntohl (msg->success);
750 {
751 if (NULL != op->rvk_cb)
752 {
753 op->rvk_cb (op->cls,
754 success,
755 NULL);
756 }
757 GNUNET_CONTAINER_DLL_remove (h->op_head,
758 h->op_tail,
759 op);
760 GNUNET_free (op);
761 return;
762 }
763 GNUNET_assert (0);
764}
765
719 766
720 767
721/** 768/**
@@ -729,7 +776,7 @@ reconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h)
729 struct GNUNET_MQ_MessageHandler handlers[] = { 776 struct GNUNET_MQ_MessageHandler handlers[] = {
730 GNUNET_MQ_hd_fixed_size (attribute_store_response, 777 GNUNET_MQ_hd_fixed_size (attribute_store_response,
731 GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_STORE_RESPONSE, 778 GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_STORE_RESPONSE,
732 struct AttributeStoreResponseMessage, 779 struct AttributeStoreResultMessage,
733 h), 780 h),
734 GNUNET_MQ_hd_var_size (attribute_result, 781 GNUNET_MQ_hd_var_size (attribute_result,
735 GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_RESULT, 782 GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_RESULT,
@@ -743,6 +790,10 @@ reconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h)
743 GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET_RESULT, 790 GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET_RESULT,
744 struct ConsumeTicketResultMessage, 791 struct ConsumeTicketResultMessage,
745 h), 792 h),
793 GNUNET_MQ_hd_fixed_size (revoke_ticket_result,
794 GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_REVOKE_TICKET_RESULT,
795 struct RevokeTicketResultMessage,
796 h),
746 GNUNET_MQ_handler_end () 797 GNUNET_MQ_handler_end ()
747 }; 798 };
748 struct GNUNET_IDENTITY_PROVIDER_Operation *op; 799 struct GNUNET_IDENTITY_PROVIDER_Operation *op;
@@ -1077,10 +1128,10 @@ GNUNET_IDENTITY_PROVIDER_ticket_issue (struct GNUNET_IDENTITY_PROVIDER_Handle *h
1077 */ 1128 */
1078struct GNUNET_IDENTITY_PROVIDER_Operation * 1129struct GNUNET_IDENTITY_PROVIDER_Operation *
1079GNUNET_IDENTITY_PROVIDER_ticket_consume (struct GNUNET_IDENTITY_PROVIDER_Handle *h, 1130GNUNET_IDENTITY_PROVIDER_ticket_consume (struct GNUNET_IDENTITY_PROVIDER_Handle *h,
1080 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 1131 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1081 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, 1132 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
1082 GNUNET_IDENTITY_PROVIDER_AttributeResult cb, 1133 GNUNET_IDENTITY_PROVIDER_AttributeResult cb,
1083 void *cb_cls) 1134 void *cb_cls)
1084{ 1135{
1085 struct GNUNET_IDENTITY_PROVIDER_Operation *op; 1136 struct GNUNET_IDENTITY_PROVIDER_Operation *op;
1086 struct ConsumeTicketMessage *ctm; 1137 struct ConsumeTicketMessage *ctm;
@@ -1280,6 +1331,50 @@ GNUNET_IDENTITY_PROVIDER_ticket_iteration_stop (struct GNUNET_IDENTITY_PROVIDER_
1280 GNUNET_free (it); 1331 GNUNET_free (it);
1281} 1332}
1282 1333
1334/**
1335 * Revoked an issued ticket. The relying party will be unable to retrieve
1336 * updated attributes.
1337 *
1338 * @param id the identity provider to use
1339 * @param identity the issuing identity
1340 * @param ticket the ticket to revoke
1341 * @param cb the callback
1342 * @param cb_cls the callback closure
1343 * @return handle to abort the operation
1344 */
1345struct GNUNET_IDENTITY_PROVIDER_Operation *
1346GNUNET_IDENTITY_PROVIDER_ticket_revoke (struct GNUNET_IDENTITY_PROVIDER_Handle *h,
1347 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1348 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
1349 GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus cb,
1350 void *cb_cls)
1351{
1352 struct GNUNET_IDENTITY_PROVIDER_Operation *op;
1353 struct GNUNET_MQ_Envelope *env;
1354 struct RevokeTicketMessage *msg;
1355 uint32_t rid;
1356
1357 rid = h->r_id_gen++;
1358 op = GNUNET_new (struct GNUNET_IDENTITY_PROVIDER_Operation);
1359 op->h = h;
1360 op->rvk_cb = cb;
1361 op->cls = cb_cls;
1362 op->r_id = rid;
1363 GNUNET_CONTAINER_DLL_insert_tail (h->op_head,
1364 h->op_tail,
1365 op);
1366 env = GNUNET_MQ_msg (msg,
1367 GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_REVOKE_TICKET);
1368 msg->id = htonl (rid);
1369 msg->identity = *identity;
1370 if (NULL == h->mq)
1371 op->env = env;
1372 else
1373 GNUNET_MQ_send (h->mq,
1374 env);
1375 return op;
1376}
1377
1283 1378
1284 1379
1285/* end of identity_provider_api.c */ 1380/* end of identity_provider_api.c */