diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-04-21 11:43:38 +0200 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-04-21 11:43:38 +0200 |
commit | 316a9ea66e029fc0ced2c76de42ba044d377ccec (patch) | |
tree | c710c1378e6583316643220b8db22f022b1e3180 | |
parent | 8e4c4ea64be4bf099afb8ffd1fd24aae0b68003b (diff) |
-use new retrieval api
-rw-r--r-- | src/reclaim/plugin_reclaim_credential_pabc.c | 65 |
1 files changed, 16 insertions, 49 deletions
diff --git a/src/reclaim/plugin_reclaim_credential_pabc.c b/src/reclaim/plugin_reclaim_credential_pabc.c index f17925248..c993ba485 100644 --- a/src/reclaim/plugin_reclaim_credential_pabc.c +++ b/src/reclaim/plugin_reclaim_credential_pabc.c @@ -228,50 +228,6 @@ pabc_parse_attributes_p (void *cls, return pabc_parse_attributes (cls, cred->data, cred->data_size); } -struct Finder -{ - const char* target; - char *result; -}; - -static void -find_attr (char const *const key, - char const *const value, - void *ctx) -{ - struct Finder *fdr = ctx; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Found `%s', looking for `%s'\n", - key, fdr->target); - if (0 == strcmp (key, fdr->target)) - fdr->result = GNUNET_strdup (value); -} - - -/** - * Parse a pabc and return an attribute value. - * - * @param cls the plugin - * @param data the pabc credential data - * @param data_size the pabc credential size - * @param skey the attribute key to look for. - * @return a string, containing the isser - */ -char * -pabc_get_attribute (void *cls, - const char *data, - size_t data_size, - const char *skey) -{ - - struct Finder fdr; - memset (&fdr, 0, sizeof (fdr)); - fdr.target = skey; - pabc_cred_inspect_credential (data, &find_attr, &fdr); - return fdr.result; -} - - /** * Parse a pabc and return the issuer * @@ -284,7 +240,12 @@ pabc_get_issuer (void *cls, const char *data, size_t data_size) { - return pabc_get_attribute (cls, data, data_size, "issuer"); + char *res; + if (PABC_OK != pabc_cred_get_attr_by_name_from_cred (data, + "issuer", + &res)) + return NULL; + return res; } @@ -456,10 +417,16 @@ pabc_create_presentation (void *cls, GNUNET_free (issuer); return GNUNET_SYSERR; } - subject = pabc_get_attribute (cls, - credential->data, - credential->data_size, - "subject"); + if (PABC_OK != pabc_cred_get_attr_by_name_from_cred (credential->data, + "subject", + &subject)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Failed to get subject.\n"); + pabc_free_ctx (&ctx); + GNUNET_free (issuer); + return GNUNET_SYSERR; + } status = PABC_read_usr_ctx (subject, issuer, ctx, pp, &usr_ctx); GNUNET_free (issuer); GNUNET_free (subject); |