AXIS2_EXTERN int AXIS2_CALL saml_authentication_query_build()

in src/omxmlsec/saml/query.c [236:305]


AXIS2_EXTERN int AXIS2_CALL saml_authentication_query_build(saml_authentication_query_t* authentication_query, 
															axiom_node_t *node, 
															const axutil_env_t *env)
{
	axutil_hash_t *attr_hash = NULL;
	axiom_element_t *element = NULL;
	axutil_hash_index_t *hi = NULL;
	axiom_child_element_iterator_t *iterator = NULL;
	axiom_node_t *child_node;


	if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT)
	{
		return AXIS2_FAILURE;
	}
	
	if ((element = axiom_node_get_data_element(node, env)) == NULL)
	{
		return AXIS2_FAILURE;
	}
	
	/* initialize the attributes */
	attr_hash = axiom_element_get_all_attributes(element, env);	

	if(attr_hash)
	{
		for (hi = axutil_hash_first(attr_hash, env); hi; hi = axutil_hash_next(env, hi))
		{
			void *v = NULL;
			axutil_hash_this(hi, NULL, NULL, &v);
			if (v)
			{
				axis2_char_t *attr_val = NULL;
				axiom_attribute_t *attr = (axiom_attribute_t*)v;			
				attr_val = axiom_attribute_get_value(attr, env);

				if(!axutil_strcmp(axiom_attribute_get_localname(attr, env), SAML_AUTHENTICATION_METHOD))
				{
					authentication_query->auth_method = attr_val;
					break;
				}
			}
		}
	}

	iterator = axiom_element_get_child_elements(element, env, node);
	if(iterator)
	{
		while(axiom_child_element_iterator_has_next(iterator, env))
		{
		
			child_node = axiom_child_element_iterator_next(iterator, env);
			element = (axiom_element_t *)axiom_node_get_data_element(child_node, env);

			if(element != NULL && !(axutil_strcmp(axiom_element_get_localname(element, env), 
																	SAML_SUBJECT)))
			{
				if(authentication_query->subject)
					return saml_subject_build(authentication_query->subject, child_node, env);
				else
					return AXIS2_FAILURE;
			}
		}
		return AXIS2_SUCCESS;
	}
	else
		return AXIS2_FAILURE;


}