/** * 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; }
/** * 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; }
bool Axis2UtilsRemoveVirtualService(const std::string& sServiceName, const struct axutil_env* pEnv, struct axis2_conf* pConf, bool bIsShuttingDown) { axis2_svc* pService = axis2_conf_get_svc(pConf, pEnv, sServiceName.c_str()); if (!pService) { staff::LogError() << "axis2_conf_get_svc"; return false; } if (!bIsShuttingDown) { std::string sServiceGroupName = sServiceName.c_str(); sServiceGroupName += "SvcGroup"; // removing from conf axis2_svc_grp* pServiceGroup = axis2_conf_get_svc_grp(pConf, pEnv, sServiceGroupName.c_str()); if (!pServiceGroup) { staff::LogError() << "axis2_conf_get_svc_grp"; return false; } axutil_hash_t* pAllServiceGroups = axis2_conf_get_all_svc_grps(pConf, pEnv); if (!pAllServiceGroups) { staff::LogError() << "axis2_conf_get_all_svc_grps"; return false; } axutil_hash_set(pAllServiceGroups, sServiceGroupName.c_str(), AXIS2_HASH_KEY_STRING, NULL); axis2_svc_grp_free(pServiceGroup, pEnv); } // axis2_svc_grp_free does not destroy the services in group if (axis2_conf_remove_svc(pConf, pEnv, sServiceName.c_str()) != AXIS2_SUCCESS) { staff::LogError() << "axis2_conf_remove_svc"; return false; } axis2_svc_free(pService, pEnv); return true; }
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; }
/* 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; }
static int AXIS2_CALL Axis2Service_init_with_conf( axis2_svc_skeleton_t * /*pSvcSkeleton*/, const axutil_env_t * pEnv, axis2_conf* pConf) { staff::CrashHandler::Enable(); #if defined WIN32 // installing handler to process Staff deinitialization before dlls are unloaded SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE); #endif const axis2_char_t* szServiceName = "StaffService"; m_pAxis2Svc = axis2_conf_get_svc(pConf, pEnv, szServiceName); // check for staff module is engaged axutil_qname_t* pQName = axutil_qname_create(pEnv, "staff", NULL, NULL); axis2_bool_t bEngaged = axis2_svc_is_module_engaged(m_pAxis2Svc, pEnv, pQName); axutil_qname_free(pQName, pEnv); if (!bEngaged) { staff::LogError() << "staff module is not engaged. Unable to continue."; exit(1); } #ifndef WITHOUT_SECURITY // check for staff_security is engaged pQName = axutil_qname_create(pEnv, "staff_security", NULL, NULL); bEngaged = axis2_svc_is_module_engaged(m_pAxis2Svc, pEnv, pQName); axutil_qname_free(pQName, pEnv); if (!bEngaged) { staff::LogError() << "staff_security module is not engaged. Unable to continue."; exit(1); } // initialize security if (!staff_security_init()) { staff::LogError() << "Failed to initialize staff::security."; exit(1); } #endif axutil_param_t* pParam = axis2_svc_get_param(m_pAxis2Svc, pEnv, "Http200OnFault"); if (pParam != NULL) { const axis2_char_t* szValue = reinterpret_cast<const axis2_char_t*>(axutil_param_get_value(pParam, pEnv)); if (szValue != NULL) { m_bHttp200OnFault = !axutil_strcasecmp(szValue, "true"); } } m_pEnv = pEnv; m_pConf = pConf; try { staff::ServiceDispatcher::Inst().Init(staff::ServiceDispatcher::Events(StaffService::OnConnect, StaffService::OnDisconnect)); std::cout << "StaffService started (version " VERSION_FULL ")" << std::endl; return AXIS2_SUCCESS; } STAFF_CATCH_ALL_DESCR("Failed to start StaffService dispatcher") return AXIS2_FAILURE; }
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; }
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; }
AXIS2_EXTERN axis2_svc_client_t *AXIS2_CALL axis2_svc_client_create_with_conf_ctx_and_svc( const axutil_env_t * env, const axis2_char_t * client_home, axis2_conf_ctx_t * conf_ctx, axis2_svc_t * svc) { axis2_svc_client_t *svc_client = NULL; axis2_svc_grp_t *svc_grp = NULL; axis2_svc_grp_ctx_t *svc_grp_ctx = NULL; const axis2_char_t *svc_grp_name = NULL; svc_client = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_client_t)); if(!svc_client) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create service client."); return NULL; } svc_client->svc = NULL; svc_client->conf = NULL; svc_client->conf_ctx = NULL; svc_client->svc_ctx = NULL; svc_client->options = NULL; svc_client->override_options = NULL; svc_client->headers = NULL; svc_client->callback_recv = NULL; svc_client->listener_manager = NULL; svc_client->op_client = NULL; svc_client->last_response_soap_envelope = NULL; svc_client->last_response_has_fault = AXIS2_FALSE; svc_client->reuse = AXIS2_FALSE; svc_client->auth_failed = AXIS2_FALSE; svc_client->required_auth_is_http = AXIS2_FALSE; svc_client->auth_type = NULL; svc_client->http_headers = NULL; svc_client->keep_externally_passed_ctx_and_svc = AXIS2_FALSE; if(!axis2_svc_client_init_data(env, svc_client)) { axis2_svc_client_free(svc_client, env); return NULL; } /*create the default conf_ctx if it is NULL */ if(!axis2_svc_client_init_transports_from_conf_ctx(env, svc_client, conf_ctx, client_home)) { axis2_svc_client_free(svc_client, env); return NULL; } svc_client->conf = axis2_conf_ctx_get_conf(svc_client->conf_ctx, env); if(svc) { svc_client->keep_externally_passed_ctx_and_svc = AXIS2_TRUE; svc_client->svc = svc; } else { svc_client->svc = axis2_svc_client_create_annonymous_svc(svc_client, env); if(!svc_client->svc) { axis2_svc_client_free(svc_client, env); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create annonymous service."); return NULL; } } /** add the service to the config context if it isn't in there already */ if(!axis2_conf_get_svc(svc_client->conf, env, axis2_svc_get_name(svc_client->svc, env))) { axis2_conf_add_svc(svc_client->conf, env, svc_client->svc); } /** create a service context for myself: create a new service group context and then get the service context for myself as I'll need that later for stuff that I gotta do */ svc_grp = axis2_svc_get_parent(svc_client->svc, env); if(!svc_grp) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot access service group of service client."); return NULL; } svc_grp_ctx = axis2_svc_grp_get_svc_grp_ctx(svc_grp, env, svc_client->conf_ctx); if(!svc_grp_ctx) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot access service group context of service client."); return NULL; } svc_grp_name = axis2_svc_grp_get_name(svc_grp, env); if(!svc_grp_name) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot access service group name of service client."); return NULL; /* service group name is mandatory */ } axis2_conf_ctx_register_svc_grp_ctx(svc_client->conf_ctx, env, svc_grp_name, svc_grp_ctx); svc_client->svc_ctx = axis2_svc_grp_ctx_get_svc_ctx(svc_grp_ctx, env, axis2_svc_get_name( svc_client->svc, env)); return svc_client; }