in src/omxmlsec/saml/query.c [468:547]
AXIS2_EXTERN int AXIS2_CALL saml_attr_query_build(saml_attr_query_t* attribute_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;
saml_attr_desig_t *attr_desig = NULL;
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);
/*One resource attribute relate to the attibute query*/
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_RESOURCE))
{
attribute_query->resource = 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(attribute_query->subject)
saml_subject_build(attribute_query->subject, child_node, env);
}
else if(element != NULL && !(axutil_strcmp(axiom_element_get_localname(element, env),
SAML_ATTRIBUTE_DESIGNATOR)))
{
/*attr_desig = saml_attr_desig_create(env);
*/
attr_desig = (saml_attr_desig_t*)AXIS2_MALLOC(env->allocator,
sizeof(saml_attr_desig_t));
if( AXIS2_SUCCESS == saml_attr_desig_build(attr_desig, child_node, env))
{
axutil_array_list_add(attribute_query->attr_desigs,env, attr_desig);
}
}
}
return AXIS2_SUCCESS;
}
else
return AXIS2_FAILURE;
}