aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/reclaim/plugin_reclaim_credential_pabc.c65
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,
228 return pabc_parse_attributes (cls, cred->data, cred->data_size); 228 return pabc_parse_attributes (cls, cred->data, cred->data_size);
229} 229}
230 230
231struct Finder
232{
233 const char* target;
234 char *result;
235};
236
237static void
238find_attr (char const *const key,
239 char const *const value,
240 void *ctx)
241{
242 struct Finder *fdr = ctx;
243 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
244 "Found `%s', looking for `%s'\n",
245 key, fdr->target);
246 if (0 == strcmp (key, fdr->target))
247 fdr->result = GNUNET_strdup (value);
248}
249
250
251/**
252 * Parse a pabc and return an attribute value.
253 *
254 * @param cls the plugin
255 * @param data the pabc credential data
256 * @param data_size the pabc credential size
257 * @param skey the attribute key to look for.
258 * @return a string, containing the isser
259 */
260char *
261pabc_get_attribute (void *cls,
262 const char *data,
263 size_t data_size,
264 const char *skey)
265{
266
267 struct Finder fdr;
268 memset (&fdr, 0, sizeof (fdr));
269 fdr.target = skey;
270 pabc_cred_inspect_credential (data, &find_attr, &fdr);
271 return fdr.result;
272}
273
274
275/** 231/**
276 * Parse a pabc and return the issuer 232 * Parse a pabc and return the issuer
277 * 233 *
@@ -284,7 +240,12 @@ pabc_get_issuer (void *cls,
284 const char *data, 240 const char *data,
285 size_t data_size) 241 size_t data_size)
286{ 242{
287 return pabc_get_attribute (cls, data, data_size, "issuer"); 243 char *res;
244 if (PABC_OK != pabc_cred_get_attr_by_name_from_cred (data,
245 "issuer",
246 &res))
247 return NULL;
248 return res;
288} 249}
289 250
290 251
@@ -456,10 +417,16 @@ pabc_create_presentation (void *cls,
456 GNUNET_free (issuer); 417 GNUNET_free (issuer);
457 return GNUNET_SYSERR; 418 return GNUNET_SYSERR;
458 } 419 }
459 subject = pabc_get_attribute (cls, 420 if (PABC_OK != pabc_cred_get_attr_by_name_from_cred (credential->data,
460 credential->data, 421 "subject",
461 credential->data_size, 422 &subject))
462 "subject"); 423 {
424 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
425 "Failed to get subject.\n");
426 pabc_free_ctx (&ctx);
427 GNUNET_free (issuer);
428 return GNUNET_SYSERR;
429 }
463 status = PABC_read_usr_ctx (subject, issuer, ctx, pp, &usr_ctx); 430 status = PABC_read_usr_ctx (subject, issuer, ctx, pp, &usr_ctx);
464 GNUNET_free (issuer); 431 GNUNET_free (issuer);
465 GNUNET_free (subject); 432 GNUNET_free (subject);