keygen/src/iam.c
/**
 * ep_auth_resp_unmarshal() - Process the response from IAM endpoints API
 * @ep: The JSON string represneing a xiam.ENDPOINT object
 * @ep_ret: A structure to write the return data into
 *
 * Return: The new endpoint
 */
Process the response from IAM endpoints API
@ep: The JSON string represneing a xiam.ENDPOINT object
@ep_ret: A structure to write the return data into

The new endpoint
Process the response from IAM endpoints API @ep : The JSON string represneing a xiam . ENDPOINT object @ep_ret : A structure to write the return data into The new endpoint
int ep_auth_resp_unmarshal(char *ep, struct iam_endpoint *ep_ret)
{
    json_error_t jerror;
    json_t *root = NULL;
    json_t *active_credentials = NULL;
    int ret = 0;
    memset(ep_ret, 0, sizeof(*ep_ret));
    root = json_loads(ep, 0, &jerror);
    if (!root) {
        goto cleanup_err;
    }
    active_credentials = json_object_get(root, "active_credentials");
    active_credentials = json_array_get(json_object_get(active_credentials, "body"), 0);
    if (!active_credentials) {
        goto cleanup_err;
    }
    ep_auth_resp_set_common(root, ep_ret);
    if(strcmp(type_daa_lrsw_bn256, json_string_value(json_object_get(active_credentials, "type"))) == 0)
        ep_auth_resp_set_daa(active_credentials, ep_ret);
    else if (strcmp(type_ecdsa_p256, json_string_value(json_object_get(active_credentials, "type"))) == 0)
        ep_auth_resp_set_ecdsa(active_credentials, ep_ret);
    else
        goto cleanup_err;
    if(!ep_ret->creation_timestamp || !ep_ret->modification_timestamp)
        goto out;
    if (ep_ret->type != EP_DAA && ep_ret->type != EP_ECDSA)
            goto cleanup_err;
    else if (ep_ret->type == EP_DAA && (!ep_ret->active_credentials.daa.creation_timestamp || !ep_ret->active_credentials.daa.pseudonym))
        goto cleanup_err;
    else if (ep_ret->type == EP_ECDSA && (!ep_ret->active_credentials.ecdsa.creation_timestamp || !ep_ret->active_credentials.ecdsa.key))
        goto cleanup_err;
    ret = 1;
    goto out;
cleanup_err:
    ret = 0;
    ep_auth_resp_destroy(ep_ret);
out:
    if (root)
        json_decref(root);
    return ret;
}
int ep_auth_resp_unmarshal ( char * ep , struct iam_endpoint * ep_ret ) { json_error_t jerror ; json_t * root = NULL ; json_t * active_credentials = NULL ; int ret = 0 ; memset ( ep_ret , 0 , sizeof ( * ep_ret ) ) ; root = json_loads ( ep , 0 , & jerror ) ; if ( ! root ) { goto cleanup_err ; } active_credentials = json_object_get ( root , " " ) ; active_credentials = json_array_get ( json_object_get ( active_credentials , " " ) , 0 ) ; if ( ! active_credentials ) { goto cleanup_err ; } ep_auth_resp_set_common ( root , ep_ret ) ; if ( strcmp ( type_daa_lrsw_bn256 , json_string_value ( json_object_get ( active_credentials , " " ) ) ) == 0 ) ep_auth_resp_set_daa ( active_credentials , ep_ret ) ; else if ( strcmp ( type_ecdsa_p256 , json_string_value ( json_object_get ( active_credentials , " " ) ) ) == 0 ) ep_auth_resp_set_ecdsa ( active_credentials , ep_ret ) ; else goto cleanup_err ; if ( ! ep_ret -> creation_timestamp || ! ep_ret -> modification_timestamp ) goto out ; if ( ep_ret -> type != EP_DAA && ep_ret -> type != EP_ECDSA ) goto cleanup_err ; else if ( ep_ret -> type == EP_DAA && ( ! ep_ret -> active_credentials . daa . creation_timestamp || ! ep_ret -> active_credentials . daa . pseudonym ) ) goto cleanup_err ; else if ( ep_ret -> type == EP_ECDSA && ( ! ep_ret -> active_credentials . ecdsa . creation_timestamp || ! ep_ret -> active_credentials . ecdsa . key ) ) goto cleanup_err ; ret = 1 ; goto out ; cleanup_err : ret = 0 ; ep_auth_resp_destroy ( ep_ret ) ; out : if ( root ) json_decref ( root ) ; return ret ; }
ep_auth_resp_unmarshal() - Process the response from IAM endpoints API
 @ep: The JSON string represneing a xiam.ENDPOINT object
 @ep_ret: A structure to write the return data into
ep_auth_resp_unmarshal () - Process the response from IAM endpoints API @ep : The JSON string represneing a xiam . ENDPOINT object @ep_ret : A structure to write the return data into
/* Json holders */ /* Zero out the return struct to make bad input distinct from allocated pointers on error */ /* Determine if an active credntial was returned and abort if nothing is given */ /* Copy common elements */ /* Copy active credentials */ /* See if the necessary values are all present */ /* Common fields */ /* Active credential types */ /* Success */