Esempio n. 1
0
AXIS2_EXTERN rp_signed_encrypted_parts_t *AXIS2_CALL
rp_signed_encrypted_parts_create(
    const axutil_env_t * env)
{
    rp_signed_encrypted_parts_t *signed_encrypted_parts = NULL;
    signed_encrypted_parts = (rp_signed_encrypted_parts_t *)AXIS2_MALLOC(env->allocator,
        sizeof(rp_signed_encrypted_parts_t));

    if(!signed_encrypted_parts)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
            "[neethi] Cannot create signed_encrypted_parts. Insuficient memory.");
        return NULL;
    }

    signed_encrypted_parts->headers = axutil_array_list_create(env, 0);
    if(!signed_encrypted_parts->headers)
    {
        rp_signed_encrypted_parts_free(signed_encrypted_parts, env);
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
            "[neethi] Cannot create signed_encrypted_parts. Headers array list creation failed.");
        return NULL;
    }

    signed_encrypted_parts->body = AXIS2_FALSE;
    signed_encrypted_parts->ref = 0;
    signed_encrypted_parts->signedparts = AXIS2_FALSE;
    signed_encrypted_parts->attachments = AXIS2_FALSE;
    return signed_encrypted_parts;
}
/**
 * Builts EncryptedParts or SignedParts assertion
 * @param env Pointer to environment struct
 * @param node Assertion node
 * @param element Assertion element
 * @param is_signed boolean showing whether signing or encryption
 * @returns neethi assertion created. NULL if failure.
 */
AXIS2_EXTERN neethi_assertion_t *AXIS2_CALL
rp_signed_encrypted_parts_builder_build(
    const axutil_env_t *env,
    axiom_node_t *parts,
    axiom_element_t *parts_ele, 
    axis2_bool_t is_signed)
{
    rp_signed_encrypted_parts_t *signed_encrypted_parts = NULL;
    axiom_children_iterator_t *children_iter = NULL;
    neethi_assertion_t *assertion = NULL;
    axis2_status_t status = AXIS2_SUCCESS;

    signed_encrypted_parts = rp_signed_encrypted_parts_create(env);
    if (!signed_encrypted_parts)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
            "[neethi] Cannot create signed_encrypted_parts.");
        return NULL;
    }

    rp_signed_encrypted_parts_set_signedparts(signed_encrypted_parts, env, is_signed);

    children_iter = axiom_element_get_children(parts_ele, env, parts);
    if (children_iter)
    {
        while (axiom_children_iterator_has_next(children_iter, env))
        {
            axiom_node_t *node = NULL;
            axiom_element_t *ele = NULL;
            axis2_char_t *local_name = NULL;
            node = axiom_children_iterator_next(children_iter, env);
            if (node)
            {
                if (axiom_node_get_node_type(node, env) == AXIOM_ELEMENT)
                {
                    ele = (axiom_element_t *) axiom_node_get_data_element(node, env);
                    if (ele)
                    {
                        local_name = axiom_element_get_localname(ele, env);
                        if (local_name)
                        {
                            status = rp_signed_encrypted_parts_builder_set_properties
                                (node, ele, local_name, signed_encrypted_parts, env);
                            if (status != AXIS2_SUCCESS)
                            {
                                rp_signed_encrypted_parts_free (signed_encrypted_parts, env);
                                signed_encrypted_parts = NULL;
                                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
                                    "[neethi] Cannot create signed_encrypted_parts. "
                                    "Error in processing child element %s", local_name);
                                    return NULL;
                            }
                        }
                    }
                }
            }
        }
    }
    assertion = neethi_assertion_create_with_args(
        env, (AXIS2_FREE_VOID_ARG)rp_signed_encrypted_parts_free, 
        signed_encrypted_parts, ASSERTION_TYPE_SIGNED_ENCRYPTED_PARTS);
    return assertion;
}
AXIS2_EXTERN void AXIS2_CALL
rp_supporting_tokens_free(
    rp_supporting_tokens_t * supporting_tokens,
    const axutil_env_t * env)
{
    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);

    if (supporting_tokens)
    {

        if (--(supporting_tokens->ref) > 0)
        {
            return;
        }

        if (supporting_tokens->tokens)
        {
            int i = 0;
            for (i = 0; i < axutil_array_list_size(supporting_tokens->tokens,
                                                   env); i++)
            {
                rp_property_t *token = NULL;
                token = (rp_property_t *)
                    axutil_array_list_get(supporting_tokens->tokens, env, i);
                if (token)
                    rp_property_free(token, env);

                token = NULL;
            }
            axutil_array_list_free(supporting_tokens->tokens, env);
            supporting_tokens->tokens = NULL;

        }
        if (supporting_tokens->algorithmsuite)
        {
            rp_algorithmsuite_free(supporting_tokens->algorithmsuite, env);
            supporting_tokens->algorithmsuite = NULL;
        }
        if (supporting_tokens->signed_parts)
        {
            rp_signed_encrypted_parts_free(supporting_tokens->signed_parts,
                                           env);
            supporting_tokens->signed_parts = NULL;
        }
        if (supporting_tokens->signed_elements)
        {
            rp_signed_encrypted_elements_free(supporting_tokens->
                                              signed_elements, env);
            supporting_tokens->signed_elements = NULL;
        }
        if (supporting_tokens->encrypted_parts)
        {
            rp_signed_encrypted_parts_free(supporting_tokens->encrypted_parts,
                                           env);
            supporting_tokens->encrypted_parts = NULL;
        }
        if (supporting_tokens->encrypted_elements)
        {
            rp_signed_encrypted_elements_free(supporting_tokens->
                                              encrypted_elements, env);
            supporting_tokens->encrypted_elements = NULL;
        }
        AXIS2_FREE(env->allocator, supporting_tokens);
        supporting_tokens = NULL;
    }
    return;
}