From cc838240da0d28fa1fc6d7a97da2808a7a622365 Mon Sep 17 00:00:00 2001 From: "Schanzenbach, Martin" Date: Fri, 6 Oct 2017 16:50:32 +0200 Subject: -remove deprecated --- src/identity-provider/identity_provider_api.c | 362 +------------------------- 1 file changed, 6 insertions(+), 356 deletions(-) (limited to 'src/identity-provider/identity_provider_api.c') diff --git a/src/identity-provider/identity_provider_api.c b/src/identity-provider/identity_provider_api.c index 6ef1d470e..d623eaf3b 100644 --- a/src/identity-provider/identity_provider_api.c +++ b/src/identity-provider/identity_provider_api.c @@ -63,18 +63,6 @@ struct GNUNET_IDENTITY_PROVIDER_Operation */ const struct GNUNET_MessageHeader *msg; - /** - * Continuation to invoke with the result of the transmission; @e cb - * will be NULL in this case. - */ - GNUNET_IDENTITY_PROVIDER_ExchangeCallback ex_cb; - - /** - * Continuation to invoke with the result of the transmission for - * 'issue' operations (@e cont will be NULL in this case). - */ - GNUNET_IDENTITY_PROVIDER_IssueCallback iss_cb; - /** * Continuation to invoke after attribute store call */ @@ -403,151 +391,6 @@ mq_error_handler (void *cls, force_reconnect (handle); } -/** - * Check validity of message received from the service - * - * @param cls the `struct GNUNET_IDENTITY_PROVIDER_Handle *` - * @param result_msg the incoming message - */ -static int -check_exchange_result (void *cls, - const struct ExchangeResultMessage *erm) -{ - char *str; - size_t size = ntohs (erm->header.size); - - - str = (char *) &erm[0]; - if ( (size > sizeof (struct ExchangeResultMessage)) && - ('\0' != str[size - 1]) ) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - return GNUNET_OK; -} - - -/** - * Check validity of message received from the service - * - * @param cls the `struct GNUNET_IDENTITY_PROVIDER_Handle *` - * @param result_msg the incoming message - */ -static int -check_result (void *cls, - const struct IssueResultMessage *irm) -{ - char *str; - size_t size = ntohs (irm->header.size); - str = (char*) &irm[0]; - if ( (size > sizeof (struct IssueResultMessage)) && - ('\0' != str[size - 1]) ) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - return GNUNET_OK; -} - -/** - * Handler for messages received from the GNS service - * - * @param cls the `struct GNUNET_GNS_Handle *` - * @param loookup_msg the incoming message - */ -static void -handle_exchange_result (void *cls, - const struct ExchangeResultMessage *erm) -{ - struct GNUNET_IDENTITY_PROVIDER_Handle *handle = cls; - struct GNUNET_IDENTITY_PROVIDER_Operation *op; - struct GNUNET_IDENTITY_PROVIDER_Token token; - uint64_t ticket_nonce; - uint32_t r_id = ntohl (erm->id); - char *str; - - for (op = handle->op_head; NULL != op; op = op->next) - if (op->r_id == r_id) - break; - if (NULL == op) - return; - str = GNUNET_strdup ((char*)&erm[1]); - op = handle->op_head; - GNUNET_CONTAINER_DLL_remove (handle->op_head, - handle->op_tail, - op); - token.data = str; - ticket_nonce = ntohl (erm->ticket_nonce); - if (NULL != op->ex_cb) - op->ex_cb (op->cls, &token, ticket_nonce); - GNUNET_free (str); - GNUNET_free (op); - -} - -/** - * Handler for messages received from the GNS service - * - * @param cls the `struct GNUNET_GNS_Handle *` - * @param loookup_msg the incoming message - */ -static void -handle_result (void *cls, - const struct IssueResultMessage *irm) -{ - struct GNUNET_IDENTITY_PROVIDER_Handle *handle = cls; - struct GNUNET_IDENTITY_PROVIDER_Operation *op; - struct GNUNET_IDENTITY_PROVIDER_Token token; - struct GNUNET_IDENTITY_PROVIDER_Ticket ticket; - uint32_t r_id = ntohl (irm->id); - char *str; - char *label_str; - char *ticket_str; - char *token_str; - - for (op = handle->op_head; NULL != op; op = op->next) - if (op->r_id == r_id) - break; - if (NULL == op) - return; - str = GNUNET_strdup ((char*)&irm[1]); - label_str = strtok (str, ","); - - if (NULL == label_str) - { - GNUNET_free (str); - GNUNET_break (0); - return; - } - ticket_str = strtok (NULL, ","); - if (NULL == ticket_str) - { - GNUNET_free (str); - GNUNET_break (0); - return; - } - token_str = strtok (NULL, ","); - if (NULL == token_str) - { - GNUNET_free (str); - GNUNET_break (0); - return; - } - GNUNET_CONTAINER_DLL_remove (handle->op_head, - handle->op_tail, - op); - ticket.data = ticket_str; - token.data = token_str; - if (NULL != op->iss_cb) - op->iss_cb (op->cls, label_str, &ticket, &token); - GNUNET_free (str); - GNUNET_free (op); - -} - - - /** * Handle an incoming message of type * #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE @@ -824,7 +667,7 @@ handle_ticket_result (void *cls, struct GNUNET_IDENTITY_PROVIDER_Handle *handle = cls; struct GNUNET_IDENTITY_PROVIDER_Operation *op; struct GNUNET_IDENTITY_PROVIDER_TicketIterator *it; - const struct GNUNET_IDENTITY_PROVIDER_Ticket2 *ticket; + const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket; uint32_t r_id = ntohl (msg->id); size_t msg_len; @@ -847,7 +690,7 @@ handle_ticket_result (void *cls, if (NULL != op->tr_cb) op->tr_cb (op->cls, NULL); } else { - ticket = (struct GNUNET_IDENTITY_PROVIDER_Ticket2 *)&msg[1]; + ticket = (struct GNUNET_IDENTITY_PROVIDER_Ticket *)&msg[1]; if (NULL != op->tr_cb) op->tr_cb (op->cls, ticket); } @@ -863,7 +706,7 @@ handle_ticket_result (void *cls, it->finish_cb (it->finish_cb_cls); } else { - ticket = (struct GNUNET_IDENTITY_PROVIDER_Ticket2 *)&msg[1]; + ticket = (struct GNUNET_IDENTITY_PROVIDER_Ticket *)&msg[1]; if (NULL != it->tr_cb) it->tr_cb (it->cls, ticket); } @@ -888,14 +731,6 @@ reconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h) GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_STORE_RESPONSE, struct AttributeStoreResponseMessage, h), - GNUNET_MQ_hd_var_size (result, - GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ISSUE_RESULT, - struct IssueResultMessage, - h), - GNUNET_MQ_hd_var_size (exchange_result, - GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_EXCHANGE_RESULT, - struct ExchangeResultMessage, - h), GNUNET_MQ_hd_var_size (attribute_result, GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_RESULT, struct AttributeResultMessage, @@ -952,117 +787,6 @@ GNUNET_IDENTITY_PROVIDER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) } -/** - * Issue an identity token - * - * @param id identity service to query - * @param service_name for which service is an identity wanted - * @param cb function to call with the result (will only be called once) - * @param cb_cls closure for @a cb - * @return handle to abort the operation - */ -struct GNUNET_IDENTITY_PROVIDER_Operation * -GNUNET_IDENTITY_PROVIDER_issue_token (struct GNUNET_IDENTITY_PROVIDER_Handle *id, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss_key, - const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, - const char* scopes, - const char* vattr, - struct GNUNET_TIME_Absolute expiration, - uint64_t nonce, - GNUNET_IDENTITY_PROVIDER_IssueCallback cb, - void *cb_cls) -{ - struct GNUNET_IDENTITY_PROVIDER_Operation *op; - struct IssueMessage *im; - size_t slen; - - slen = strlen (scopes) + 1; - if (NULL != vattr) - slen += strlen (vattr) + 1; - if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct IssueMessage)) - { - GNUNET_break (0); - return NULL; - } - op = GNUNET_new (struct GNUNET_IDENTITY_PROVIDER_Operation); - op->h = id; - op->iss_cb = cb; - op->cls = cb_cls; - op->r_id = id->r_id_gen++; - op->env = GNUNET_MQ_msg_extra (im, - slen, - GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ISSUE); - im->id = op->r_id; - im->iss_key = *iss_key; - im->aud_key = *aud_key; - im->scope_len = htonl (strlen(scopes)+1); - im->nonce = htonl (nonce); - im->expiration = GNUNET_TIME_absolute_hton (expiration); - GNUNET_memcpy (&im[1], scopes, strlen(scopes)); - if (NULL != vattr) - GNUNET_memcpy ((char*)&im[1]+strlen(scopes)+1, vattr, strlen(vattr)); - GNUNET_CONTAINER_DLL_insert_tail (id->op_head, - id->op_tail, - op); - if (NULL != id->mq) - GNUNET_MQ_send_copy (id->mq, - op->env); - return op; -} - - -/** - * Exchange a token ticket for a token - * - * @param id identity provider service - * @param ticket ticket to exchange - * @param cont function to call once the operation finished - * @param cont_cls closure for @a cont - * @return handle to abort the operation - */ -struct GNUNET_IDENTITY_PROVIDER_Operation * -GNUNET_IDENTITY_PROVIDER_exchange_ticket (struct GNUNET_IDENTITY_PROVIDER_Handle *id, - const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *aud_privkey, - GNUNET_IDENTITY_PROVIDER_ExchangeCallback cont, - void *cont_cls) -{ - struct GNUNET_IDENTITY_PROVIDER_Operation *op; - struct ExchangeMessage *em; - size_t slen; - char *ticket_str; - - ticket_str = GNUNET_IDENTITY_PROVIDER_ticket_to_string (ticket); - - slen = strlen (ticket_str) + 1; - if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct ExchangeMessage)) - { - GNUNET_free (ticket_str); - GNUNET_break (0); - return NULL; - } - op = GNUNET_new (struct GNUNET_IDENTITY_PROVIDER_Operation); - op->h = id; - op->ex_cb = cont; - op->cls = cont_cls; - op->r_id = id->r_id_gen++; - op->env = GNUNET_MQ_msg_extra (em, - slen, - GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_EXCHANGE); - em->aud_privkey = *aud_privkey; - em->id = htonl (op->r_id); - GNUNET_memcpy (&em[1], ticket_str, slen); - GNUNET_free (ticket_str); - GNUNET_CONTAINER_DLL_insert_tail (id->op_head, - id->op_tail, - op); - if (NULL != id->mq) - GNUNET_MQ_send_copy (id->mq, - op->env); - return op; -} - - /** * Cancel an operation. Note that the operation MAY still * be executed; this merely cancels the continuation; if the request @@ -1107,80 +831,6 @@ GNUNET_IDENTITY_PROVIDER_disconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h) GNUNET_free (h); } -/** - * Convenience API - */ - - -/** - * Destroy token - * - * @param token the token - */ -void -GNUNET_IDENTITY_PROVIDER_token_destroy(struct GNUNET_IDENTITY_PROVIDER_Token *token) -{ - GNUNET_assert (NULL != token); - if (NULL != token->data) - GNUNET_free (token->data); - GNUNET_free (token); -} - -/** - * Returns string representation of token. A JSON-Web-Token. - * - * @param token the token - * @return The JWT (must be freed) - */ -char * -GNUNET_IDENTITY_PROVIDER_token_to_string (const struct GNUNET_IDENTITY_PROVIDER_Token *token) -{ - return GNUNET_strdup (token->data); -} - -/** - * Returns string representation of ticket. Base64-Encoded - * - * @param ticket the ticket - * @return the Base64-Encoded ticket - */ -char * -GNUNET_IDENTITY_PROVIDER_ticket_to_string (const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket) -{ - return GNUNET_strdup (ticket->data); -} - -/** - * Created a ticket from a string (Base64 encoded ticket) - * - * @param input Base64 encoded ticket - * @param ticket pointer where the ticket is stored - * @return GNUNET_OK - */ -int -GNUNET_IDENTITY_PROVIDER_string_to_ticket (const char* input, - struct GNUNET_IDENTITY_PROVIDER_Ticket **ticket) -{ - *ticket = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_PROVIDER_Ticket)); - (*ticket)->data = GNUNET_strdup (input); - return GNUNET_OK; -} - - -/** - * Destroys a ticket - * - * @param ticket the ticket to destroy - */ -void -GNUNET_IDENTITY_PROVIDER_ticket_destroy(struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket) -{ - GNUNET_assert (NULL != ticket); - if (NULL != ticket->data) - GNUNET_free (ticket->data); - GNUNET_free (ticket); -} - /** * Store an attribute. If the attribute is already present, * it is replaced with the new attribute. @@ -1428,7 +1078,7 @@ GNUNET_IDENTITY_PROVIDER_idp_ticket_issue (struct GNUNET_IDENTITY_PROVIDER_Handl 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, + const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, GNUNET_IDENTITY_PROVIDER_AttributeResult cb, void *cb_cls) { @@ -1444,14 +1094,14 @@ GNUNET_IDENTITY_PROVIDER_rp_ticket_consume (struct GNUNET_IDENTITY_PROVIDER_Hand h->op_tail, op); op->env = GNUNET_MQ_msg_extra (ctm, - sizeof (const struct GNUNET_IDENTITY_PROVIDER_Ticket2), + sizeof (const struct GNUNET_IDENTITY_PROVIDER_Ticket), GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET); ctm->identity = *identity; ctm->id = htonl (op->r_id); GNUNET_memcpy ((char*)&ctm[1], ticket, - sizeof (const struct GNUNET_IDENTITY_PROVIDER_Ticket2)); + sizeof (const struct GNUNET_IDENTITY_PROVIDER_Ticket)); if (NULL != h->mq) GNUNET_MQ_send_copy (h->mq, -- cgit v1.2.3