Exemplo n.º 1
0
int AXIS2_CALL 
savan_subs_mgr_svc_init_with_conf(
    axis2_svc_skeleton_t *svc_skeleton,
    const axutil_env_t *env,
    axis2_conf_t *conf)
{
    /*savan_subs_mgr_t *subs_mgr = NULL;
    axutil_array_list_t *topic_param_list = NULL;
    axis2_svc_t *subs_svc = NULL;
    axis2_op_t *op = NULL;
    int i = 0, size = 0;*/

    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] Start:savan_subs_mgr_svc_init_with_conf");

    /*subs_mgr = savan_subs_mgr_get_subs_mgr(env, NULL, conf);
    if(!subs_mgr)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[savan] Could not create the database. Check \
            whether database path is correct and accessible. Exit loading the Savan module");
        AXIS2_ERROR_HANDLE(env, SAVAN_ERROR_DATABASE_CREATION_ERROR, AXIS2_FAILURE);

        return AXIS2_FAILURE;
    }*/

    savan_subs_mgr_svc_init(svc_skeleton, env);
    /*subs_svc = axis2_conf_get_svc(conf, env, "subscription");
    op = axis2_svc_get_op_with_name(subs_svc, env, "get_topic_list");
    topic_param_list = axis2_op_get_all_params(op, env);
    if(topic_param_list)
    {
        size = axutil_array_list_size(topic_param_list, env);
    }

    for(i = 0; i < size; i++)
    {
        axutil_param_t *topic_param = NULL;
        axis2_char_t *topic_url_str = NULL;
        axis2_char_t *topic_name = NULL;
        topic_param = axutil_array_list_get(topic_param_list, env, i);
        topic_url_str = axutil_param_get_value(topic_param, env);
        topic_name = axutil_param_get_name(topic_param, env);
        if(!axutil_strcmp(topic_name, "wsamapping"))
        {
            continue;
        }

        if(savan_db_mgr_insert_topic(env, dbname, topic_name, topic_url_str))
        {
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] Topic %s added", topic_url_str);
        }
        else
        {
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] Topic %s could not be added", topic_url_str);
        }
    }*/

    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] End:savan_subs_mgr_svc_init_with_conf");

    return AXIS2_SUCCESS;
}
Exemplo n.º 2
0
AXIS2_EXTERN axis2_char_t* AXIS2_CALL
service_admin_util_get_epr_address(const axutil_env_t *env,
						   axis2_msg_ctx_t *msg_ctx,
						   axis2_char_t *service_name)
{
	axis2_endpoint_ref_t *epr = NULL;
	axis2_char_t *address = NULL;
	axis2_conf_ctx_t *conf_ctx = NULL;
	axis2_conf_t *conf = NULL;
	axis2_transport_in_desc_t *transport_in = NULL;

	conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
	conf = axis2_conf_ctx_get_conf(conf_ctx, env);
	
	transport_in = axis2_conf_get_transport_in(conf, env, AXIS2_TRANSPORT_ENUM_HTTP);

	if(transport_in)
	{
		axis2_transport_receiver_t *receiver = NULL;
		receiver = axis2_transport_in_desc_get_recv(transport_in, env);
		if(!receiver)
		{
			AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Transport Receiver Not found ");
			return NULL;
		}
		epr = axis2_transport_receiver_get_epr_for_service(receiver, env, service_name);
		if(!epr)
		{
			AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Endpoint reference null");
			return NULL;
		}
		address = (axis2_char_t*)axis2_endpoint_ref_get_address(epr,env);
	}
	return address;
}
Exemplo n.º 3
0
/**
 * Verify that an addressing element is located in <Envelope>/<Header>
 */
int verify_addr_hdr_elem_loc(axiom_node_t *signed_node, const axutil_env_t *env, axis2_char_t *ref) {

    axiom_node_t *parent = axiom_node_get_parent(signed_node,env);

    if(axutil_strcmp(OXS_NODE_HEADER, axiom_util_get_localname(parent, env))) {
       AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[euca-rampart] parent of addressing elem is %s", axiom_node_to_string(parent, env));
       oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_ELEMENT_FAILED, "Unexpected location of signed addressing elem with ID = %s", ref);
       return 1;

    }
     parent = axiom_node_get_parent(parent,env);

    if(axutil_strcmp(OXS_NODE_ENVELOPE, axiom_util_get_localname(parent, env))) {
       AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[euca-rampart] second parent of addressing elem is %s", axiom_node_to_string(parent, env));
       oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_ELEMENT_FAILED, "Unexpected location of signed addressing elem with ID = %s", ref);
       return 1;

    }

     parent = axiom_node_get_parent(parent,env);
     if(parent) {
       AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[euca-rampart] parent of Envelope = %s", axiom_node_to_string(parent, env));
       oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_ELEMENT_FAILED, "Unexpected location of signed Body with ID = %s", ref);
       return 1;
     }

     return 0;
}
Exemplo n.º 4
0
static axis2_op_t *AXIS2_CALL
axis2_addr_disp_find_op(
    axis2_msg_ctx_t * msg_ctx,
    const axutil_env_t * env,
    axis2_svc_t * svc)
{
    const axis2_char_t *action = NULL;
    axutil_qname_t *name = NULL;
    axis2_op_t *op = NULL;

    AXIS2_ENV_CHECK(env, NULL);
    AXIS2_PARAM_CHECK(env->error, svc, NULL);

    if(axis2_msg_ctx_get_doing_rest(msg_ctx, env))
        return NULL;

    action = axis2_msg_ctx_get_wsa_action(msg_ctx, env);

    if(action)
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Checking for operation using WSA Action : %s",
            action);

        name = axutil_qname_create(env, action, NULL, NULL);
        op = axis2_svc_get_op_with_qname(svc, env, name);
        if(op)
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Operation found using WSA Action");
        axutil_qname_free(name, env);
    }

    return op;
}
Exemplo n.º 5
0
axiom_node_t *
axis2_listener_notify(const axutil_env_t *env, axiom_node_t *node)
{
    axis2_char_t *str = NULL;
    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Start:axis2_listener_notify");
    AXIS2_ENV_CHECK(env, NULL);

    str = axiom_node_to_string(node, env);
    if (str)
        printf("\nReceived : %s\n", str);
    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "End:axis2_listener_notify");

    return NULL;
}
Exemplo n.º 6
0
WSF_PHP_API axis2_msg_recv_t *WSF_CALL
wsf_xml_msg_recv_create(
        const axutil_env_t * env)
{

    axis2_msg_recv_t *msg_recv = NULL;
    axis2_status_t status = AXIS2_FAILURE;

    AXIS2_ENV_CHECK(env, NULL);
    msg_recv = axis2_msg_recv_create(env);

    if (NULL == msg_recv)
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "xml msg recv null");
        return NULL;
    }
    status = axis2_msg_recv_set_scope(msg_recv, env, AXIS2_APPLICATION_SCOPE);

    if (AXIS2_TRUE != status)
    {
        axis2_msg_recv_free(msg_recv, env);
        return NULL;
    }

    axis2_msg_recv_set_invoke_business_logic(msg_recv, env,
            wsf_xml_msg_recv_invoke_business_logic_sync);

    return msg_recv;
}
Exemplo n.º 7
0
axis2_status_t AXIS2_CALL
savan_client_add_sub_id_to_soap_header(
    savan_client_t *client,
    const axutil_env_t *env,
    axis2_svc_client_t *svc_client)
{
    axiom_namespace_t *ns = NULL;
    axiom_node_t *id_node = NULL;
    axiom_element_t *id_elem = NULL;

    /* Create a node with the subscription id and attach it as a soap header
     * to the service client */

    ns = axiom_namespace_create(env, EVENTING_NAMESPACE, EVENTING_NS_PREFIX);
    id_elem = axiom_element_create(env, NULL, ELEM_NAME_ID, ns, &id_node);
    if (!id_elem)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[savan] [client] Failed to "
            "create element for Identifier node");
        return AXIS2_FAILURE;
    }

    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "client->sub_id:%s\n", client->sub_id);
    axiom_element_set_text(id_elem, env, client->sub_id, id_node);

    axis2_svc_client_add_header(svc_client, env, id_node);

    return AXIS2_SUCCESS;

}
Exemplo n.º 8
0
int
wsf_util_engage_module (
    axis2_conf_t * conf,
    axis2_char_t * module_name,
    axutil_env_t * env,
    axis2_svc_t * svc)
{
    axis2_module_desc_t *module = NULL;
    axutil_qname_t *mod_qname = NULL;
    axis2_phase_resolver_t *phase_resolver = NULL;
    int status = AXIS2_FAILURE;

    mod_qname = axutil_qname_create (env, module_name, NULL, NULL);
    module = axis2_conf_get_module (conf, env, mod_qname);
    if (module) {
        status = axis2_svc_engage_module (svc, env, module, conf);
        if (!status) {
            phase_resolver =
                axis2_phase_resolver_create_with_config (env, conf);
            if (!phase_resolver) {
                AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI,
                                 " [wsf-log] PHASE RESLOVER NULL");
                return AXIS2_FAILURE;
            }
            status =
                axis2_phase_resolver_engage_module_to_svc (phase_resolver,
                        env, svc, module);
        }
    }
    return status;
}
Exemplo n.º 9
0
static xsltStylesheetPtr 
savan_xpath_filter_mod_get_filter_template(
    const axutil_env_t *env,
    axis2_char_t *filter_template_path,
    xmlChar *filter)
{
    xsltStylesheetPtr xslt_template_xslt = NULL;
    xmlDocPtr xslt_template_xml = NULL;
    xmlChar* xpathExpr = NULL; 
    xmlXPathContextPtr xpathCtx = NULL;
    xmlXPathObjectPtr xpathObj = NULL;
	
    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] filter_template_path:%s", filter_template_path);

    xslt_template_xml = xmlParseFile(filter_template_path);
    xpathExpr = (xmlChar*)"//@select";
    xpathCtx = xmlXPathNewContext(xslt_template_xml);
    xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx);
    savan_xpath_filter_mod_update_filter_template(xpathObj->nodesetval, filter);

    xslt_template_xslt = xsltParseStylesheetDoc(xslt_template_xml);

	xmlXPathFreeObject(xpathObj);
	xmlXPathFreeContext(xpathCtx);

    return xslt_template_xslt;
}
Exemplo n.º 10
0
AXIS2_EXTERN void AXIS2_CALL
axis2_arch_file_data_free(
    axis2_arch_file_data_t * arch_file_data,
    const axutil_env_t * env)
{
    if (arch_file_data->file)
    {
        axutil_file_free(arch_file_data->file, env);
    }
    if (arch_file_data->msg_recv)
    {
        AXIS2_FREE(env->allocator, arch_file_data->msg_recv);
    }
    if (arch_file_data->module_name)
    {
        AXIS2_FREE(env->allocator, arch_file_data->module_name);
    }
    if (arch_file_data->module_dll_name)
    {
        AXIS2_FREE(env->allocator, arch_file_data->module_dll_name);
    }
    if (arch_file_data->name)
    {
        AXIS2_FREE(env->allocator, arch_file_data->name);
    }

    if (arch_file_data->svc_map)
    {
        axutil_hash_index_t *hi = NULL;
        void *val = NULL;

        for (hi = axutil_hash_first(arch_file_data->svc_map, env); hi;
             hi = axutil_hash_next(env, hi))
        {
            axis2_svc_t *svc = NULL;
            axutil_hash_this(hi, NULL, NULL, &val);
            svc = (axis2_svc_t *) val;
            if (svc)
            {
                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Service name :%s",
                                axis2_svc_get_name(svc, env));
                axis2_svc_free(svc, env);
            }
        }
        axutil_hash_free(arch_file_data->svc_map, env);
    }
    if (arch_file_data->deployable_svcs)
    {
        axutil_array_list_free(arch_file_data->deployable_svcs, env);
    }

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

    return;
}
Exemplo n.º 11
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
savan_client_unsubscribe(
    savan_client_t *client,
    const axutil_env_t *env,
    axis2_svc_client_t *svc_client)
{
    axis2_options_t *wsa_options = NULL;
    const axis2_char_t *old_action = NULL;
    axiom_namespace_t *ns = NULL;
    axiom_node_t *reply = NULL;
    axiom_node_t *unsub_node = NULL;
    axiom_element_t *unsub_elem = NULL;
    axis2_status_t status = AXIS2_FAILURE;
    
    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] Entry:savan_client_unsubscribe");
    
    /* set wsa action as Unsub. remember the old action */
    wsa_options = (axis2_options_t*)axis2_svc_client_get_options(svc_client, env);
    old_action = axis2_options_get_action(wsa_options, env);
    axis2_options_set_action(wsa_options, env, SAVAN_ACTIONS_UNSUB);
    
    /* create the body of the Unsub request */
    ns = axiom_namespace_create (env, EVENTING_NAMESPACE, EVENTING_NS_PREFIX);
    unsub_elem = axiom_element_create(env, NULL, ELEM_NAME_UNSUB, ns, &unsub_node);
        
    savan_client_add_sub_id_to_soap_header(client, env, svc_client);

    /* send the Unsub request and wait for the response */
    reply = axis2_svc_client_send_receive(svc_client, env, unsub_node);
    
    /* reset the old action */
    axis2_options_set_action(wsa_options, env, old_action);
    
    if (!reply)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[savan] Failed to send unsubscribe "
            "request. Error: %d Reason: %s", env->error->error_number,
            AXIS2_ERROR_GET_MESSAGE(env->error));
        status = AXIS2_FAILURE;
    }
    else
        status = AXIS2_SUCCESS;
    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] Exit:savan_client_unsubscribe");
    return status;
}
Exemplo n.º 12
0
axis2_op_t *AXIS2_CALL
axis2_req_uri_disp_find_op(
    axis2_msg_ctx_t * msg_ctx,
    const axutil_env_t * env,
    axis2_svc_t * svc)
{
    axis2_endpoint_ref_t *endpoint_ref = NULL;
    axis2_op_t *op = NULL;

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

    if(axis2_msg_ctx_get_doing_rest(msg_ctx, env))
        return NULL;

    endpoint_ref = axis2_msg_ctx_get_to(msg_ctx, env);

    if(endpoint_ref)
    {
        const axis2_char_t *address = NULL;

        address = axis2_endpoint_ref_get_address(endpoint_ref, env);
        if(address)
        {
            axis2_char_t **url_tokens = NULL;

            url_tokens = axutil_parse_request_url_for_svc_and_op(env, address);

            if(url_tokens)
            {
                if(url_tokens[1])
                {
                    axutil_qname_t *op_qname = NULL;
                    AXIS2_LOG_DEBUG(
                        env->log,
                        AXIS2_LOG_SI,
                        "Checking for operation using \
                             target endpoint uri fragment : %s",
                        url_tokens[1]);
                    op_qname = axutil_qname_create(env, url_tokens[1], NULL, NULL);
                    op = axis2_svc_get_op_with_name(svc, env, axutil_qname_get_localpart(op_qname,
                        env));
                    axutil_qname_free(op_qname, env);
                    if(op)
                        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                            "Operation found using target endpoint uri fragment");
                }
                if(url_tokens[0])
                    AXIS2_FREE(env->allocator, url_tokens[0]);
                if(url_tokens[1])
                    AXIS2_FREE(env->allocator, url_tokens[1]);
                AXIS2_FREE(env->allocator, url_tokens);
            }
        }
    }

    return op;
}
Exemplo n.º 13
0
axiom_node_t *axis2_saml_issuer_issue(
    const axutil_env_t * env, 
    trust_context_t *trust_ctx)
{
    axis2_char_t *token_type = NULL;
    axiom_node_t *issued_saml_token = NULL;    
    axiom_node_t *rstr_node = NULL;
    axiom_node_t *requested_sec_token_node = NULL;

	trust_rst_t *rst = NULL;	/*Created RST Context*/
	trust_rstr_t *rstr = NULL;	/*Used for Creating RSTR*/
    
	rst = trust_context_get_rst(trust_ctx, env);
	

    token_type = trust_rst_get_token_type(rst, env);
	if(token_type)
    	AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sts] token type: %s !", token_type);
	else
		return NULL;
    
    if (axutil_strcmp(token_type, SAML_TOKEN))
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sts] token type not equal..!");
        return NULL;
    }
    
    rstr = trust_rstr_create(env);
    
	
	
    issued_saml_token = create_saml_token(env);	
	trust_rstr_set_requested_security_token(rstr, env, issued_saml_token);
    trust_rstr_set_wst_ns_uri(rstr, env, "http://schemas.xmlsoap.org/ws/2005/02/trust");
	trust_rstr_set_requested_proof_token(rstr, env, trust_util_create_random_session_key_proof_token_element(env, 
				"http://schemas.xmlsoap.org/ws/2005/02/trust")
			);

	trust_context_set_rstr(trust_ctx, env, rstr);
	rstr_node = trust_context_build_rstr_node(trust_ctx, env);
   	
    return rstr_node;
}
Exemplo n.º 14
0
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
sandesha2_seq_mgr_has_seq_timedout(
    const axutil_env_t *env,
    axis2_char_t *property_key,
    sandesha2_seq_property_mgr_t *seq_prop_mgr,
    axis2_svc_t *svc)
{
    sandesha2_property_bean_t *property_bean = NULL;
    axis2_bool_t seq_timedout = AXIS2_FALSE;
    long last_activated_time = -1;
    long current_time = -1;
    long timeout_interval = -1;
    
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:sandesha2_seq_mgr_has_seq_timedout");

    AXIS2_PARAM_CHECK(env->error, property_key, AXIS2_FALSE);
    AXIS2_PARAM_CHECK(env->error, seq_prop_mgr, AXIS2_FALSE);
    
    property_bean = sandesha2_utils_get_property_bean(env, svc);
    timeout_interval = sandesha2_property_bean_get_inactive_timeout_interval(property_bean, env);
    if(timeout_interval <= 0)
    {
        return AXIS2_FALSE;
    }

    last_activated_time = sandesha2_seq_mgr_get_last_activated_time(env, property_key, seq_prop_mgr);
    current_time = sandesha2_utils_get_current_time_in_millis(env);

    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]timeout_interval:%ld", timeout_interval);
    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]last_activated_time:%ld", last_activated_time);
    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]current_time:%ld", current_time);

    if(last_activated_time > 0 && ((last_activated_time + timeout_interval) < current_time))
    {
        seq_timedout = AXIS2_TRUE;
    }

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Exit:sandesha2_seq_mgr_has_seq_timedout");

    return seq_timedout;
}
Exemplo n.º 15
0
AXIS2_EXTERN axis2_char_t* AXIS2_CALL 
service_admin_util_get_wsdl_for_service(axutil_env_t *env, 
									   axis2_char_t *service_name, 
									   axis2_conf_t *conf)
{
	axis2_transport_in_desc_t *transport_in = axis2_conf_get_transport_in(conf, env, AXIS2_TRANSPORT_ENUM_HTTP);
	
	if(transport_in)
	{
		axis2_endpoint_ref_t *epr = NULL;
		axis2_char_t *address = NULL;
		axis2_transport_receiver_t *receiver = axis2_transport_in_desc_get_recv(transport_in, env);
		if(!receiver)
		{
			AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Transport Receiver Not found ");
			return NULL;
		}
		epr = axis2_transport_receiver_get_epr_for_service(receiver, env, service_name);
		if(!epr)
		{
			AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Endpoint reference null");
			return NULL;
		}
		address = (axis2_char_t*)axis2_endpoint_ref_get_address(epr,env);
		if(address)
		{
			int length = axutil_strlen(address);
			if(address[length -1 ] == '\\')
			{
				address = axutil_stracat(env, address,"?wsdl");
			}else{
					address = axutil_stracat(env, address,"\?wsdl");
			}

		}
		return address;
	}
	return NULL;
}
Exemplo n.º 16
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_phase_add_handler_at(
    axis2_phase_t * phase,
    const axutil_env_t * env,
    const int idx,
    axis2_handler_t * handler)
{
    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
        "axis2_handler_t *%s added to the index %d of the phase %s", axutil_string_get_buffer(
            axis2_handler_get_name(handler, env), env), idx, phase->name);

    return axutil_array_list_add_at(phase->handlers, env, idx, handler);
}
Exemplo n.º 17
0
/**
 * Traverse thru the node and its descendents. Check if the localname is equal to the given name
 * @param env Environment. MUST NOT be NULL,
 * @param node the node to be searched
 * @param localname the local name of the node to be searched
 * @return the node if found, else NULL
 */
AXIS2_EXTERN axiom_node_t* AXIS2_CALL
oxs_axiom_get_node_by_local_name(
    const axutil_env_t *env,
    axiom_node_t *node,
    axis2_char_t *local_name)
{
    axis2_char_t *temp_name = NULL;

    if(!node)
    {
        return NULL;
    }

    if(axiom_node_get_node_type(node, env) != AXIOM_ELEMENT)
    {
        return NULL;
    }

    temp_name = axiom_util_get_localname(node, env);
    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
        "[rampart]Checking node %s for %s", temp_name, local_name );

    if(!axutil_strcmp(temp_name, local_name))
    {
        /* Gottcha.. return this node */
        return node;
    }
    else
    {
        /* Doesn't match? Get the children and search for them */
        axiom_node_t *temp_node = NULL;

        temp_node = axiom_node_get_first_element(node, env);
        while(temp_node)
        {
            axiom_node_t *res_node = NULL;
            res_node = oxs_axiom_get_node_by_local_name(env, temp_node, local_name);
            if(res_node)
            {
                return res_node;
            }
            temp_node = axiom_node_get_next_sibling(temp_node, env);
        }
    }
    return NULL;
}
Exemplo n.º 18
0
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
savan_xpath_filter_mod_apply(
    savan_filter_mod_t *filtermod,
    const axutil_env_t *env,
    savan_subscriber_t *subscriber,
    axiom_node_t *payload)
{
    axis2_char_t *payload_string = NULL;
    xmlDocPtr payload_doc = NULL;
    xsltStylesheetPtr xslt_template_filter = NULL;
    xmlChar *xfilter = NULL;
    xmlDocPtr result_doc;
    savan_xpath_filter_mod_t *filtermodimpl = NULL;

    filtermodimpl = SAVAN_INTF_TO_IMPL(filtermod);

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

	xfilter = (xmlChar *) savan_subscriber_get_filter(subscriber, env);
	if(!xfilter)
	{
		return AXIS2_FALSE;
	}

    payload_string = axiom_node_to_string(payload, env);
    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
        "[savan] payload_string before applying filter %s:%s", xfilter, payload_string);

    payload_doc = (xmlDocPtr)xmlParseDoc((xmlChar*)payload_string);

    xslt_template_filter = (xsltStylesheetPtr) savan_xpath_filter_mod_get_filter_template(env, 
            filtermodimpl->filter_template_path, xfilter);

    result_doc = (xmlDocPtr)xsltApplyStylesheet(xslt_template_filter, payload_doc, NULL);

    if(result_doc)
    {
        /*free(payload_string);*/ /* In apache freeing this give seg fault:damitha */
	    xmlFreeDoc(result_doc);
        return AXIS2_TRUE;
    }

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Exit:savan_xpath_filter_mod_apply");
    return AXIS2_FALSE;
}
Exemplo n.º 19
0
AXIS2_EXTERN int AXIS2_CALL
openssl_sig_sign(const axutil_env_t *env,
                 openssl_pkey_t *prvkey,
                 oxs_buffer_t *input_buf,
                 oxs_buffer_t *output_buf)
{
    unsigned char sig_buf[4096]; /*Enough for the signature*/
    unsigned int sig_len;
    const EVP_MD*   digest;
    EVP_MD_CTX      md_ctx;
    EVP_PKEY*       pkey = NULL;
    int err, ret;
    /*Get the key*/
    /*open_pkey = oxs_sign_ctx_get_private_key(sign_ctx, env);*/
    pkey = openssl_pkey_get_key(prvkey, env);
    if(!pkey){
        oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_SIGN_FAILED,"Cannot load the private key" );
    }

    /*TODO: Set the digest according to the signature method*/
    digest = EVP_sha1();

    /*MD Ctx init*/
    EVP_MD_CTX_init(&md_ctx);

    /*Sign init*/
    ret = EVP_SignInit(&md_ctx, digest);
    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[openssl][sig] Signing content %s", oxs_buffer_get_data(input_buf, env) );
    EVP_SignUpdate (&md_ctx, oxs_buffer_get_data(input_buf, env), oxs_buffer_get_size(input_buf, env));
    sig_len = sizeof(sig_buf);
    err = EVP_SignFinal (&md_ctx,
                         sig_buf,
                         &sig_len,
                         pkey);
    if (err != 1) {
        ERR_print_errors_fp (stderr);
    }
    /*Fill the output buffer*/
    oxs_buffer_populate(output_buf, env, sig_buf, sig_len);

    EVP_MD_CTX_cleanup(&md_ctx);

    return sig_len;
}
Exemplo n.º 20
0
void
test_log_write(
    )
{
    char msg[20];
    printf("start of test_log_write\n\n");
    axutil_allocator_t *allocator = axutil_allocator_init(NULL);
    if (!allocator)
    {
        printf("allocator is NULL\n");
        return;
    }
    axutil_error_t *error = axutil_error_create(allocator);
    if (!error)
    {
        printf("cannot create error\n");
        return;
    }
    axutil_log_t *log22 = axutil_log_create(allocator, NULL, NULL);
    if (!log22)
    {
        printf("cannot create log\n");
        return;
    }
    log22->level = AXIS2_LOG_LEVEL_DEBUG;

    const axutil_env_t *env =
        axutil_env_create_with_error_log(allocator, error, log22);
    if (!env)
    {
        printf("cannot create env with error and log\n");
        return;
    }
    strcpy(msg, "abcd test123");

    AXIS2_LOG_CRITICAL(env->log, AXIS2_LOG_SI, "log1 %s", "test1");
    AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "log2 %d", 2);
    AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, "log3 %s", "test3");
    AXIS2_LOG_INFO(env->log, AXIS2_LOG_SI, "log4 %s %s", "info1", "info2");
    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "log5 %s %d", "test", 5);
    printf("end of test_log_write \n\n");

}
Exemplo n.º 21
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axiom_soap_fault_code_set_sub_code(
    axiom_soap_fault_code_t * fault_code,
    const axutil_env_t * env,
    axiom_soap_fault_sub_code_t * fault_subcode)
{
    AXIS2_PARAM_CHECK(env->error, fault_subcode, AXIS2_FAILURE);

    if(!(fault_code->subcode))
    {
        fault_code->subcode = fault_subcode;
        return AXIS2_SUCCESS;
    }
    else
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                        "trying to set fault subcode to fault code more than once ");
    }
    return AXIS2_FAILURE;
}
Exemplo n.º 22
0
/*Create function */
axis2_svc_skeleton_t *
savan_subs_mgr_svc_create(
    const axutil_env_t *env)
{

    axis2_svc_skeleton_t *svc_skeleton = NULL;

	
	AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "savan_subs_mgr_svc service create called");

	/* Allocate memory for the structs */
    svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t));

    svc_skeleton->ops = &savan_subs_mgr_svc_skeleton_ops_var;
    svc_skeleton->func_array = NULL;

    /* Assign function pointers */
    
    return svc_skeleton;
}
/**
 * Set a security processed result to the message context
 * @param env Environment structure
 * @param msg_ctx message context sttucture
 * @param key key of the security processed result
 * @param value value of the security processed result
 * @return status of the operation
 */
AXIS2_EXTERN axis2_status_t AXIS2_CALL
rampart_set_security_processed_result(
    const axutil_env_t *env,
    axis2_msg_ctx_t *msg_ctx,
    axis2_char_t *key,
    void *value)
{
    axutil_hash_t *sec_processed_results = NULL;

    sec_processed_results = rampart_get_all_security_processed_results(env, msg_ctx);
    if(!sec_processed_results)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
            "[rampart]Cannot retrieve security processed results container.");
        return AXIS2_FAILURE;
    }

    axutil_hash_set(sec_processed_results, key, AXIS2_HASH_KEY_STRING, value);
    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
        "[rampart]Set %s in Security Processed Results of message context ", key);
    return AXIS2_SUCCESS;
}
Exemplo n.º 24
0
axiom_node_t *
build_om_programatically(
    const axutil_env_t * env)
{
    axiom_node_t *version_om_node = NULL;
    axiom_element_t *version_om_ele = NULL;
    axiom_namespace_t *ns1 = NULL;

    axiom_xml_writer_t *xml_writer = NULL;
    axiom_output_t *om_output = NULL;
    axis2_char_t *buffer = NULL;

    ns1 =
        axiom_namespace_create(env, "urn:aewebservices71",
                               "ns1");

    version_om_ele =
        axiom_element_create(env, NULL, "GetVersion", ns1, &version_om_node);


    xml_writer =
        axiom_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE, AXIS2_FALSE,
                                           AXIS2_XML_PARSER_TYPE_BUFFER);
    om_output = axiom_output_create(env, xml_writer);

    axiom_node_serialize(version_om_node, env, om_output);
    buffer = (axis2_char_t *) axiom_xml_writer_get_xml(xml_writer, env);
    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "\nSending OM node in XML : %s \n",
                    buffer);
    if (om_output)
    {
        axiom_output_free(om_output, env);
        om_output = NULL;
    }

    axiom_namespace_free(ns1, env);
    return version_om_node;
}
/**
 * Prints all ke/val pairs in the security processed results. For debugging purposes
 * @env the environment 
 * @msg_ctx the message context in which data are extracted
 * @return void
 */
AXIS2_EXTERN void AXIS2_CALL
rampart_print_security_processed_results_set(
    const axutil_env_t *env,
    axis2_msg_ctx_t *msg_ctx)
{
    axutil_hash_t *sec_processed_results = NULL;
    axutil_hash_index_t *hi = NULL;
    const void *key = NULL;
    void *val = NULL;

    sec_processed_results = rampart_get_all_security_processed_results(env, msg_ctx);
    if(!sec_processed_results)
    {
        return;
    }

    for (hi = axutil_hash_first(sec_processed_results, env); hi; hi = axutil_hash_next(env, hi)) 
    {
        axutil_hash_this(hi, &key, NULL, &val);
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
            "[rampart](key, val) %s = %s\n", (axis2_char_t*)key, (axis2_char_t*)val);
    }
}
Exemplo n.º 26
0
void
test_validate_data_and_payload_creation(const axutil_env_t* env)
{
	wsf_wsdl_data_t* data = NULL;
	wsf_wsdl_data_template_t* data_template = NULL;
	axis2_bool_t success;
	axis2_char_t* payload;
	
	AXIS2_LOG_DEBUG_MSG(env->log, "[wsf_wsdl_test] Starting test_wsdl_data...");

	data = create_params(env);

	if (data)
	{
		AXIS2_LOG_DEBUG_MSG(env->log, "[wsf_wsdl_test]data is not NULL, again a good sign!");
	}

	data_template = create_template(env);

	if (data_template)
	{
		AXIS2_LOG_DEBUG_MSG(env->log, "[wsf_wsdl_test]wow!, even template is not NULL!");
	}

	success = validate_data(env, NULL, data_template, data, VALIDATION_CRITERIA_REQUEST_MODE_TYPE);
	
	if (success)	
	{
		AXIS2_LOG_DEBUG_MSG(env->log, "[wsf_wsdl_test]validation result : SUCCESS!!!");
	}
	
	payload = create_payload(env, data);
	AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[wsf_wsdl_test]payload : %s", payload);

	AXIS2_LOG_DEBUG_MSG(env->log, "[wsf_wsdl_test] Ending test_wsdl_data...");
}
Exemplo n.º 27
0
WSF_WSDL_EXTERN axis2_bool_t WSF_WSDL_CALL 
wsf_wsdl_request(
    const axutil_env_t* env,
    axis2_char_t* wsdl_file_name,
    const axis2_char_t* operation_name,	
    wsf_wsdl_data_t* parameters,
    axis2_char_t* script_binding_home,
    axis2_svc_client_t* svc_client,
    axutil_hash_t* svc_client_user_options,
    axis2_char_t* service_name,
    axis2_char_t* port_name,
    wsf_wsdl_data_t** response)
{
    int soap_version = 2; 
    int has_fault = AXIS2_FALSE;
    int binding_style = WSDL_BINDING_STYLE_DOC_LIT_W;
    axis2_char_t* payload = NULL;	
    axiom_node_t* payload_node = NULL;
    axis2_char_t* request_buffer = NULL;	
    axiom_node_t* type_map = NULL;	
    axis2_char_t *res_text = NULL;	
    axiom_node_t* sig_axiom = NULL;	
    axiom_node_t *fault_node = NULL;	
    axiom_node_t* wsdl_axiom = NULL;	
    axiom_node_t* params_node = NULL;	
    axiom_node_t* returns_node = NULL;	
    axiom_soap_body_t *soap_body = NULL;	
    axiom_node_t *body_base_node = NULL;	
    /*axis2_char_t *wrapper_element = NULL;*/	
    axiom_node_t* operation_axiom = NULL;	
    axiom_soap_fault_t *soap_fault = NULL;	
    axis2_options_t *client_options = NULL;	
    /*axis2_char_t *wrapper_element_ns = NULL;*/	
    /*axiom_node_t *axiom_soap_base_node = NULL;	*/
    axiom_soap_envelope_t *response_envelope = NULL;	
    wsf_wsdl_data_template_t* input_template = NULL;	
    wsf_wsdl_data_template_t* output_template = NULL;	
    axis2_bool_t is_version1_wsdl = AXIS2_FALSE;
    axis2_char_t* xslt_location = NULL;
    axis2_char_t* type_map_file = NULL;

    AXIS2_LOG_TRACE_MSG(env->log, "Starting execution of wsf_wsdl_request..."); 

    xslt_location = axutil_strcat(env, script_binding_home, WSF_WSDL_XSLT_LOCATION_POSTFIX, NULL);
    type_map_file = axutil_strcat(env, script_binding_home, WSF_WSDL_TYPE_MAP_POSTFIX, NULL);

    client_options = (axis2_options_t *)axis2_svc_client_get_options(svc_client, env);

    axis2_options_set_xml_parser_reset(client_options, env, AXIS2_FALSE);

    if (!wsf_wsdl_parser_load_wsdl(env, wsdl_file_name, xslt_location, &wsdl_axiom, &sig_axiom, &is_version1_wsdl, AXIS2_FALSE))
        return AXIS2_FALSE;

    wsdl_util_create_type_map(env, type_map_file, &type_map);

    wsdl_util_manage_client_options(env, 
        svc_client, 
        svc_client_user_options, 
        client_options, 
        operation_name, 
        wsdl_axiom, 
        is_version1_wsdl, 
        sig_axiom, 
        service_name,
        port_name,
        &operation_axiom, 
        &soap_version);

    wsdl_util_identify_binding_style(env, operation_axiom, &binding_style);

    if (!operation_axiom)
    {
        AXIS2_LOG_ERROR_MSG(env->log, "Operation axiom is NULL");

        if (wsdl_axiom) 
            axiom_node_free_tree(wsdl_axiom, env);
        if (sig_axiom)
            axiom_node_free_tree(sig_axiom, env);
        if (type_map)
            axiom_node_free_tree(type_map, env);
        return AXIS2_FALSE;
    }

    wsdl_util_get_params_node(env, operation_axiom, &params_node);
    wsdl_util_get_returns_node(env, operation_axiom, &returns_node);

    wsdl_data_util_axiom_to_template(env, params_node, &input_template);
    wsdl_data_util_axiom_to_template(env, returns_node, &output_template);

#ifdef WSDL_DEBUG_MODE
    {
        axis2_char_t* buffer = NULL;
        wsdl_data_util_serialize_data(env, parameters, &buffer);
        AXIS2_LOG_DEBUG_MSG(env->log, buffer);
        AXIS2_FREE(env->allocator, buffer);
        wsdl_data_util_serialize_template(env, input_template, &buffer);
        AXIS2_LOG_DEBUG_MSG(env->log, buffer);
        AXIS2_FREE(env->allocator, buffer);
        buffer = NULL;
    }
#endif

    if (wsdl_data_util_validate_data(env, type_map, input_template, parameters, VALIDATION_CRITERIA_REQUEST_MODE_TYPE) == AXIS2_TRUE)
    {
        payload_node = wsdl_data_util_create_payload(env, parameters, binding_style);
        payload = payload_node? axiom_node_to_string(payload_node, env) : NULL;
        // axiom_node_free_tree(payload_node, env);
    }
    else
    {
        AXIS2_LOG_ERROR_MSG(env->log, "User data is not valid or not in proper format");

        if (input_template)
            wsdl_data_template_free(env, input_template);
        if (output_template)
            wsdl_data_template_free(env, output_template);

        if (wsdl_axiom) 
            axiom_node_free_tree(wsdl_axiom, env);
        if (sig_axiom)
            axiom_node_free_tree(sig_axiom, env);
        if (type_map)
            axiom_node_free_tree(type_map, env);
        return AXIS2_FALSE;
    }

    if (!payload_node)
    {
        AXIS2_LOG_ERROR_MSG(env->log, "Request payload is not found");

        if (input_template)
            wsdl_data_template_free(env, input_template);
        if (output_template)
            wsdl_data_template_free(env, output_template);

        if (wsdl_axiom) 
            axiom_node_free_tree(wsdl_axiom, env);
        if (sig_axiom)
            axiom_node_free_tree(sig_axiom, env);
        if (type_map)
            axiom_node_free_tree(type_map, env);
        return AXIS2_FALSE; 
    }

    request_buffer = (axis2_char_t*)wsdl_util_create_request_envelope(env, payload_node, soap_version);

    if (!request_buffer)
    {
        AXIS2_LOG_ERROR_MSG(env->log, "Error in creating request payload dom");

        if (input_template)
            wsdl_data_template_free(env, input_template);
        if (output_template)
            wsdl_data_template_free(env, output_template);

        if (wsdl_axiom) 
            axiom_node_free_tree(wsdl_axiom, env);
        if (sig_axiom)
            axiom_node_free_tree(sig_axiom, env);
        if (type_map)
            axiom_node_free_tree(type_map, env);

        return AXIS2_FALSE;
    }

    response_envelope = (axiom_soap_envelope_t*)wsdl_util_send_receive_soap_envelope_with_op_client(env, 
        svc_client, 
        client_options, 
        request_buffer);
    if (response_envelope) 
    {
        has_fault = AXIS2_TRUE;
        soap_body = axiom_soap_envelope_get_body (response_envelope, env);

        if (soap_body)
        {
            soap_fault = axiom_soap_body_get_fault (soap_body, env);
        }

        if (soap_fault) 
        {
            soap_version = axis2_options_get_soap_version(client_options, env);
            fault_node = axiom_soap_fault_get_base_node(soap_fault, env);
            if (fault_node)
            {
                res_text = axiom_node_to_string(fault_node, env);
                AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI, "Fault payload is %s", res_text);

                if (input_template)
                    wsdl_data_template_free(env, input_template);
                if (output_template)
                    wsdl_data_template_free(env, output_template);
                if (wsdl_axiom) 
                    axiom_node_free_tree(wsdl_axiom, env);
                if (sig_axiom)
                    axiom_node_free_tree(sig_axiom, env);
                if (type_map)
                    axiom_node_free_tree(type_map, env);

                return AXIS2_FALSE;
            }    
        }

        if (soap_body)
        {
            body_base_node = axiom_soap_body_get_base_node(soap_body, env);
        }

        if (body_base_node && !soap_fault)
        {
            axis2_char_t *response_buffer = NULL;	
            wsf_wsdl_data_t *response_data = NULL;

            response_buffer = axiom_node_to_string(body_base_node, env);
            AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI,
                "Response buffer is %s", response_buffer);

            AXIS2_FREE(env->allocator, response_buffer);

            wsdl_data_util_axiom_to_data(env, body_base_node, &response_data);

#ifdef WSDL_DEBUG_MODE
            {
                axis2_char_t* buffer = NULL;
                wsdl_data_util_serialize_data(env, response_data, &buffer);
                AXIS2_LOG_DEBUG_MSG(env->log, buffer);
                AXIS2_FREE(env->allocator, buffer);
                wsdl_data_util_serialize_template(env, output_template, &buffer);
                AXIS2_LOG_DEBUG_MSG(env->log, buffer);
                AXIS2_FREE(env->allocator, buffer);
                buffer = NULL;
            }
#endif

            if (wsdl_data_util_validate_data(env, type_map, output_template, response_data, VALIDATION_CRITERIA_RESPONSE_MODE) == AXIS2_TRUE)
            {
                AXIS2_LOG_DEBUG_MSG(env->log, "Valid response!!!");
                *response = response_data;

                if (input_template)
                    wsdl_data_template_free(env, input_template);
                if (output_template)
                    wsdl_data_template_free(env, output_template);
                if (wsdl_axiom) 
                    axiom_node_free_tree(wsdl_axiom, env);
                if (sig_axiom)
                    axiom_node_free_tree(sig_axiom, env);
                if (type_map)
                    axiom_node_free_tree(type_map, env);

                return AXIS2_TRUE;
            }
            else
            {
                AXIS2_LOG_ERROR_MSG(env->log, "Response data is not valid or not in proper format");

                if (input_template)
                    wsdl_data_template_free(env, input_template);
                if (output_template)
                    wsdl_data_template_free(env, output_template);
                if (wsdl_axiom) 
                    axiom_node_free_tree(wsdl_axiom, env);
                if (sig_axiom)
                    axiom_node_free_tree(sig_axiom, env);
                if (type_map)
                    axiom_node_free_tree(type_map, env);

                return AXIS2_FALSE;
            }
        }
    }
    else  /* response_envelope == NULL */
    {
        AXIS2_LOG_ERROR_MSG(env->log, "Response envelope not found");
    }

    if (input_template)
        wsdl_data_template_free(env, input_template);
    if (output_template)
        wsdl_data_template_free(env, output_template);

    if (wsdl_axiom) 
        axiom_node_free_tree(wsdl_axiom, env);
    if (sig_axiom)
        axiom_node_free_tree(sig_axiom, env);
    if (type_map)
        axiom_node_free_tree(type_map, env);

    return AXIS2_FALSE;
}
Exemplo n.º 28
0
axis2_status_t AXIS2_CALL
sandesha2_out_handler_invoke(
    struct axis2_handler *handler, 
    const axutil_env_t *env,
    struct axis2_msg_ctx *msg_ctx)
{
    axutil_property_t *temp_prop = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_conf_t *conf = NULL;
    axis2_char_t *str_done = NULL;
    axis2_char_t *dummy_msg_str = NULL;
    axis2_bool_t dummy_msg = AXIS2_FALSE;
    axis2_svc_t *svc = NULL;
    axutil_qname_t *module_qname = NULL;
    sandesha2_msg_ctx_t *rm_msg_ctx = NULL;
    sandesha2_msg_processor_t *msg_processor = NULL;
    int msg_type = -1;

    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:sandesha2_out_handler_invoke");
            
    temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_SEQ_PROP_MAKE_CONNECTION_OUT_PATH);
    if (temp_prop)
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
            "[sandesha2] In make connection out path. So return here.");
        return AXIS2_SUCCESS;
        temp_prop = NULL;
    }

    if(sandesha2_util_is_rstr_msg(env, msg_ctx))
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
            "[sandesha2] A RSTR message. Sandesha don't process.");
        return AXIS2_SUCCESS;
    }

    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    if(!conf_ctx)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
            "[sandesha2] Configuration Context is NULL");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CONF_CTX_NULL, AXIS2_FAILURE);
        return AXIS2_FAILURE;
    }
    svc = axis2_msg_ctx_get_svc(msg_ctx, env);
    if(!svc)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]Axis2 Service is NULL");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SVC_NULL, AXIS2_FAILURE);
        return AXIS2_FAILURE;
    }
    module_qname = axutil_qname_create(env, SANDESHA2_MODULE, NULL, NULL);
    if(!axis2_svc_is_module_engaged(svc, env, module_qname))
    {
        if(module_qname)
        {
            axutil_qname_free(module_qname, env);
        }

        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]RM is not engaged. So return here");
        return AXIS2_SUCCESS;
    }

    if(module_qname)
    {
        axutil_qname_free(module_qname, env);
    }

    temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE);
    if(temp_prop)
    {
        str_done = (axis2_char_t *) axutil_property_get_value(temp_prop, env); 
    }

    if(str_done && 0 == axutil_strcmp(AXIS2_VALUE_TRUE, str_done))
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
            "[sandesha2]Application Processing Done. So return here.");
        return AXIS2_SUCCESS; 
    }

    temp_prop = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);
    axis2_msg_ctx_set_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE, temp_prop);
    conf = axis2_conf_ctx_get_conf(conf_ctx, env);
    if(!sandesha2_permanent_storage_mgr_create_db(env, conf_ctx))
    {
        return AXIS2_FAILURE;
    }

    /* Getting rm message */ 
    rm_msg_ctx = sandesha2_msg_init_init_msg(env, msg_ctx);
    temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_CLIENT_DUMMY_MESSAGE);
    if(NULL != temp_prop)
    {
        dummy_msg_str = (axis2_char_t *) axutil_property_get_value(temp_prop, env); 
    }

    if(dummy_msg_str && 0 == axutil_strcmp(AXIS2_VALUE_TRUE, dummy_msg_str))
    {
        dummy_msg = AXIS2_TRUE;
    }

    temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_SVC_CLIENT_CLOSED);
    if(temp_prop)
    {
        axis2_char_t *spec_version = NULL;

        axis2_endpoint_ref_t *reply_to = axis2_msg_ctx_get_reply_to(msg_ctx, env);
        if(reply_to)
        {
            axis2_char_t *address = axis2_endpoint_ref_get_address(reply_to, env);
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "dam_reply_to_address:%s", address);
        }
        spec_version = sandesha2_utils_get_rm_version(env, msg_ctx);

        if(!axutil_strcmp(SANDESHA2_SPEC_VERSION_1_1, spec_version))
        {
            axis2_char_t *action = NULL;
            axutil_string_t *str_action = NULL;

            action = sandesha2_spec_specific_consts_get_terminate_seq_action(env, spec_version);
            str_action = axutil_string_create(env, action);
            axis2_msg_ctx_set_soap_action(msg_ctx, env, str_action);
            axutil_string_free(str_action, env);
            /*axis2_msg_ctx_set_reply_to(msg_ctx, env, NULL);*/
            msg_type = sandesha2_msg_ctx_set_msg_type(rm_msg_ctx, env, 
                SANDESHA2_MSG_TYPE_CLOSE_SEQ);
        }
        else if(!axutil_strcmp(SANDESHA2_SPEC_VERSION_1_0, spec_version))
        {
            axutil_property_t *property = NULL;
            axutil_string_t *str_action = NULL;
            
            /*axis2_msg_info_headers_set_action(axis2_msg_ctx_get_msg_info_headers(msg_ctx, env), 
             * env, SANDESHA2_SPEC_2005_02_SOAP_ACTION_LAST_MESSAGE); */
            str_action = axutil_string_create(env, SANDESHA2_SPEC_2005_02_SOAP_ACTION_LAST_MESSAGE);
            axis2_msg_ctx_set_soap_action(msg_ctx, env, str_action);
            axutil_string_free(str_action, env);
            property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);
            axis2_msg_ctx_set_property(msg_ctx, env, "Sandesha2LastMessage", property);
            /*axis2_msg_ctx_set_reply_to(msg_ctx, env, NULL);*/
        }
    }

    msg_type = sandesha2_msg_ctx_get_msg_type(rm_msg_ctx, env);
    if(msg_type == SANDESHA2_MSG_TYPE_UNKNOWN)
    {
        axis2_msg_ctx_t *req_msg_ctx = NULL;
        axis2_op_ctx_t *op_ctx = NULL;

        op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
        req_msg_ctx =  axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN);
        if(req_msg_ctx) /* For the server side */
        {
            sandesha2_msg_ctx_t *req_rm_msg_ctx = NULL;
            sandesha2_seq_t *seq_part = NULL;

            req_rm_msg_ctx = sandesha2_msg_init_init_msg(env, req_msg_ctx);
            seq_part = sandesha2_msg_ctx_get_sequence(req_rm_msg_ctx, env);
            if(seq_part)
            {
                msg_processor = (sandesha2_msg_processor_t *) 
                sandesha2_app_msg_processor_create(env); /* rm intended msg */
            }
            if(req_rm_msg_ctx)
                sandesha2_msg_ctx_free(req_rm_msg_ctx, env);
        }
        else if(!axis2_msg_ctx_get_server_side(msg_ctx, env))
        {
            msg_processor = (sandesha2_msg_processor_t *) sandesha2_app_msg_processor_create(env);
        }
    }
    else
    {
        msg_processor = sandesha2_msg_processor_create_msg_processor(env, rm_msg_ctx);
    }
    if(msg_processor)
    {
        sandesha2_msg_processor_process_out_msg(msg_processor, env, rm_msg_ctx);
        sandesha2_msg_processor_free(msg_processor, env);
    }
    if(AXIS2_SUCCESS != AXIS2_ERROR_GET_STATUS_CODE(env->error))
    {
        /* Message should not be sent in an exception situation */

        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Pausing message context");
        axis2_msg_ctx_set_paused(msg_ctx, env, AXIS2_TRUE);
        if(rm_msg_ctx)
        {
            sandesha2_msg_ctx_free(rm_msg_ctx, env);
        }
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Error in processing the message");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_PROCESS_MSG, AXIS2_FAILURE);
        return AXIS2_FAILURE;
    }
    
    temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE);
    if(temp_prop)
    {
        axutil_property_set_value(temp_prop, env, AXIS2_VALUE_FALSE);
    }

    if(rm_msg_ctx)
    {
        sandesha2_msg_ctx_free(rm_msg_ctx, env);
    }

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Exit:sandesha2_out_handler_invoke");

    return AXIS2_SUCCESS;
}
Exemplo n.º 29
0
axis2_status_t
axis2_addr_in_extract_addr_params(
    const axutil_env_t * env,
    axiom_soap_header_t * soap_header,
    axis2_msg_info_headers_t ** msg_info_headers_p,
    axutil_array_list_t * addr_headers,
    const axis2_char_t * addr_ns_str,
    axis2_msg_ctx_t * msg_ctx)
{
    axutil_hash_t *header_block_ht = NULL;
    axutil_hash_index_t *hash_index = NULL;
    axis2_msg_info_headers_t *msg_info_headers = *(msg_info_headers_p);
    axis2_status_t status = AXIS2_SUCCESS;
    axis2_bool_t to_found = AXIS2_FALSE;
    axis2_bool_t reply_to_found = AXIS2_FALSE;
    axis2_bool_t fault_to_found = AXIS2_FALSE;
    axis2_bool_t action_found = AXIS2_FALSE;
    axis2_bool_t msg_id_found = AXIS2_FALSE;

    AXIS2_PARAM_CHECK(env->error, soap_header, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, msg_info_headers_p, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, addr_headers, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, addr_ns_str, AXIS2_FAILURE);

    if (!msg_info_headers)
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No messgae info header. Creating new");
        msg_info_headers = axis2_msg_info_headers_create(env, NULL, NULL);
        if (!msg_info_headers)
        {
            AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MSG_INFO_HEADERS, AXIS2_FAILURE);
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "No message information headers available");
            return AXIS2_FAILURE;
        }
    }

    header_block_ht = axiom_soap_header_get_all_header_blocks(soap_header, env);
    if (!header_block_ht)
    {
        return AXIS2_FAILURE;
    }

    /* Iterate thru header blocks */
    for (hash_index = axutil_hash_first(header_block_ht, env); hash_index;
         hash_index = axutil_hash_next(env, hash_index))
    {
        void *hb = NULL;
        axiom_soap_header_block_t *header_block = NULL;
        axiom_node_t *header_block_node = NULL;
        axiom_element_t *header_block_ele = NULL;
        axis2_char_t *ele_localname = NULL;
        axis2_endpoint_ref_t *epr = NULL;
        axis2_char_t *role = NULL;

        axutil_hash_this(hash_index, NULL, NULL, &hb);

        header_block = (axiom_soap_header_block_t *) hb;
        header_block_node =
            axiom_soap_header_block_get_base_node(header_block, env);
        header_block_ele =
            (axiom_element_t *) axiom_node_get_data_element(header_block_node,
                                                            env);
        ele_localname = axiom_element_get_localname(header_block_ele, env);

        role = axiom_soap_header_block_get_role(header_block, env);
        if (role && !axutil_strcmp(role, AXIOM_SOAP12_SOAP_ROLE_NONE))
        {
            /* Role is none, no need of processing */
            continue;
        }

        if (!axutil_strcmp(ele_localname, AXIS2_WSA_TO))
        {
            /* Here the addressing epr overidde what ever already there in the message context */

            epr =
                axis2_endpoint_ref_create(env,
                                          axiom_element_get_text
                                          (header_block_ele, env,
                                           header_block_node));
            if (AXIS2_TRUE == to_found)
            {
                /* Duplicate To */
                axis2_addr_in_create_fault_envelope(env,
                                                    AXIS2_WSA_PREFIX_TO, addr_ns_str,
                                                    msg_ctx);
                status = AXIS2_FAILURE;
                continue;
            }
            axis2_msg_info_headers_set_to(msg_info_headers, env, epr);

            axis2_addr_in_extract_to_epr_ref_params(env, epr, soap_header,
                                                    addr_ns_str);
            axiom_soap_header_block_set_processed(header_block, env);
            to_found = AXIS2_TRUE;
        }
        else if (!axutil_strcmp(ele_localname, AXIS2_WSA_FROM))
        {
            epr = axis2_msg_info_headers_get_from(msg_info_headers, env);
            if (!epr)
            {
                /* The address is not known now. Pass the empty
                   string and fill this once the element 
                   under this is processed. */

                epr = axis2_endpoint_ref_create(env, "");
                axis2_msg_info_headers_set_from(msg_info_headers, env, epr);
            }
            axis2_addr_in_extract_epr_information(env, header_block, epr,
                                                  addr_ns_str);
            axiom_soap_header_block_set_processed(header_block, env);
        }
        else if (!axutil_strcmp(ele_localname, AXIS2_WSA_REPLY_TO))
        {
            epr = axis2_msg_info_headers_get_reply_to(msg_info_headers, env);

            if (reply_to_found == AXIS2_TRUE)
            {
                /* Duplicate Reply To */
                axis2_addr_in_create_fault_envelope(env,
                                                    AXIS2_WSA_PREFIX_REPLY_TO, addr_ns_str,
                                                    msg_ctx);
                status = AXIS2_FAILURE;
                continue;
            }

            if (!epr)
            {
                epr = axis2_endpoint_ref_create(env, "");
                axis2_msg_info_headers_set_reply_to(msg_info_headers, env, epr);
            }
            axis2_addr_in_extract_epr_information(env, header_block, epr,
                                                  addr_ns_str);
            axiom_soap_header_block_set_processed(header_block, env);
            reply_to_found = AXIS2_TRUE;
        }
        else if (!axutil_strcmp(ele_localname, AXIS2_WSA_FAULT_TO))
        {
            epr = axis2_msg_info_headers_get_fault_to(msg_info_headers, env);

            if (fault_to_found == AXIS2_TRUE)
            {
                /* Duplicate Fault To */
                axis2_addr_in_create_fault_envelope(env,
                                                    AXIS2_WSA_PREFIX_FAULT_TO, addr_ns_str,
                                                    msg_ctx);
                status = AXIS2_FAILURE;
                axis2_msg_info_headers_set_fault_to(msg_info_headers, env,
                                                    NULL);
                continue;
            }

            if (!epr)
            {
                epr = axis2_endpoint_ref_create(env, "");
                axis2_msg_info_headers_set_fault_to(msg_info_headers, env, epr);
            }
            axis2_addr_in_extract_epr_information(env, header_block, epr,
                                                  addr_ns_str);
            axiom_soap_header_block_set_processed(header_block, env);
            fault_to_found = AXIS2_TRUE;
        }
        else if (!axutil_strcmp(ele_localname, AXIS2_WSA_MESSAGE_ID))
        {
            axis2_char_t *text = NULL;

            if (msg_id_found == AXIS2_TRUE)
            {
                /* Duplicate Message ID */
                axis2_addr_in_create_fault_envelope(env,
                                                    AXIS2_WSA_PREFIX_MESSAGE_ID,
                                                    addr_ns_str, msg_ctx);
                status = AXIS2_FAILURE;
                continue;
            }

            text =
                axiom_element_get_text(header_block_ele, env,
                                       header_block_node);
            axis2_msg_info_headers_set_in_message_id(msg_info_headers, env, text);
            axiom_soap_header_block_set_processed(header_block, env);
            msg_id_found = AXIS2_TRUE;
        }
        else if (!axutil_strcmp(ele_localname, AXIS2_WSA_ACTION))
        {
            axis2_char_t *text = NULL;

            if (action_found == AXIS2_TRUE)
            {
                /* Duplicate Action */
                axis2_addr_in_create_fault_envelope(env,
                                                    AXIS2_WSA_PREFIX_ACTION, addr_ns_str,
                                                    msg_ctx);
                status = AXIS2_FAILURE;
                continue;
            }

            text =
                axiom_element_get_text(header_block_ele, env,
                                       header_block_node);
            axis2_msg_info_headers_set_action(msg_info_headers, env, text);
            axiom_soap_header_block_set_processed(header_block, env);
            action_found = AXIS2_TRUE;
        }
        else if (!axutil_strcmp(ele_localname, AXIS2_WSA_RELATES_TO))
        {
            axis2_char_t *address = NULL;
            axutil_qname_t *rqn = NULL;
            axiom_attribute_t *relationship_type = NULL;
            const axis2_char_t *relationship_type_default_value = NULL;
            const axis2_char_t *relationship_type_value = NULL;
            axis2_relates_to_t *relates_to = NULL;
            if (!axutil_strcmp(AXIS2_WSA_NAMESPACE_SUBMISSION, addr_ns_str))
            {
                relationship_type_default_value =
                    AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE_SUBMISSION;
            }
            else
            {
                relationship_type_default_value =
                    AXIS2_WSA_ANONYMOUS_URL_SUBMISSION;
            }
            rqn =
                axutil_qname_create(env, AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE,
                                    NULL, NULL);

            relationship_type =
                axiom_element_get_attribute(header_block_ele, env, rqn);

            if (!relationship_type)
            {
                relationship_type_value =
                    AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE_SUBMISSION;
            }
            else
            {
                relationship_type_value =
                    axiom_attribute_get_value(relationship_type, env);
            }

            address =
                axiom_element_get_text(header_block_ele, env,
                                       header_block_node);
            relates_to =
                axis2_relates_to_create(env, address, relationship_type_value);

            axis2_msg_info_headers_set_relates_to(msg_info_headers, env,
                                                  relates_to);
            axiom_soap_header_block_set_processed(header_block, env);

            axutil_qname_free(rqn, env);
        }
    }

    /* If an action is not found, it's a false*/
    if (action_found == AXIS2_FALSE)   
    {
        axis2_addr_in_create_fault_envelope(env,
                                            AXIS2_WSA_PREFIX_ACTION, addr_ns_str, msg_ctx);
        status = AXIS2_FAILURE;
    }

    return status;
}
Exemplo n.º 30
0
static axis2_status_t AXIS2_CALL
axis2_msg_recv_load_and_init_svc_impl(
    axis2_msg_recv_t *msg_recv,
    const axutil_env_t *env,
    struct axis2_svc *svc)
{
    axutil_param_t *impl_info_param = NULL;
    void *impl_class = NULL;

    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);

    if(!svc)
    {
        return AXIS2_FAILURE;
    }

    impl_class = axis2_svc_get_impl_class(svc, env);
    if(impl_class)
    {
        return AXIS2_SUCCESS;
    }
    /* When we load the DLL we have to make sure that only one thread will load it */
    axutil_thread_mutex_lock(axis2_svc_get_mutex(svc, env));
    /* If more than one thread tries to acquires the lock, first thread loads the DLL.
     Others should not load the DLL */
    impl_class = axis2_svc_get_impl_class(svc, env);
    if(impl_class)
    {
        axutil_thread_mutex_unlock(axis2_svc_get_mutex(svc, env));
        return AXIS2_SUCCESS;
    }
    impl_info_param = axis2_svc_get_param(svc, env, AXIS2_SERVICE_CLASS);
    if(!impl_info_param)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC, AXIS2_FAILURE);
        axutil_thread_mutex_unlock(axis2_svc_get_mutex(svc, env));
        return AXIS2_FAILURE;
    }

    axutil_allocator_switch_to_global_pool(env->allocator);

    axutil_class_loader_init(env);

    impl_class = axutil_class_loader_create_dll(env, impl_info_param);
    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "loading the services from msg_recv_load_and_init_svc");

    if(impl_class)
    {
        axis2_svc_skeleton_t *skel = (axis2_svc_skeleton_t *)impl_class;
        axis2_conf_t *conf = NULL;
        conf = axis2_conf_ctx_get_conf(msg_recv->conf_ctx, env);
        if (skel->ops->init)
        {
            AXIS2_SVC_SKELETON_INIT(skel, env);
        }
        if (skel->ops->init_with_conf)
        {
            AXIS2_SVC_SKELETON_INIT_WITH_CONF(skel, env, conf);
        }
    }

    axis2_svc_set_impl_class(svc, env, impl_class);

    axutil_allocator_switch_to_local_pool(env->allocator);
    axutil_thread_mutex_unlock(axis2_svc_get_mutex(svc, env));
    return AXIS2_SUCCESS;
}