Example #1
0
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
service_admin_util_is_filtered_out_service(
	axutil_env_t *env,
	axis2_svc_t *svc)
{
	axutil_param_t *param =  NULL;
	if(!svc)
		return AXIS2_FALSE;

	param = axis2_svc_get_param(svc, env, ADMIN_SERVICE_PARAM_NAME);
	if(param)
	{
		axis2_char_t *value = NULL;
		value = axutil_param_get_value(param, env);
		if(value && axutil_strcmp(value, "true") == 0)
			return AXIS2_TRUE;
	}
	
	param = axis2_svc_get_param(svc, env, HIDDEN_SERVICE_PARAM_NAME);
	if(param)
	{
		axis2_char_t *value = NULL;
		value = axutil_param_get_value(param, env);
		if(value && axutil_strcmp(value, "true") == 0)
			return AXIS2_TRUE;
	}
	return AXIS2_FALSE;

}
Example #2
0
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
axis2_svc_is_param_locked(
    axis2_svc_t * svc,
    const axutil_env_t * env,
    const axis2_char_t * param_name)
{
    axis2_bool_t locked = AXIS2_FALSE;
    axutil_param_t *param = NULL;
    axis2_svc_grp_t *parent = NULL;
    axis2_bool_t ret = AXIS2_FALSE;

    AXIS2_PARAM_CHECK(env->error, param_name, AXIS2_FALSE);

    /* Checking the locked value of parent */

    parent = axis2_svc_get_parent(svc, env);
    if(parent)
        locked = axis2_svc_grp_is_param_locked(parent, env, param_name);
    if(parent && locked)
    {
        return AXIS2_TRUE;
    }
    param = axis2_svc_get_param(svc, env, param_name);
    if(param)
    {
        ret = axutil_param_is_locked(param, env);
    }
    return ret;
}
Example #3
0
AXIS2_EXPORT axis2_status_t AXIS2_CALL
axis2_msg_recv_delete_svc_obj(
    axis2_msg_recv_t * msg_recv,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx)
{
    axis2_svc_t *svc = NULL;
    axis2_op_ctx_t *op_ctx = NULL;
    axis2_svc_ctx_t *svc_ctx = NULL;
    axutil_param_t *impl_info_param = NULL;
    axutil_param_t *scope_param = NULL;
    axis2_char_t *param_value = NULL;
    axutil_dll_desc_t *dll_desc = NULL;

    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);

    op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
    svc_ctx = axis2_op_ctx_get_parent(op_ctx, env);
    svc = axis2_svc_ctx_get_svc(svc_ctx, env);
    if(!svc)
    {
        return AXIS2_FAILURE;
    }

    scope_param = axis2_svc_get_param(svc, env, AXIS2_SCOPE);
    if(scope_param)
    {
        param_value = axutil_param_get_value(scope_param, env);
    }
    if(param_value && (0 == axutil_strcmp(AXIS2_APPLICATION_SCOPE, param_value)))
    {
        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);
        return AXIS2_FAILURE;
    }
    dll_desc = axutil_param_get_value(impl_info_param, env);
    return axutil_class_loader_delete_dll(env, dll_desc);
    (void)msg_recv;
}
Example #4
0
  static int AXIS2_CALL Axis2Service_init_with_conf(
    axis2_svc_skeleton_t * /*pSvcSkeleton*/,
    const axutil_env_t * pEnv, 
    axis2_conf* pConf)
  {
    staff::CrashHandler::Enable();
#if defined WIN32
    // installing handler to process Staff deinitialization before dlls are unloaded
    SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE);
#endif

    const axis2_char_t* szServiceName = "StaffService";
    m_pAxis2Svc = axis2_conf_get_svc(pConf, pEnv, szServiceName);

    // check for staff module is engaged
    axutil_qname_t* pQName = axutil_qname_create(pEnv, "staff", NULL, NULL);
    axis2_bool_t bEngaged = axis2_svc_is_module_engaged(m_pAxis2Svc, pEnv, pQName);
    axutil_qname_free(pQName, pEnv);

    if (!bEngaged)
    {
      staff::LogError() << "staff module is not engaged. Unable to continue.";
      exit(1);
    }

#ifndef WITHOUT_SECURITY
    // check for staff_security is engaged
    pQName = axutil_qname_create(pEnv, "staff_security", NULL, NULL);
    bEngaged = axis2_svc_is_module_engaged(m_pAxis2Svc, pEnv, pQName);
    axutil_qname_free(pQName, pEnv);

    if (!bEngaged)
    {
      staff::LogError() << "staff_security module is not engaged. Unable to continue.";
      exit(1);
    }

    // initialize security
    if (!staff_security_init())
    {
      staff::LogError() << "Failed to initialize staff::security.";
      exit(1);
    }
#endif

    axutil_param_t* pParam = axis2_svc_get_param(m_pAxis2Svc, pEnv, "Http200OnFault");
    if (pParam != NULL)
    {
      const axis2_char_t* szValue = reinterpret_cast<const axis2_char_t*>(axutil_param_get_value(pParam, pEnv));
      if (szValue != NULL)
      {
        m_bHttp200OnFault = !axutil_strcasecmp(szValue, "true");
      }
    }

    m_pEnv = pEnv;
    m_pConf = pConf;

    try
    {
      staff::ServiceDispatcher::Inst().Init(staff::ServiceDispatcher::Events(StaffService::OnConnect, StaffService::OnDisconnect));
      std::cout << "StaffService started (version " VERSION_FULL ")" << std::endl;

      return AXIS2_SUCCESS;
    }
    STAFF_CATCH_ALL_DESCR("Failed to start StaffService dispatcher")

    return AXIS2_FAILURE;
  }
Example #5
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;
}
Example #6
0
AXIS2_EXPORT axis2_svc_skeleton_t *AXIS2_CALL
axis2_msg_recv_make_new_svc_obj(
    axis2_msg_recv_t * msg_recv,
    const axutil_env_t * env,
    struct axis2_msg_ctx * msg_ctx)
{
    struct axis2_svc *svc = NULL;
    struct axis2_op_ctx *op_ctx = NULL;
    struct axis2_svc_ctx *svc_ctx = NULL;
    axutil_param_t *impl_info_param = NULL;
    void *impl_class = NULL;

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

    op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
    svc_ctx = axis2_op_ctx_get_parent(op_ctx, env);
    svc = axis2_svc_ctx_get_svc(svc_ctx, env);
    if(!svc)
    {
        return NULL;
    }

    impl_class = axis2_svc_get_impl_class(svc, env);
    if(impl_class)
    {
        return impl_class;
    }
    else
    {
        /* 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 impl_class;
        }
        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 NULL;
        }

        axutil_allocator_switch_to_global_pool(env->allocator);

        axutil_class_loader_init(env);

        impl_class = axutil_class_loader_create_dll(env, impl_info_param);

        if(impl_class)
        {
            AXIS2_SVC_SKELETON_INIT((axis2_svc_skeleton_t *)impl_class, env);
        }

        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 impl_class;
	(void)msg_recv;
    }
}
/**
* auto generated function definition signature
* for "getKeyStores|http://service.keystore.security.carbon.wso2.org" operation.
* @param env environment ( mandatory)* @param MessageContext the outmessage context
*
* @return adb_getKeyStoresResponse_t*
*/
adb_getKeyStoresResponse_t* 
axis2_skel_KeyStoreAdminService_getKeyStores(const axutil_env_t *env , 
											 axis2_msg_ctx_t *msg_ctx,
											 axis2_skel_KeyStoreAdminService_getKeyStores_fault *fault )
{
	axis2_svc_t* svc = NULL;
	axutil_param_t* param = NULL;
	axis2_char_t* primary_keystore = NULL;
	axis2_bool_t is_primary_keystore = AXIS2_FALSE;
	axis2_conf_ctx_t* conf_ctx = NULL;
	axis2_conf_t* conf = NULL;
	axis2_char_t* repo_path = NULL;
	axutil_array_list_t* keystore_filenames = NULL;
	int keystore_file_count = 0;
	int index = 0;
	adb_getKeyStoresResponse_t* response = NULL;
	axis2_char_t* keystore_filename = NULL;
	axis2_char_t* keystore_name = NULL;
	axis2_char_t* extension = NULL;
	axis2_char_t* keystore_type = NULL;
	axis2_char_t* provider = NULL;
	axis2_bool_t private_store = AXIS2_FALSE;
	axis2_char_t* tok = NULL;
	adb_KeyStoreData_t* data = NULL;

	/* Get primary keystore filename */
	svc = axis2_msg_ctx_get_svc(msg_ctx, env);
	param = axis2_svc_get_param(svc, env, "PrimaryKeystore");
	if (param)
	{
		primary_keystore = (axis2_char_t*)
			axutil_param_get_value(param, env);
	}

	/* Form keystore directory name*/
	conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    conf = axis2_conf_ctx_get_conf(conf_ctx, env);
    repo_path = axis2_conf_get_repo(conf, env);

	/* Read file names in keystore directory */	
	keystore_filenames = keystore_admin_util_get_keystore_filenames(
		env, repo_path);

	if (!keystore_filenames) return NULL;
	
	/* Create response */
	response = adb_getKeyStoresResponse_create(env);

	/* Fill data */
	keystore_file_count = axutil_array_list_size(keystore_filenames, env);
	for (index = 0; index < keystore_file_count; ++index)
	{
		axis2_char_t* filename = NULL;

		keystore_filename = NULL;
		keystore_name = NULL;
		extension = NULL;
		keystore_type = NULL;
		provider = NULL;
		private_store = AXIS2_FALSE;
		tok = NULL;

		/* Get name */
		filename = (axis2_char_t*)axutil_array_list_get(keystore_filenames, env, index);
		keystore_filename = axutil_strdup(env, filename);

		tok = strtok(filename, ".");
		if (tok) /* Keystore name */
		{
			keystore_name = tok;
			
			tok = strtok(NULL, " .");
			if (tok) /* Extension */
			{
				extension = tok;
			}
		}

		if (NULL == extension) /* No extension found */
		{
			AXIS2_FREE(env->allocator, filename);
			AXIS2_FREE(env->allocator, keystore_filename);
			keystore_filename = filename = NULL;
			continue;
		}

		if (0 == axutil_strcmp(extension, "p12")) /* PKCS12 */
		{
			keystore_type = "PKCS12";
		}
		else
		{
			AXIS2_FREE(env->allocator, filename);
			AXIS2_FREE(env->allocator, keystore_filename);
			keystore_filename = filename = NULL;
			continue;
		}

		is_primary_keystore = 
			(0 == axutil_strcmp(keystore_filename, primary_keystore)) ? AXIS2_TRUE : AXIS2_FALSE;

		if (is_primary_keystore)
		{
			/* Primary keystore */
			provider = axutil_strcat(env, " ", NULL);
			private_store = AXIS2_TRUE;
		}
		else
		{
			axis2_char_t password_tmp[10];
			axis2_char_t provider_tmp[20];
			axis2_char_t pvt_key_pass_tmp[10];

			/* Get password, provider and pvt_key_pass */
			if (!keystore_admin_util_get_keystore_details(env, repo_path, keystore_name, 
				password_tmp, provider_tmp, pvt_key_pass_tmp))
			{
				AXIS2_FREE(env->allocator, filename);
				AXIS2_FREE(env->allocator, keystore_filename);
				keystore_filename = filename = NULL;
				continue;
			}

			provider = axutil_strdup(env, provider_tmp);

			private_store = keystore_admin_util_get_private_store(env, repo_path,
				keystore_name, password_tmp);
		}
		
		data = adb_KeyStoreData_create(env);

		adb_KeyStoreData_set_keyStoreName(data, env, keystore_filename);
		adb_KeyStoreData_set_keyStoreType(data, env, keystore_type);
		adb_KeyStoreData_set_provider(data, env, provider);
		adb_KeyStoreData_set_privateStore(data, env, private_store);

		adb_getKeyStoresResponse_add_return(response, env, data);
	}

	axutil_array_list_free(keystore_filenames, env);
	
	return response;
}
/**
* auto generated function definition signature
* for "deleteStore|http://service.keystore.security.carbon.wso2.org" operation.
* @param env environment ( mandatory)* @param MessageContext the outmessage context
* @param _deleteStore of the adb_deleteStore_t*
*
* @return 
*/
axis2_status_t  
axis2_skel_KeyStoreAdminService_deleteStore(const axutil_env_t *env , 
											axis2_msg_ctx_t *msg_ctx,
											adb_deleteStore_t* _deleteStore,
											axis2_skel_KeyStoreAdminService_deleteStore_fault *fault )
{
	axis2_svc_t* svc = NULL;
	axutil_param_t* param = NULL;
	axis2_char_t* primary_keystore = NULL;
	axis2_char_t* keystore_name = NULL;
	axis2_conf_ctx_t* conf_ctx = NULL;
	axis2_conf_t* conf = NULL;
	axis2_char_t* repo_path = NULL;
	axis2_char_t* keystore_file = NULL;
	axis2_char_t* keystore_details_file = NULL;
	int status = 0;

	/* Get required keystore name*/
	keystore_name = axutil_strdup(
		env, adb_deleteStore_get_keyStoreName(_deleteStore, env));
	if (!keystore_name) return AXIS2_FAILURE;

	/* Get primary keystore filename */
	svc = axis2_msg_ctx_get_svc(msg_ctx, env);
	param = axis2_svc_get_param(svc, env, "PrimaryKeystore");
	if (param)
	{
		primary_keystore = (axis2_char_t*)
			axutil_param_get_value(param, env);
	}

	/* Primary keystore should not be deleted*/
	if (0 == axutil_strcmp(keystore_name, primary_keystore))
		return AXIS2_FAILURE;

	keystore_name = strtok(keystore_name, ".");

	/* Form keystore file names*/
	conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    conf = axis2_conf_ctx_get_conf(conf_ctx, env);
    repo_path = axis2_conf_get_repo(conf, env);
	keystore_file = axutil_strcat(env, repo_path, AXIS2_PATH_SEP_STR, "services", 
		AXIS2_PATH_SEP_STR, "KeyStoreAdminService", AXIS2_PATH_SEP_STR, "keystores", 
		AXIS2_PATH_SEP_STR, keystore_name, ".p12", NULL);
	keystore_details_file = axutil_strcat(env, repo_path, AXIS2_PATH_SEP_STR, "services", 
		AXIS2_PATH_SEP_STR, "KeyStoreAdminService", AXIS2_PATH_SEP_STR, "keystores", 
		AXIS2_PATH_SEP_STR, keystore_name, ".dat", NULL);

	/* Remove keystore and detail files*/
	status = remove(keystore_file);
	if (0 == status)
		status = remove(keystore_details_file);

	AXIS2_FREE(env->allocator, keystore_name);
	AXIS2_FREE(env->allocator, keystore_file);
	AXIS2_FREE(env->allocator, keystore_details_file);
	
	if (0 != status) return AXIS2_FAILURE;

	return AXIS2_SUCCESS;
}
Example #9
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;
}