static axutil_hash_t *
sct_provider_hash_map_get_sct_hash_store(
    const axutil_env_t *env, 
    axis2_msg_ctx_t* msg_ctx)
{
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_ctx_t *ctx = NULL;
    axutil_property_t *property = NULL;
    axutil_hash_t *hash_store = NULL;
    
    /* Get the conf ctx */
    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    if(!conf_ctx)
    {
        AXIS2_LOG_ERROR(env->log,AXIS2_LOG_SI, 
            "[rampart]Config context is NULL. Cannot get security context token hash store.");
        return NULL;
    }

    ctx = axis2_conf_ctx_get_base(conf_ctx,env);
    if(!ctx)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
            "[rampart]Axis2 context is NULL. Cannot get security context token hash store.");
        return NULL;
    }

    /* Get the hash store property */
    property = axis2_ctx_get_property(ctx, env, RAMPART_SCT_PROVIDER_HASH_PROB);
    if(property)
    {
        /* Get the store */
        hash_store = (axutil_hash_t*)axutil_property_get_value(property, env);
    }
    else
    {
        axutil_property_t *hash_store_prop = NULL;

        hash_store = axutil_hash_make(env);
        hash_store_prop = axutil_property_create_with_args(env, AXIS2_SCOPE_APPLICATION,
               AXIS2_TRUE, (void *)sct_provider_hash_map_sct_hash_store_free, hash_store);
        axis2_ctx_set_property(ctx, env, RAMPART_SCT_PROVIDER_HASH_PROB, hash_store_prop);
    }

    return hash_store;
}
Exemple #2
0
axis2_status_t AXIS2_CALL
mod_sandesha2_init(
    axis2_module_t *module,
    const axutil_env_t *env,
    axis2_conf_ctx_t *conf_ctx,
    axis2_module_desc_t *module_desc)
{
    /*sandesha2_property_bean_t *property_bean = NULL;
    axutil_param_t *param = NULL;
    axis2_conf_t *conf = NULL;*/
    axis2_ctx_t *ctx = NULL;

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:mod_sandesha2_init");
    AXIS2_PARAM_CHECK(env->error, conf_ctx, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, module_desc, AXIS2_FAILURE);

    sandesha2_error_init();
    /*property_bean = sandesha2_property_mgr_load_properties_from_module_desc(env, module_desc);
    if(!property_bean)
    {
        property_bean = sandesha2_property_mgr_load_properties_from_def_values(env);
    }

    param = axutil_param_create(env, SANDESHA2_SANDESHA_PROPERTY_BEAN, property_bean);
    axutil_param_set_value_free(param, env, sandesha2_property_bean_free_void_arg);

    conf = axis2_conf_ctx_get_conf(conf_ctx, env);
    axis2_conf_add_param(conf, env, param);*/

    ctx = axis2_conf_ctx_get_base(conf_ctx, env);
    axis2_ctx_set_property(ctx, env, SANDESHA2_INMEMORY_STORAGE_MGR, NULL);
    axis2_ctx_set_property(ctx, env, SANDESHA2_PERMANENT_STORAGE_MGR, NULL);

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

    return AXIS2_SUCCESS;
}
Exemple #3
0
/* This is the function where threads start running */
void *AXIS2_THREAD_FUNC
axis2_udp_receiver_thread_worker_func(
    axutil_thread_t * thd,
    void *data)
{
	const axutil_env_t *env = NULL;
	axis2_status_t status = AXIS2_FAILURE;
	axis2_conf_t *conf = NULL;
	axis2_svc_t *svc = NULL;
	axis2_udp_recv_thd_args_t *args = NULL;
	axis2_udp_response_t response;
	axutil_hash_index_t *hi = NULL;
	axutil_hash_t *ori_all_svcs = NULL, *all_svcs = NULL;
	void *val = NULL;
	
	args = (axis2_udp_recv_thd_args_t *) data;
	env = (axutil_env_t *) args->env;	

	conf = axis2_conf_ctx_get_conf(args->conf_ctx, env);
	/* Get all the service discriptions */
	ori_all_svcs = axis2_conf_get_all_svcs(conf, env);
	if (!ori_all_svcs)
	{
		return NULL;
	}
	all_svcs = axutil_hash_copy(ori_all_svcs, env);	
	if (args->is_multicast)
	{
	/* If multicast we go through every service and try to figure out weather they are 
	   accepting multicast messages. If a service accepts a multicast message we send the 
	   request to that service bypassing the normal dispatchers. Dispatchers cannot be 
	   used since no dispatching information is found in the multicast messages 
	*/
    for (hi = axutil_hash_first(all_svcs, env); hi;
         hi = axutil_hash_next(env, hi))
    {		
        axutil_hash_this(hi, NULL, NULL, &val);
        svc = (axis2_svc_t *) val;
        if (svc)
        {
			axutil_param_t *param = NULL;
			axis2_char_t *param_val = NULL;
			/* Get the Multicast accept parameter from the services.xml */
            param = axis2_svc_get_param(svc, env, AXIS2_UDP_MULTICAST_ACCEPT);
			if (!param) 
			{
				continue;
			}
			/* check weather this service accepts multicast requests */
			param_val = axutil_param_get_value(param, env);
			if (!param_val || !axutil_strcmp(param_val, "false") || axutil_strcmp(param_val, "true"))
			{
				continue;
			}
			
			response.buf_size = 0;
			response.buff = NULL;

			/* set the service to the request. This will bypass the dispatches */
			args->request.svc = svc;
			/* Process the request */
			status = axis2_udp_receiver_process_request(args->env, args->conf_ctx, 
															&args->request, &response);
			if (status == AXIS2_FAILURE)
			{
				AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error processing the request.");
				return NULL;
			}

			/* If we have a response send it */
			if (response.buff)
			{
				status = axutil_network_handler_send_dgram(env, args->send_socket, 
													response.buff, &response.buf_size, 
													args->req_addr, args->req_port, NULL);
				if (status == AXIS2_FAILURE)
				{
					AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error sending the response.");
					return NULL;
				}
			}
		}
	}
	}
	else
	{
		axis2_ctx_t *ctx = NULL;
		axutil_property_t *prop = NULL;
		axis2_udp_backchannel_info_t *binfo = NULL;

		ctx = axis2_conf_ctx_get_base(args->conf_ctx, env);
		prop = axis2_ctx_get_property(ctx, env, AXIS2_UDP_BACKCHANNEL_INFO);
		if (prop)
		{
			binfo = axutil_property_get_value(prop, env);
		}
		/* Unicast case. In this case message contains dispatching information. 
		 * So we send the request in the normal way 
		 */
		response.buf_size = 0;
		response.buff = NULL;
		if (binfo)
		{
			args->request.svc = binfo->svc;
			args->request.op = binfo->op;
		}
		
		/* Process the request */
		status = axis2_udp_receiver_process_request(args->env, args->conf_ctx, 
														&args->request, &response);
		if (status == AXIS2_FAILURE)
		{
			AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error processing the request.");
			return NULL;
		}

		/* If we have a response send it */
		if (response.buff)
		{
			status = axutil_network_handler_send_dgram(env, args->send_socket, 
												response.buff, &response.buf_size, 
												args->req_addr, args->req_port, NULL);
			if (status == AXIS2_FAILURE)
			{
				AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error sending the response.");
				return NULL;
			}
		}
	}
	return NULL;
}
Exemple #4
0
axis2_status_t AXIS2_CALL
axis2_udp_receiver_start(
    axis2_transport_receiver_t *tr_receiver,
    const axutil_env_t * env)
{
	axis2_status_t status;
	axis2_udp_receiver_impl_t *receiver = NULL;

	receiver = AXIS2_INTF_TO_IMPL(tr_receiver);

	AXIS2_LOG_INFO(env->log, "Started the UDP server");
	if (receiver->socket == AXIS2_INVALID_SOCKET)
	{
		/* socket not set, we should create one */
		if (receiver->is_multicast && receiver->multicast_group)
		{
			/* Setup a socket to receive multicast packets */
			receiver->socket = axutil_network_hadler_create_multicast_svr_socket(
				env, receiver->port, receiver->multicast_group);		
		}
		else
		{
			axis2_ctx_t *ctx = NULL;
			/* Setup a socket to receive unicast packets */
			receiver->socket = axutil_network_handler_create_dgram_svr_socket(
				env, receiver->port);
			receiver->owns_socket = AXIS2_TRUE; 
			/* bind the socket to a unique address */
			/*axutil_network_handler_bind_socket(env, receiver->socket, 0);*/
			ctx = axis2_conf_ctx_get_base(receiver->conf_ctx, env);
			axis2_udp_transport_add_backchannel_info(env, ctx, receiver->socket);
		}
		receiver->owns_socket = AXIS2_TRUE;
	}
	if (receiver->socket == AXIS2_INVALID_SOCKET)
	{
		AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Socket creation faild on socket");
		return AXIS2_FAILURE;
	}

	/* We are using a seperate socket to send the request */
	receiver->send_socket = axutil_network_handler_open_dgram_socket(env);
	if (receiver->send_socket == AXIS2_INVALID_SOCKET)
	{
		AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Socket creation faild on socket");
		return AXIS2_FAILURE;
	}
	receiver->stop =  AXIS2_FALSE;
	axutil_thread_mutex_unlock(receiver->mutex);
	while (!receiver->stop)
	{
		axis2_udp_recv_thd_args_t *args = NULL;
		axutil_thread_t *worker_thread = NULL;
		axis2_char_t *addr = NULL;
		int port = receiver->port;		
		int buf_len = AXIS2_UDP_PACKET_MAX_SIZE;
		axis2_char_t *in_buff = NULL;

		in_buff = AXIS2_MALLOC(env->allocator, sizeof(char) * receiver->max_packet_size);
		/* This is a blocking call. This will block until data is available in the socket */
		status = axutil_network_handler_read_dgram(env, receiver->socket, in_buff, &buf_len, &addr, &port);   
		if (status == AXIS2_FAILURE)
		{
			AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in reading data from the datagram.");
			return AXIS2_FAILURE;
		}	

		args = (axis2_udp_recv_thd_args_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_udp_recv_thd_args_t));		
		if (!args)
		{
			AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
			return AXIS2_FAILURE;
		}
		/* Set the data required by the thread */
		args->env = axutil_init_thread_env(env);
		args->socket = receiver->socket;
		args->send_socket = receiver->send_socket;
		args->conf_ctx = receiver->conf_ctx;
		args->req_addr = addr;
		args->req_port = port;
		args->request.buff = in_buff;
		args->request.buf_size = buf_len;
		args->request.op = NULL;
		args->request.svc = NULL;
		args->is_multicast = receiver->is_multicast;
#ifdef AXIS2_SVR_MULTI_THREADED
		worker_thread = axutil_thread_pool_get_thread(env->thread_pool,
													axis2_udp_receiver_thread_worker_func,
													(void *) args);
		if (!worker_thread)
		{
			AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Thread creation failed"
							"server thread loop");
			continue;
		}
		axutil_thread_pool_thread_detach(env->thread_pool, worker_thread);
#else
		axis2_udp_receiver_thread_worker_func(NULL, (void *)args);
#endif
	}
	return AXIS2_SUCCESS;
}