AXIS2_EXTERN axis2_status_t AXIS2_CALL
oxs_xml_enc_decrypt_node(
    const axutil_env_t *env,
    oxs_ctx_t * enc_ctx,
    axiom_node_t *enc_type_node,
    axiom_node_t **decrypted_node)
{
    axiom_node_t *deserialized_node = NULL;
    axiom_node_t *parent_of_enc_node = NULL;
    oxs_buffer_t *result_buf = NULL;
    axis2_char_t *decrypted_data = NULL;/*Can be either am XML-Element or XML-Content*/
    axis2_status_t status = AXIS2_FAILURE;

    /*Create an empty buffer for results*/
    result_buf = oxs_buffer_create(env);

    /*Decrypt*/
    status = oxs_xml_enc_decrypt_data(env, enc_ctx, enc_type_node, result_buf);
    if(AXIS2_FAILURE == status)
    {
        oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_ENCRYPT_FAILED, "Data encryption failed");
        return AXIS2_FAILURE;
    }
    decrypted_data = axutil_strmemdup(oxs_buffer_get_data(result_buf, env), oxs_buffer_get_size(
        result_buf, env), env);
    /*De-serialize the decrypted content to build the node*/
    deserialized_node = (axiom_node_t*)oxs_axiom_deserialize_node(env, decrypted_data);
    if(!deserialized_node)
    {
        oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_ENCRYPT_FAILED,
            "Cannot deserialize a node from the content.\n%s", decrypted_data);
        return AXIS2_FAILURE;
    }
    /*Assign deserialized_node to the reference passed*/
    *decrypted_node = deserialized_node;

    /*Replace the encrypted node with the de-serialized node*/
    parent_of_enc_node = axiom_node_get_parent(enc_type_node, env);

    axiom_node_insert_sibling_after(enc_type_node, env, deserialized_node);
    axiom_node_free_tree(enc_type_node, env);
    enc_type_node = NULL;

    /*Free result buf*/

    oxs_buffer_free(result_buf, env);
    result_buf = NULL;

    AXIS2_FREE(env->allocator, decrypted_data);
    decrypted_data = NULL;

    return AXIS2_SUCCESS;
}
Beispiel #2
0
AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
axis2_svc_get_rest_op_list_with_method_and_location(
    const axis2_svc_t * svc,
    const axutil_env_t * env,
    const axis2_char_t * method,
    const axis2_char_t * location)
{
    axutil_array_list_t *op_list = NULL;
    axis2_char_t *key = NULL;
    axis2_char_t *loc_str = NULL;
    axis2_char_t *loc_str_tmp = NULL;
    axis2_char_t *r_idx = NULL;
    size_t plen;

    AXIS2_PARAM_CHECK(env->error, method, NULL);
    AXIS2_PARAM_CHECK(env->error, location, NULL);

    loc_str_tmp = (axis2_char_t *)location; /* Casted to facilitate loop */
    if(loc_str_tmp[1] == '/')
    {
        loc_str_tmp++;
    } /* ignore any '/' at the beginning */
    if(strchr(loc_str_tmp, '?'))
    {
        axis2_char_t *temp = NULL;

        temp = strchr(loc_str_tmp, '?');
        temp[0] = '\0';
    } /* ignore block after '?' */
    do
    {
        axis2_char_t *temp = NULL;
        temp = strchr(loc_str_tmp, '{');
        if(temp)
        {
            loc_str_tmp = temp;
        }
        else
        {
            loc_str_tmp += strlen(loc_str_tmp);
            break;
        }
    }
    while(loc_str_tmp[1] && loc_str_tmp[1] == '{');

    loc_str = (axis2_char_t *)axutil_strmemdup(location, (size_t)(loc_str_tmp - location), env);

    r_idx = axutil_rindex(loc_str, '/');
    if(r_idx && *r_idx)
    {
        loc_str_tmp = axutil_string_substring_ending_at(loc_str, (int)(r_idx - loc_str));
        /* We are sure that the difference lies within the int range */
    }
    else
    {
        loc_str_tmp = loc_str;
    }

    plen = axutil_strlen(method) + axutil_strlen(loc_str_tmp) + 2;
    key = (axis2_char_t *)(AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * plen));
    sprintf(key, "%s:%s", method, loc_str_tmp);
    AXIS2_FREE(env->allocator, loc_str);
    op_list = (axutil_array_list_t *)axutil_hash_get(svc->op_rest_map, key, AXIS2_HASH_KEY_STRING);
    AXIS2_FREE(env->allocator, key);
    return op_list;
}