コード例 #1
0
ファイル: service_admin_util.c プロジェクト: AdrianRys/wsf
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;
}
コード例 #2
0
ファイル: engine.c プロジェクト: alexis-gruet/axis2c-trunk
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_engine_receive_fault(
    axis2_engine_t * engine,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx)
{
    axis2_op_ctx_t *op_ctx = NULL;

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Start:axis2_engine_receive_fault");
    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);

    op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);

    if(!op_ctx)
    {
        /* If we do not have an op context that means this may be an incoming
         dual channel response. So try to dispatch the service */
        axis2_conf_ctx_t *conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
        if(conf_ctx)
        {
            axis2_conf_t *conf = axis2_conf_ctx_get_conf(conf_ctx, env);
            if(conf)
            {
                axutil_array_list_t *phases =
                    axis2_conf_get_in_phases_upto_and_including_post_dispatch(conf, env);
                if(phases)
                {
                    if(axis2_msg_ctx_is_paused(msg_ctx, env))
                    {
                        axis2_engine_resume_invocation_phases(engine, env, phases, msg_ctx);
                    }
                    else
                    {
                        axis2_engine_invoke_phases(engine, env, phases, msg_ctx);
                    }
                }
            }
        }
    }

    op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
    /* Find and execute the fault in flow handlers */
    if(op_ctx)
    {
        axis2_op_t *op = axis2_op_ctx_get_op(op_ctx, env);
        axutil_array_list_t *phases = axis2_op_get_fault_in_flow(op, env);
        if(axis2_msg_ctx_is_paused(msg_ctx, env))
        {
            axis2_engine_resume_invocation_phases(engine, env, phases, msg_ctx);
        }
        else
        {
            axis2_engine_invoke_phases(engine, env, phases, msg_ctx);
        }
    }
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_engine_receive_fault");
    return AXIS2_SUCCESS;
}
コード例 #3
0
ファイル: util.c プロジェクト: AdrianRys/wsf
axis2_status_t
wsclient_set_https_transport_parameretes (const axutil_env_t *env,
										  axis2_svc_client_t *svc_client)
{
	axis2_conf_ctx_t *conf_ctx;
	axis2_svc_ctx_t *svc_ctx;
	axis2_conf_t *conf;
	axutil_qname_t *qname;
	axis2_transport_out_desc_t *transport_out;
	axis2_transport_sender_t *transport_sender;
	axutil_param_t *param;
	AXIS2_TRANSPORT_ENUMS transport_enum=AXIS2_TRANSPORT_ENUM_HTTP;

	if (svc_client)
		svc_ctx = axis2_svc_client_get_svc_ctx (svc_client, env);
	else 
		return AXIS2_FAILURE;

	if (svc_ctx)
		conf_ctx = axis2_svc_ctx_get_conf_ctx(svc_ctx, env);
	else 
		return AXIS2_FAILURE;

	if (conf_ctx)
		conf = axis2_conf_ctx_get_conf(conf_ctx, env);
	else 
		return AXIS2_FAILURE;


	qname = axutil_qname_create (env, "https", NULL, NULL);
	if (qname)
		transport_out = axis2_transport_out_desc_create(env, transport_enum);
	else 
		return AXIS2_FAILURE;

	transport_sender = (axis2_transport_sender_t *)axis2_http_transport_sender_create (env);

	param = axutil_param_create (env, NULL, NULL);
	if (param)
	{
		axutil_param_set_name(param, env, (void *)axutil_strdup (env, AXIS2_HTTP_PROTOCOL_VERSION));
		axutil_param_set_value(param, env, (void *)axutil_strdup (env, AXIS2_HTTP_HEADER_PROTOCOL_11));
		axutil_param_set_locked(param, env, AXIS2_FALSE);
	}
	else 
		return AXIS2_FAILURE;

	if (transport_out && conf)
	{
        axis2_transport_out_desc_add_param (transport_out, env, param);
		axis2_transport_out_desc_set_sender(transport_out, env, transport_sender);
		axis2_conf_add_transport_out (conf, env, transport_out, AXIS2_TRANSPORT_ENUM_HTTP);
	}
	else
		return AXIS2_FAILURE;

	return AXIS2_SUCCESS;
}
コード例 #4
0
        /**
         * auto generated function definition signature
         * for "applySecurity|http://service.config.security.carbon.wso2.org" operation.
         * @param env environment ( mandatory)* @param MessageContext the outmessage context
         * @param _applySecurity of the adb_applySecurity_t*
         *
         * @return 
         */
        axis2_status_t  axis2_skel_SecurityAdminService_applySecurity(const axutil_env_t *env , axis2_msg_ctx_t *msg_ctx,
                                              adb_applySecurity_t* _applySecurity,
                                          axis2_skel_SecurityAdminService_applySecurity_fault *fault )
        {
			axis2_char_t* service_name = NULL;
			axis2_char_t* scenario_id = NULL;
			axis2_conf_ctx_t* conf_ctx = NULL;
			axis2_conf_t* conf = NULL;
			axis2_svc_t* svc = NULL;
			axis2_char_t* repo_path = NULL;
			axis2_char_t* policy_file_name = NULL;
			neethi_policy_t* neethi_policy = NULL;
			axis2_desc_t* desc = NULL;
			axis2_policy_include_t* policy_include = NULL;
			axutil_qname_t* module_qname = NULL;
			axis2_module_desc_t* module_desc = NULL;

			/* Get parameters */
			service_name = adb_applySecurity_get_serviceName(_applySecurity, env);
			scenario_id = adb_applySecurity_get_policyId(_applySecurity, env);

			/* Load neethi policy */
			conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
			repo_path = axis2_conf_ctx_get_root_dir(conf_ctx, env);
			policy_file_name = axutil_strcat(env, repo_path, AXIS2_PATH_SEP_STR, "services",
				AXIS2_PATH_SEP_STR, "SecurityAdminService", AXIS2_PATH_SEP_STR, "policies",
				AXIS2_PATH_SEP_STR, scenario_id, "-policy.xml", NULL);

			neethi_policy = neethi_util_create_policy_from_file(env, policy_file_name);
			AXIS2_FREE(env->allocator, policy_file_name);
			if (!neethi_policy) return AXIS2_FAILURE;
			
			/* Get service instance*/
			conf = axis2_conf_ctx_get_conf(conf_ctx, env);
			svc = axis2_conf_get_svc(conf, env, service_name);
			if (!svc) return AXIS2_FAILURE;

			desc = axis2_svc_get_base(svc, env);
			if (!desc) return AXIS2_FAILURE;

			policy_include = axis2_desc_get_policy_include(desc, env);
			if (!policy_include) return AXIS2_FAILURE;

			/* Attach policy*/
			axis2_policy_include_add_policy_element(policy_include, env, 
				AXIS2_SERVICE_POLICY, neethi_policy);

			/* Enagage modules*/
			module_qname = axutil_qname_create(env, "rampart", NULL, NULL);
			module_desc = axis2_conf_get_module(conf, env, module_qname);
			axutil_qname_free(module_qname, env);

			axis2_svc_disengage_module(svc, env, module_desc, conf);
			axis2_svc_engage_module(svc, env, module_desc, conf);

			return AXIS2_SUCCESS;
        }
コード例 #5
0
ファイル: engine.c プロジェクト: alexis-gruet/axis2c-trunk
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_engine_resume_receive(
    axis2_engine_t * engine,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx)
{
    axis2_status_t status = AXIS2_FAILURE;
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_conf_t *conf = NULL;
    axutil_array_list_t *phases = NULL;

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Start:axis2_engine_resume_receive");
    /* Find and invoke the phases */
    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    conf = axis2_conf_ctx_get_conf(conf_ctx, env);
    phases = axis2_conf_get_in_phases_upto_and_including_post_dispatch(conf, env);

    axis2_engine_resume_invocation_phases(engine, env, phases, msg_ctx);
    /* Invoking the message receiver */
    if(axis2_msg_ctx_get_server_side(msg_ctx, env) && !axis2_msg_ctx_is_paused(msg_ctx, env))
    {
        /* Invoke the message receivers */
        axis2_op_ctx_t *op_ctx = NULL;

        status = axis2_engine_check_must_understand_headers(env, msg_ctx);

        if(status != AXIS2_SUCCESS)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Checking for must understand headers failed");
            return status;
        }

        op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
        if(op_ctx)
        {
            axis2_op_t *op = axis2_op_ctx_get_op(op_ctx, env);
            if(op)
            {
                axis2_msg_recv_t *receiver = NULL;
                receiver = axis2_op_get_msg_recv(op, env);
                if(!receiver)
                {
                    AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Message receiver not set in operation description");
                    return AXIS2_FAILURE;
                }
                status = axis2_msg_recv_receive(receiver, env, msg_ctx, axis2_msg_recv_get_derived(
                    receiver, env));
            }
        }
    }
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_engine_resume_receive");
    return status;
}
コード例 #6
0
axis2_status_t
axis2_keystore_admin_save_keystore_details(
    const axutil_env_t* env,
	axis2_msg_ctx_t* msg_ctx,
    adb_addKeyStore_t* addKeyStore)
{
	axis2_char_t* file_name = NULL;
	axis2_char_t* password = NULL;
	axis2_char_t* provider = NULL;
	axis2_char_t* pvt_key_pass = NULL;
	axis2_char_t* record = NULL;
	axis2_conf_ctx_t* conf_ctx = NULL;
	axis2_conf_t* axis2_conf = NULL;
	axis2_char_t* repo_path = NULL;
	axis2_char_t* data_file_name = NULL;
	FILE* file = NULL;
	axis2_char_t* encoded_record = NULL;
	int encoded_length = 0;

	/* Get parameters*/
	file_name = axutil_strdup(env, adb_addKeyStore_get_filename(addKeyStore, env));
	file_name = strtok(file_name, ".");
	password = adb_addKeyStore_get_password(addKeyStore, env);
	provider = adb_addKeyStore_get_provider(addKeyStore, env);
	pvt_key_pass = adb_addKeyStore_get_pvtkeyPass(addKeyStore, env);

	/* Persist keystore details*/
	record = axutil_strcat(env, password, "|", pvt_key_pass, "|", provider, NULL);

	conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    axis2_conf = axis2_conf_ctx_get_conf(conf_ctx, env);
    repo_path = axis2_conf_get_repo(axis2_conf, env);
    data_file_name = axutil_strcat(env, repo_path, AXIS2_PATH_SEP_STR, "services", 
		AXIS2_PATH_SEP_STR, "KeyStoreAdminService", AXIS2_PATH_SEP_STR, "keystores",
        AXIS2_PATH_SEP_STR, file_name, ".dat", NULL);

	file = fopen(data_file_name, "w");
	/*encoded_record = (axis2_char_t*)
		AXIS2_MALLOC(env->allocator, axutil_strlen(record));
	encoded_length = axutil_base64_encode(encoded_record, record, 
		axutil_strlen(record));*/

	fwrite(record, sizeof(axis2_char_t), axutil_strlen(record), file);
	fflush(file);
	fclose(file);

	AXIS2_FREE(env->allocator, file_name);
	AXIS2_FREE(env->allocator, record);
	AXIS2_FREE(env->allocator, data_file_name);

	return AXIS2_SUCCESS;
}
コード例 #7
0
        /**
         * auto generated function definition signature
         * for "disableSecurityOnService|http://service.config.security.carbon.wso2.org" operation.
         * @param env environment ( mandatory)* @param MessageContext the outmessage context
         * @param _disableSecurityOnService of the adb_disableSecurityOnService_t*
         *
         * @return 
         */
        axis2_status_t  axis2_skel_SecurityAdminService_disableSecurityOnService(const axutil_env_t *env , axis2_msg_ctx_t *msg_ctx,
                                              adb_disableSecurityOnService_t* _disableSecurityOnService,
                                          axis2_skel_SecurityAdminService_disableSecurityOnService_fault *fault )
        {
			axis2_char_t* service_name = NULL;
			axis2_conf_ctx_t* conf_ctx = NULL;
			axis2_conf_t* conf = NULL;
			axis2_svc_t* svc = NULL;
			neethi_policy_t* neethi_policy = NULL;
			axis2_char_t* policy_name = NULL;
			axis2_desc_t* desc = NULL;
			axis2_policy_include_t* policy_include = NULL;
			axutil_qname_t* module_qname = NULL;
			axis2_module_desc_t* module_desc = NULL;

			/* Get parameters*/
			service_name = adb_disableSecurityOnService_get_serviceName(
				_disableSecurityOnService, env);
			
			/* Get service instance*/
			conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
			conf = axis2_conf_ctx_get_conf(conf_ctx, env);
			svc = axis2_conf_get_svc(conf, env, service_name);
			if (!svc) return AXIS2_FAILURE;

			desc = axis2_svc_get_base(svc, env);
			if (!desc) return AXIS2_FAILURE;

			policy_include = axis2_desc_get_policy_include(desc, env);
			if (!policy_include) return AXIS2_FAILURE;

			/* Detach policy*/
			neethi_policy = axis2_policy_include_get_policy(policy_include, env);
			if (!neethi_policy) return AXIS2_FAILURE;

			policy_name = neethi_policy_get_name(neethi_policy, env);
			if (!policy_name)
				policy_name = neethi_policy_get_id(neethi_policy, env);
			axis2_policy_include_remove_policy_element(policy_include, env,
				policy_name);

			/* Disenagage modules*/
			module_qname = axutil_qname_create(env, "rampart", NULL, NULL);
			module_desc = axis2_conf_get_module(conf, env, module_qname);
			axutil_qname_free(module_qname, env);

			axis2_svc_disengage_module(svc, env, module_desc, conf);

			return AXIS2_SUCCESS;
        }
コード例 #8
0
ファイル: service_admin_util.c プロジェクト: AdrianRys/wsf
AXIS2_EXTERN axis2_svc_t* AXIS2_CALL
service_admin_util_get_service(
	axutil_env_t *env,
	axis2_msg_ctx_t *msg_ctx,
	axis2_char_t *service_name)
{
	axis2_conf_ctx_t *conf_ctx = NULL;
	axis2_conf_t *conf = NULL;
	axis2_svc_t *service = NULL;
	conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
	conf = axis2_conf_ctx_get_conf(conf_ctx, env);
	service = axis2_conf_get_svc(conf, env, service_name);
	if(service)
	{
		return service;
	}else
	{
		AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI , "service not found");
	}
	return NULL;
}
コード例 #9
0
ファイル: util.c プロジェクト: kasungayan/commons
axis2_status_t
wsf_wsdl_util_add_security_to_svc_client_configuration(
    const axutil_env_t* env,
    axutil_hash_t* security_token_hash,
    axis2_svc_client_t* svc_client)
{
    rampart_context_t* rampart_ctx = NULL;
    axis2_svc_ctx_t *svc_ctx = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_conf_t *conf = NULL;
    axutil_param_t *security_param = NULL;

    svc_ctx = axis2_svc_client_get_svc_ctx (svc_client, env);
    conf_ctx = axis2_svc_ctx_get_conf_ctx (svc_ctx, env);
    conf = axis2_conf_ctx_get_conf (conf_ctx, env);
    
    rampart_ctx = rampart_context_create(env);

    wsf_wsdl_util_set_security_token_options_to_rampart_ctx (env, security_token_hash, rampart_ctx);
    
    security_param = axutil_param_create (env, WSF_WSDL_RAMPART_CONFIGURATION, (void *)rampart_ctx);

    return axis2_conf_add_param (conf, env, security_param);
}
コード例 #10
0
ファイル: wsf_util.c プロジェクト: harunjuhasz/wsf
/* create service */
void
wsf_util_create_svc_from_svc_info (
    wsf_svc_info_t * svc_info,
    axutil_env_t * env)
{
    axutil_qname_t *svc_qname = NULL;
    axis2_svc_t *svc = NULL;
    axis2_conf_t *conf = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;

    if (!svc_info->ruby_worker) {
        /* php_error_docref (NULL TSRMLS_CC, E_ERROR, "error creating service"); */
        return;
    }

    conf_ctx = wsf_worker_get_conf_ctx (svc_info->ruby_worker, env);

    conf = axis2_conf_ctx_get_conf (conf_ctx, env);
    if (!conf) {
        /* php_error_docref (NULL TSRMLS_CC, E_ERROR, "error creating qname"); */
        return;
    }

    svc = axis2_conf_get_svc (conf, env, svc_info->svc_name);

    if (NULL != svc) {

        svc_info->svc = svc;

    } else {
        svc_qname = axutil_qname_create (env, svc_info->svc_name, NULL, NULL);
        svc_info->svc = axis2_svc_create_with_qname (env, svc_qname);
        axutil_qname_free (svc_qname, env);
    }
    return;
}
コード例 #11
0
/**
* auto generated function definition signature
* for "addKeyStore|http://service.keystore.security.carbon.wso2.org" operation.
* @param env environment ( mandatory)* @param MessageContext the outmessage context
* @param _addKeyStore of the adb_addKeyStore_t*
*
* @return 
*/
axis2_status_t  
axis2_skel_KeyStoreAdminService_addKeyStore(const axutil_env_t *env , 
											axis2_msg_ctx_t *msg_ctx,
											adb_addKeyStore_t* _addKeyStore,
											axis2_skel_KeyStoreAdminService_addKeyStore_fault *fault )
{
	axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_conf_t *axis2_conf = NULL;
    axis2_char_t *repo_path = NULL;
    axis2_char_t *file_name = NULL;
    FILE *file = NULL;
    axis2_char_t *file_content = NULL;
    axis2_char_t *encoded_file_content = NULL;
    int file_content_size = 0;

    /* Validate the contents of the request */
    if(!adb_addKeyStore_get_filename(_addKeyStore, env))
    {
        axis2_keystore_admin_create_fault(env, "Key store file name is not given",
            AXIS2_SKEL_KEYSTOREADMINSERVICE_ADDKEYSTORE_FAULT_SECURITYCONFIGEXCEPTION,
            &(fault->SecurityConfigException), AXIS2_LOG_SI);
        return AXIS2_FAILURE;
    }
    if(!adb_addKeyStore_get_fileData(_addKeyStore, env))
    {
        axis2_keystore_admin_create_fault(env, "Key store data is not given",
            AXIS2_SKEL_KEYSTOREADMINSERVICE_ADDKEYSTORE_FAULT_SECURITYCONFIGEXCEPTION,
            &(fault->SecurityConfigException), AXIS2_LOG_SI);
        return AXIS2_FAILURE;
    }
    if(!adb_addKeyStore_get_password(_addKeyStore, env))
    {
        axis2_keystore_admin_create_fault(env, "Keystore password is not given",
            AXIS2_SKEL_KEYSTOREADMINSERVICE_ADDKEYSTORE_FAULT_SECURITYCONFIGEXCEPTION,
            &(fault->SecurityConfigException), AXIS2_LOG_SI);
        return AXIS2_FAILURE;
    }
    if(!adb_addKeyStore_get_pvtkeyPass(_addKeyStore, env))
    {
        axis2_keystore_admin_create_fault(env, "Private key password is not given",
            AXIS2_SKEL_KEYSTOREADMINSERVICE_ADDKEYSTORE_FAULT_SECURITYCONFIGEXCEPTION,
            &(fault->SecurityConfigException), AXIS2_LOG_SI);
        return AXIS2_FAILURE;
    }
    if(!adb_addKeyStore_get_type(_addKeyStore, env))
    {
        axis2_keystore_admin_create_fault(env, "Key store type is not given",
            AXIS2_SKEL_KEYSTOREADMINSERVICE_ADDKEYSTORE_FAULT_SECURITYCONFIGEXCEPTION,
            &(fault->SecurityConfigException), AXIS2_LOG_SI);
        return AXIS2_FAILURE;
    }

    /* construct file name with path */
    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    axis2_conf = axis2_conf_ctx_get_conf(conf_ctx, env);
    repo_path = axis2_conf_get_repo(axis2_conf, env);
    file_name = axutil_strcat(env, repo_path, AXIS2_PATH_SEP_STR, "services", 
		AXIS2_PATH_SEP_STR, "KeyStoreAdminService", AXIS2_PATH_SEP_STR, "keystores",
        AXIS2_PATH_SEP_STR, adb_addKeyStore_get_filename(_addKeyStore, env), NULL);
    if(!file_name)
    {
        axis2_keystore_admin_create_fault(env, "Internal Server Error; File path is invalid",
            AXIS2_SKEL_KEYSTOREADMINSERVICE_ADDKEYSTORE_FAULT_SECURITYCONFIGEXCEPTION,
            &(fault->SecurityConfigException), AXIS2_LOG_SI);
        return AXIS2_FAILURE;
    }

    /* check whether already a file exists */
    file = fopen(file_name, "r");
    if(file)
    {
        axis2_keystore_admin_create_fault(env, "Key store with given name already exists",
            AXIS2_SKEL_KEYSTOREADMINSERVICE_ADDKEYSTORE_FAULT_SECURITYCONFIGEXCEPTION,
            &(fault->SecurityConfigException), AXIS2_LOG_SI);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
            "[KeyStoreAdmin] already a file exists with name [%s]", file_name);
        AXIS2_FREE(env->allocator, file_name);
        fclose(file);
        return AXIS2_FAILURE;
    }

    /* file does not exist. Create one and write the contents */
    file = fopen(file_name, "wb");
    if(!file)
    {
        axis2_keystore_admin_create_fault(env, "Internal Server Error; File cannot be open to write",
            AXIS2_SKEL_KEYSTOREADMINSERVICE_ADDKEYSTORE_FAULT_SECURITYCONFIGEXCEPTION,
            &(fault->SecurityConfigException), AXIS2_LOG_SI);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
            "[KeyStoreAdmin] file [%s] cannot be open to write", file_name);
        AXIS2_FREE(env->allocator, file_name);
        return AXIS2_FAILURE;
    }

    encoded_file_content = adb_addKeyStore_get_fileData(_addKeyStore, env);
    file_content = AXIS2_MALLOC(env->allocator, axutil_strlen(encoded_file_content));
    file_content_size = axutil_base64_decode_binary(file_content, encoded_file_content);
    fwrite(file_content, sizeof(axis2_char_t), file_content_size, file);
    AXIS2_FREE(env->allocator, file_content);

    if(ferror(file))
    {
        axis2_keystore_admin_create_fault(env, "Internal Server Error; File writing failed",
            AXIS2_SKEL_KEYSTOREADMINSERVICE_ADDKEYSTORE_FAULT_SECURITYCONFIGEXCEPTION,
            &(fault->SecurityConfigException), AXIS2_LOG_SI);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
            "[KeyStoreAdmin] cannot write to file [%s]", file_name);
        AXIS2_FREE(env->allocator, file_name);
        fclose(file);
        return AXIS2_FAILURE;
    }

    fflush(file);
    fclose(file);

    /* Persist keystore details*/
    if(axis2_keystore_admin_save_keystore_details(env, msg_ctx, _addKeyStore)
        != AXIS2_SUCCESS)
    {
        axis2_keystore_admin_create_fault(env,
            "Internal Server Error; Cannot save key store to registry",
            AXIS2_SKEL_KEYSTOREADMINSERVICE_ADDKEYSTORE_FAULT_SECURITYCONFIGEXCEPTION,
            &(fault->SecurityConfigException), AXIS2_LOG_SI);
        AXIS2_FREE(env->allocator, file_name);
        return AXIS2_FAILURE;
    }

    AXIS2_FREE(env->allocator, file_name);

    return AXIS2_SUCCESS;
}
コード例 #12
0
/**
 * axis2_libcurl_set_proxy_options maps proxy AXIS2/C options to
 * libcURL options.
 *
 * CURLOPT_PROXY - char * proxy hostname
 * CURLOPT_PROXYPORT - long proxy listen port
 * CURLOPT_PROXYUSERPWD - char * user:password to authenticate to proxy
 *
 * TODO:
 * CURLOPT_PROXYTYPE - long enum type of proxy (HTTP, SOCKS)
 * CURLOPT_PROXYAUTH - long bitmask which authentication methods to use for proxy
 */
static axis2_status_t
axis2_libcurl_set_proxy_options(
    CURL *handler,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx)
{
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_conf_t *conf = NULL;
    axis2_transport_out_desc_t *trans_desc = NULL;
    axutil_param_t *proxy_param = NULL;
    axutil_hash_t *transport_attrs = NULL;
    axutil_property_t *property = NULL;
    axis2_char_t *uname = NULL;
    axis2_char_t *passwd = NULL;
    axis2_char_t *proxy_host = NULL;
    axis2_char_t *proxy_port = NULL;

    property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_PROXY_AUTH_UNAME);
    if (property)
    {
        uname = (axis2_char_t *) axutil_property_get_value(property, env);
    }
    property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_PROXY_AUTH_PASSWD);
    if (property)
    {
        passwd = (axis2_char_t *) axutil_property_get_value(property, env);
    }

    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    if (conf_ctx)
    {
        conf = axis2_conf_ctx_get_conf(conf_ctx, env);
        if (conf)
        {
            trans_desc = axis2_conf_get_transport_out(conf, env, AXIS2_TRANSPORT_ENUM_HTTP);
        }
    }
    if (trans_desc)
    {
        proxy_param = axutil_param_container_get_param(
            axis2_transport_out_desc_param_container(trans_desc, env), env, AXIS2_HTTP_PROXY_API);
        if (!proxy_param)
        {
            proxy_param = axutil_param_container_get_param(
                axis2_transport_out_desc_param_container(trans_desc, env), env, AXIS2_HTTP_PROXY);
        }
        if (proxy_param)
        {
            transport_attrs = axutil_param_get_attributes(proxy_param, env);
        }
    }

    if (transport_attrs)
    {
        axutil_generic_obj_t *obj = NULL;
        axiom_attribute_t *attr = NULL;

        if (!uname || !passwd)
        {
            obj = axutil_hash_get(transport_attrs, AXIS2_HTTP_PROXY_USERNAME, AXIS2_HASH_KEY_STRING);
            if (obj)
            {
                attr = (axiom_attribute_t *) axutil_generic_obj_get_value(obj, env);
            }
            if (attr)
            {
                uname = axiom_attribute_get_value(attr, env);
            }

            attr = NULL;
            obj = axutil_hash_get(transport_attrs, AXIS2_HTTP_PROXY_PASSWORD, AXIS2_HASH_KEY_STRING);
            if (obj)
            {
                attr = (axiom_attribute_t *)axutil_generic_obj_get_value(obj, env);
            }
            if (attr)
            {
                passwd = axiom_attribute_get_value(attr, env);
            }
        }

        obj = axutil_hash_get(transport_attrs, AXIS2_HTTP_PROXY_HOST, AXIS2_HASH_KEY_STRING);
        if (obj)
        {
            attr = (axiom_attribute_t *)axutil_generic_obj_get_value(obj, env);
        }
        if (attr)
        {
            proxy_host = axiom_attribute_get_value(attr, env);
        }
        if (proxy_host)
        {
            curl_easy_setopt(handler, CURLOPT_PROXY, proxy_host);
        }

        attr = NULL;
        obj = axutil_hash_get(transport_attrs, AXIS2_HTTP_PROXY_PORT, AXIS2_HASH_KEY_STRING);
        if (obj)
        {
            attr = (axiom_attribute_t *)axutil_generic_obj_get_value(obj, env);
        }
        if (attr)
        {
            proxy_port = axiom_attribute_get_value(attr, env);
        }
        if (proxy_port)
        {
            curl_easy_setopt(handler, CURLOPT_PROXYPORT, AXIS2_ATOI(proxy_port));
        }
    }
    if (uname && passwd)
    {
        axis2_char_t buffer[256];
        strncpy(buffer, uname, 256);
        strncat(buffer, ":", 256);
        strncat(buffer, passwd, 256);
        curl_easy_setopt(handler, CURLOPT_PROXYUSERPWD, buffer);
    }

    return AXIS2_SUCCESS;
}
コード例 #13
0
axis2_status_t AXIS2_CALL
axis2_libcurl_send(
    axis2_libcurl_t *data,
    axiom_output_t * om_output,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx,
    axiom_soap_envelope_t * out,
    const axis2_char_t * str_url,
    const axis2_char_t * soap_action)
{
    struct curl_slist *headers = NULL;
    axiom_soap_body_t *soap_body;
    axis2_bool_t is_soap = AXIS2_TRUE;
    axis2_bool_t send_via_get = AXIS2_FALSE;
    axis2_bool_t send_via_head = AXIS2_FALSE;
    axis2_bool_t send_via_put = AXIS2_FALSE;
    axis2_bool_t send_via_delete = AXIS2_FALSE;
    axis2_bool_t doing_mtom = AXIS2_FALSE;
    axiom_node_t *body_node = NULL;
    axiom_node_t *data_out = NULL;
    axutil_property_t *method = NULL;
    axis2_char_t *method_value = NULL;
    axiom_xml_writer_t *xml_writer = NULL;
    axis2_char_t *buffer = NULL;
    unsigned int buffer_size = 0;
    int content_length = -1;
    axis2_char_t *content_type = NULL;
    /*axis2_char_t *content_len = AXIS2_HTTP_HEADER_CONTENT_LENGTH_; */
    const axis2_char_t *char_set_enc = NULL;
    axis2_char_t *content = AXIS2_HTTP_HEADER_CONTENT_TYPE_;
    axis2_char_t *soap_action_header = AXIS2_HTTP_HEADER_SOAP_ACTION_;
    axutil_stream_t *in_stream;
    axutil_property_t *trans_in_property;
    axutil_string_t *char_set_enc_str;
    axis2_byte_t *output_stream = NULL;
    int output_stream_size = 0;
    CURL *handler;
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_conf_t *conf = NULL;
    axis2_transport_out_desc_t *trans_desc = NULL;
    axutil_param_t *write_xml_declaration_param = NULL;
    axutil_hash_t *transport_attrs = NULL;
    axis2_bool_t write_xml_declaration = AXIS2_FALSE;
    axutil_property_t *property;
    int *response_length = NULL;
    axis2_http_status_line_t *status_line = NULL;
    axis2_char_t *status_line_str = NULL;
    axis2_char_t *tmp_strcat = NULL;
    int status_code = 0;

    AXIS2_PARAM_CHECK(env->error, data, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, data->handler, AXIS2_FAILURE);

    handler = data->handler;
    curl_easy_reset(handler);
    curl_easy_setopt(handler, CURLOPT_ERRORBUFFER, data->errorbuffer);
    headers = curl_slist_append(headers, AXIS2_HTTP_HEADER_USER_AGENT_AXIS2C);
    headers = curl_slist_append(headers, AXIS2_HTTP_HEADER_ACCEPT_);
    headers = curl_slist_append(headers, AXIS2_HTTP_HEADER_EXPECT_);

    if(AXIS2_FAILURE == axis2_libcurl_set_options(handler, env, msg_ctx))
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[axis2libcurl]Setting options in Libcurl failed");
        return AXIS2_FAILURE;
    }

    if (AXIS2_TRUE == axis2_msg_ctx_get_doing_rest(msg_ctx, env))
    {
        is_soap = AXIS2_FALSE;
    }
    else
    {
        is_soap = AXIS2_TRUE;
    }

    if (!is_soap)
    {
        soap_body = axiom_soap_envelope_get_body(out, env);
        if (!soap_body)
        {
            AXIS2_HANDLE_ERROR(env,
                AXIS2_ERROR_SOAP_ENVELOPE_OR_SOAP_BODY_NULL,
                AXIS2_FAILURE);
            return AXIS2_FAILURE;
        }

        body_node = axiom_soap_body_get_base_node(soap_body, env);
        if (!body_node)
        {
            AXIS2_HANDLE_ERROR(env,
                AXIS2_ERROR_SOAP_ENVELOPE_OR_SOAP_BODY_NULL,
                AXIS2_FAILURE);

            return AXIS2_FAILURE;
        }
        data_out = axiom_node_get_first_element(body_node, env);

        method = (axutil_property_t *) axis2_msg_ctx_get_property(msg_ctx, env,
            AXIS2_HTTP_METHOD);

        if (method)
        {
            method_value =
            (axis2_char_t *) axutil_property_get_value(method, env);
        }

        /* The default is POST */
        if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_GET))
        {
            send_via_get = AXIS2_TRUE;
        }
        else if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_HEAD))
        {
            send_via_head = AXIS2_TRUE;
        }
        else if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_PUT))
        {
            send_via_put = AXIS2_TRUE;
        }
        else if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_DELETE))
        {
            send_via_delete = AXIS2_TRUE;
        }
    }

    conf_ctx = axis2_msg_ctx_get_conf_ctx (msg_ctx, env);
    if (conf_ctx)
    {
        conf = axis2_conf_ctx_get_conf (conf_ctx, env);
    }

    if (conf)
    {
        trans_desc = axis2_conf_get_transport_out (conf,
            env, AXIS2_TRANSPORT_ENUM_HTTP);
    }

    if (trans_desc)
    {
        write_xml_declaration_param =
        axutil_param_container_get_param
        (axis2_transport_out_desc_param_container (trans_desc, env), env,
            AXIS2_XML_DECLARATION);
    }

    if (write_xml_declaration_param)
    {
        transport_attrs =
        axutil_param_get_attributes (write_xml_declaration_param, env);
        if (transport_attrs)
        {
            axutil_generic_obj_t *obj = NULL;
            axiom_attribute_t *write_xml_declaration_attr = NULL;
            axis2_char_t *write_xml_declaration_attr_value = NULL;

            obj = axutil_hash_get (transport_attrs, AXIS2_ADD_XML_DECLARATION,
                AXIS2_HASH_KEY_STRING);
            if (obj)
            {
                write_xml_declaration_attr = (axiom_attribute_t *)
                axutil_generic_obj_get_value (obj,
                    env);
            }
            if (write_xml_declaration_attr)
            {
                write_xml_declaration_attr_value =
                axiom_attribute_get_value (write_xml_declaration_attr, env);
            }
            if (write_xml_declaration_attr_value &&
                0 == axutil_strcasecmp (write_xml_declaration_attr_value,
                    AXIS2_VALUE_TRUE))
            {
                write_xml_declaration = AXIS2_TRUE;
            }
        }
    }

    if (write_xml_declaration)
    {
        axiom_output_write_xml_version_encoding (om_output, env);
    }

    if (!send_via_get && !send_via_head && !send_via_delete)
    {
        xml_writer = axiom_output_get_xml_writer(om_output, env);

        char_set_enc_str = axis2_msg_ctx_get_charset_encoding(msg_ctx, env);

        if (!char_set_enc_str)
        {
            char_set_enc = AXIS2_DEFAULT_CHAR_SET_ENCODING;
        }
        else
        {
            char_set_enc = axutil_string_get_buffer(char_set_enc_str, env);
        }

        if (!send_via_put && is_soap)
        {
            doing_mtom = axis2_msg_ctx_get_doing_mtom(msg_ctx, env);

            axiom_output_set_do_optimize(om_output, env, doing_mtom);
            axiom_soap_envelope_serialize(out, env, om_output, AXIS2_FALSE);
            if (AXIS2_TRUE == axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
            {
                if (AXIS2_ESC_DOUBLE_QUOTE != *soap_action)
                {
                    axis2_char_t *tmp_soap_action = NULL;
                    tmp_soap_action =
                    AXIS2_MALLOC(env->allocator,
                        (axutil_strlen(soap_action) +
                            5) * sizeof(axis2_char_t));
                    sprintf(tmp_soap_action, "\"%s\"", soap_action);
                    tmp_strcat = axutil_stracat(env, soap_action_header,tmp_soap_action);
                    headers = curl_slist_append(headers, tmp_strcat);
                    AXIS2_FREE(env->allocator, tmp_strcat);
                    AXIS2_FREE(env->allocator, tmp_soap_action);
                }
                else
                {
                    tmp_strcat = axutil_stracat(env, soap_action_header, soap_action);
                    headers = curl_slist_append(headers, tmp_strcat );
                    AXIS2_FREE(env->allocator, tmp_strcat);
                }
            }

            if (doing_mtom)
            {
                /*axiom_output_flush(om_output, env, &output_stream,
                 &output_stream_size);*/
                axiom_output_flush(om_output, env);
                content_type =
                (axis2_char_t *) axiom_output_get_content_type(om_output,
                    env);
                if (AXIS2_TRUE != axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
                {
                    if (axutil_strcmp(soap_action, ""))
                    {
                        /* handle SOAP action for SOAP 1.2 case */
                        axis2_char_t *temp_content_type = NULL;
                        temp_content_type = axutil_stracat (env,
                            content_type,
                            AXIS2_CONTENT_TYPE_ACTION);
                        content_type = temp_content_type;
                        temp_content_type = axutil_stracat (env,
                            content_type,
                            soap_action);
                        AXIS2_FREE (env->allocator, content_type);
                        content_type = temp_content_type;
                        temp_content_type =
                        axutil_stracat (env, content_type,
                            AXIS2_ESC_DOUBLE_QUOTE_STR);
                        AXIS2_FREE (env->allocator, content_type);
                        content_type = temp_content_type;
                    }
                }
            }
            else if (AXIS2_TRUE == axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
            {
                axis2_char_t *temp_content_type = NULL;
                content_type =
                (axis2_char_t *) AXIS2_HTTP_HEADER_ACCEPT_TEXT_XML;
                content_type = axutil_stracat(env, content_type,
                    AXIS2_CONTENT_TYPE_CHARSET);
                temp_content_type =
                axutil_stracat(env, content_type, char_set_enc);
                AXIS2_FREE(env->allocator, content_type);
                content_type = temp_content_type;
            }
            else
            {
                axis2_char_t *temp_content_type = NULL;
                content_type =
                (axis2_char_t *) AXIS2_HTTP_HEADER_ACCEPT_APPL_SOAP;
                content_type = axutil_stracat(env, content_type,
                    AXIS2_CONTENT_TYPE_CHARSET);
                temp_content_type =
                axutil_stracat(env, content_type, char_set_enc);
                AXIS2_FREE(env->allocator, content_type);
                content_type = temp_content_type;
                if (axutil_strcmp(soap_action, ""))
                {
                    temp_content_type =
                    axutil_stracat(env, content_type,
                        AXIS2_CONTENT_TYPE_ACTION);
                    AXIS2_FREE(env->allocator, content_type);
                    content_type = temp_content_type;
                    temp_content_type =
                    axutil_stracat(env, content_type, soap_action);
                    AXIS2_FREE(env->allocator, content_type);
                    content_type = temp_content_type;
                }
                temp_content_type = axutil_stracat(env, content_type,
                    AXIS2_SEMI_COLON_STR);
                AXIS2_FREE(env->allocator, content_type);
                content_type = temp_content_type;
            }
        }
        else if (is_soap)
        {
            AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "Attempt to send SOAP"
                "message using HTTP PUT failed");
            return AXIS2_FAILURE;
        }
        else
        {
            axutil_property_t *content_type_property = NULL;
            axutil_hash_t *content_type_hash = NULL;
            axis2_char_t *content_type_value = NULL;

            axiom_node_serialize(data_out, env, om_output);
            content_type_property =
            (axutil_property_t *)
            axis2_msg_ctx_get_property(msg_ctx, env,
                AXIS2_USER_DEFINED_HTTP_HEADER_CONTENT_TYPE);

            if (content_type_property)
            {
                content_type_hash =
                (axutil_hash_t *)
                axutil_property_get_value(content_type_property, env);

                if (content_type_hash)
                {
                    content_type_value =
                    (char *) axutil_hash_get(content_type_hash,
                        AXIS2_HTTP_HEADER_CONTENT_TYPE,
                        AXIS2_HASH_KEY_STRING);
                }
            }

            if (content_type_value)
            {
                content_type = content_type_value;
            }
            else
            {
                content_type = axutil_strdup(env,AXIS2_HTTP_HEADER_ACCEPT_TEXT_XML);
            }

        }

        buffer = axiom_xml_writer_get_xml(xml_writer, env);
        if (!doing_mtom)
        {
            buffer_size = axiom_xml_writer_get_xml_size(xml_writer, env);
        }
        else
        buffer_size = output_stream_size;
        {
            /*
             * Curl calculates the content-length automatically.
             * This commented section is not only unnecessary,
             * it interferes with authentication.
             *
             * NTLM, for example, will send an empty request
             * first (no body) to get the auth challenge
             * before resending with actual content.
             */
            /*char tmp_buf[10];
            sprintf(tmp_buf, "%d", buffer_size);
            tmp_strcat = axutil_stracat(env, content_len, tmp_buf);
            headers = curl_slist_append(headers, tmp_strcat);
            AXIS2_FREE(env->allocator, tmp_strcat);
            tmp_strcat = NULL;*/

            tmp_strcat = axutil_stracat(env, content, content_type);
            headers = curl_slist_append(headers, tmp_strcat);
            AXIS2_FREE(env->allocator, tmp_strcat);
            tmp_strcat = NULL;
        }

        if (!doing_mtom)
        {
            curl_easy_setopt(handler, CURLOPT_POSTFIELDSIZE, buffer_size);
            curl_easy_setopt(handler, CURLOPT_POSTFIELDS, buffer);
        }
        else
        {
            curl_easy_setopt(handler, CURLOPT_POSTFIELDSIZE,
                output_stream_size);
            curl_easy_setopt(handler, CURLOPT_POSTFIELDS, output_stream);
        }

        if (send_via_put)
        {
            curl_easy_setopt(handler, CURLOPT_CUSTOMREQUEST, AXIS2_HTTP_PUT);
        }
        curl_easy_setopt(handler, CURLOPT_URL, str_url);
    }
    else
    {
        axis2_char_t *request_param;
        axis2_char_t *url_encode;
        request_param =
        (axis2_char_t *) axis2_http_sender_get_param_string(NULL, env,
            msg_ctx);
        url_encode = axutil_strcat(env, str_url, AXIS2_Q_MARK_STR,
            request_param, NULL);
        if (send_via_get)
        {
            curl_easy_setopt(handler, CURLOPT_HTTPGET, 1);
        }
        else if (send_via_head)
        {
            curl_easy_setopt(handler, CURLOPT_NOBODY, 1);
        }
        else if (send_via_delete)
        {
            curl_easy_setopt(handler, CURLOPT_CUSTOMREQUEST, AXIS2_HTTP_DELETE);
        }
        curl_easy_setopt(handler, CURLOPT_URL, url_encode);
    }

    {
        axis2_bool_t manage_session;
        manage_session = axis2_msg_ctx_get_manage_session(msg_ctx, env);
        if (manage_session == AXIS2_TRUE)
        {
            if (data->cookies == AXIS2_FALSE)
            {
                /* Ensure cookies enabled to manage session */
                /* Pass empty cookie string to enable cookies */
                curl_easy_setopt(handler, CURLOPT_COOKIEFILE, " ");
                data->cookies = AXIS2_TRUE;
            }
        }
        else if (data->cookies == AXIS2_TRUE)
        {
            /* Pass special string ALL to reset cookies if any have been enabled. */
            /* If cookies have ever been enabled, we reset every time as long as 
             manage_session is false, as there is no clear curl option to
             turn off the cookie engine once enabled. */
            curl_easy_setopt(handler, CURLOPT_COOKIELIST, AXIS2_ALL);
        }
    }

    curl_easy_setopt(handler, CURLOPT_HTTPHEADER, headers);
    curl_easy_setopt(handler, CURLOPT_WRITEFUNCTION,
        axis2_libcurl_write_memory_callback);
    curl_easy_setopt(handler, CURLOPT_WRITEDATA, data);

    curl_easy_setopt (handler, CURLOPT_HEADERFUNCTION, axis2_libcurl_header_callback);

    curl_easy_setopt (handler, CURLOPT_WRITEHEADER, data);

    /* Free response data from previous request */
    if( data->size )
    {
        if (data->memory)
        {
            AXIS2_FREE(data->env->allocator, data->memory);
        }
        data->size = 0;
    }

    if (curl_easy_perform(handler))
    {
        AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "%s", &data->errorbuffer);
        AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_HTTP_CLIENT_TRANSPORT_ERROR,
            AXIS2_FAILURE);
        return AXIS2_FAILURE;
    }

    in_stream = axutil_stream_create_libcurl(env, data->memory, data->size);
    trans_in_property = axutil_property_create(env);
    axutil_property_set_scope(trans_in_property, env, AXIS2_SCOPE_REQUEST);
    axutil_property_set_free_func(trans_in_property, env,
        libcurl_stream_free);
    axutil_property_set_value(trans_in_property, env, in_stream);
    axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_TRANSPORT_IN,
        trans_in_property);

    if (axutil_array_list_size(data->alist, env) > 0)
    {
        status_line_str = axutil_array_list_get(data->alist, env, 0);
        if (status_line_str)
        {
            status_line = axis2_http_status_line_create(env, status_line_str);
        }
    }

    if (status_line)
    {
        status_code = axis2_http_status_line_get_status_code(status_line, env);
    }

    axis2_msg_ctx_set_status_code (msg_ctx, env, status_code);
    AXIS2_FREE(data->env->allocator, content_type);
    content_type = axis2_libcurl_get_content_type(data, env);

    if (content_type)
    {
        if (strstr (content_type, AXIS2_HTTP_HEADER_ACCEPT_MULTIPART_RELATED)
            && strstr (content_type, AXIS2_HTTP_HEADER_ACCEPT_XOP_XML))
        {
            axis2_ctx_t *axis_ctx =
            axis2_op_ctx_get_base (axis2_msg_ctx_get_op_ctx (msg_ctx, env),
                env);
            property = axutil_property_create (env);
            axutil_property_set_scope (property, env, AXIS2_SCOPE_REQUEST);
            axutil_property_set_value (property,
                env, axutil_strdup (env, content_type));
            axis2_ctx_set_property (axis_ctx,
                env, MTOM_RECIVED_CONTENT_TYPE, property);
        }
    }

    content_length = axis2_libcurl_get_content_length(data, env);
    if (content_length >= 0)
    {
        response_length = AXIS2_MALLOC (env->allocator, sizeof (int));
        memcpy (response_length, &content_length, sizeof (int));
        property = axutil_property_create (env);
        axutil_property_set_scope (property, env, AXIS2_SCOPE_REQUEST);
        axutil_property_set_value (property, env, response_length);
        axis2_msg_ctx_set_property (msg_ctx, env,
            AXIS2_HTTP_HEADER_CONTENT_LENGTH, property);
    }

    curl_slist_free_all (headers);
    /* release the read http headers. */
    /* (commenting out the call below is a clever way to force a premature EOF 
     condition in subsequent messages, as they will be read using the content-length
     of the first message.) */
    axis2_libcurl_free_headers(data, env);
    AXIS2_FREE(data->env->allocator, content_type);
    axis2_http_status_line_free( status_line, env);

    return AXIS2_SUCCESS;
}
コード例 #14
0
ファイル: wsf_util.c プロジェクト: harunjuhasz/wsf
/* CHANGED */
void
wsf_util_create_op_and_add_to_svc (
    wsf_svc_info_t * svc_info,
    char *action,
    axutil_env_t * env,
    char *op_name,
    VALUE ht_mep)
{
    axis2_svc_t *svc = NULL;
    axis2_op_t *op = NULL;
    axutil_qname_t *op_qname = NULL;
    op_qname = axutil_qname_create (env, op_name, NULL, NULL);
    svc = svc_info->svc;

    if (NULL != svc && NULL != op_name) {
        op = axis2_svc_get_op_with_name (svc_info->svc, env, op_name);
        if (!op) {
            axis2_conf_t *conf = NULL;
            axis2_conf_ctx_t *conf_ctx = NULL;
            axis2_phases_info_t *info = NULL;

            op_qname = axutil_qname_create (env, op_name, NULL, NULL);

            op = axis2_op_create_with_qname (env, op_qname);

            axis2_op_set_msg_recv (op, env, svc_info->msg_recv);

            conf_ctx = wsf_worker_get_conf_ctx (svc_info->ruby_worker, env);

            conf = axis2_conf_ctx_get_conf (conf_ctx, env);

            info = axis2_conf_get_phases_info (conf, env);
            axis2_phases_info_set_op_phases (info, env, op);
            axis2_svc_add_op (svc_info->svc, env, op);

            if (ht_mep) {
                char operation[300];
                VALUE mep_value;
                char *mep;

                AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI,
                                 "[wsf_service] ht mep not null, %s", op_name);
                snprintf (operation, sizeof(operation), "%s", op_name);
                if(TYPE(ht_mep) == T_HASH)
                {
                    mep_value = rb_hash_aref(ht_mep, ID2SYM(rb_intern(operation)));
                }
                if(mep_value != Qnil)
                {
                    mep = RSTRING(mep_value)->ptr;
                    if (mep) {
                        AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI,
                                         "[wsf_service] op mep %s", mep);
                        if (strcmp (mep, "IN_ONLY") == 0) {
                            axis2_op_set_msg_exchange_pattern (op, env,
                                                               AXIS2_MEP_URI_IN_ONLY);
                            AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI,
                                             "[wsf_service] AXIS2_MEP_URI_IN_ONLY");

                        } else if (strcmp (mep, "IN_OUT") == 0) {
                            axis2_op_set_msg_exchange_pattern (op, env,
                                                               AXIS2_MEP_URI_IN_OUT);
                            AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI,
                                             "[wsf_service] AXIS2_MEP_URI_IN_OUT");
                        }
                    }
                }
                else {
                    AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI,
                                     "[wsf service] message exchange pattern for %s not found",
                                     op_name);
                }
            }
            if (action) {
                axis2_svc_add_mapping (svc_info->svc, env, action, op);
            }
        }
    }
    if(op_qname) {
        axutil_qname_free(op_qname, env);
    }

    return;
}
コード例 #15
0
ファイル: engine.c プロジェクト: alexis-gruet/axis2c-trunk
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_engine_send(
    axis2_engine_t * engine,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx)
{
    axis2_status_t status = AXIS2_SUCCESS;
    axis2_op_ctx_t *op_ctx = NULL;
    axutil_array_list_t *phases = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_conf_t *conf = NULL;

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "axis2_engine_send start");

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

    /* Find and invoke the phases */
    op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
    if(op_ctx)
    {
        axis2_op_t *op = axis2_op_ctx_get_op(op_ctx, env);
        if(op)
        {
            phases = axis2_op_get_out_flow(op, env);
        }
    }

    if(axis2_msg_ctx_is_paused(msg_ctx, env))
    {
        /* Message has paused, so rerun it from the position it stopped.
         The handler which paused the message will be the first one to resume
         invocation
         */
        status = axis2_engine_resume_invocation_phases(engine, env, phases, msg_ctx);
        if(status != AXIS2_SUCCESS)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Resuming invocation of phases failed");
            return status;
        }

        conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
        if(conf_ctx)
        {
            conf = axis2_conf_ctx_get_conf(conf_ctx, env);
            if(conf)
            {
                axutil_array_list_t *global_out_phase = axis2_conf_get_out_phases(conf, env);
                if(global_out_phase)
                {
                    axis2_engine_invoke_phases(engine, env, global_out_phase, msg_ctx);
                }
            }
        }
    }
    else
    {
        status = axis2_engine_invoke_phases(engine, env, phases, msg_ctx);
        if(status != AXIS2_SUCCESS)
        {
            return status;
        }

        conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
        if(conf_ctx)
        {
            conf = axis2_conf_ctx_get_conf(conf_ctx, env);
            if(conf)
            {
                axutil_array_list_t *global_out_phase = axis2_conf_get_out_phases(conf, env);
                if(global_out_phase)
                {
                    axis2_engine_invoke_phases(engine, env, global_out_phase, msg_ctx);
                }
            }
        }
    }

    if(!(axis2_msg_ctx_is_paused(msg_ctx, env)))
    {
        /* Write the message to wire */
        axis2_transport_sender_t *transport_sender = NULL;
        axis2_transport_out_desc_t *transport_out = axis2_msg_ctx_get_transport_out_desc(msg_ctx,
            env);

        if(transport_out)
        {
            transport_sender = axis2_transport_out_desc_get_sender(transport_out, env);
            if(!transport_sender)
                return AXIS2_FAILURE;

            status = AXIS2_TRANSPORT_SENDER_INVOKE(transport_sender, env, msg_ctx);
            if(status != AXIS2_SUCCESS)
            {
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport sender invoke failed");
                return status;
            }
        }
        else
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport out is not set in message context");
            return AXIS2_FAILURE;
        }
    }

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "axis2_engine_send end successfully");
    return AXIS2_SUCCESS;
}
コード例 #16
0
ファイル: util.c プロジェクト: kasungayan/commons
axis2_status_t
wsf_wsdl_util_configure_security_for_service(
    const axutil_env_t* env, 
    axutil_hash_t* script_client_options_hash, 
    axutil_hash_t* policies_hash,
    axis2_svc_t* svc,
    axis2_conf_ctx_t* worker_conf_ctx)
{
    axis2_char_t* policy_xml_str = NULL;
    axutil_hash_t* policy_hash = NULL;
    axutil_hash_t* security_token_hash = NULL;
    axiom_node_t* input_policy_node_axiom = NULL;
    axiom_node_t* binding_policy_node_axiom = NULL;
    neethi_policy_t* merged_neethi_policy = NULL;
    axis2_status_t success = AXIS2_FAILURE;

    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);

    if (script_client_options_hash)
    {
        policy_xml_str = (axis2_char_t*)axutil_hash_get(script_client_options_hash, 
            WSF_WSDL_HK_POLICY_STRING, 
            AXIS2_HASH_KEY_STRING);
        policy_hash = (axutil_hash_t*)axutil_hash_get(script_client_options_hash, 
            WSF_WSDL_HK_POLICY_HASH, 
            AXIS2_HASH_KEY_STRING);
        security_token_hash = (axutil_hash_t*)axutil_hash_get(script_client_options_hash, 
            WSF_WSDL_HK_SECURITY_TOKEN, 
            AXIS2_HASH_KEY_STRING);
    }

    if (policy_xml_str)
    {
        success = wsf_wsdl_util_policy_from_xml_string(env, 
            policy_xml_str, 
            &input_policy_node_axiom);
    }
    else if (policy_hash)
    {
        success = wsf_wsdl_util_policy_from_options_hash(env, 
            policy_hash, 
            &input_policy_node_axiom);
    }
    else if (policies_hash) /* TODO: correct this condition */
    {
        success = AXIS2_SUCCESS;
    }
    else 
    {
        AXIS2_LOG_DEBUG_MSG(env->log, "No policies found! so security is not added");
        return AXIS2_SUCCESS; /* this is not a failure case, simply security is ommitted */
    }

    if (success)
    {
        success = AXIS2_FAILURE;

        if (security_token_hash)
        {
            axis2_char_t* op_name = NULL;
            /* loop policies hash */
            axutil_hash_index_t* hi = NULL;
            void* val = NULL;
  
            for (hi = axutil_hash_first(policies_hash, env); hi; hi = axutil_hash_next(env, hi)) 
            {
                axutil_hash_t* wsdl_policy_hash = NULL;
                axis2_ssize_t size;
                op_name = NULL;
                axutil_hash_this(hi, &op_name, &size, &val);
                wsdl_policy_hash = (axutil_hash_t *)val;

                if (!(op_name && wsdl_policy_hash))
                {
                    continue;
                }
           
                success = wsf_wsdl_util_policy_from_wsdl_policy_hash(env, 
                                                                     wsdl_policy_hash, 
                                                                     &input_policy_node_axiom,
                                                                     &binding_policy_node_axiom);
                if (success)
                {                                                  
                    if (wsf_wsdl_util_create_merged_neethi_policy(env,
                                                                  input_policy_node_axiom,
                                                                  binding_policy_node_axiom,
                                                                  &merged_neethi_policy))
                    {
                        if (wsf_wsdl_util_insert_policy_to_svc(env,
                                                               merged_neethi_policy,
                                                               svc,
                                                               op_name))
                        {
                            if (wsf_wsdl_util_add_security_to_svc_configuration(env, 
                                                                                security_token_hash, 
                                                                                svc))
                            {	
                                axis2_conf_t *conf = NULL;
                                conf = axis2_conf_ctx_get_conf (worker_conf_ctx, env);
                                wsf_wsdl_util_engage_module (conf, 
                                                             WSF_WSDL_MODULE_SECURITY, 
                                                             env, 
                                                             svc);
                            }
                        }
                    }
                }
            }
        }
    }

    return success;
}
コード例 #17
0
/**
* auto generated function definition signature
* for "getStoreEntries|http://service.keystore.security.carbon.wso2.org" operation.
* @param env environment ( mandatory)* @param MessageContext the outmessage context
* @param _getStoreEntries of the adb_getStoreEntries_t*
*
* @return adb_getStoreEntriesResponse_t*
*/
adb_getStoreEntriesResponse_t* 
axis2_skel_KeyStoreAdminService_getStoreEntries(const axutil_env_t *env , 
												axis2_msg_ctx_t *msg_ctx,
												adb_getStoreEntries_t* _getStoreEntries,
												axis2_skel_KeyStoreAdminService_getStoreEntries_fault *fault )
{
	axis2_char_t* keystore_name = NULL;
	axis2_conf_ctx_t* conf_ctx = NULL;
	axis2_conf_t* axis2_conf = NULL;
	axis2_char_t* repo_path = NULL;
	axis2_char_t* keystore_file = NULL;
	axis2_char_t* keystore_details_file = NULL;
	axis2_char_t password[10];
	axis2_char_t provider[20];
	axis2_char_t pvt_key_pass[10];
	pkcs12_keystore_t* pkcs12_keystore = NULL;
	axutil_array_list_t* cert_array_tmp = NULL;
	int cert_count = 0;
	oxs_x509_cert_t* oxs_cert = NULL;
	adb_getStoreEntriesResponse_t* response = NULL;

	/* Get required keystore name*/
	keystore_name = axutil_strdup(env, 
		adb_getStoreEntries_get_keyStoreName(_getStoreEntries, env));
	if (!keystore_name) return NULL;
	keystore_name = strtok(keystore_name, ".");

	conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    axis2_conf = axis2_conf_ctx_get_conf(conf_ctx, env);
    repo_path = axis2_conf_get_repo(axis2_conf, env);
	
	/* Get password, provider and pvt_key_pass from details file */
	if (!keystore_admin_util_get_keystore_details(env, repo_path, keystore_name, 
		password, provider, pvt_key_pass))
	{
		AXIS2_FREE(env->allocator, keystore_name);
		return NULL;
	}

	/* Load keystore file */
	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);

	pkcs12_keystore = pkcs12_keystore_create(env, keystore_file, password);
	AXIS2_FREE(env->allocator, keystore_file);
	AXIS2_FREE(env->allocator, keystore_name);

	if (!pkcs12_keystore) return NULL;

	/* Create response*/
	response = adb_getStoreEntriesResponse_create(env);

	/* Get public cert alias*/
	cert_array_tmp = pkcs12_keystore_populate_cert_array(env, 
		pkcs12_keystore_get_other_certs(pkcs12_keystore));
	cert_count = axutil_array_list_size(cert_array_tmp, env);

	if (0 < cert_count) /* Public certs available */
	{
		int index = 0;

		for (index = 0; index < cert_count; ++index)
		{
			oxs_cert = (oxs_x509_cert_t*)
				axutil_array_list_get(cert_array_tmp, env, index);
			
			if (oxs_x509_cert_get_alias(oxs_cert, env))
			{
				adb_getStoreEntriesResponse_add_return(response, env, 
					oxs_x509_cert_get_alias(oxs_cert, env));
			}

			oxs_x509_cert_free(oxs_cert, env);
		}

		axutil_array_list_free(cert_array_tmp, env);
	}

	/* Set private cert alias*/
	oxs_cert = pkcs12_keystore_get_owner_certificate(pkcs12_keystore, env);
	if (oxs_cert)
	{
		adb_getStoreEntriesResponse_add_return(response, env, 
					oxs_x509_cert_get_alias(oxs_cert, env));

		oxs_x509_cert_free(oxs_cert, env);
	}

	return response;
}
コード例 #18
0
ファイル: msg_recv.c プロジェクト: Denisss025/wsfcpp
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;
}
コード例 #19
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;
}
コード例 #20
0
axis2_status_t
axis2_amqp_process_request(
    const axutil_env_t* env,
    axis2_amqp_request_processor_resource_pack_t* request_resource_pack)
{
    axiom_xml_reader_t* xml_reader = NULL;
    axiom_stax_builder_t* stax_builder = NULL;
    axiom_soap_builder_t* soap_builder = NULL;
    axis2_transport_out_desc_t* out_desc = NULL;
    axis2_transport_in_desc_t* in_desc = NULL;
    axis2_msg_ctx_t* msg_ctx = NULL;
    axiom_soap_envelope_t* soap_envelope = NULL;
    axis2_engine_t* engine = NULL;
    const axis2_char_t* soap_ns_uri = NULL;
    axis2_bool_t is_soap_11 = AXIS2_FALSE;
    axis2_char_t *soap_body_str = NULL;
    int soap_body_len = 0;
    axis2_bool_t is_mtom = AXIS2_FALSE;
    axis2_status_t status = AXIS2_FAILURE;
    axutil_hash_t *binary_data_map = NULL;
    axiom_soap_body_t *soap_body = NULL;
    axutil_property_t* reply_to_property = NULL;

    /* Create msg_ctx */
    if(!request_resource_pack->conf_ctx)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Conf Context not Available");
        return AXIS2_FAILURE;
    }

    out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf(
        request_resource_pack->conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_AMQP);
    if(!out_desc)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport Out Descriptor not Found");
        return AXIS2_FAILURE;
    }

    in_desc = axis2_conf_get_transport_in(axis2_conf_ctx_get_conf(request_resource_pack->conf_ctx,
        env), env, AXIS2_TRANSPORT_ENUM_AMQP);
    if(!in_desc)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport In Descriptor not Found");
        return AXIS2_FAILURE;
    }

    /* Create msg_ctx */
    msg_ctx = axis2_msg_ctx_create(env, request_resource_pack->conf_ctx, in_desc, out_desc);

    axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE);

    /* Handle MTOM */
    if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_MULTIPART_RELATED))
    {
        axis2_char_t* mime_boundary = axis2_amqp_util_get_value_from_content_type(env,
            request_resource_pack->content_type, AXIS2_AMQP_HEADER_CONTENT_TYPE_MIME_BOUNDARY);

        if(mime_boundary)
        {
            axiom_mime_parser_t *mime_parser = NULL;
            int soap_body_len = 0;
            axutil_param_t *buffer_size_param = NULL;
            axutil_param_t *max_buffers_param = NULL;
            axutil_param_t *attachment_dir_param = NULL;
            axis2_char_t *value_size = NULL;
            axis2_char_t *value_num = NULL;
            axis2_char_t *value_dir = NULL;
            int size = 0;
            int num = 0;

            mime_parser = axiom_mime_parser_create(env);

            buffer_size_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_BUFFER_SIZE);
            if(buffer_size_param)
            {
                value_size = (axis2_char_t*)axutil_param_get_value(buffer_size_param, env);
                if(value_size)
                {
                    size = atoi(value_size);
                    axiom_mime_parser_set_buffer_size(mime_parser, env, size);
                }
            }

            max_buffers_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_MAX_BUFFERS);
            if(max_buffers_param)
            {
                value_num = (axis2_char_t*)axutil_param_get_value(max_buffers_param, env);
                if(value_num)
                {
                    num = atoi(value_num);
                    axiom_mime_parser_set_max_buffers(mime_parser, env, num);
                }
            }

            /* If this paramter is there mime_parser will cached the attachment 
             * using to the directory for large attachments. */
            attachment_dir_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_ATTACHMENT_DIR);
            if(attachment_dir_param)
            {
                value_dir = (axis2_char_t*)axutil_param_get_value(attachment_dir_param, env);
                if(value_dir)
                {
                    axiom_mime_parser_set_attachment_dir(mime_parser, env, value_dir);
                }
            }

            if(mime_parser)
            {
                axis2_callback_info_t *callback_ctx = NULL;
                axutil_stream_t *stream = NULL;

                callback_ctx = AXIS2_MALLOC(env->allocator, sizeof(axis2_callback_info_t));

                stream = axutil_stream_create_basic(env);
                if(stream)
                {
                    axutil_stream_write(stream, env, request_resource_pack->request_content,
                        request_resource_pack->content_length);
                    callback_ctx->env = env;
                    callback_ctx->in_stream = stream;
                    callback_ctx->content_length = request_resource_pack->content_length;
                    callback_ctx->unread_len = request_resource_pack->content_length;
                    callback_ctx->chunked_stream = NULL;
                }

                /*binary_data_map = 
                 axiom_mime_parser_parse(mime_parser, env,
                 axis2_amqp_util_on_data_request,
                 (void*)callback_ctx,
                 mime_boundary);*/
                if(!binary_data_map)
                {
                    return AXIS2_FAILURE;
                }

                soap_body_str = axiom_mime_parser_get_soap_body_str(mime_parser, env);
                soap_body_len = axiom_mime_parser_get_soap_body_len(mime_parser, env);

                axutil_stream_free(stream, env);
                AXIS2_FREE(env->allocator, callback_ctx);
                axiom_mime_parser_free(mime_parser, env);
            }

            AXIS2_FREE(env->allocator, mime_boundary);
        }

        is_mtom = AXIS2_TRUE;
    }
    else
    {
        soap_body_str = request_resource_pack->request_content;
        soap_body_len = request_resource_pack->content_length;
    }

    soap_body_len = axutil_strlen(soap_body_str);

    xml_reader = axiom_xml_reader_create_for_memory(env, soap_body_str, soap_body_len, NULL,
        AXIS2_XML_PARSER_TYPE_BUFFER);
    if(!xml_reader)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create XML Reader");
        return AXIS2_FAILURE;
    }

    stax_builder = axiom_stax_builder_create(env, xml_reader);
    if(!stax_builder)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create StAX Builder");
        return AXIS2_FAILURE;
    }

    soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;

    if(request_resource_pack->content_type)
    {
        if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML))
        {
            is_soap_11 = AXIS2_TRUE;
            soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI;
        }
        /*if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_APPL_SOAP))
         {
         is_soap_11 = AXIS2_FALSE;
         soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
         }
         else if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML))
         {
         is_soap_11 = AXIS2_TRUE;
         soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI;
         }*/
    }

    soap_builder = axiom_soap_builder_create(env, stax_builder, soap_ns_uri);
    if(!soap_builder)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create SOAP Builder");
        return AXIS2_FAILURE;
    }

    if(binary_data_map)
    {
        axiom_soap_builder_set_mime_body_parts(soap_builder, env, binary_data_map);
    }

    soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env);
    axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope);

    soap_body = axiom_soap_envelope_get_body(soap_envelope, env);

    if(!soap_body)
    {
        return AXIS2_FAILURE;
    }

    /* SOAPAction */
    if(request_resource_pack->soap_action)
    {
        axis2_msg_ctx_set_soap_action(msg_ctx, env, axutil_string_create(env,
            request_resource_pack->soap_action));
    }

    /* SOAP version */
    axis2_msg_ctx_set_is_soap_11(msg_ctx, env, is_soap_11);

    /* Set ReplyTo in the msg_ctx as a property. This is used by the server when
     * 1. WS-A is not in use
     * 2. ReplyTo is an anonymous EPR - Sandesha2/Dual-channel */
    reply_to_property = axutil_property_create_with_args(env, AXIS2_SCOPE_REQUEST, 0, 0,
        (void*)request_resource_pack->reply_to);
    axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO,
        reply_to_property);

    engine = axis2_engine_create(env, request_resource_pack->conf_ctx);

    if(AXIS2_TRUE == axiom_soap_body_has_fault(soap_body, env))
    {
        status = axis2_engine_receive_fault(engine, env, msg_ctx);
    }
    else
    {
        status = axis2_engine_receive(engine, env, msg_ctx);
    }

    if(engine)
    {
        axis2_engine_free(engine, env);
    }

    if(soap_body_str && is_mtom)
    {
        AXIS2_FREE(env->allocator, soap_body_str);
    }

    return status;
}
コード例 #21
0
/* Process a request. If the request has a response the response structure will be populated */
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
axis2_udp_receiver_process_request(
	const axutil_env_t * env,
	axis2_conf_ctx_t *conf_ctx,    
    axis2_udp_request_t * request,
	axis2_udp_response_t * responce)
{   
    axis2_transport_out_desc_t *out_desc = NULL;
    axis2_transport_in_desc_t *in_desc = NULL;
    axis2_msg_ctx_t *msg_ctx = NULL;
    axiom_xml_reader_t *reader = NULL;
    axiom_stax_builder_t *builder = NULL;
    axiom_soap_builder_t *soap_builder = NULL;
    axiom_soap_envelope_t *soap_envelope = NULL;
    axis2_engine_t *engine = NULL;
    axis2_status_t status = AXIS2_FALSE;
    axutil_stream_t *out_stream = NULL;

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
                    "start:axis2_udp_worker_process_request");

    if (!conf_ctx)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "conf ctx not available");
        return AXIS2_FAILURE;
    }

    reader = axiom_xml_reader_create_for_memory(env, request->buff,
                                                request->buf_size,
                                                NULL,
                                                AXIS2_XML_PARSER_TYPE_BUFFER);
    if (!reader)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to create XML reader");
        return AXIS2_FAILURE;
    }

    builder = axiom_stax_builder_create(env, reader);
    if (!builder)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Failed to create Stax builder");
        return AXIS2_FAILURE;
    }

    soap_builder = axiom_soap_builder_create(env, builder,
                                             AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI);

    if (!soap_builder)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Failed to create SOAP builder");
        return AXIS2_FAILURE;
    }    

    out_desc =
        axis2_conf_get_transport_out(axis2_conf_ctx_get_conf(conf_ctx, env),
                                     env, AXIS2_TRANSPORT_ENUM_UDP);
    if (!out_desc)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport out not set");
        return AXIS2_FAILURE;
    }

    in_desc =
        axis2_conf_get_transport_in(axis2_conf_ctx_get_conf(conf_ctx, env), env,
                                    AXIS2_TRANSPORT_ENUM_UDP);

    msg_ctx = axis2_msg_ctx_create(env, conf_ctx, in_desc, out_desc);
    axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE);

    out_stream = axutil_stream_create_basic(env);
    axis2_msg_ctx_set_transport_out_stream(msg_ctx, env, out_stream);

    soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env);
    axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope);
	if (request->svc)
	{
		axis2_msg_ctx_set_svc(msg_ctx, env, request->svc);
	}
	if (request->op)
	{
		axis2_msg_ctx_set_op(msg_ctx, env, request->op);	
	}
    engine = axis2_engine_create(env, conf_ctx);
    status = axis2_engine_receive(engine, env, msg_ctx);

    responce->buff = axutil_stream_get_buffer(out_stream, env);
	responce->buf_size = axutil_stream_get_len(out_stream, env);
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
                    "end:axis2_udp_worker_process_request");
    return AXIS2_SUCCESS;
}
コード例 #22
0
/**
* auto generated function definition signature
* for "getKeystoreInfo|http://service.keystore.security.carbon.wso2.org" operation.
* @param env environment ( mandatory)* @param MessageContext the outmessage context
* @param _getKeystoreInfo of the adb_getKeystoreInfo_t*
*
* @return adb_getKeystoreInfoResponse_t*
*/
adb_getKeystoreInfoResponse_t* 
axis2_skel_KeyStoreAdminService_getKeystoreInfo(const axutil_env_t *env , 
												axis2_msg_ctx_t *msg_ctx,
												adb_getKeystoreInfo_t* _getKeystoreInfo,
												axis2_skel_KeyStoreAdminService_getKeystoreInfo_fault *fault )
{
	axis2_char_t* keystore_name = NULL;
	axis2_conf_ctx_t* conf_ctx = NULL;
	axis2_conf_t* axis2_conf = NULL;
	axis2_char_t* repo_path = NULL;
	axis2_char_t* keystore_file = NULL;
	axis2_char_t password[10];
	axis2_char_t provider[20];
	axis2_char_t pvt_key_pass[10];
	pkcs12_keystore_t* pkcs12_keystore = NULL;
	axutil_array_list_t* cert_array_tmp = NULL;
	int cert_count = 0;
	adb_CertData_t* cert_data = NULL;
	oxs_x509_cert_t* oxs_cert = NULL;
	adb_KeyStoreData_t* data = NULL;
	adb_getKeystoreInfoResponse_t* response = NULL;

	/* Get required keystore name*/
	keystore_name = axutil_strdup(env, 
		adb_getKeystoreInfo_get_keyStoreName(_getKeystoreInfo, env));
	if (!keystore_name) return NULL;
	keystore_name = strtok(keystore_name, ".");

	conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    axis2_conf = axis2_conf_ctx_get_conf(conf_ctx, env);
    repo_path = axis2_conf_get_repo(axis2_conf, env);
	
	/* Get password, provider and pvt_key_pass from details file */
	if (!keystore_admin_util_get_keystore_details(env, repo_path, keystore_name, 
		password, provider, pvt_key_pass))
	{
		AXIS2_FREE(env->allocator, keystore_name);
		return NULL;
	}

	/* Load keystore file */
	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);

	pkcs12_keystore = pkcs12_keystore_create(env, keystore_file, password);
	AXIS2_FREE(env->allocator, keystore_file);
	AXIS2_FREE(env->allocator, keystore_name);

	if (!pkcs12_keystore) return NULL;

	/* Create data*/
	data = adb_KeyStoreData_create(env);

	/* Set keystore name*/
	adb_KeyStoreData_set_keyStoreName(data, env, 
		(axis2_char_t*)axutil_strdup(env, 
		adb_getKeystoreInfo_get_keyStoreName(_getKeystoreInfo, env)));

	/* Set keystore type*/
	adb_KeyStoreData_set_keyStoreType(data, env, "PKCS12");

	/* Set provider*/
	adb_KeyStoreData_set_provider(data, env, provider);

	/* Add certs*/
	cert_array_tmp = pkcs12_keystore_populate_cert_array(env, 
		pkcs12_keystore_get_other_certs(pkcs12_keystore));
	cert_count = axutil_array_list_size(cert_array_tmp, env);

	if (0 < cert_count) /* Public certs available */
	{
		axutil_array_list_t* cert_array = NULL;
		int index = 0;

		cert_array = axutil_array_list_create(env, cert_count);

		for (index = 0; index < cert_count; ++index)
		{
			oxs_cert = (oxs_x509_cert_t*)
				axutil_array_list_get(cert_array_tmp, env, index);
			
			if (oxs_x509_cert_get_alias(oxs_cert, env))
			{
				axis2_char_t not_after[20];
				axis2_char_t not_before[20];

				/* Create and store cert data*/
				cert_data = adb_CertData_create(env);

				keystore_admin_util_format_date(env, oxs_x509_cert_get_date(oxs_cert, env), not_after);
				keystore_admin_util_format_date(env, oxs_x509_cert_get_valid_from(oxs_cert, env), not_before);

				adb_CertData_set_alias(cert_data, env, oxs_x509_cert_get_alias(oxs_cert, env));
				adb_CertData_set_issuerDN(cert_data, env, oxs_x509_cert_get_issuer(oxs_cert, env));
				adb_CertData_set_notAfter(cert_data, env, not_after);
				adb_CertData_set_notBefore(cert_data, env, not_before);
				adb_CertData_set_serialNumber(cert_data, env, oxs_x509_cert_get_serial_number(oxs_cert, env));
				adb_CertData_set_subjectDN(cert_data, env, oxs_x509_cert_get_subject(oxs_cert, env));
				adb_CertData_set_version(cert_data, env, oxs_x509_cert_get_version(oxs_cert, env));

				axutil_array_list_add(cert_array, env, cert_data);
			}

			oxs_x509_cert_free(oxs_cert, env);
		}

		adb_KeyStoreData_set_certs(data, env, cert_array);

		axutil_array_list_free(cert_array_tmp, env);
	}
	else
	{
		adb_KeyStoreData_set_certs_nil(data, env);
	}

	/* Set private cert*/
	oxs_cert = pkcs12_keystore_get_owner_certificate(pkcs12_keystore, env);
	if (oxs_cert)
	{
		axis2_char_t not_after[20];
		axis2_char_t not_before[20];

		cert_data = adb_CertData_create(env);

		keystore_admin_util_format_date(env, oxs_x509_cert_get_date(oxs_cert, env), not_after);
		keystore_admin_util_format_date(env, oxs_x509_cert_get_valid_from(oxs_cert, env), not_before);

		adb_CertData_set_alias(cert_data, env, oxs_x509_cert_get_alias(oxs_cert, env));
		adb_CertData_set_issuerDN(cert_data, env, oxs_x509_cert_get_issuer(oxs_cert, env));
		adb_CertData_set_notAfter(cert_data, env, not_after);
		adb_CertData_set_notBefore(cert_data, env, not_before);
		adb_CertData_set_serialNumber(cert_data, env, oxs_x509_cert_get_serial_number(oxs_cert, env));
		adb_CertData_set_subjectDN(cert_data, env, oxs_x509_cert_get_subject(oxs_cert, env));
		adb_CertData_set_version(cert_data, env, oxs_x509_cert_get_version(oxs_cert, env));

		adb_KeyStoreData_set_key(data, env, cert_data);

		oxs_x509_cert_free(oxs_cert, env);
	}
	else
	{
		adb_KeyStoreData_set_key_nil(data, env);
	}

	/* Create response*/
	response = adb_getKeystoreInfoResponse_create(env);
	adb_getKeystoreInfoResponse_set_return(response, env, data);

	return response;
}
コード例 #23
0
/**
* 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;
}
コード例 #24
0
ファイル: addr_disp.c プロジェクト: Denisss025/wsfcpp
static axis2_svc_t *AXIS2_CALL
axis2_addr_disp_find_svc(
    axis2_msg_ctx_t * msg_ctx,
    const axutil_env_t * env)
{
    axis2_endpoint_ref_t *endpoint_ref = NULL;
    axis2_svc_t *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;
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                "Checking for service using WSA enpoint address : %s", address);

            if((axutil_strcmp(AXIS2_WSA_ANONYMOUS_URL, address) == 0) || (axutil_strcmp(
                AXIS2_WSA_NAMESPACE_SUBMISSION, address) == 0))
            {
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                    "Endpoint address cannot be the same as WSA namespace : %s", address);
                return NULL;
            }

            url_tokens = axutil_parse_request_url_for_svc_and_op(env, address);

            if(url_tokens)
            {
                if(url_tokens[0])
                {
                    axis2_conf_ctx_t *conf_ctx = NULL;

                    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
                    if(conf_ctx)
                    {
                        axis2_conf_t *conf = NULL;
                        conf = axis2_conf_ctx_get_conf(conf_ctx, env);
                        if(conf)
                        {
                            svc = axis2_conf_get_svc(conf, env, url_tokens[0]);

                            if(svc)
                            {
                                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                                    "Service found using WSA enpoint address");
                            }
                        }
                    }
                    AXIS2_FREE(env->allocator, url_tokens[0]);
                }
                if(url_tokens[1])
                {
                    AXIS2_FREE(env->allocator, url_tokens[1]);
                }
                AXIS2_FREE(env->allocator, url_tokens);
                url_tokens = NULL;
            }
        }
    }

    return svc;
}
コード例 #25
0
/**
* 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;
}
コード例 #26
0
ファイル: rest_disp.c プロジェクト: bnoordhuis/axis2-c
axis2_svc_t *AXIS2_CALL
axis2_rest_disp_find_svc(
    axis2_msg_ctx_t * msg_ctx,
    const axutil_env_t * env)
{
    axis2_endpoint_ref_t *endpoint_ref = NULL;
    axis2_svc_t *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;
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                "Checking for service using target endpoint address : %s", address);

            url_tokens = axutil_parse_request_url_for_svc_and_op(env, address);

            if(url_tokens)
            {
                if(url_tokens[0])
                {
                    axis2_conf_ctx_t *conf_ctx = NULL;

                    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
                    if(conf_ctx)
                    {
                        axis2_conf_t *conf = NULL;
                        conf = axis2_conf_ctx_get_conf(conf_ctx, env);
                        if(conf)
                        {
                            svc = axis2_conf_get_svc(conf, env, url_tokens[0]);
                            if(svc)
                                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                                    "Service found using target endpoint address");
                        }
                    }
                    AXIS2_FREE(env->allocator, url_tokens[0]);

                    if(url_tokens[1])
                    {
                        AXIS2_FREE(env->allocator, url_tokens[1]);
                    }

                }
                AXIS2_FREE(env->allocator, url_tokens);
                url_tokens = NULL;
            }
        }
    }

    return svc;
}
コード例 #27
0
bool
Axis2QpidReceiver::start(
    void)
{
    if(!conf_ctx)
        return false;

    Connection connection;
    axis2_bool_t serverSide = AXIS2_TRUE;

    serverSide = axis2_amqp_util_conf_ctx_get_server_side(conf_ctx, env);

    while(true)
    {
        try
        {
            std::list<string> queueNameList;
            string qpidBrokerIP = axis2_amqp_util_conf_ctx_get_qpid_broker_ip(conf_ctx, env);
            int qpidBrokerPort = axis2_amqp_util_conf_ctx_get_qpid_broker_port(conf_ctx, env);

            /* Check if Client Side and Resolve Dynamic Queue Name */
            if(serverSide == AXIS2_TRUE) /* Server side */
            {
                std::cout << "Connecting to Qpid Broker on " << qpidBrokerIP << ":"
                    << qpidBrokerPort << " ... ";
            }

            /* Create Connection to Qpid Broker */
            connection.open(qpidBrokerIP, qpidBrokerPort);

            if(serverSide == AXIS2_TRUE) /* Server side */
            {
                /* Create queue for each service. Queue name is equal to service name */
                axis2_conf_t* conf = axis2_conf_ctx_get_conf(conf_ctx, env);
                if(!conf)
                    return false;

                axutil_hash_t* serviceMap = axis2_conf_get_all_svcs(conf, env);
                if(!serviceMap)
                    return false;

                axutil_hash_index_t* serviceHI = NULL;
                void* serviceValue = NULL;

                for(serviceHI = axutil_hash_first(serviceMap, env); serviceHI; serviceHI
                    = axutil_hash_next(env, serviceHI))
                {
                    axutil_hash_this(serviceHI, NULL, NULL, &serviceValue);

                    axis2_svc_t* service = (axis2_svc_t*)serviceValue;
                    if(!service)
                        return false;

                    axis2_char_t* serviceName = axutil_qname_get_localpart(axis2_svc_get_qname(
                        service, env), env);
                    if(!serviceName)
                        return false;

                    queueNameList.push_back(serviceName);
                }

                std::cout << "CONNECTED" << std::endl;
            }
            else /* Client side separate listener in dual-channel case */
            {
                string queueName = axis2_amqp_util_conf_ctx_get_dual_channel_queue_name(conf_ctx,
                    env);

                queueNameList.push_back(queueName);
            }

            /* Create new session */
            Session session = connection.newSession();

            /* Create Subscription manager */
            SubscriptionManager subscriptionManager(session);

            Axis2QpidReceiverListener qpidReceiverListener(env, conf_ctx);

            /* Subscribe to queues */
            while(!queueNameList.empty())
            {
                string queueName = queueNameList.front();

                session.queueDeclare(arg::queue = queueName, arg::autoDelete = true);
                session.exchangeBind(arg::exchange = AXIS2_AMQP_EXCHANGE_DIRECT, arg::queue
                    = queueName, arg::bindingKey = queueName);

                subscriptionManager.subscribe(qpidReceiverListener, queueName);

                queueNameList.pop_front();
            }

            /* Listen and Wait */
            if(serverSide == AXIS2_TRUE) /* Server side */
            {
                std::cout << "Started Axis2 AMQP Server ..." << std::endl;
            }

            subscriptionManager.run();

            return true;
        }
        catch(const std::exception& e)
        {
            connection.close();

            if(serverSide == AXIS2_TRUE) /* Server side */
            {
                std::cout << "FAILED" << std::endl;
            }

            sleep(5);
        }
    }

    connection.close();

    return false;
}
コード例 #28
0
ファイル: engine.c プロジェクト: alexis-gruet/axis2c-trunk
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_engine_receive(
    axis2_engine_t * engine,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx)
{
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_conf_t *conf = NULL;
    axis2_op_ctx_t *op_ctx = NULL;
    axis2_op_t *op = NULL;
    axutil_array_list_t *pre_calculated_phases = NULL;
    axutil_array_list_t *op_specific_phases = NULL;
    axis2_status_t status = AXIS2_FAILURE;

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Start:axis2_engine_receive");
    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);

    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);

    conf = axis2_conf_ctx_get_conf(conf_ctx, env);

    pre_calculated_phases = axis2_conf_get_in_phases_upto_and_including_post_dispatch(conf, env);

    if(axis2_msg_ctx_is_paused(msg_ctx, env))
    {
        /* The message has paused, so re-run them from the position they stopped. */
        axis2_engine_resume_invocation_phases(engine, env, pre_calculated_phases, msg_ctx);
        if(axis2_msg_ctx_is_paused(msg_ctx, env))
        {
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Message context is paused. So return here.");
            return AXIS2_SUCCESS;
        }

        /* Resume op specific phases */
        op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
        if(op_ctx)
        {
            op = axis2_op_ctx_get_op(op_ctx, env);
            op_specific_phases = axis2_op_get_in_flow(op, env);
            axis2_engine_resume_invocation_phases(engine, env, op_specific_phases, msg_ctx);
            if(axis2_msg_ctx_is_paused(msg_ctx, env))
            {
                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                    "Message context is paused. So return here.");
                return AXIS2_SUCCESS;
            }
        }
    }
    else
    {
        status = axis2_engine_invoke_phases(engine, env, pre_calculated_phases, msg_ctx);
        if(status != AXIS2_SUCCESS)
        {
            if(axis2_msg_ctx_get_server_side(msg_ctx, env))
            {
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invoking pre-calculated phases failed");
                return status;
            }
        }

        if(axis2_msg_ctx_is_paused(msg_ctx, env))
        {
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Message context is paused. So return here.");
            return AXIS2_SUCCESS;
        }

        op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
        if(op_ctx)
        {
            op = axis2_op_ctx_get_op(op_ctx, env);
            op_specific_phases = axis2_op_get_in_flow(op, env);
            status = axis2_engine_invoke_phases(engine, env, op_specific_phases, msg_ctx);
            if(status != AXIS2_SUCCESS)
            {
                axis2_char_t *op_name = NULL;
                op_name = axutil_qname_get_localpart(axis2_op_get_qname(op, env), env);
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                    "Invoking operation specific phases failed for operation %s", op_name);
                return status;
            }

            if(axis2_msg_ctx_is_paused(msg_ctx, env))
            {
                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                    "Message context is paused. So return here.");
                return AXIS2_SUCCESS;
            }
        }
    }

    if((axis2_msg_ctx_get_server_side(msg_ctx, env)) && !(axis2_msg_ctx_is_paused(msg_ctx, env)))
    {
        axis2_msg_recv_t *receiver = NULL;

        status = axis2_engine_check_must_understand_headers(env, msg_ctx);
        if(status != AXIS2_SUCCESS)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Check for must understand headers failed");
            return status;
        }

        /* Invoke the message receivers */
        if(!op)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Operation not found");
            return AXIS2_FAILURE;
        }
        receiver = axis2_op_get_msg_recv(op, env);
        if(!receiver)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                "Message receiver not set in operation description");
            return AXIS2_FAILURE;
        }
        status = axis2_msg_recv_receive(receiver, env, msg_ctx, axis2_msg_recv_get_derived(
            receiver, env));
    }

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_engine_receive");

    return status;
}
コード例 #29
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;
}
コード例 #30
0
ファイル: tcp_worker.c プロジェクト: Denisss025/wsfcpp
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
axis2_tcp_worker_process_request(
    axis2_tcp_worker_t * tcp_worker,
    const axutil_env_t * env,
    axis2_simple_tcp_svr_conn_t * svr_conn,
    axis2_char_t * simple_request)
{
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_transport_out_desc_t *out_desc = NULL;
    axis2_transport_in_desc_t *in_desc = NULL;
    axis2_msg_ctx_t *msg_ctx = NULL;
    axiom_xml_reader_t *reader = NULL;
    axiom_stax_builder_t *builder = NULL;
    axiom_soap_builder_t *soap_builder = NULL;
    axiom_soap_envelope_t *soap_envelope = NULL;
    axis2_engine_t *engine = NULL;
    axis2_status_t status = AXIS2_FALSE;
    axutil_stream_t *svr_stream = NULL;
    axis2_char_t *buffer = NULL;
    int len = 0;
    int write = -1;
    axutil_stream_t *out_stream = NULL;

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "start:axis2_tcp_worker_process_request");

    reader = axiom_xml_reader_create_for_memory(env, simple_request, axutil_strlen(simple_request),
        NULL, AXIS2_XML_PARSER_TYPE_BUFFER);
    if(!reader)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to create XML reader");
        return AXIS2_FAILURE;
    }

    builder = axiom_stax_builder_create(env, reader);
    if(!builder)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to create Stax builder");
        return AXIS2_FAILURE;
    }

    soap_builder= axiom_soap_builder_create(env, builder, NULL);
    if(!soap_builder)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to create SOAP builder");
        return AXIS2_FAILURE;
    }

    conf_ctx = tcp_worker->conf_ctx;

    if(!conf_ctx)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "conf ctx not available");
        return AXIS2_FAILURE;
    }

    out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf(conf_ctx, env), env,
        AXIS2_TRANSPORT_ENUM_TCP);
    if(!out_desc)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport out not set");
        return AXIS2_FAILURE;
    }

    in_desc = axis2_conf_get_transport_in(axis2_conf_ctx_get_conf(conf_ctx, env), env,
        AXIS2_TRANSPORT_ENUM_TCP);

    msg_ctx = axis2_msg_ctx_create(env, conf_ctx, in_desc, out_desc);
    axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE);

    out_stream = axutil_stream_create_basic(env);
    axis2_msg_ctx_set_transport_out_stream(msg_ctx, env, out_stream);

    soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env);
    axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope);

    engine = axis2_engine_create(env, conf_ctx);
    status = axis2_engine_receive(engine, env, msg_ctx);

    svr_stream = axis2_simple_tcp_svr_conn_get_stream(svr_conn, env);
    buffer = out_stream->buffer;
    len = out_stream->len;
    buffer[len] = 0;
    if(svr_stream && buffer)
    {
        write = axutil_stream_write(svr_stream, env, buffer, len + 1);
        if(write < 0)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "stream write failed");
            return AXIS2_FAILURE;
        }
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "stream wrote:%s", buffer);
    }
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "end:axis2_tcp_worker_process_request");
    return AXIS2_SUCCESS;
}