Пример #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;
}
Пример #2
0
/**
 * Delete the first child of 'root_node' with a matching 'local_name'.
 * @param env
 * @param root_node
 * @param local_name
 */
void rp_delete_named_child(
	const axutil_env_t * env,
	axiom_node_t       *root_node,
	const axis2_char_t *local_name
)
{
	axiom_node_t *del_node =
			rp_find_named_child(env, root_node, local_name, 1);
	if (NULL != del_node)
	{
		axiom_node_detach    (del_node, env);
		axiom_node_free_tree (del_node, env);
	}
}
        axis2_status_t AXIS2_CALL
        adb_TransformTypeChoice_deserialize_obj(
                adb_TransformTypeChoice_t* _TransformTypeChoice,
                const axutil_env_t *env,
                axiom_node_t **dp_parent,
                axis2_bool_t *dp_is_early_node_valid,
                axis2_bool_t dont_care_minoccurs)
        {
          axiom_node_t *parent = *dp_parent;
          
          axis2_status_t status = AXIS2_SUCCESS;
           
             const axis2_char_t* text_value = NULL;
             axutil_qname_t *qname = NULL;
          
            axutil_qname_t *element_qname = NULL; 
            
               axiom_node_t *first_node = NULL;
               axis2_bool_t is_early_node_valid = AXIS2_TRUE;
               axiom_node_t *current_node = NULL;
               axiom_element_t *current_element = NULL;
            
            AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
            AXIS2_PARAM_CHECK(env->error, _TransformTypeChoice, AXIS2_FAILURE);

            
                         first_node = parent;
                    

                     
                     /*
                      * building extraElement element
                      */
                     
                     
                     
                                   current_node = first_node;
                                   is_early_node_valid = AXIS2_FALSE;
                                   
                                   

                           if ( 
                                (current_node ))
                           {
                              if( current_node )
                              {
                                is_early_node_valid = AXIS2_TRUE;
                              }
                              
                                 
                                      text_value = NULL; /* just to avoid warning */
                                      
                                        {
                                          axiom_node_t *current_property_node = current_node;
                                          current_node = axiom_node_get_next_sibling(current_node, env);
                                          axiom_node_detach(current_property_node, env);
                                          status = adb_TransformTypeChoice_set_extraElement(_TransformTypeChoice, env,
                                                                          current_property_node);
                                        }
                                        
                                 if(AXIS2_FAILURE ==  status)
                                 {
                                     AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for extraElement ");
                                     if(element_qname)
                                     {
                                         axutil_qname_free(element_qname, env);
                                     }
                                     return AXIS2_FAILURE;
                                 }
                              }
                           
                  if(element_qname)
                  {
                     axutil_qname_free(element_qname, env);
                     element_qname = NULL;
                  }
                 

                     
                     /*
                      * building XPath element
                      */
                     
                     
                     
                                    /*
                                     * because elements are ordered this works fine
                                     */
                                  
                                   
                                   if(current_node != NULL && is_early_node_valid)
                                   {
                                       current_node = axiom_node_get_next_sibling(current_node, env);
                                       
                                       
                                        while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT)
                                        {
                                            current_node = axiom_node_get_next_sibling(current_node, env);
                                        }
                                        if(current_node != NULL)
                                        {
                                            current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env);
                                            qname = axiom_element_get_qname(current_element, env, current_node);
                                        }
                                       
                                   }
                                   is_early_node_valid = AXIS2_FALSE;
                                 
                                 element_qname = axutil_qname_create(env, "XPath", "http://www.w3.org/2000/09/xmldsig#", NULL);
                                 

                           if ( 
                                (current_node   && current_element && (axutil_qname_equals(element_qname, env, qname))))
                           {
                              if( current_node   && current_element && (axutil_qname_equals(element_qname, env, qname)))
                              {
                                is_early_node_valid = AXIS2_TRUE;
                              }
                              
                                 
                                      text_value = axiom_element_get_text(current_element, env, current_node);
                                      if(text_value != NULL)
                                      {
                                            status = adb_TransformTypeChoice_set_XPath(_TransformTypeChoice, env,
                                                               text_value);
                                      }
                                      
                                      else
                                      {
                                            /*
                                             * axis2_qname_t *qname = NULL;
                                             * axiom_attribute_t *the_attri = NULL;
                                             * 
                                             * qname = axutil_qname_create(env, "nil", "http://www.w3.org/2001/XMLSchema-instance", "xsi");
                                             * the_attri = axiom_element_get_attribute(current_element, env, qname);
                                             */
                                            /* currently thereis a bug in the axiom_element_get_attribute, so we have to go to this bad method */

                                            axiom_attribute_t *the_attri = NULL;
                                            axis2_char_t *attrib_text = NULL;
                                            axutil_hash_t *attribute_hash = NULL;

                                            attribute_hash = axiom_element_get_all_attributes(current_element, env);

                                            attrib_text = NULL;
                                            if(attribute_hash)
                                            {
                                                 axutil_hash_index_t *hi;
                                                 void *val;
                                                 const void *key;
                                        
                                                 for (hi = axutil_hash_first(attribute_hash, env); hi; hi = axutil_hash_next(env, hi)) 
                                                 {
                                                     axutil_hash_this(hi, &key, NULL, &val);
                                                     
                                                     if(strstr((axis2_char_t*)key, "nil|http://www.w3.org/2001/XMLSchema-instance"))
                                                     {
                                                         the_attri = (axiom_attribute_t*)val;
                                                         break;
                                                     }
                                                 }
                                            }

                                            if(the_attri)
                                            {
                                                attrib_text = axiom_attribute_get_value(the_attri, env);
                                            }
                                            else
                                            {
                                                /* this is hoping that attribute is stored in "http://www.w3.org/2001/XMLSchema-instance", this happnes when name is in default namespace */
                                                attrib_text = axiom_element_get_attribute_value_by_name(current_element, env, "nil");
                                            }

                                            if(attrib_text && 0 == axutil_strcmp(attrib_text, "1"))
                                            {
                                                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "NULL value is set to a non nillable element XPath");
                                                status = AXIS2_FAILURE;
                                            }
                                            else
                                            {
                                                /* after all, we found this is a empty string */
                                                status = adb_TransformTypeChoice_set_XPath(_TransformTypeChoice, env,
                                                                   "");
                                            }
                                      }
                                      
                                 if(AXIS2_FAILURE ==  status)
                                 {
                                     AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for XPath ");
                                     if(element_qname)
                                     {
                                         axutil_qname_free(element_qname, env);
                                     }
                                     return AXIS2_FAILURE;
                                 }
                              }
                           
                  if(element_qname)
                  {
                     axutil_qname_free(element_qname, env);
                     element_qname = NULL;
                  }
                 
                *dp_parent = current_node;
                *dp_is_early_node_valid = is_early_node_valid;
            
          return status;
       }
Пример #4
0
        axis2_status_t AXIS2_CALL
        adb_source_deserialize_obj(
                adb_source_t* _source,
                const axutil_env_t *env,
                axiom_node_t **dp_parent,
                axis2_bool_t *dp_is_early_node_valid,
                axis2_bool_t dont_care_minoccurs)
        {
          axiom_node_t *parent = *dp_parent;
          
          axis2_status_t status = AXIS2_SUCCESS;
           
             const axis2_char_t* text_value = NULL;
             axutil_qname_t *qname = NULL;
          
            axutil_qname_t *element_qname = NULL; 
            
               axiom_node_t *first_node = NULL;
               axis2_bool_t is_early_node_valid = AXIS2_TRUE;
               axiom_node_t *current_node = NULL;
               axiom_element_t *current_element = NULL;
            
            AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
            AXIS2_PARAM_CHECK(env->error, _source, AXIS2_FAILURE);

            
              
              while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT)
              {
                  parent = axiom_node_get_next_sibling(parent, env);
              }
              if (NULL == parent)
              {
                /* This should be checked before everything */
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
                            "Failed in building adb object for source : "
                            "NULL element can not be passed to deserialize");
                return AXIS2_FAILURE;
              }
              

                    current_element = (axiom_element_t *)axiom_node_get_data_element(parent, env);
                    qname = axiom_element_get_qname(current_element, env, parent);
                    if (axutil_qname_equals(qname, env, _source-> qname))
                    {
                        
                          first_node = parent;
                          
                    }
                    else
                    {
                        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
                              "Failed in building adb object for source : "
                              "Expected %s but returned %s",
                              axutil_qname_to_string(_source-> qname, env),
                              axutil_qname_to_string(qname, env));
                        
                        return AXIS2_FAILURE;
                    }
                    

                     
                     /*
                      * building source element
                      */
                     
                     
                     
                                   current_node = first_node;
                                   is_early_node_valid = AXIS2_FALSE;
                                   
                                   

                           if ( 
                                (current_node ))
                           {
                              if( current_node )
                              {
                                is_early_node_valid = AXIS2_TRUE;
                              }
                              
                                 
                                      text_value = NULL; /* just to avoid warning */
                                      
                                        {
                                          axiom_node_t *current_property_node = current_node;
                                          current_node = axiom_node_get_next_sibling(current_node, env);
                                          axiom_node_detach(current_property_node, env);
                                          status = adb_source_set_source(_source, env,
                                                                          current_property_node);
                                        }
                                        
                                 if(AXIS2_FAILURE ==  status)
                                 {
                                     AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for source ");
                                     if(element_qname)
                                     {
                                         axutil_qname_free(element_qname, env);
                                     }
                                     return AXIS2_FAILURE;
                                 }
                              }
                           
                              else if(!dont_care_minoccurs)
                              {
                                  if(element_qname)
                                  {
                                      axutil_qname_free(element_qname, env);
                                  }
                                  /* this is not a nillable element*/
                                  AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "non nillable or minOuccrs != 0 element source missing");
                                  return AXIS2_FAILURE;
                              }
                           
                  if(element_qname)
                  {
                     axutil_qname_free(element_qname, env);
                     element_qname = NULL;
                  }
                 
          return status;
       }
        axis2_status_t AXIS2_CALL
        adb_CanonicalizationMethodType_deserialize_obj(
                adb_CanonicalizationMethodType_t* _CanonicalizationMethodType,
                const axutil_env_t *env,
                axiom_node_t **dp_parent,
                axis2_bool_t *dp_is_early_node_valid,
                axis2_bool_t dont_care_minoccurs)
        {
          axiom_node_t *parent = *dp_parent;
          
          axis2_status_t status = AXIS2_SUCCESS;
          
              axiom_attribute_t *parent_attri = NULL;
              axiom_element_t *parent_element = NULL;
              axis2_char_t *attrib_text = NULL;

              axutil_hash_t *attribute_hash = NULL;

           
             const axis2_char_t* text_value = NULL;
             axutil_qname_t *qname = NULL;
          
               int i = 0;
               axutil_array_list_t *arr_list = NULL;
            
               int sequence_broken = 0;
               axiom_node_t *tmp_node = NULL;
            
            axutil_qname_t *element_qname = NULL; 
            
               axiom_node_t *first_node = NULL;
               axis2_bool_t is_early_node_valid = AXIS2_TRUE;
               axiom_node_t *current_node = NULL;
               axiom_element_t *current_element = NULL;
            
            AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
            AXIS2_PARAM_CHECK(env->error, _CanonicalizationMethodType, AXIS2_FAILURE);

            
              
              while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT)
              {
                  parent = axiom_node_get_next_sibling(parent, env);
              }
              if (NULL == parent)
              {
                /* This should be checked before everything */
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
                            "Failed in building adb object for CanonicalizationMethodType : "
                            "NULL element can not be passed to deserialize");
                return AXIS2_FAILURE;
              }
              
                      
                      first_node = axiom_node_get_first_child(parent, env);
                      
                    
                 parent_element = (axiom_element_t *)axiom_node_get_data_element(parent, env);
                 attribute_hash = axiom_element_get_all_attributes(parent_element, env);
              
                    /*
                     * building extraElement array
                     */
                       arr_list = axutil_array_list_create(env, 10);
                   

                     
                     /*
                      * building extraElement element
                      */
                     
                     
                     
                            /* 'any' arrays are not handling correctly when there are other elements mixed with the 'any' element. */
                           
                               
                               for (i = 0, sequence_broken = 0, current_node = first_node; !sequence_broken && current_node != NULL;) 
                                             
                               {
                                  if(axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT)
                                  {
                                     current_node =axiom_node_get_next_sibling(current_node, env);
                                     is_early_node_valid = AXIS2_FALSE;
                                     continue;
                                  }
                                  
                                      if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname) || !axutil_strcmp("extraElement", axiom_element_get_localname(current_element, env))))
                                      {
                                          is_early_node_valid = AXIS2_TRUE;
                                      }
                                      
                                     
                                          text_value = NULL; /* just to avoid warning */
                                          
                                            {
                                              axiom_node_t *current_property_node = current_node;
                                              current_node = axiom_node_get_next_sibling(current_node, env);
                                              axiom_node_detach(current_property_node, env);
                                              axutil_array_list_add_at(arr_list, env, i, (void*)current_property_node);
                                            }
                                            
                                     if(AXIS2_FAILURE ==  status)
                                     {
                                         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for extraElement ");
                                         if(element_qname)
                                         {
                                            axutil_qname_free(element_qname, env);
                                         }
                                         if(arr_list)
                                         {
                                            axutil_array_list_free(arr_list, env);
                                         }
                                         return AXIS2_FAILURE;
                                     }

                                     i ++;
                                    
                               }

                               

                               if(0 == axutil_array_list_size(arr_list,env))
                               {
                                    axutil_array_list_free(arr_list, env);
                               }
                               else
                               {
                                    status = adb_CanonicalizationMethodType_set_extraElement(_CanonicalizationMethodType, env,
                                                                   arr_list);
                               }

                             
                  if(element_qname)
                  {
                     axutil_qname_free(element_qname, env);
                     element_qname = NULL;
                  }
                 
                
                
                  parent_attri = NULL;
                  attrib_text = NULL;
                  if(attribute_hash)
                  {
                       axutil_hash_index_t *hi;
                       void *val;
                       const void *key;

                       for (hi = axutil_hash_first(attribute_hash, env); hi; hi = axutil_hash_next(env, hi)) 
                       {
                           axutil_hash_this(hi, &key, NULL, &val);
                           
                           
                               if(!strcmp((axis2_char_t*)key, "Algorithm"))
                             
                               {
                                   parent_attri = (axiom_attribute_t*)val;
                                   AXIS2_FREE(env->allocator, hi);
                                   break;
                               }
                       }
                  }

                  if(parent_attri)
                  {
                    attrib_text = axiom_attribute_get_value(parent_attri, env);
                  }
                  else
                  {
                    /* this is hoping that attribute is stored in "Algorithm", this happnes when name is in default namespace */
                    attrib_text = axiom_element_get_attribute_value_by_name(parent_element, env, "Algorithm");
                  }

                  if(attrib_text != NULL)
                  {
                      
                      adb_CanonicalizationMethodType_set_Algorithm(_CanonicalizationMethodType,
                                                          env, axutil_uri_parse_string(env, attrib_text));
                        
                    }
                  
                    else if(!dont_care_minoccurs)
                    {
                        if(element_qname)
                        {
                            axutil_qname_free(element_qname, env);
                        }
                        /* this is not a nillable element*/
                        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "required attribute Algorithm missing");
                        return AXIS2_FAILURE;
                    }
                  
                  if(element_qname)
                  {
                     axutil_qname_free(element_qname, env);
                     element_qname = NULL;
                  }
                 
          return status;
       }
Пример #6
0
        axis2_status_t AXIS2_CALL
        adb_Exception_deserialize_obj(
                adb_Exception_t* _Exception,
                const axutil_env_t *env,
                axiom_node_t **dp_parent,
                axis2_bool_t *dp_is_early_node_valid,
                axis2_bool_t dont_care_minoccurs)
        {
          axiom_node_t *parent = *dp_parent;
          
          axis2_status_t status = AXIS2_SUCCESS;
           
             const axis2_char_t* text_value = NULL;
             axutil_qname_t *qname = NULL;
          
            axutil_qname_t *element_qname = NULL; 
            
               axiom_node_t *first_node = NULL;
               axis2_bool_t is_early_node_valid = AXIS2_TRUE;
               axiom_node_t *current_node = NULL;
               axiom_element_t *current_element = NULL;
            
            AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
            AXIS2_PARAM_CHECK(env->error, _Exception, AXIS2_FAILURE);

            
              
              while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT)
              {
                  parent = axiom_node_get_next_sibling(parent, env);
              }
              if (NULL == parent)
              {
                /* This should be checked before everything */
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
                            "Failed in building adb object for Exception : "
                            "NULL element can not be passed to deserialize");
                return AXIS2_FAILURE;
              }
              
                      
                      first_node = axiom_node_get_first_child(parent, env);
                      
                    

                     
                     /*
                      * building Exception element
                      */
                     
                     
                     
                                   current_node = first_node;
                                   is_early_node_valid = AXIS2_FALSE;
                                   
                                   
                                    while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT)
                                    {
                                        current_node = axiom_node_get_next_sibling(current_node, env);
                                    }
                                    if(current_node != NULL)
                                    {
                                        current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env);
                                        qname = axiom_element_get_qname(current_element, env, current_node);
                                    }
                                   
                                 element_qname = axutil_qname_create(env, "Exception", "http://services.resource.ui.mgt.registry.carbon.wso2.org", NULL);
                                 

                           if ( 
                                (current_node   && current_element && (axutil_qname_equals(element_qname, env, qname))))
                           {
                              if( current_node   && current_element && (axutil_qname_equals(element_qname, env, qname)))
                              {
                                is_early_node_valid = AXIS2_TRUE;
                              }
                              
                                 
                                      text_value = NULL; /* just to avoid warning */
                                      
                                          if(axiom_node_get_first_child(current_node, env))
                                          {
                                              axiom_node_t *current_property_node = axiom_node_get_first_child(current_node, env);
                                              axiom_node_detach(current_property_node, env);
                                              status = adb_Exception_set_Exception(_Exception, env,
                                                                          current_property_node);
                                          }
                                          else
                                          {
                                              status = adb_Exception_set_Exception(_Exception, env,
                                                                          NULL);
                                          }
                                        
                                 if(AXIS2_FAILURE ==  status)
                                 {
                                     AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for Exception ");
                                     if(element_qname)
                                     {
                                         axutil_qname_free(element_qname, env);
                                     }
                                     return AXIS2_FAILURE;
                                 }
                              }
                           
                  if(element_qname)
                  {
                     axutil_qname_free(element_qname, env);
                     element_qname = NULL;
                  }
                 
          return status;
       }
Пример #7
0
static axis2_status_t
savan_default_publisher_publish_to_subscriber(
    savan_publisher_t *publishermod,
    const axutil_env_t *env,
    axis2_svc_client_t *svc_client,
    savan_subscriber_t *subscriber,
    savan_filter_mod_t *filtermod,
    axiom_node_t *payload)
{
    axis2_options_t *options = NULL;
    axis2_status_t status = AXIS2_SUCCESS;
    axis2_endpoint_ref_t *to = NULL;
    const axis2_char_t *address = NULL;
    axis2_bool_t filter_apply = AXIS2_TRUE;
    axis2_endpoint_ref_t *notifyto = NULL;

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Entry:savan_default_publisher_publish_to_subscriber");

    options = (axis2_options_t *) axis2_svc_client_get_options(svc_client, env);
    if(!options)
    {
        options = axis2_options_create(env);
        axis2_svc_client_set_options(svc_client, env, options);
    }
    axis2_options_set_action(options, env, "http://ws.apache.org/ws/2007/05/eventing-extended/Publish");
    axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);

    notifyto = savan_subscriber_get_notify_to(subscriber, env);
    if(notifyto)
    {
        address = axis2_endpoint_ref_get_address(notifyto, env);
        if(address)
        {
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] Publishing to:%s", address);
            to = axis2_endpoint_ref_create(env, address);
            axis2_options_set_to(options, env, to);
        }
    }
    axis2_options_set_xml_parser_reset(options, env, AXIS2_FALSE);

#ifdef SAVAN_FILTERING
    /* If this is a filtering request and filter module is defined then filter the request.
     */
    {
        axis2_char_t *filter_dialect = NULL;
        filter_dialect = savan_subscriber_get_filter_dialect(subscriber, env);
        if(!axutil_strcmp(filter_dialect, SYNAPSE_FILTER_DIALECT))
        {
            /* Do nothing */
        }
        else if(filtermod && savan_subscriber_get_filter(subscriber, env))
        {
            /* Apply the filter, and check whether it evaluates to success */
            filter_apply = savan_filter_mod_apply(filtermod ,env, subscriber, payload);
            if(!filter_apply)
            {
                status = axutil_error_get_status_code(env->error);
                if(AXIS2_SUCCESS != status)
                {
                    axiom_node_detach(payload, env);
                    return status;
                }
            }
        }
        else
        {
            AXIS2_HANDLE_ERROR(env, SAVAN_ERROR_FILTER_MODULE_COULD_NOT_BE_RETRIEVED, 
                    AXIS2_FAILURE);
            return AXIS2_FAILURE;
        }
    }
#endif

    if(filter_apply)
    {
        axis2_svc_client_fire_and_forget(svc_client, env, payload);
    }

    axiom_node_detach(payload, env); /*insert this to prevent payload corruption in subsequent 
                                       "publish" calls with some payload.*/

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Exit:savan_default_publisher_publish_to_subscriber");

    return status;
}
Пример #8
0
void wsf_util_pack_attachments (
    axutil_env_t *env,
    axiom_node_t *node,
    VALUE 		  attach_ht,
    int 		  enable_mtom,
    char 		 *default_cnt_type)
{
    axiom_element_t *node_element = NULL;
    axiom_element_t *child_element = NULL;
    axiom_child_element_iterator_t *child_element_ite = NULL;
    axiom_node_t *child_node = NULL;
    int attachment_done = 0;
    axis2_char_t *element_localname = NULL;
    axiom_namespace_t *element_namespace = NULL;
    axis2_char_t *namespace_uri = NULL;

    if (!node)
        return;

    if (axiom_node_get_node_type(node, env) == AXIOM_ELEMENT)
    {
        node_element = axiom_node_get_data_element(node, env);
        if (node_element)
        {
            child_element_ite = axiom_element_get_child_elements(node_element, env, node);
            if (child_element_ite)
            {
                child_node = axiom_child_element_iterator_next(child_element_ite, env);
                attachment_done = 0;

                while (child_node && !attachment_done)
                {
                    child_element = axiom_node_get_data_element(child_node, env);

                    element_localname = axiom_element_get_localname(child_element, env);
                    if (element_localname && (axutil_strcmp(element_localname, AXIS2_ELEMENT_LN_INCLUDE) == 0))
                    {
                        element_namespace = axiom_element_get_namespace(child_element, env, child_node);
                        if (element_namespace)
                        {
                            namespace_uri = axiom_namespace_get_uri(element_namespace, env);
                            if (namespace_uri && (axutil_strcmp(namespace_uri, AXIS2_NAMESPACE_URI_INCLUDE) == 0))
                            {
                                axis2_char_t *cnt_type = NULL;
                                axis2_char_t *content_type = NULL;
                                axis2_char_t *href = NULL;
                                axis2_char_t* pos = NULL;

                                cnt_type = axiom_element_get_attribute_value_by_name(node_element, env, AXIS2_ELEMENT_ATTR_NAME_CONTENT_TYPE);
                                content_type = !cnt_type ? default_cnt_type : cnt_type;

                                href = axiom_element_get_attribute_value_by_name(child_element, env, AXIS2_ELEMENT_ATTR_NAME_HREF);

                                if ((axutil_strlen(href) > 4) && (pos = axutil_strstr (href, "cid:")))
                                {
                                    axis2_char_t* cid = NULL;
                                    VALUE content_tmp;
                                    void* content = NULL;
                                    unsigned int content_length = 0;

                                    cid = href + 4;

                                    content_tmp = rb_hash_aref(attach_ht, rb_str_new2(cid));
                                    content_length = RSTRING(content_tmp)->len;

                                    content = malloc(sizeof (char) * content_length);
                                    memcpy (content, (const void*)STR2CSTR(content_tmp), content_length);

                                    if (content)
                                    {
                                        void *data_buffer = NULL;
                                        axiom_data_handler_t *data_handler = NULL;
                                        axiom_node_t *text_node = NULL;
                                        axiom_text_t *text = NULL;

                                        data_buffer = AXIS2_MALLOC (env->allocator, sizeof (char) * content_length);
                                        if (data_buffer)
                                        {
                                            memcpy (data_buffer, content, content_length);

                                            data_handler = axiom_data_handler_create (env, NULL, content_type);
                                            if (data_handler)
                                            {
                                                axiom_data_handler_set_binary_data (data_handler, env, (axis2_byte_t *)content, content_length);

                                                text = axiom_text_create_with_data_handler (env, node, data_handler, &text_node);

                                                if (enable_mtom == AXIS2_FALSE)
                                                    axiom_text_set_optimize (text, env, AXIS2_FALSE);

                                                axiom_node_detach (child_node, env);
                                            }
                                        }

                                        attachment_done = 1;
                                    }
                                }
                            }
                        }
                    }

                    child_node = axiom_child_element_iterator_next(child_element_ite, env);
                }
            }
        }
    }

    // Process child nodes
    child_node = axiom_node_get_first_child(node, env);
    while (child_node)
    {
        wsf_util_pack_attachments(env, child_node, attach_ht, enable_mtom, default_cnt_type);

        child_node = axiom_node_get_next_sibling(child_node, env);
    }
}
/*Public functions*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
rampart_shb_ensure_sec_header_order(const axutil_env_t *env,
                                    axis2_msg_ctx_t *msg_ctx,
                                    rampart_context_t *rampart_context,
                                    axiom_node_t* sec_node)
{
    axis2_bool_t signature_protection = AXIS2_FALSE;
    axis2_bool_t is_encrypt_before_sign = AXIS2_FALSE;
    axiom_node_t *sig_node = NULL;
    axiom_node_t *enc_key_node = NULL;
    axiom_node_t *ref_list_node = NULL;
    axiom_node_t *h_node = NULL;
    axutil_array_list_t *dk_list = NULL;
    axutil_array_list_t *enc_key_list = NULL;
    axiom_node_t* first_protection_item = NULL;
    int i = 0;

    signature_protection = rampart_context_is_encrypt_signature(rampart_context, env);
    is_encrypt_before_sign = rampart_context_is_encrypt_before_sign(rampart_context, env);

    dk_list = axutil_array_list_create(env, 5);
    enc_key_list = axutil_array_list_create(env, 2);

    h_node = axiom_node_get_first_child(sec_node, env);
    while(h_node)
    {
        if(0 == axutil_strcmp(OXS_NODE_DERIVED_KEY_TOKEN, axiom_util_get_localname(h_node, env)) ||
                (0 == axutil_strcmp(OXS_NODE_BINARY_SECURITY_TOKEN, axiom_util_get_localname(h_node, env))))
        {
            axutil_array_list_add(dk_list, env, h_node);
        }
        else if((0 == axutil_strcmp(OXS_NODE_ENCRYPTED_KEY, axiom_util_get_localname(h_node, env))) ||
                (0 == axutil_strcmp(OXS_NODE_SECURITY_CONTEXT_TOKEN, axiom_util_get_localname(h_node, env))))
        {
            axutil_array_list_add(enc_key_list, env, h_node);
        }
        h_node = axiom_node_get_next_sibling(h_node, env);
    }

    ref_list_node = oxs_axiom_get_first_child_node_by_name(env, sec_node, OXS_NODE_REFERENCE_LIST, OXS_ENC_NS, NULL);
    sig_node = oxs_axiom_get_first_child_node_by_name(env, sec_node, OXS_NODE_SIGNATURE, OXS_DSIG_NS, NULL);

    /*Ensure the protection order in the header*/
    if(sig_node && ref_list_node)
    {
        if(is_encrypt_before_sign)
        {
            int no_of_sig_node = 0;
            /*Encrypt->Sig         <Sig><RefList>*/
            oxs_axiom_interchange_nodes(env,  sig_node, ref_list_node );
            first_protection_item = sig_node;
            no_of_sig_node = oxs_axiom_get_number_of_children_with_qname(env, sec_node, OXS_NODE_SIGNATURE, OXS_DSIG_NS, NULL);
            if(no_of_sig_node > 1)
            {
                axiom_node_t* cur_node = NULL;
                cur_node = axiom_node_get_first_child(sec_node, env);
                while(cur_node)
                {
                    axis2_char_t *cur_local_name = NULL;
                    cur_local_name = axiom_util_get_localname(cur_node, env);

                    if(0 == axutil_strcmp(cur_local_name, OXS_NODE_SIGNATURE))
                    {
                        oxs_axiom_interchange_nodes(env,  cur_node, ref_list_node);
                    }
                    cur_node = axiom_node_get_next_sibling(cur_node, env);
                }
            }
        }
        else
        {
            /*Sig->Encrypt         <RefList> <Sig>*/
            oxs_axiom_interchange_nodes(env, ref_list_node, sig_node );
            first_protection_item = ref_list_node;
        }
    }
    else if(sig_node)
    {
        first_protection_item = sig_node;
    }
    else
    {
        first_protection_item = ref_list_node;
    }

    /*makesure enc_key_node is appearing before first protection item*/
    if(first_protection_item)
    {
        for(i = 0; i < axutil_array_list_size(enc_key_list, env); i++)
        {
            axiom_node_t *tmp_node = NULL;
            tmp_node = (axiom_node_t*)axutil_array_list_get(enc_key_list, env, i);
            enc_key_node = axiom_node_detach_without_namespaces(tmp_node, env);
            axiom_node_insert_sibling_before(first_protection_item, env, enc_key_node);
        }
    }

    /*
     * If there are derived keys, make sure they come after the EncryptedKey/security context token
        1. First we get all the derived keys
        2. Then we attach after the EncryptedKey(hidden sessionkey)/security context token 
        3. If key is not available, then attach derived keys before sig_node and ref_list_node (whichever is first)
     */

    if(enc_key_node)
    {
        for(i = 0; i < axutil_array_list_size(dk_list, env); i++)
        {
            axiom_node_t *dk_node = NULL;
            axiom_node_t *tmp_node = NULL;

            dk_node = (axiom_node_t*)axutil_array_list_get(dk_list, env, i);
            tmp_node = axiom_node_detach(dk_node, env);
            axiom_node_insert_sibling_after(enc_key_node, env, tmp_node);
        }
    }
    else
    {
        if(first_protection_item)
        {
            for(i = 0; i < axutil_array_list_size(dk_list, env); i++)
            {
                axiom_node_t *dk_node = NULL;
                axiom_node_t *tmp_node = NULL;
                dk_node = (axiom_node_t*)axutil_array_list_get(dk_list, env, i);
                tmp_node = axiom_node_detach(dk_node, env);
                axiom_node_insert_sibling_before(first_protection_item, env, tmp_node);
            }
        }
    }
    
    axutil_array_list_free(dk_list, env);
    axutil_array_list_free(enc_key_list, env);
    return AXIS2_SUCCESS;
}
Пример #10
0
AXIS2_EXTERN axiom_soap_header_t *AXIS2_CALL
axiom_soap_header_create_with_parent(
    const axutil_env_t * env,
    axiom_soap_envelope_t * envelope)
{
    axiom_soap_header_t *soap_header = NULL;

    /*axiom_element_t *this_ele = NULL;
     axiom_node_t *this_node = NULL;*/
    axiom_node_t *body_node = NULL;
    axiom_node_t *parent_node = NULL;
    axiom_element_t *parent_ele = NULL;

    /*axiom_namespace_t *parent_ns = NULL;*/

    AXIS2_PARAM_CHECK(env->error, envelope, NULL);

    soap_header = axiom_soap_header_create(env);
    if(!soap_header)
    {
        return NULL;
    }
    soap_header->soap_version = axiom_soap_envelope_get_soap_version(envelope, env);

    parent_node = axiom_soap_envelope_get_base_node(envelope, env);

    if(!parent_node || axiom_node_get_node_type(parent_node, env) != AXIOM_ELEMENT)
    {
        axiom_soap_header_free(soap_header, env);
        return NULL;
    }

    parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env);
    if(!parent_ele)
    {
        axiom_soap_header_free(soap_header, env);
        return NULL;
    }
    if(axiom_node_get_first_element(parent_node, env))
    {
        body_node = axiom_node_get_first_element(parent_node, env);
        axiom_node_detach(body_node, env);
    }

    /*parent_ns = axiom_element_get_namespace(parent_ele, env, parent_node);
     this_ele = axiom_element_create(env, parent_node,
     AXIOM_SOAP_HEADER_LOCAL_NAME, parent_ns,
     &this_node);
     if (!this_ele)
     {
     axiom_soap_header_free(soap_header, env);
     return NULL;
     }

     soap_header->om_ele_node = this_node;*/

    axiom_soap_envelope_set_header(envelope, env, soap_header);

    if(body_node)
    {
        axiom_node_add_child(parent_node, env, body_node);
    }

    soap_header->soap_envelope = envelope;

    return soap_header;
}
Пример #11
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axiom_soap_header_remove_header_block(
    axiom_soap_header_t * soap_header,
    const axutil_env_t * env,
    axutil_qname_t * qname)
{
    axis2_char_t *qn_localname = NULL;
    axis2_char_t *qname_ns = NULL;
    axis2_char_t *qname_prefix = NULL;
    axutil_hash_index_t *hi = NULL;

    AXIS2_PARAM_CHECK(env->error, qname, AXIS2_FAILURE);

    qn_localname = axutil_qname_get_localpart(qname, env);
    qname_ns = axutil_qname_get_uri(qname, env);
    qname_prefix = axutil_qname_get_prefix(qname, env);

    if(!soap_header->header_blocks)
    {
        return AXIS2_FAILURE;
    }
    for(hi = axutil_hash_first(soap_header->header_blocks, env); hi; hi = axutil_hash_next(env, hi))
    {
        const void *key = NULL;
        void *val = NULL;

        axutil_hash_this(hi, &key, NULL, &val);
        if(val)
        {
            axiom_soap_header_block_t *header_block = NULL;
            axiom_element_t *ele = NULL;
            axiom_node_t *node = NULL;

            header_block = (axiom_soap_header_block_t *)val;
            node = axiom_soap_header_block_get_base_node(header_block, env);
            if(node)
            {
                axutil_qname_t *element_qname = NULL;

                ele = (axiom_element_t *)axiom_node_get_data_element(node, env);
                element_qname = axiom_element_get_qname(ele, env, node);
                if(axiom_soap_header_qname_matches(env, element_qname, qname) == AXIS2_TRUE)
                {
                    axiom_node_detach(node, env);
                    /* axiom_node_free_tree(node, env); */
                    axutil_hash_set(soap_header->header_blocks, key, AXIS2_HASH_KEY_STRING, NULL);
                    axiom_soap_header_block_free(header_block, env);
                    axiom_node_free_tree(node, env);
                    break;
                }
            }
        }
    }

    if(hi)
    {
        AXIS2_FREE(env->allocator, hi);
    }

    return AXIS2_SUCCESS;
}
        axis2_status_t AXIS2_CALL
        adb_metadataChoice_type1_deserialize_obj(
                adb_metadataChoice_type1_t* _metadataChoice_type1,
                const axutil_env_t *env,
                axiom_node_t **dp_parent,
                axis2_bool_t *dp_is_early_node_valid,
                axis2_bool_t dont_care_minoccurs)
        {
          axiom_node_t *parent = *dp_parent;
          
          axis2_status_t status = AXIS2_SUCCESS;
           
             const axis2_char_t* text_value = NULL;
             axutil_qname_t *qname = NULL;
          
            axutil_qname_t *element_qname = NULL; 
            
               axiom_node_t *first_node = NULL;
               axis2_bool_t is_early_node_valid = AXIS2_TRUE;
               axiom_node_t *current_node = NULL;
               axiom_element_t *current_element = NULL;
            
            AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
            AXIS2_PARAM_CHECK(env->error, _metadataChoice_type1, AXIS2_FAILURE);

            
                         first_node = parent;
                    

                     
                     /*
                      * building extraElement element
                      */
                     
                     
                     
                                   current_node = first_node;
                                   is_early_node_valid = AXIS2_FALSE;
                                   
                                   

                           if ( 
                                (current_node ))
                           {
                              if( current_node )
                              {
                                is_early_node_valid = AXIS2_TRUE;
                              }
                              
                                 
                                      text_value = NULL; /* just to avoid warning */
                                      
                                        {
                                          axiom_node_t *current_property_node = current_node;
                                          current_node = axiom_node_get_next_sibling(current_node, env);
                                          axiom_node_detach(current_property_node, env);
                                          status = adb_metadataChoice_type1_set_extraElement(_metadataChoice_type1, env,
                                                                          current_property_node);
                                        }
                                        
                                 if(AXIS2_FAILURE ==  status)
                                 {
                                     AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for extraElement ");
                                     if(element_qname)
                                     {
                                         axutil_qname_free(element_qname, env);
                                     }
                                     return AXIS2_FAILURE;
                                 }
                              }
                           
                  if(element_qname)
                  {
                     axutil_qname_free(element_qname, env);
                     element_qname = NULL;
                  }
                 
                *dp_parent = current_node;
                *dp_is_early_node_valid = is_early_node_valid;
            
          return status;
       }
Пример #13
0
axis2_status_t
wsclient_set_attachment (const axutil_env_t *env,
						 axiom_node_t *node,
						 axis2_char_t *base_dir,
						 int is_mtom_enabled)
{
	axiom_node_t *child_node = NULL;
	axiom_element_t *element;
	if (!node || !env)
		return AXIS2_FAILURE;

	if (axiom_node_get_node_type (node, env) == AXIOM_ELEMENT)
	{
		axis2_char_t *local_name;
		axiom_namespace_t *ns;
		axis2_char_t *ns_uri;
		element = (axiom_element_t *) axiom_node_get_data_element (node, env);
		local_name = axiom_element_get_localname (element, env);
		if (local_name)
		{
			if (!strcmp (local_name, "Include"))
			{
				ns = axiom_element_get_namespace(element, env, node);
				if (ns && (ns_uri = axiom_namespace_get_uri (ns, env))
					&& (!strcmp (ns_uri, "http://www.w3.org/2004/08/xop/include")))
				{
					axis2_char_t *file_path;
					axiom_data_handler_t *data_handler;
					axiom_text_t *data_text;
					axiom_node_t *data_node;
					axiom_node_t *parent;
					axutil_uri_t *file_uri = NULL;
					axutil_uri_t *base_uri = NULL;
					axutil_uri_t *real_uri = NULL;
					axis2_char_t *real_path = NULL;

					parent = axiom_node_get_parent (node, env);
					axiom_node_detach (node, env);
					file_path = axiom_element_get_attribute_value_by_name (element, env, "href");
					file_uri = axutil_uri_parse_string (env, file_path);

					if (base_dir)
						base_uri = axutil_uri_parse_string (env, base_dir);
					else 
						return AXIS2_FAILURE;


					if (base_uri)
						real_uri = axutil_uri_parse_relative (env, base_uri, file_path);
					else
						return AXIS2_FAILURE;

					if (real_uri)
						real_path = axutil_uri_to_string (real_uri, env, 1);
					else 
						return AXIS2_FAILURE;


					if (real_path)
						data_handler = axiom_data_handler_create (env, real_path, "image/jpeg");
					else
						return AXIS2_FAILURE;

					if (data_handler)
						data_text = axiom_text_create_with_data_handler (env, parent, data_handler, &data_node);
					else
						return AXIS2_FAILURE;

					if (data_text)
					{
						if (!is_mtom_enabled)
							axiom_text_set_optimize (data_text, env, AXIS2_FALSE);
					}
				}
			}
		}

		child_node = axiom_node_get_first_element (node, env);
		while (child_node)
		{
			wsclient_set_attachment (env, child_node, base_dir, is_mtom_enabled); 
			child_node = axiom_node_get_next_sibling (child_node, env);
		}
	}
	else
		return AXIS2_FAILURE;

	return AXIS2_SUCCESS;
}
Пример #14
0
//-----------------------------------------------------------------------------
void
sp_update_lineage(
    const axutil_env_t * env,
    const sp_props     *props,
    axiom_node_t *return_node,
    axiom_node_t *request_node,
    time_t        request_time)
{
    axiom_node_t *eom_node =
    		rp_find_named_child(env, return_node, "EOMetadata", 1);
    if (NULL == eom_node)
    {
    	rp_log_error(env, "*Warning S2P(%s:%d): %s node not found.\n",
    			__FILE__, __LINE__,  "EOMetadata");
    	return;
    }

    time_t lineage_time = 0;
    axiom_node_t *curr_lineage =
    		sp_latest_named(env, eom_node, "lineage", &lineage_time);

    // TODO: should improve handling of insignificant whitespace.

    // grab some whitespace for future use
    axiom_node_t *lin_whsp_node = sp_get_last_text_node(curr_lineage, env);
    axiom_node_t *eom_whsp_node = sp_get_last_text_node(eom_node,     env);

    const axis2_char_t *lin_whsp_str = sp_get_text_text(lin_whsp_node, env);
    const axis2_char_t *eom_whsp_str = sp_get_text_text(eom_whsp_node, env);
    int whspace_indent = SP_DEFAULT_WHSPACE;
    if (NULL != lin_whsp_str && NULL != eom_whsp_str)
    {
    	whspace_indent =
    			axutil_strlen(lin_whsp_str) - axutil_strlen(eom_whsp_str);
    	if (whspace_indent < 0 || whspace_indent >12)
    	{
    		rp_log_error(env,
    				"*Warning S2P: funny whitespace indent (%d) calculated.\n",
    				whspace_indent);
    		whspace_indent = SP_DEFAULT_WHSPACE;
    	}
    }

    axis2_char_t curr_whspace[SP_MAX_LOCAL_STR_LEN];
    strncpy(curr_whspace, lin_whsp_str, SP_MAX_LOCAL_STR_LEN-1);
    curr_whspace[SP_MAX_LOCAL_STR_LEN-1] = '\0';

    // The most recent Lineage data is deleted only if it has been added
    // in the time period since we started processing this request.
    if (NULL != curr_lineage && lineage_time >= request_time)
    {
    	// OK to delete lineage
    	axiom_node_detach    (curr_lineage, env);
		axiom_node_free_tree (curr_lineage, env);
		curr_lineage  = NULL;
		lin_whsp_node = NULL;
		lin_whsp_str  = NULL;
    }
    else
    {
    	sp_add_whspace(env, eom_node, curr_whspace);
    }

    // Add a new lineage.  here is an example:
    //    <wcseo:lineage>
    //        <wcseo:referenceGetCoverage>
    //            <ows:ServiceReference xlink:href="http://www.someWCS.org">
    //                <ows:RequestMessage>
    //                    <wcs:GetCoverage service="WCS" version="2.0.0">
    //                        <wcs:format>application/gml+xml</wcs:format>
    //                        <wcs:CoverageId>someEOCoverage1</wcs:CoverageId>
    //                    </wcs:GetCoverage>
    //                </ows:RequestMessage>
    //            </ows:ServiceReference>
    //        </wcseo:referenceGetCoverage>
    //        <gml:timePosition>2011-08-24T14:18:52Z</gml:timePosition>
    //    </wcseo:lineage>


    // <wcseo:lineage>
    axiom_node_t *lineage_node =
    		rp_add_child_el(env, eom_node, "lineage", NULL);

    sp_inc_whspace(curr_whspace, whspace_indent);
    sp_add_whspace(env, lineage_node, curr_whspace);

    // comment
    axiom_node_t *comment  = axiom_node_create(env);
    axiom_comment_create (
    		env,
    		lineage_node,
    		"POST GetCoverage request added by SOAP-TO-POST proxy.",
    		&comment);

	//<wcseo:referenceGetCoverage>
	axiom_node_t *ref_g1_node =
			rp_add_child_el(env, lineage_node, "referenceGetCoverage", curr_whspace);

	// <ows:ServiceReference xlink:href="http://www.someWCS.org">
    sp_inc_whspace(curr_whspace, whspace_indent);
    sp_add_whspace(env, ref_g1_node, curr_whspace);
	axiom_namespace_t *ows_ns =
			sp_find_or_create_ns(env, return_node, SP_OWS_NAMESPACE_STR, "ows");

    axiom_node_t    *service_ref_node = axiom_node_create(env);
    axiom_element_t *service_ref_el =
      axiom_element_create(
    		  env, ref_g1_node, "ServiceReference", ows_ns, &service_ref_node);

	axiom_namespace_t *xlink_ns = sp_find_or_create_ns(
			env, return_node, SP_XLINK_NAMESPACE_STR, "xlink");

    axiom_attribute_t *attr =
      axiom_attribute_create (env, "type", "simple", xlink_ns);
    axiom_element_add_attribute (service_ref_el, env, attr, service_ref_node);

    attr = axiom_attribute_create (env, "href", rp_getSoapOpsURL(env, props), xlink_ns);
    axiom_element_add_attribute (service_ref_el, env, attr, service_ref_node);

    //<ows:RequestMessage>
    axiom_node_t *req_msg_node =
    		rp_add_child_el(env,
    				service_ref_node, "RequestMessage", curr_whspace);
    sp_inc_whspace(curr_whspace, whspace_indent);


    // Detach the request GetCoverage element from its parent
    //  and attach it here.
    axiom_node_t *gc_node =
    		rp_find_named_node(env, request_node, "GetCoverage", 1);
    if (gc_node)
    {
    	// TODO - pretty-up the the indentation to match current.
        sp_add_whspace(env, req_msg_node, curr_whspace);
    	axiom_node_detach    (gc_node, env);
    	axiom_node_add_child (req_msg_node, env, gc_node);
    }

    // Adjust the indentation of closing tags
    sp_inc_whspace(curr_whspace, -whspace_indent);
    sp_add_whspace(env, req_msg_node, curr_whspace);
    sp_inc_whspace(curr_whspace, -whspace_indent);
    sp_add_whspace(env, service_ref_node, curr_whspace);
    sp_inc_whspace(curr_whspace, -whspace_indent);
    sp_add_whspace(env, ref_g1_node, curr_whspace);
    sp_inc_whspace(curr_whspace, -whspace_indent);

    //<gml:timePosition>2011-08-24T14:18:52Z</gml:timePosition>
    sp_add_whspace(env, lineage_node, curr_whspace);
	axiom_namespace_t *gml_ns = sp_find_or_create_ns(
			env, return_node, SP_GML_NAMESPACE_STR, "gml");

    axiom_node_t    *time_pos_node = axiom_node_create(env);
    axiom_element_t *time_pos_el = axiom_element_create(
    		env, lineage_node, "timePosition", gml_ns, &time_pos_node);

    char tmbuf[22];
    sp_time_str(tmbuf, time(NULL));
    axiom_element_set_text(time_pos_el, env, tmbuf, time_pos_node);

    // Adjust the indentation of remaining closing tags
    sp_inc_whspace(curr_whspace, -whspace_indent);
    sp_add_whspace(env, lineage_node, curr_whspace);

    // Adjust whitespace before the element
    // that follows our new lineage element, whatever it may be.
    sp_add_whspace(env, eom_node, eom_whsp_str);

    // Delete the whitespace before any our insertions.
	axiom_node_detach    (eom_whsp_node, env);
	axiom_node_free_tree (eom_whsp_node, env);
}