Beispiel #1
0
AXIS2_EXTERN axiom_node_t * AXIS2_CALL
trust_rst_build_rst_with_issued_token_assertion(
		trust_rst_t *rst,
		const axutil_env_t *env,
		rp_issued_token_t *issued_token)
{
	axiom_node_t *rst_node = NULL;
	axiom_node_t *rst_template_node = NULL;
	axiom_element_t * rst_template_element = NULL;
	axiom_children_iterator_t *rst_template_children_iter = NULL;
	axiom_node_t *rst_template_child = NULL;


	/*Attr Context is NULL -?*/
	rst_node = (axiom_node_t*)trust_util_create_rst_element(env, rst->wst_ns_uri, rst->attr_context);
	rst_template_node = rp_issued_token_get_requested_sec_token_template(issued_token, env);
	rst_template_node = axiom_node_detach(rst_template_node, env);	/*Detaching RSTTemplate from the original location- FIX - Detaching problem with NS'*/
	rst_template_element = axiom_node_get_data_element(rst_template_node, env);

	rst_template_children_iter = axiom_element_get_children(rst_template_element, env, rst_template_node);


	while(axiom_children_iterator_has_next(rst_template_children_iter, env))
	{
		rst_template_child = axiom_children_iterator_next(rst_template_children_iter, env);
		if(rst_template_node)
			axiom_node_add_child(rst_node, env, rst_template_child);
	}

	if(rst_node)
		return rst_node;
	

	return NULL;
}
Beispiel #2
0
/** Find the most recent named node.
 * @param env
 * @param root_node
 * @param local_name
 * @param node_time return parameter, is set the time timePosition of the node.
 * @return the most recent.
 */
axiom_node_t *sp_latest_named(
    const axutil_env_t *env,
    axiom_node_t       *root_node,
    const axis2_char_t *local_name,
    time_t             *node_time
    )
{
	axiom_node_t *ret_node  = NULL;
	axis2_char_t  last_time[MAX_LAST_TIMELEN];
	strcpy(last_time, "0");

    axiom_children_iterator_t *chit =
      axiom_children_iterator_create (env,
    		  axiom_node_get_first_child(root_node, env));

    if (NULL != chit)
    {
        axiom_node_t *curr_node = NULL;
        while (axiom_children_iterator_has_next(chit, env))
        {
            curr_node = axiom_children_iterator_next(chit, env);
            if (axiom_node_get_node_type(curr_node, env) == AXIOM_ELEMENT)
            {
                axiom_element_t * el = (axiom_element_t *)
                  axiom_node_get_data_element (curr_node, env);
                axis2_char_t *el_name = axiom_element_get_localname( el, env);

                if ( 0 == strncasecmp(local_name, el_name, strlen(local_name)))
                {
                    axiom_node_t *t_node =
                    		rp_find_named_child(env, curr_node, "timePosition", 1);
            		const axis2_char_t *txt = sp_get_text_el(t_node, env);

            		if (strncmp(last_time, txt, strlen(last_time)) < 0)
            		{
            			if (strlen(txt) >= MAX_LAST_TIMELEN)
            			{
            				rp_log_error(env,
            						"*WARNING sp_util.c(%s %d):"
            						" timePosition text too long (%d)\n",
            						__FILE__, __LINE__, strlen(txt));
            			}

            			strncpy(last_time, txt, MAX_LAST_TIMELEN-1);
            			ret_node = curr_node;
            		}
                }
            }  // if
        } // while

        axiom_children_iterator_free (chit, env);
    }

    *node_time = sp_parse_time_str(last_time);
    return ret_node;
}
Beispiel #3
0
axutil_array_list_t* AXIS2_CALL
remote_registry_comment_load_from_feed(
    const axutil_env_t *env,
    axis2_char_t *buffer)
{
    axiom_children_iterator_t *node_it = NULL;
    axiom_node_t *feed_node = NULL;
    axiom_element_t *feed_ele = NULL;
    axutil_array_list_t *comment_list = NULL;
    

    feed_node = axiom_node_create_from_buffer(env, buffer);
    if(!feed_node)
    {
        return NULL;
    }

    comment_list = axutil_array_list_create(env, 10);
    if(!comment_list)
    {
        return NULL;
    }

    feed_ele = axiom_node_get_data_element(feed_node, env);

    node_it = axiom_element_get_children(feed_ele, env, feed_node);

    /* iterate all the children */
    while(axiom_children_iterator_has_next(node_it, env)) 
    {
        axiom_node_t *child = NULL;
        axiom_element_t *child_ele = NULL;
        axis2_char_t *local_name = NULL;

        child = axiom_children_iterator_next(node_it, env);

        if(axiom_node_get_node_type(child, env) != AXIOM_ELEMENT) 
        {
            continue;
        }
        child_ele = (axiom_element_t *)axiom_node_get_data_element(child, env);
        
        local_name = axiom_element_get_localname(child_ele, env);

        /* retriving the attribute one by one */
        if(!axutil_strcmp(local_name, "entry")) 
        {
            remote_registry_comment_t *comment = NULL;
            comment = remote_registry_comment_create_from_entry_node(env, child);

            axutil_array_list_add(comment_list, env, comment);
        }
    }

    return comment_list;
}
Beispiel #4
0
AXIS2_EXTERN int AXIS2_CALL
remote_registry_util_get_ratings_from_feed(
    const axutil_env_t *env,
    axis2_char_t *feed)
{
	axiom_node_t *entry_node;
	
    axiom_children_iterator_t *entry_it = NULL;
    axiom_element_t *entry_ele = NULL;

	int rating = -1;


	entry_node = axiom_node_create_from_buffer(env, feed);
	if(!entry_node) {
		return -1;
	}

	entry_ele = axiom_node_get_data_element(entry_node, env);
    entry_it = axiom_element_get_children(entry_ele, env, entry_node);

    while(axiom_children_iterator_has_next(entry_it, env))
    {
        axiom_node_t *child = NULL;
        axiom_element_t *child_ele = NULL;
        axis2_char_t *local_name = NULL;

        child = axiom_children_iterator_next(entry_it, env);

        if(axiom_node_get_node_type(child, env) != AXIOM_ELEMENT) 
        {
            continue;
        }
        child_ele = (axiom_element_t *)axiom_node_get_data_element(child, env);
        
        local_name = axiom_element_get_localname(child_ele, env);
		if(!axutil_strcmp(local_name, "AverageRating"))
		{
			axis2_char_t *rating_str = NULL;

			rating_str = axiom_element_get_text(child_ele, env, child);

			rating = atoi(rating_str);
			break;
		}
	}
	return rating;
}
Beispiel #5
0
/**
 * Find the first child of 'root_node' with a matching 'local_name',
 * non-recursive.
 *
 * @param env
 * @param root_node
 * @param local_name
 * @param search_str
 * @return  the first matching child of 'root_node', or NULL if none found.
 */
axiom_node_t *rp_find_named_node_nr(
    const axutil_env_t * env,
    axiom_node_t       *root_node,
    const axis2_char_t *local_name,
    const axis2_char_t *search_str)
{
   axiom_node_t *found_node = NULL;

    axiom_children_iterator_t *chit =
      axiom_children_iterator_create (env, root_node);

    if (NULL != chit)
    {
        axiom_node_t *curr_node = NULL;
        while (axiom_children_iterator_has_next(chit, env))
        {
            curr_node = axiom_children_iterator_next(chit, env);
            if (axiom_node_get_node_type(curr_node, env) == AXIOM_ELEMENT)
            {
                axiom_element_t * el = (axiom_element_t *)
                  axiom_node_get_data_element (curr_node, env);
                axis2_char_t *el_name = axiom_element_get_localname( el, env);
                if ( 0 == strncasecmp( local_name, el_name, strlen(local_name) ) )
                {
                	if ( search_str )
                	{
                		axis2_char_t *txt =
                				axiom_element_get_text (el, env, curr_node);
                		if ( 0 == strncmp(search_str, txt, strlen(search_str)))
                		{
                			found_node = curr_node;
                			break;
                		}
                	}
                	else
                	{
                		found_node = curr_node;
                		break;
                	}
                }
            }  // if
        } // while

        axiom_children_iterator_free (chit, env);
    }

    return found_node;
}
Beispiel #6
0
axis2_char_t *
get_policy_ref(
    axiom_node_t * node,
    const axutil_env_t * env)
{
    axiom_element_t *policy_element = NULL;
    axiom_children_iterator_t *children_iter = NULL;
    axiom_node_t *child_node = NULL;
    axutil_qname_t *qname = NULL;
    axis2_char_t *value = NULL;
    axis2_char_t *val = NULL;
    axiom_attribute_t *attr = NULL;

    policy_element = (axiom_element_t *) axiom_node_get_data_element(node, env);
    children_iter = axiom_element_get_children(policy_element, env, node);

    while (axiom_children_iterator_has_next(children_iter, env))
    {
        child_node = axiom_children_iterator_next(children_iter, env);
        if (axiom_node_get_node_type(child_node, env) == AXIOM_ELEMENT)
        {
            policy_element =
                (axiom_element_t *) axiom_node_get_data_element(child_node,
                                                                env);

            if (axutil_strcmp
                (axiom_element_get_localname(policy_element, env),
                 "PolicyReference") == 0)
            {
                qname = axutil_qname_create(env, "URI", NULL, NULL);
                attr = axiom_element_get_attribute(policy_element, env, qname);

                if (attr)
                {
                    value = axiom_attribute_get_value(attr, env);
                    val = axutil_string_substring_starting_at(value, 1);
                    return val;
                }
            }
        }
    }
    return NULL;
}
Beispiel #7
0
/** Excecute 'func' on all immediate children of 'root_node' with 'local_name'.
 * @param env
 * @param root_node
 * @param local_name
 * @param func
 *   Takes 3 args: const axutil_env_t * env, axiom_node_t *node, void *arg3
 *   node is the ptr to the node matching 'local_name', arg3 is func_arg.
 *   The function should return zero if successful, non-zero otherwise.
 * @param func_arg passed as the third arg to the function.
 * @return the number of times func returned 0.
 */
int sp_func_at_nodes(
    const axutil_env_t *env,
    axiom_node_t *root_node,
    const axis2_char_t *local_name,
    int (* func)(const axutil_env_t * env, axiom_node_t *node, void *arg3),
    void *func_arg
    )
{
    int         num_executed = 0;

    axiom_children_iterator_t *chit =
      axiom_children_iterator_create (env, root_node);

    if (NULL != chit)
    {
        axiom_node_t *curr_node = NULL;
        while (axiom_children_iterator_has_next(chit, env))
        {
            curr_node = axiom_children_iterator_next(chit, env);
            if (axiom_node_get_node_type(curr_node, env) == AXIOM_ELEMENT)
            {
                axiom_element_t * el = (axiom_element_t *)
                  axiom_node_get_data_element (curr_node, env);
                axis2_char_t *el_name = axiom_element_get_localname( el, env);
                if ( 0 == strncasecmp(local_name, el_name, strlen(local_name)))
                {
                    if (0 == func(env, curr_node, func_arg)) num_executed++;
                }
            }  // if
        } // while

        axiom_children_iterator_free (chit, env);
    }

    return num_executed;
}
/**
 * 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;
}
Beispiel #9
0
AXIS2_EXTERN axutil_array_list_t* AXIS2_CALL
remote_registry_util_get_tags_from_feed(
    const axutil_env_t *env,
    axis2_char_t *feed)
{
	axiom_node_t *entry_node = NULL;
	
    axiom_children_iterator_t *entry_it = NULL;
    axiom_element_t *entry_ele = NULL;

	axutil_array_list_t *tags = NULL;


	entry_node = axiom_node_create_from_buffer(env, feed);
	if(!entry_node) {
		return NULL;
	}

	entry_ele = axiom_node_get_data_element(entry_node, env);
    entry_it = axiom_element_get_children(entry_ele, env, entry_node);

    while(axiom_children_iterator_has_next(entry_it, env))
    {
        axiom_node_t *child = NULL;
        axiom_element_t *child_ele = NULL;
        axis2_char_t *local_name = NULL;

        child = axiom_children_iterator_next(entry_it, env);

        if(axiom_node_get_node_type(child, env) != AXIOM_ELEMENT) 
        {
            continue;
        }
        child_ele = (axiom_element_t *)axiom_node_get_data_element(child, env);
        
        local_name = axiom_element_get_localname(child_ele, env);
		if(!axutil_strcmp(local_name, "entry"))
		{
			axiom_children_iterator_t *entry_child_it = NULL;
			axis2_char_t *is_tagging = NULL;

			entry_child_it = axiom_element_get_children(entry_ele, env, entry_node);

			while(axiom_children_iterator_has_next(entry_child_it, env))
			{
				axiom_element_t *entry_child_ele = NULL;
				axiom_node_t *entry_child = NULL;

				entry_child = axiom_children_iterator_next(entry_child_it, env);
				if(axiom_node_get_node_type(entry_child, env) != AXIOM_ELEMENT)
				{
					continue;
				}

				entry_child_ele = (axiom_element_t*)axiom_node_get_data_element(entry_child, env);

				local_name = axiom_element_get_localname(entry_child_ele, env);

				if(!axutil_strcmp(local_name, "taggings"))
				{
					is_tagging = axiom_element_get_text(entry_child_ele, env, entry_child);
				}
			}

			if(!axutil_strcmp("1", is_tagging))
			{
				axiom_children_iterator_reset(entry_child_it, env);
				while(axiom_children_iterator_has_next(entry_child_it, env))
				{
					axiom_element_t *entry_child_ele = NULL;
					axiom_node_t *entry_child = NULL;

					entry_child = axiom_children_iterator_next(entry_child_it, env);
					if(axiom_node_get_node_type(entry_child, env) != AXIOM_ELEMENT)
					{
						continue;
					}

					entry_child_ele = (axiom_element_t*)axiom_node_get_data_element(entry_child, env);

					local_name = axiom_element_get_localname(entry_child_ele, env);

					if(!axutil_strcmp(local_name, "title"))
					{
						axis2_char_t *tag_name = NULL;
						tag_name = axiom_element_get_text(entry_child_ele, env, entry_child);

						axutil_array_list_add(tags, env, tag_name);
					}
				}
			}
		}
	}
	return tags;
}
Beispiel #10
0
AXIS2_EXTERN void AXIS2_CALL
remote_registry_resource_load_metadata_from_feed_node(const axutil_env_t *env,
                                remote_registry_resource_t *resource,
                                axiom_node_t *feed_node)
{
    axiom_children_iterator_t *node_it = NULL;
    axiom_element_t *feed_ele = NULL;
    
    feed_ele = axiom_node_get_data_element(feed_node, env);

    node_it = axiom_element_get_children(feed_ele, env, feed_node);

    /* iterate all the children */
    while(axiom_children_iterator_has_next(node_it, env)) 
    {
        axiom_node_t *child = NULL;
        axiom_element_t *child_ele = NULL;
        axis2_char_t *local_name = NULL;

        child = axiom_children_iterator_next(node_it, env);

        if(axiom_node_get_node_type(child, env) != AXIOM_ELEMENT) 
        {
            continue;
        }
        child_ele = (axiom_element_t *)axiom_node_get_data_element(child, env);
        
        local_name = axiom_element_get_localname(child_ele, env);

        /* retriving the attribute one by one */
        if(!axutil_strcmp(local_name, REMOTE_REGISTRY_FEED_KEY_ID)) 
        {
            axis2_char_t *id_text = NULL;

            id_text = axiom_element_get_text(child_ele, env, child);

            resource->id = id_text;
        }
        else if(!axutil_strcmp(local_name, REMOTE_REGISTRY_FEED_KEY_MEDIA_TYPE))
        {
            axis2_char_t *media_type = NULL;

            media_type = axiom_element_get_text(child_ele, env, child);

            /* for the root feed the feed xml is NULL */
            if(media_type != NULL) {
                if(!axutil_strcmp(media_type, REMOTE_REGISTRY_FEED_KEY_DIR)) 
                {
                    resource->is_collection = 1;
                }
                resource->media_type = media_type;
            }
        }
        else if(!axutil_strcmp(local_name, REMOTE_REGISTRY_FEED_KEY_ENTRY)) 
        {
            /* now iterate through the entries */
            axutil_array_list_t *entry_arr = NULL;
            remote_registry_resource_t *entry_resource = NULL;
			axis2_char_t *child_path = NULL;

            entry_arr = resource->entries;
            if(!entry_arr) {
                entry_arr = axutil_array_list_create(env, 5);
                resource->entries = entry_arr;
            }

            entry_resource = remote_registry_resource_create_from_entry_node(env, child);
            axutil_array_list_add(entry_arr, env, entry_resource);

			/* adding child as a path */
			child_path = entry_resource->link_path;
			if(!resource->child_paths)
			{
				resource->child_paths = axutil_array_list_create(env, 10);
			}
			axutil_array_list_add(resource->child_paths, env, child_path);
        }
        else if(!axutil_strcmp(local_name, REMOTE_REGISTRY_FEED_KEY_LINK))
        {
            /* loading all the links */
            axis2_char_t *href = NULL;
            axis2_char_t *rel = NULL;
                
            href = axiom_element_get_attribute_value_by_name(child_ele, env, REMOTE_REGISTRY_FEED_ATTR_HREF);
            rel = axiom_element_get_attribute_value_by_name(child_ele, env, REMOTE_REGISTRY_FEED_ATTR_REL);

            if(!axutil_strcmp(rel, REMOTE_REGISTRY_FEED_ATTR_SELF)) 
            {
                resource->link_self = axutil_strdup(env, href);
            }
            else if(!axutil_strcmp(rel, REMOTE_REGISTRY_FEED_ATTR_ALTERNATE))
            {
                resource->link_alternate = axutil_strdup(env, href);
            }
            else if(!axutil_strcmp(rel, REMOTE_REGISTRY_FEED_ATTR_PATH))
            {
                remote_registry_resource_set_link_path(resource, env, href);
            }
            else if(!axutil_strcmp(rel, REMOTE_REGISTRY_FEED_ATTR_EDIT))
            {
                resource->link_edit = axutil_strdup(env, href);
            }
            else if(!axutil_strcmp(rel, REMOTE_REGISTRY_FEED_ATTR_EDIT_MEDIA))
            {
                resource->link_edit_media = axutil_strdup(env, href);
            }

        }
        else if(!axutil_strcmp(local_name, REMOTE_REGISTRY_FEED_KEY_CONTENT))
        {
            axis2_char_t *content_src_url = NULL;

            content_src_url = axiom_element_get_attribute_value_by_name(child_ele, env, REMOTE_REGISTRY_FEED_ATTR_SRC);
            remote_registry_resource_set_content_src_url(resource, env, content_src_url);
			if(content_src_url != NULL) {
				resource->is_collection = 0;
			}
        }
        else if(!axutil_strcmp(local_name, REMOTE_REGISTRY_FEED_KEY_AUTHOR))
        {
            axiom_node_t *name_node = NULL;
            axiom_element_t *name_element = NULL;

            name_node = axiom_node_get_first_child(child, env);

            /* get the first child (with type AXIOM_ELEMENT) where we can find the name */
            if(name_node && axiom_node_get_node_type(name_node, env) != AXIOM_ELEMENT)
            {
                name_node = axiom_node_get_next_sibling(name_node, env);
            }

            if(name_node)
            {
                axis2_char_t *name = NULL;
                name_element = axiom_node_get_data_element(name_node, env);

                name = axiom_element_get_text(name_element, env, name_node);

                remote_registry_resource_set_author_name(resource, env, name);
            }
        }
		else if(!axutil_strcmp(local_name, REMOTE_REGISTRY_FEED_KEY_PROPERTIES))
		{
			axiom_children_iterator_t *properties_it = NULL;
			axiom_element_t *properties_ele = NULL;

			if(!resource->properties)
			{
				resource->properties = axutil_hash_make(env);
			}
		    
			properties_ele = axiom_node_get_data_element(child, env);

			properties_it = axiom_element_get_children(properties_ele, env, child);

			/* iterate all the properties */
			while(axiom_children_iterator_has_next(properties_it, env)) 
			{
				axiom_node_t *property_node = NULL;
				axiom_node_t *name_node = NULL;
				axiom_node_t *value_node = NULL;
				axiom_element_t *name_element = NULL;
				axiom_element_t *value_element = NULL;

				axis2_char_t *name = NULL;
				axis2_char_t *value = NULL;

				property_node = axiom_children_iterator_next(properties_it, env);

				if(axiom_node_get_node_type(property_node, env) != AXIOM_ELEMENT) 
				{
					continue;
				}
		        
				name_node = axiom_node_get_first_child(property_node, env);
				while(name_node && axiom_node_get_node_type(name_node, env) != AXIOM_ELEMENT) 
				{
					name_node = axiom_node_get_next_sibling(name_node, env);
				}

				if(!name_node) 
				{
					continue;
				}

				value_node = axiom_node_get_next_sibling(name_node, env);
				while(value_node && axiom_node_get_node_type(value_node, env) != AXIOM_ELEMENT) 
				{
					value_node = axiom_node_get_next_sibling(value_node, env);
				}

				if(!value_node) 
				{
					continue;
				}

				name_element = axiom_node_get_data_element(name_node, env);
				value_element = axiom_node_get_data_element(value_node, env);

				name = axiom_element_get_text(name_element, env, name_node);
				value = axiom_element_get_text(value_element, env, value_node);
				
				axutil_hash_set(resource->properties, name, AXIS2_HASH_KEY_STRING, value);
			}
		}
    }
}
Beispiel #11
0
AXIS2_EXTERN remote_registry_comment_t* AXIS2_CALL
remote_registry_comment_create_from_entry_node(
    const axutil_env_t *env,
    axiom_node_t *entry_node)
{
    remote_registry_comment_t *comment = NULL;
    axiom_children_iterator_t *entry_it = NULL;
    axiom_element_t *entry_ele = NULL;

    comment = remote_registry_comment_create(env);
    if(comment == NULL)
    {
		AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        return NULL;
    }
    entry_ele = axiom_node_get_data_element(entry_node, env);
    entry_it = axiom_element_get_children(entry_ele, env, entry_node);

    while(axiom_children_iterator_has_next(entry_it, env))
    {
        axiom_node_t *child = NULL;
        axiom_element_t *child_ele = NULL;
        axis2_char_t *local_name = NULL;

        child = axiom_children_iterator_next(entry_it, env);

        if(axiom_node_get_node_type(child, env) != AXIOM_ELEMENT) 
        {
            continue;
        }
        child_ele = (axiom_element_t *)axiom_node_get_data_element(child, env);
        
        local_name = axiom_element_get_localname(child_ele, env);

        /* retriving the attribute one by one */
        if(!axutil_strcmp(local_name, "updated")) 
        {
            axis2_char_t *updated_text = NULL;
            axutil_date_time_t *updated_datetime = NULL;

            updated_text = axiom_element_get_text(child_ele, env, child);
            updated_datetime = axutil_date_time_create(env);
            axutil_date_time_deserialize_time(updated_datetime, env, updated_text);

            remote_registry_comment_set_date_time(comment, env, updated_datetime);
        }
        else if(!axutil_strcmp(local_name, "content")) 
        {
            axis2_char_t *content = NULL;
            
            content = axiom_element_get_text(child_ele, env, child);
            remote_registry_comment_set_text(comment, env, content);
        }
        else if(!axutil_strcmp(local_name, "author"))
        {
            axiom_node_t *name_node = NULL;
            axiom_element_t *name_element = NULL;

            name_node = axiom_node_get_first_child(child, env);

            /* get the first child (with type AXIOM_ELEMENT) where we can find the name */
            if(name_node && axiom_node_get_node_type(name_node, env) != AXIOM_ELEMENT)
            {
                name_node = axiom_node_get_next_sibling(name_node, env);
            }

            if(name_node)
            {
                axis2_char_t *name = NULL;
                name_element = axiom_node_get_data_element(name_node, env);

                name = axiom_element_get_text(name_element, env, name_node);

                remote_registry_comment_set_user(comment, env, name);
            }
        }
            
    }
   
    return comment;
}
Beispiel #12
0
AXIS2_EXTERN axutil_array_list_t* AXIS2_CALL
security_admin_load_scenarios(
		const axutil_env_t* env, 
		axis2_msg_ctx_t* msg_ctx)
{
	/* Read senarios from config file*/
	axis2_conf_ctx_t* conf_ctx = NULL;
	axis2_char_t* repo_path = NULL;
	axis2_char_t* scenario_config_file_path = NULL;
	axiom_xml_reader_t* xml_reader = NULL;
	axiom_document_t* document = NULL;
	axiom_stax_builder_t* stax_builder = NULL;
	axiom_node_t* scenario_config_root_node = NULL;
	axiom_element_t* scenario_config_root_element = NULL;
	axiom_children_iterator_t* children_ite = NULL;
	axutil_array_list_t* scenarios = NULL;
			
	/* Form absolute path to config file*/
	conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
	repo_path = axis2_conf_ctx_get_root_dir(conf_ctx, env);
	scenario_config_file_path = axutil_strcat(env, repo_path, AXIS2_PATH_SEP_STR, "services", 
		AXIS2_PATH_SEP_STR, "SecurityAdminService", AXIS2_PATH_SEP_STR, "scenario-config.xml", 
		NULL);

	xml_reader = axiom_xml_reader_create_for_file(env, scenario_config_file_path, NULL);
	AXIS2_FREE(env->allocator, scenario_config_file_path);
	if (!xml_reader) return NULL;

	stax_builder = axiom_stax_builder_create(env, xml_reader);
	if (!stax_builder) return NULL;

	document = axiom_stax_builder_get_document(stax_builder, env);
	if (!document) return NULL;

	/* Build XML document*/
	axiom_document_build_all(document, env);

	scenario_config_root_node = axiom_document_get_root_element(document, env);
	scenario_config_root_element = axiom_node_get_data_element(scenario_config_root_node, env);
	axiom_stax_builder_free_self(stax_builder, env);
			
	children_ite = axiom_element_get_children(scenario_config_root_element, env, 
		scenario_config_root_node);
	if (children_ite)
	{
		/* Get Scenario nodes and build hash*/
		while (axiom_children_iterator_has_next(children_ite, env))
		{
			axiom_node_t* node = NULL;

			node = axiom_children_iterator_next(children_ite, env);

			if (axiom_node_get_node_type(node, env) == AXIOM_ELEMENT)
			{
				axis2_char_t* localname = NULL;
				axiom_element_t* scenario_ele = NULL;
				axiom_children_iterator_t* ite = NULL;
	
				scenario_ele = axiom_node_get_data_element(node, env);

				localname = axiom_element_get_localname(scenario_ele, env);

				if (0 == axutil_strcmp(localname, "Scenario")) /* Scenario */
				{
					axis2_char_t* id = NULL;
					security_admin_scenario_data_t* data = NULL;

					/* Create scenarios hash*/
					if (!scenarios)
						scenarios = axutil_array_list_create(env, SEC_ADMIN_SCENARIO_COUNT);

					data = security_admin_scenario_data_create(env);

					/* Current scenario*/
					security_admin_scenario_data_set_current_scenario(data, AXIS2_TRUE);

					/* id*/
					id = axiom_element_get_attribute_value_by_name(scenario_ele, env, "id");
					security_admin_scenario_data_set_id(data, axutil_strdup(env, id));

					ite = axiom_element_get_children(scenario_ele, env, node);
					while (axiom_children_iterator_has_next(ite, env))
					{
						axiom_node_t* node = NULL;
						node = axiom_children_iterator_next(ite, env);

						if (axiom_node_get_node_type(node, env) == AXIOM_ELEMENT)
						{
							axiom_element_t* node_ele = NULL;
							axis2_char_t* localname = NULL;
							axis2_char_t* text = NULL;

							node_ele = axiom_node_get_data_element(node, env);

							localname = axiom_element_get_localname(node_ele, env);
							text = axiom_element_get_text(node_ele, env, node);
									
							if (0 == axutil_strcmp(localname, "Summary")) /* Summary */
							{
								security_admin_scenario_data_set_summary(data, 
									axutil_strdup(env, text));
							}
							else if (0 == axutil_strcmp(localname, "Description")) /* Description */
							{
								security_admin_scenario_data_set_description(data, 
									axutil_strdup(env, text));
							}
							else if (0 == axutil_strcmp(localname, "Category")) /* Category */
							{
								security_admin_scenario_data_set_category(data, 
									axutil_strdup(env, text));
							}
							/*else if (0 == axutil_strcmp(localname, "WsuId")*/ /* WsuId */
							/*{
							}*/
							else if (0 == axutil_strcmp(localname, "Type")) /* Type */
							{
								security_admin_scenario_data_set_type(data, 
									axutil_strdup(env, text));
							}
							else if (0 == axutil_strcmp(localname, "Modules")) /* Modules */
							{
										
							}
						}
					}

					/* Add scenario data into the hash map*/
					axutil_array_list_add(scenarios, env, data);
				}
			}
		}
	}

	return scenarios;
}
AXIS2_EXTERN neethi_assertion_t *AXIS2_CALL
axis2_rm_assertion_builder_build(
    const axutil_env_t *env,
    axiom_node_t *rm_assertion_node,
    axiom_element_t *rm_assertion_ele)
{
    axis2_rm_assertion_t *rm_assertion = NULL;
    axis2_status_t status = AXIS2_SUCCESS;
    axiom_children_iterator_t *children_iter = NULL;
    neethi_assertion_t *assertion = NULL;
    axis2_char_t *ns = NULL;
    axutil_qname_t *node_qname = NULL;

    node_qname = axiom_element_get_qname(rm_assertion_ele, env, rm_assertion_node);
    if(!node_qname)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[neethi] Cannot get qname from element");
        return NULL;
    }

    ns = axutil_qname_get_uri(node_qname, env);
    if(!ns)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[neethi] Cannot get namespace from element.");
        return NULL;
    }

    rm_assertion = axis2_rm_assertion_create(env);
    if(!rm_assertion)
    {
        return NULL;
    }

    /* First we check whether this is in 1.0 or 1.1 
     * namespace. Then we called the appropriate builder */

    children_iter = axiom_element_get_children(rm_assertion_ele, env, rm_assertion_node);

    if(!axutil_strcmp(ns, AXIS2_RM_POLICY_10_NS))
    {
        status = axis2_rm_assertion_builder_populate_for_10(env, rm_assertion, rm_assertion_node,
            rm_assertion_ele);

        axiom_children_iterator_reset(children_iter, env);

    }
    else if(!axutil_strcmp(ns, AXIS2_RM_POLICY_11_NS))
    {
        status = axis2_rm_assertion_builder_populate_for_11(env, rm_assertion, rm_assertion_node,
            rm_assertion_ele);
    }

    if(status == AXIS2_FAILURE)
    {
        axis2_rm_assertion_free(rm_assertion, env);
        rm_assertion = NULL;
        return NULL;
    }

    /*children_iter = axiom_element_get_children(rm_assertion_ele, env, rm_assertion_node);*/
    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;
            axutil_qname_t *node_qn = 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);
                    node_qn = axiom_element_get_qname(ele, env, node);
                    if(!node_qn)
                    {
                        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                            "[neethi] Cannot get qname from element %s.", local_name);
                        return NULL;
                    }
                    ns = axutil_qname_get_uri(node_qn, env);
                    if(!ns)
                    {
                        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                            "[neethi] Cannot get namespace from element %s.", local_name);
                        return NULL;
                    }
                    if(!axutil_strcmp(ns, AXIS2_SANDESHA2_NS))
                    {
                        status = axis2_rm_assertion_builder_process_sandesha2_assertions(env,
                            rm_assertion, node, ele);
                        if(status == AXIS2_FAILURE)
                        {
                            axis2_rm_assertion_free(rm_assertion, env);
                            rm_assertion = NULL;
                            return NULL;
                        }
                    }
                }
            }
        }
    }
    assertion = neethi_assertion_create_with_args(env,
        (AXIS2_FREE_VOID_ARG)axis2_rm_assertion_free, rm_assertion, ASSERTION_TYPE_RM_ASSERTION);
    return assertion;
}
static axis2_status_t AXIS2_CALL
axis2_rm_assertion_builder_process_delivery_assuarance(
    const axutil_env_t *env,
    axis2_rm_assertion_t *rm_assertion,
    axiom_node_t *da_node,
    axiom_element_t *da_element)
{
    axiom_children_iterator_t *children_iter = NULL;
    axis2_status_t status = AXIS2_FAILURE;
    axiom_node_t *child_node = NULL;
    axiom_element_t *child_element = NULL;
    (void)da_element;

    child_node = axiom_node_get_first_element(da_node, env);
    if(child_node)
    {
        child_element = (axiom_element_t *)axiom_node_get_data_element(child_node, env);
        if(child_element)
        {
            children_iter = axiom_element_get_children(child_element, env, child_node);
            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)
                                {
                                    if(!axutil_strcmp(local_name, AXIS2_RM_EXACTLY_ONCE))
                                    {
                                        status = axis2_rm_assertion_set_is_exactly_once(
                                            rm_assertion, env, AXIS2_TRUE);
                                    }
                                    else if(!axutil_strcmp(local_name, AXIS2_RM_AT_LEAST_ONCE))
                                    {
                                        status = axis2_rm_assertion_set_is_atleast_once(
                                            rm_assertion, env, AXIS2_TRUE);
                                    }
                                    else if(!axutil_strcmp(local_name, AXIS2_RM_AT_MOST_ONCE))
                                    {
                                        status = axis2_rm_assertion_set_is_atmost_once(
                                            rm_assertion, env, AXIS2_TRUE);
                                    }
                                    else if(!axutil_strcmp(local_name, AXIS2_RM_IN_ORDER))
                                    {
                                        status = axis2_rm_assertion_set_is_inorder(rm_assertion,
                                            env, AXIS2_TRUE);
                                    }
                                    else
                                    {
                                        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                                            "[neethi] Unknown Assertion %s ", local_name);
                                        return AXIS2_FAILURE;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return status;
}
static axis2_status_t AXIS2_CALL
axis2_rm_assertion_builder_populate_for_11(
    const axutil_env_t *env,
    axis2_rm_assertion_t *rm_assertion,
    axiom_node_t *rm_assertion_node,
    axiom_element_t *rm_assertion_element)
{
    axiom_children_iterator_t *children_iter = NULL;
    axis2_status_t status = AXIS2_FAILURE;
    axiom_node_t *child_node = NULL;
    axiom_element_t *child_element = NULL;
    (void)rm_assertion_element;
    
    status = axis2_rm_assertion_set_spec_version(rm_assertion, env, RM_SPEC_VERSION_1_1);

    child_node = axiom_node_get_first_element(rm_assertion_node, env);
    if(child_node)
    {
        child_element = (axiom_element_t *)axiom_node_get_data_element(child_node, env);
        if(child_element)
        {
            children_iter = axiom_element_get_children(child_element, env, child_node);
            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)
                            {
                                axutil_qname_t *node_qname = NULL;
                                axis2_char_t *ns = NULL;
                                node_qname = axiom_element_get_qname(ele, env, node);
                                if(!node)
                                {
                                    AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                                        "[neethi] Cannot get qname from element");
                                    return AXIS2_FAILURE;
                                }

                                ns = axutil_qname_get_uri(node_qname, env);
                                if(!ns)
                                {
                                    AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                                        "[neethi] Cannot get namespace from element.");
                                    return AXIS2_FAILURE;
                                }

                                if(axutil_strcmp(ns, AXIS2_RM_POLICY_11_NS))
                                {
                                    continue;
                                }
                                local_name = axiom_element_get_localname(ele, env);
                                if(local_name)
                                {
                                    if(!axutil_strcmp(local_name, AXIS2_RM_SEQUENCE_STR))
                                    {
                                        status = axis2_rm_assertion_set_is_sequence_str(
                                            rm_assertion, env, AXIS2_TRUE);
                                    }
                                    else if(!axutil_strcmp(local_name,
                                        AXIS2_RM_SEQUENCE_TRANSPORT_SECURITY))
                                    {
                                        status
                                            = axis2_rm_assertion_set_is_sequence_transport_security(
                                                rm_assertion, env, AXIS2_TRUE);
                                    }
                                    else if(!axutil_strcmp(local_name, AXIS2_RM_DELIVERY_ASSURANCE))
                                    {
                                        status
                                            = axis2_rm_assertion_builder_process_delivery_assuarance(
                                                env, rm_assertion, node, ele);
                                    }
                                    else
                                    {
                                        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                                            "[neethi] Unknown Assertion %s ", local_name);
                                        return AXIS2_FAILURE;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    return status;
}
static axis2_status_t AXIS2_CALL
axis2_rm_assertion_builder_populate_for_10(
    const axutil_env_t *env,
    axis2_rm_assertion_t *rm_assertion,
    axiom_node_t *rm_assertion_node,
    axiom_element_t *rm_assertion_element)
{
    axiom_children_iterator_t *children_iter = NULL;
    axis2_status_t status = AXIS2_FAILURE;

    /* In rm 1.0 it is just child elements which inside 
     * rm_assertion contains all the properties. */
    
    status = axis2_rm_assertion_set_spec_version(rm_assertion, env, RM_SPEC_VERSION_1_0);

    children_iter = axiom_element_get_children(rm_assertion_element, env, rm_assertion_node);
    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)
                    {
                        axutil_qname_t *node_qname = NULL;
                        axis2_char_t *ns = NULL;
                        node_qname = axiom_element_get_qname(ele, env, node);
                        if(!node)
                        {
                            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                                "[neethi] Cannot get qname from element");
                            return AXIS2_FAILURE;
                        }

                        ns = axutil_qname_get_uri(node_qname, env);
                        if(!ns)
                        {
                            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                                "[neethi] Cannot get namespace from element.");
                            return AXIS2_FAILURE;
                        }

                        if(axutil_strcmp(ns, AXIS2_RM_POLICY_10_NS))
                        {
                            continue;
                        }

                        local_name = axiom_element_get_localname(ele, env);
                        if(local_name)
                        {

                            if(!axutil_strcmp(local_name, AXIS2_RM_INACTIVITY_TIMEOUT))
                            {
                                axis2_char_t *inactivity_timeout = NULL;
                                axutil_qname_t *qname = NULL;

                                qname = axutil_qname_create(env, "Milliseconds", NULL, NULL);

                                inactivity_timeout = axiom_element_get_attribute_value(ele, env,
                                    qname);
                                if(qname)
                                {
                                    axutil_qname_free(qname, env);
                                    qname = NULL;
                                }
                                status = axis2_rm_assertion_set_inactivity_timeout(rm_assertion,
                                    env, inactivity_timeout);
                            }
                            else if(!axutil_strcmp(local_name,
                                AXIS2_RM_BASE_RETRANSMISSION_INTERVAL))
                            {
                                axis2_char_t *rti = NULL;
                                axutil_qname_t *qname = NULL;
                                qname = axutil_qname_create(env, "Milliseconds", NULL, NULL);

                                rti = axiom_element_get_attribute_value(ele, env, qname);
                                if(qname)
                                {
                                    axutil_qname_free(qname, env);
                                    qname = NULL;
                                }
                                status = axis2_rm_assertion_set_retrans_interval(rm_assertion, env,
                                    rti);
                            }
                            else if(!axutil_strcmp(local_name, AXIS2_RM_EXPONENTIAL_BACK_OFF))
                            {
                                status = axis2_rm_assertion_set_is_exp_backoff(rm_assertion, env,
                                    AXIS2_TRUE);
                            }
                            else if(!axutil_strcmp(local_name, AXIS2_RM_ACKNOWLEDGEMENT_INTERVAL))
                            {
                                axis2_char_t *ack_interval = NULL;
                                axutil_qname_t *qname = NULL;

                                qname = axutil_qname_create(env, "Milliseconds", NULL, NULL);

                                ack_interval = axiom_element_get_attribute_value(ele, env, qname);
                                if(qname)
                                {
                                    axutil_qname_free(qname, env);
                                    qname = NULL;
                                }
                                status = axis2_rm_assertion_set_ack_interval(rm_assertion, env,
                                    ack_interval);
                            }
                            else
                            {
                                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                                    "[neethi] Unknown Assertion %s ", local_name);
                                return AXIS2_FAILURE;
                            }
                        }
                    }
                }
            }
        }
    }
    return status;
}