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; }
static void topic_index_init() { remote_registry_t *remote_registry = NULL; const axutil_env_t *env = NULL; remote_registry_resource_t *res = NULL; axis2_char_t *id = NULL; axis2_char_t *reg_url = "http://localhost:9762/registry"; env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE); remote_registry = remote_registry_create(env, reg_url, "admin", "admin"); res = remote_registry_get(remote_registry, env, TOPIC_INDEX, NULL); if(!res) { res = remote_registry_resource_create(env); id = axutil_strcat(env, reg_url, TOPIC_INDEX, NULL); remote_registry_resource_set_properties(res, env, axutil_hash_make(env)); /*remote_registry_resource_set_author_name(res, env, "admin"); */ remote_registry_resource_set_description(res, env, ""); /*remote_registry_resource_set_last_modified_time(res, env, axutil_date_time_create(env));*/ remote_registry_put(remote_registry, env, TOPIC_INDEX, res); return; } }
static char * create_type1_header(const axutil_env_t *env, axis2_char_t *encoded) { char *type1_header = NULL; char *header1 = NULL; type1_header = axutil_strcat(env, "Authorization: NTLM " ,encoded, NULL); header1 = "HEAD /myservice/Service1.asmx HTTP/1.1\n"\ "Host: 172.16.176.132:8080\n"\ "User-Agent: Axis2C/1.7.0\n"; header1 = axutil_strcat(env, header1, type1_header, "\n\n", NULL); AXIS2_FREE(env->allocator, type1_header); return header1; }
/** * 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; }
static long remote_registry_rest_client_get_only_if_modified( remote_registry_rest_client_t *rest_client, const axutil_env_t *env, const axis2_char_t *url, axis2_char_t *uname_passwd, axis2_char_t **buffer, int *content_len) { long status_code; axis2_char_t *last_etag = NULL; struct curl_slist *headers = NULL; axis2_char_t *if_none_match_header = NULL; /* get the last updated time, if the cache entry exist */ last_etag = axutil_hash_get(rest_client->etags, url, AXIS2_HASH_KEY_STRING); /* if the last updated time doesn't exist*/ if(!last_etag) { return -1; } /* if the last etag exists, add it to the if-none-match header */ if_none_match_header = axutil_strcat(env, "if-none-match: ", last_etag, NULL); if(if_none_match_header) { headers = curl_slist_append(headers, if_none_match_header); AXIS2_FREE(env->allocator, if_none_match_header); } /* no need to sending the prior request */ if(!headers) { return -1; } status_code = remote_registry_rest_client_get_internal(rest_client, env, url, uname_passwd, buffer, content_len, headers); if(headers) { curl_slist_free_all(headers); /* free the header list */ } return status_code; }
void remove_subscriber(axis2_char_t *id) { remote_registry_t *remote_registry = NULL; const axutil_env_t *env = NULL; remote_registry_resource_t *res = NULL; axis2_char_t *val; axis2_char_t *index_path = NULL; axis2_status_t status = AXIS2_FAILURE; axis2_char_t *path = NULL; axis2_char_t *reg_url = "http://localhost:9762/registry"; env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE); remote_registry = remote_registry_create(env, reg_url, "admin", "admin"); res = remote_registry_get(remote_registry, env, TOPIC_INDEX, NULL); if(!res) { return; } printf("\n\nroot resource id:%s\n\n",remote_registry_resource_get_id(res, env)); val = remote_registry_resource_get_property(res, env, id); if(val) { path = axutil_strcat(env, val, "/", id, NULL); printf("path:%s\n", path); status = remote_registry_delete(remote_registry, env, path); } if(AXIS2_SUCCESS != status) { printf("\nSubscription deletion failed\n"); } res = remote_registry_get(remote_registry, env, TOPIC_INDEX, NULL); if(!res) { return; } printf("\n\nroot resource id:%s\n\n",remote_registry_resource_get_id(res, env)); /*remote_registry_resource_remove_property(res, env, id); remote_registry_resource_set_content(res, env, NULL); remote_registry_resource_set_content_len(res, env, 0); remote_registry_resource_set_parent_path(res, env, "/eventing/index"); index_path = axutil_strcat(env, TOPIC_INDEX, "/TopicIndex", NULL); remote_registry_put(remote_registry, env, index_path, res);*/ remote_registry_resource_free(res, env); }
axis2_status_t AXIS2_CALL reg_client_rest_client_post( reg_client_rest_client_t *rest_client, const axutil_env_t *env, const axis2_char_t *url, const axis2_char_t *data, const axis2_char_t *content_type) { CURL *curl_handle; CURLcode res; axis2_status_t status = AXIS2_FAILURE; curl_handle = curl_easy_init(); if(curl_handle) { curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, content_type); curl_easy_setopt(curl_handle, CURLOPT_URL, url); curl_easy_setopt(curl_handle, CURLOPT_POST, 1); curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, data); /*curl_easy_setopt(curl_handle, CURLOPT_RETURNTRANSFER, 1);*/ curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, REG_CLIENT_USER_AGENT); if(rest_client->username) { axis2_char_t *uname_passwd = NULL; uname_passwd = axutil_strcat(env, rest_client->username, ":", rest_client->password, NULL); curl_easy_setopt(curl_handle, CURLOPT_USERPWD, uname_passwd); } res = curl_easy_perform(curl_handle); if(res == CURLE_OK) { res = curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &rest_client->status); if(res != CURLE_OK) { status = AXIS2_FAILURE; } } /* always cleanup */ curl_easy_cleanup(curl_handle); } return status; }
AXIS2_EXTERN axis2_http_status_line_t *AXIS2_CALL axis2_http_status_line_create_with_values( const axutil_env_t * env, const axis2_char_t * http_ver, const int status_code, const axis2_char_t * phrase) { axis2_http_status_line_t *status_line = NULL; status_line = (axis2_http_status_line_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_http_status_line_t)); if(!status_line) { AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); return NULL; } memset((void *)status_line, 0, sizeof(axis2_http_status_line_t)); status_line->status_code = AXIS2_MALLOC(env->allocator, 6 * sizeof(axis2_char_t *)); if(!status_line->status_code) { AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); axis2_http_status_line_free(status_line, env); return NULL; } sprintf(status_line->status_code, "%3d", status_code); status_line->http_version = axutil_strdup(env, http_ver); status_line->reason_phrase = axutil_strdup(env, phrase); if(!status_line->http_version || !status_line->reason_phrase) { axis2_http_status_line_free(status_line, env); AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); return NULL; } status_line->line = axutil_strcat(env, http_ver, " ", status_line->status_code, " ", phrase, AXIS2_HTTP_CRLF, NULL); if(!status_line->line) { axis2_http_status_line_free(status_line, env); AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); return NULL; } return status_line; }
void get_all_subscribers() { remote_registry_t *remote_registry = NULL; const axutil_env_t *env = NULL; remote_registry_resource_t *res = NULL; axutil_hash_t *properties = NULL; axis2_char_t *path = NULL; axis2_char_t *reg_url = "http://localhost:9762/registry"; env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE); remote_registry = remote_registry_create(env, reg_url, "admin", "admin"); res = remote_registry_get(remote_registry, env, TOPIC_INDEX, NULL); if(!res) { return; } properties = remote_registry_resource_get_properties(res, env); if(properties) { axutil_hash_index_t *hi; void *val; void *key; for (hi = axutil_hash_first(properties, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, (const void**)&key, NULL, &val); path = axutil_strcat(env, val, "/", key, NULL); res = remote_registry_get(remote_registry, env, path, NULL); if(res) { if(res) { printf("\n\nresource id:%s\n\n",remote_registry_resource_get_id(res, env)); } } remove_subscriber((axis2_char_t *) key); } } remote_registry_resource_free(res, env); }
void AXIS2_CALL service_admin_counter_set_last_count ( const axutil_env_t *env, axis2_msg_ctx_t *msg_ctx, axis2_char_t *svc_name, axis2_char_t *op_name, int last_count) { int *count = NULL; axis2_conf_ctx_t *conf_ctx = NULL; axutil_property_t *property = NULL; axutil_hash_t *last_counts = NULL; conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); if(svc_name && op_name) { axis2_char_t *key = NULL; key = axutil_strcat(env, svc_name, "-", op_name, NULL); property = axis2_conf_ctx_get_property(conf_ctx, env, SERVICE_ADMIN_COUNTER_LAST_OPERATION_COUNT); /* set_last_count is always called after get_last_count. So checking for existence of property * is not necessary here */ last_counts = axutil_property_get_value(property, env); count = axutil_hash_get(last_counts, key, AXIS2_HASH_KEY_STRING); *count = last_count; AXIS2_FREE(env->allocator, key); } else if(svc_name) { property = axis2_conf_ctx_get_property(conf_ctx, env, SERVICE_ADMIN_COUNTER_LAST_SERVICE_COUNT); /* set_last_count is always called after get_last_count. So checking for existence of property * is not necessary here */ last_counts = axutil_property_get_value(property, env); count = axutil_hash_get(last_counts, svc_name, AXIS2_HASH_KEY_STRING); *count = last_count; } }
/** * initializes the service and create the wsdl_info_t structure */ WSF_WSDL_EXTERN axis2_bool_t WSF_WSDL_CALL wsf_wsdl_mode_initialize_for_service( const axutil_env_t* env, axis2_char_t* wsdl_file_name, axis2_char_t* script_binding_home, axis2_svc_t* service, axis2_conf_ctx_t* worker_conf_ctx, axutil_hash_t* script_service_user_options, axis2_char_t* service_name, axis2_char_t* port_name, wsf_wsdl_info_t** wsdl_info) { axiom_node_t* type_map = NULL; axiom_node_t* sig_axiom = NULL; axiom_node_t* wsdl_axiom = NULL; axutil_hash_t* operations = NULL; axis2_bool_t success = AXIS2_FAILURE; wsf_wsdl_info_t* info = NULL; axis2_bool_t is_version1_wsdl = AXIS2_FALSE; axis2_char_t* xslt_location = NULL; axis2_char_t* type_map_file = NULL; xslt_location = axutil_strcat(env, script_binding_home, WSF_WSDL_XSLT_LOCATION_POSTFIX, NULL); type_map_file = axutil_strcat(env, script_binding_home, WSF_WSDL_TYPE_MAP_POSTFIX, NULL); if (wsf_wsdl_parser_load_wsdl(env, wsdl_file_name, xslt_location, &wsdl_axiom, &sig_axiom, &is_version1_wsdl, AXIS2_TRUE)) { wsf_wsdl_util_handle_service_security(env, service, worker_conf_ctx, script_service_user_options, service_name, port_name, wsdl_axiom, is_version1_wsdl); wsdl_util_create_type_map(env, type_map_file, &type_map); wsdl_util_get_operations(env, sig_axiom, &operations); if (wsdl_info) { if (*wsdl_info) { AXIS2_FREE(env->allocator, *wsdl_info); } info = (wsf_wsdl_info_t*)AXIS2_MALLOC(env->allocator, sizeof(wsf_wsdl_info_t)); info->type_map = type_map; info->operations = operations; *wsdl_info = info; success = AXIS2_SUCCESS; } } return success; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL rampart_replay_detector_with_flat_file( rampart_replay_detector_t *rrd, const axutil_env_t *env, axis2_msg_ctx_t* msg_ctx, rampart_context_t *rampart_context) { axutil_linked_list_t *ll = NULL; const axis2_char_t *msg_id = NULL; const axis2_char_t *ts = NULL; const axis2_char_t *addr_msg_id = NULL; int max_rcds = RAMPART_RD_DEF_MAX_RCDS; axis2_status_t status = AXIS2_FAILURE; axutil_hash_t *sec_process_result = NULL; /*Get timestamp from security processed results */ sec_process_result = rampart_get_all_security_processed_results(env, msg_ctx); ts = axutil_hash_get(sec_process_result, RAMPART_SPR_TS_CREATED, AXIS2_HASH_KEY_STRING); /* get message id from addressing headers */ addr_msg_id = axis2_msg_ctx_get_wsa_message_id(msg_ctx, env); if(!ts && addr_msg_id) { msg_id = addr_msg_id; } else if(ts && !addr_msg_id) { msg_id = ts; } else if(ts && addr_msg_id) { msg_id = axutil_strcat(env, addr_msg_id, ts, NULL); } else { msg_id = NULL; } if(!msg_id) { /* using default msg id */ msg_id = "RAMPART-DEFAULT-TS"; AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart]No msg_id specified, using default = %s", msg_id); } ll = axutil_linked_list_create(env); if(!ll) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Linked list creation failed."); return AXIS2_FAILURE; } status = rampart_replay_detector_read_file(env, ll); if(status != AXIS2_SUCCESS) { /* we have to clear linked list. We don't need to write the contents. So pass false to * denote whether to write the content */ rampart_replay_detector_write_file(env, ll, AXIS2_FALSE); return AXIS2_FAILURE; } else { /* Get the number of records to be kept */ if(rampart_context_get_rd_val(rampart_context, env)) { max_rcds = axutil_atoi(rampart_context_get_rd_val(rampart_context, env)); AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart]Using the specified max_rcds %d\n", max_rcds ); } else { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart]Using the default max_rcds %d\n", max_rcds ); } /* If the table already have the same key it's a replay */ if(rampart_replay_detector_check_in_linked_list(ll, env, (void*)msg_id)) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]For ID=%s, a replay detected", msg_id); rampart_replay_detector_write_file(env, ll, AXIS2_FALSE); return AXIS2_FAILURE; } /* if number of records saved are more than allowed, we have to remove them */ while(axutil_linked_list_size(ll, env) >= max_rcds) { axis2_char_t *tmp_msg_id = NULL; tmp_msg_id = (axis2_char_t*)axutil_linked_list_remove_first(ll, env); AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart]Deleting record %s\n", tmp_msg_id ); AXIS2_FREE(env->allocator, tmp_msg_id); tmp_msg_id = NULL; } /* Add current record */ status = axutil_linked_list_add(ll, env, (void*)axutil_strdup(env,msg_id)); if(status == AXIS2_SUCCESS) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart]Adding record %s\n", msg_id ); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,"[rampart]Cannot add record %s\n", msg_id); rampart_replay_detector_write_file(env, ll, AXIS2_FALSE); return AXIS2_FAILURE; } status = rampart_replay_detector_write_file(env, ll, AXIS2_TRUE); axutil_linked_list_free(ll, env); if(status == AXIS2_SUCCESS) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart]Writing records to file succeed." ); return AXIS2_SUCCESS; } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,"[rampart]Writing records to file failed"); return AXIS2_FAILURE; } } }
WSF_WSDL_EXTERN axis2_bool_t WSF_WSDL_CALL wsf_wsdl_request( const axutil_env_t* env, axis2_char_t* wsdl_file_name, const axis2_char_t* operation_name, wsf_wsdl_data_t* parameters, axis2_char_t* script_binding_home, axis2_svc_client_t* svc_client, axutil_hash_t* svc_client_user_options, axis2_char_t* service_name, axis2_char_t* port_name, wsf_wsdl_data_t** response) { int soap_version = 2; int has_fault = AXIS2_FALSE; int binding_style = WSDL_BINDING_STYLE_DOC_LIT_W; axis2_char_t* payload = NULL; axiom_node_t* payload_node = NULL; axis2_char_t* request_buffer = NULL; axiom_node_t* type_map = NULL; axis2_char_t *res_text = NULL; axiom_node_t* sig_axiom = NULL; axiom_node_t *fault_node = NULL; axiom_node_t* wsdl_axiom = NULL; axiom_node_t* params_node = NULL; axiom_node_t* returns_node = NULL; axiom_soap_body_t *soap_body = NULL; axiom_node_t *body_base_node = NULL; /*axis2_char_t *wrapper_element = NULL;*/ axiom_node_t* operation_axiom = NULL; axiom_soap_fault_t *soap_fault = NULL; axis2_options_t *client_options = NULL; /*axis2_char_t *wrapper_element_ns = NULL;*/ /*axiom_node_t *axiom_soap_base_node = NULL; */ axiom_soap_envelope_t *response_envelope = NULL; wsf_wsdl_data_template_t* input_template = NULL; wsf_wsdl_data_template_t* output_template = NULL; axis2_bool_t is_version1_wsdl = AXIS2_FALSE; axis2_char_t* xslt_location = NULL; axis2_char_t* type_map_file = NULL; AXIS2_LOG_TRACE_MSG(env->log, "Starting execution of wsf_wsdl_request..."); xslt_location = axutil_strcat(env, script_binding_home, WSF_WSDL_XSLT_LOCATION_POSTFIX, NULL); type_map_file = axutil_strcat(env, script_binding_home, WSF_WSDL_TYPE_MAP_POSTFIX, NULL); client_options = (axis2_options_t *)axis2_svc_client_get_options(svc_client, env); axis2_options_set_xml_parser_reset(client_options, env, AXIS2_FALSE); if (!wsf_wsdl_parser_load_wsdl(env, wsdl_file_name, xslt_location, &wsdl_axiom, &sig_axiom, &is_version1_wsdl, AXIS2_FALSE)) return AXIS2_FALSE; wsdl_util_create_type_map(env, type_map_file, &type_map); wsdl_util_manage_client_options(env, svc_client, svc_client_user_options, client_options, operation_name, wsdl_axiom, is_version1_wsdl, sig_axiom, service_name, port_name, &operation_axiom, &soap_version); wsdl_util_identify_binding_style(env, operation_axiom, &binding_style); if (!operation_axiom) { AXIS2_LOG_ERROR_MSG(env->log, "Operation axiom is NULL"); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; } wsdl_util_get_params_node(env, operation_axiom, ¶ms_node); wsdl_util_get_returns_node(env, operation_axiom, &returns_node); wsdl_data_util_axiom_to_template(env, params_node, &input_template); wsdl_data_util_axiom_to_template(env, returns_node, &output_template); #ifdef WSDL_DEBUG_MODE { axis2_char_t* buffer = NULL; wsdl_data_util_serialize_data(env, parameters, &buffer); AXIS2_LOG_DEBUG_MSG(env->log, buffer); AXIS2_FREE(env->allocator, buffer); wsdl_data_util_serialize_template(env, input_template, &buffer); AXIS2_LOG_DEBUG_MSG(env->log, buffer); AXIS2_FREE(env->allocator, buffer); buffer = NULL; } #endif if (wsdl_data_util_validate_data(env, type_map, input_template, parameters, VALIDATION_CRITERIA_REQUEST_MODE_TYPE) == AXIS2_TRUE) { payload_node = wsdl_data_util_create_payload(env, parameters, binding_style); payload = payload_node? axiom_node_to_string(payload_node, env) : NULL; // axiom_node_free_tree(payload_node, env); } else { AXIS2_LOG_ERROR_MSG(env->log, "User data is not valid or not in proper format"); if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; } if (!payload_node) { AXIS2_LOG_ERROR_MSG(env->log, "Request payload is not found"); if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; } request_buffer = (axis2_char_t*)wsdl_util_create_request_envelope(env, payload_node, soap_version); if (!request_buffer) { AXIS2_LOG_ERROR_MSG(env->log, "Error in creating request payload dom"); if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; } response_envelope = (axiom_soap_envelope_t*)wsdl_util_send_receive_soap_envelope_with_op_client(env, svc_client, client_options, request_buffer); if (response_envelope) { has_fault = AXIS2_TRUE; soap_body = axiom_soap_envelope_get_body (response_envelope, env); if (soap_body) { soap_fault = axiom_soap_body_get_fault (soap_body, env); } if (soap_fault) { soap_version = axis2_options_get_soap_version(client_options, env); fault_node = axiom_soap_fault_get_base_node(soap_fault, env); if (fault_node) { res_text = axiom_node_to_string(fault_node, env); AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI, "Fault payload is %s", res_text); if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; } } if (soap_body) { body_base_node = axiom_soap_body_get_base_node(soap_body, env); } if (body_base_node && !soap_fault) { axis2_char_t *response_buffer = NULL; wsf_wsdl_data_t *response_data = NULL; response_buffer = axiom_node_to_string(body_base_node, env); AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI, "Response buffer is %s", response_buffer); AXIS2_FREE(env->allocator, response_buffer); wsdl_data_util_axiom_to_data(env, body_base_node, &response_data); #ifdef WSDL_DEBUG_MODE { axis2_char_t* buffer = NULL; wsdl_data_util_serialize_data(env, response_data, &buffer); AXIS2_LOG_DEBUG_MSG(env->log, buffer); AXIS2_FREE(env->allocator, buffer); wsdl_data_util_serialize_template(env, output_template, &buffer); AXIS2_LOG_DEBUG_MSG(env->log, buffer); AXIS2_FREE(env->allocator, buffer); buffer = NULL; } #endif if (wsdl_data_util_validate_data(env, type_map, output_template, response_data, VALIDATION_CRITERIA_RESPONSE_MODE) == AXIS2_TRUE) { AXIS2_LOG_DEBUG_MSG(env->log, "Valid response!!!"); *response = response_data; if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_TRUE; } else { AXIS2_LOG_ERROR_MSG(env->log, "Response data is not valid or not in proper format"); if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; } } } else /* response_envelope == NULL */ { AXIS2_LOG_ERROR_MSG(env->log, "Response envelope not found"); } if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; }
axiom_node_t* AXIS2_CALL adb_supportedContentFormats_type0_serialize_obj( adb_supportedContentFormats_type0_t* _supportedContentFormats_type0, const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index) { axis2_char_t *string_to_stream; axiom_node_t* current_node = NULL; int tag_closed = 0; axis2_char_t* xsi_prefix = NULL; axiom_namespace_t* xsi_ns = NULL; axiom_attribute_t* xsi_type_attri = NULL; axis2_char_t* type_attrib = NULL; axiom_namespace_t *ns1 = NULL; axis2_char_t *qname_uri = NULL; axis2_char_t *qname_prefix = NULL; axis2_char_t *p_prefix = NULL; axis2_bool_t ns_already_defined; int i = 0; int count = 0; void *element = NULL; axis2_char_t *text_value_1; axis2_char_t *text_value_1_temp; axis2_char_t *start_input_str = NULL; axis2_char_t *end_input_str = NULL; unsigned int start_input_str_len = 0; unsigned int end_input_str_len = 0; axiom_data_source_t *data_source = NULL; axutil_stream_t *stream = NULL; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _supportedContentFormats_type0, NULL); current_node = parent; data_source = (axiom_data_source_t *)axiom_node_get_data_element(current_node, env); if (!data_source) return NULL; stream = axiom_data_source_get_stream(data_source, env); /* assume parent is of type data source */ if (!stream) return NULL; if(!parent_tag_closed) { if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING))) { /* it is better to stick with the standard prefix */ xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi"); axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix); if(parent_element) { axiom_namespace_t *element_ns = NULL; element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance", xsi_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns); if(element_ns) { axiom_namespace_free(element_ns, env); } } } type_attrib = axutil_strcat(env, " ", xsi_prefix, ":type=\"supportedContentFormats_type0\"", NULL); axutil_stream_write(stream, env, type_attrib, axutil_strlen(type_attrib)); AXIS2_FREE(env->allocator, type_attrib); string_to_stream = ">"; axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); tag_closed = 1; } else { /* if the parent tag closed we would be able to declare the type directly on the parent element */ if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING))) { /* it is better to stick with the standard prefix */ xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi"); axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix); if(parent_element) { axiom_namespace_t *element_ns = NULL; element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance", xsi_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns); if(element_ns) { axiom_namespace_free(element_ns, env); } } } } xsi_ns = axiom_namespace_create (env, "http://www.daisy.org/ns/daisy-online/", xsi_prefix); xsi_type_attri = axiom_attribute_create (env, "type", "supportedContentFormats_type0", xsi_ns); axiom_element_add_attribute (parent_element, env, xsi_type_attri, parent); if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.daisy.org/ns/daisy-online/", AXIS2_HASH_KEY_STRING))) { p_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof (axis2_char_t) * ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT); sprintf(p_prefix, "n%d", (*next_ns_index)++); axutil_hash_set(namespaces, "http://www.daisy.org/ns/daisy-online/", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://www.daisy.org/ns/daisy-online/", p_prefix)); } if (!_supportedContentFormats_type0->is_valid_contentFormat) { /* no need to complain for minoccurs=0 element */ } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("contentFormat"))); /* axutil_strlen("<:>") + 1 = 4 */ end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (5 + axutil_strlen(p_prefix) + axutil_strlen("contentFormat"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * Parsing contentFormat array */ if (_supportedContentFormats_type0->property_contentFormat != NULL) { sprintf(start_input_str, "<%s%scontentFormat>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%scontentFormat>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); count = axutil_array_list_size(_supportedContentFormats_type0->property_contentFormat, env); for(i = 0; i < count; i ++) { element = axutil_array_list_get(_supportedContentFormats_type0->property_contentFormat, env, i); if(NULL == element) { continue; } /* * parsing contentFormat element */ text_value_1 = (axis2_char_t*)element; axutil_stream_write(stream, env, start_input_str, start_input_str_len); text_value_1_temp = axutil_xml_quote_string(env, text_value_1, AXIS2_TRUE); if (text_value_1_temp) { axutil_stream_write(stream, env, text_value_1_temp, axutil_strlen(text_value_1_temp)); AXIS2_FREE(env->allocator, text_value_1_temp); } else { axutil_stream_write(stream, env, text_value_1, axutil_strlen(text_value_1)); } axutil_stream_write(stream, env, end_input_str, end_input_str_len); } } AXIS2_FREE(env->allocator,start_input_str); AXIS2_FREE(env->allocator,end_input_str); } return parent; }
axiom_node_t* AXIS2_CALL adb_TransformTypeChoice_serialize_obj( adb_TransformTypeChoice_t* _TransformTypeChoice, const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index) { axis2_char_t *string_to_stream; axiom_node_t* current_node = NULL; int tag_closed = 0; axis2_char_t* xsi_prefix = NULL; axiom_namespace_t* xsi_ns = NULL; axiom_attribute_t* xsi_type_attri = NULL; axis2_char_t* type_attrib = NULL; axiom_namespace_t *ns1 = NULL; axis2_char_t *qname_uri = NULL; axis2_char_t *qname_prefix = NULL; axis2_char_t *p_prefix = NULL; axis2_bool_t ns_already_defined; axis2_char_t *text_value_1; axis2_char_t *text_value_1_temp; axis2_char_t *text_value_2; axis2_char_t *text_value_2_temp; axis2_char_t *start_input_str = NULL; axis2_char_t *end_input_str = NULL; unsigned int start_input_str_len = 0; unsigned int end_input_str_len = 0; axiom_data_source_t *data_source = NULL; axutil_stream_t *stream = NULL; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _TransformTypeChoice, NULL); current_node = parent; data_source = (axiom_data_source_t *)axiom_node_get_data_element(current_node, env); if (!data_source) return NULL; stream = axiom_data_source_get_stream(data_source, env); /* assume parent is of type data source */ if (!stream) return NULL; if(!parent_tag_closed) { if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING))) { /* it is better to stick with the standard prefix */ xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi"); axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix); if(parent_element) { axiom_namespace_t *element_ns = NULL; element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance", xsi_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns); if(element_ns) { axiom_namespace_free(element_ns, env); } } } type_attrib = axutil_strcat(env, " ", xsi_prefix, ":type=\"TransformTypeChoice\"", NULL); axutil_stream_write(stream, env, type_attrib, axutil_strlen(type_attrib)); AXIS2_FREE(env->allocator, type_attrib); string_to_stream = ">"; axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); tag_closed = 1; } else { /* if the parent tag closed we would be able to declare the type directly on the parent element */ if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING))) { /* it is better to stick with the standard prefix */ xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi"); axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix); if(parent_element) { axiom_namespace_t *element_ns = NULL; element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance", xsi_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns); if(element_ns) { axiom_namespace_free(element_ns, env); } } } } xsi_ns = axiom_namespace_create (env, "http://www.w3.org/2000/09/xmldsig#", xsi_prefix); xsi_type_attri = axiom_attribute_create (env, "type", "TransformTypeChoice", xsi_ns); axiom_element_add_attribute (parent_element, env, xsi_type_attri, parent); if(0 == axutil_strcmp(_TransformTypeChoice->current_choice, ":extraElement")) { p_prefix = NULL; if (!_TransformTypeChoice->is_valid_extraElement) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property extraElement"); return NULL; } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("extraElement"))); /* axutil_strlen("<:>") + 1 = 4 */ end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (5 + axutil_strlen(p_prefix) + axutil_strlen("extraElement"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing extraElement element */ sprintf(start_input_str, "<%s%sextraElement>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sextraElement>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); text_value_1 = axiom_node_to_string(_TransformTypeChoice->property_extraElement, env); axutil_stream_write(stream, env, text_value_1, axutil_strlen(text_value_1)); AXIS2_FREE(env->allocator,start_input_str); AXIS2_FREE(env->allocator,end_input_str); } } if(0 == axutil_strcmp(_TransformTypeChoice->current_choice, "http://www.w3.org/2000/09/xmldsig#:XPath")) { if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2000/09/xmldsig#", AXIS2_HASH_KEY_STRING))) { p_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof (axis2_char_t) * ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT); sprintf(p_prefix, "n%d", (*next_ns_index)++); axutil_hash_set(namespaces, "http://www.w3.org/2000/09/xmldsig#", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://www.w3.org/2000/09/xmldsig#", p_prefix)); } if (!_TransformTypeChoice->is_valid_XPath) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property XPath"); return NULL; } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("XPath"))); /* axutil_strlen("<:>") + 1 = 4 */ end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (5 + axutil_strlen(p_prefix) + axutil_strlen("XPath"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing XPath element */ sprintf(start_input_str, "<%s%sXPath>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sXPath>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); text_value_2 = _TransformTypeChoice->property_XPath; axutil_stream_write(stream, env, start_input_str, start_input_str_len); text_value_2_temp = axutil_xml_quote_string(env, text_value_2, AXIS2_TRUE); if (text_value_2_temp) { axutil_stream_write(stream, env, text_value_2_temp, axutil_strlen(text_value_2_temp)); AXIS2_FREE(env->allocator, text_value_2_temp); } else { axutil_stream_write(stream, env, text_value_2, axutil_strlen(text_value_2)); } axutil_stream_write(stream, env, end_input_str, end_input_str_len); AXIS2_FREE(env->allocator,start_input_str); AXIS2_FREE(env->allocator,end_input_str); } } return parent; }
/** * 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; }
axiom_node_t* AXIS2_CALL adb_KeyPairType_serialize_obj( adb_KeyPairType_t* _KeyPairType, const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index) { axis2_char_t *string_to_stream; axiom_node_t* current_node = NULL; int tag_closed = 0; axis2_char_t* xsi_prefix = NULL; axiom_namespace_t* xsi_ns = NULL; axiom_attribute_t* xsi_type_attri = NULL; axis2_char_t* type_attrib = NULL; axiom_namespace_t *ns1 = NULL; axis2_char_t *qname_uri = NULL; axis2_char_t *qname_prefix = NULL; axis2_char_t *p_prefix = NULL; axis2_bool_t ns_already_defined; axis2_char_t text_value_1[ADB_DEFAULT_DIGIT_LIMIT]; axis2_char_t text_value_2[ADB_DEFAULT_DIGIT_LIMIT]; axis2_char_t *start_input_str = NULL; axis2_char_t *end_input_str = NULL; unsigned int start_input_str_len = 0; unsigned int end_input_str_len = 0; axiom_data_source_t *data_source = NULL; axutil_stream_t *stream = NULL; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _KeyPairType, NULL); current_node = parent; data_source = (axiom_data_source_t *)axiom_node_get_data_element(current_node, env); if (!data_source) return NULL; stream = axiom_data_source_get_stream(data_source, env); /* assume parent is of type data source */ if (!stream) return NULL; if(!parent_tag_closed) { if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING))) { /* it is better to stick with the standard prefix */ xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi"); axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix); if(parent_element) { axiom_namespace_t *element_ns = NULL; element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance", xsi_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns); if(element_ns) { axiom_namespace_free(element_ns, env); } } } type_attrib = axutil_strcat(env, " ", xsi_prefix, ":type=\"KeyPairType\"", NULL); axutil_stream_write(stream, env, type_attrib, axutil_strlen(type_attrib)); AXIS2_FREE(env->allocator, type_attrib); string_to_stream = ">"; axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); tag_closed = 1; } else { /* if the parent tag closed we would be able to declare the type directly on the parent element */ if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING))) { /* it is better to stick with the standard prefix */ xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi"); axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix); if(parent_element) { axiom_namespace_t *element_ns = NULL; element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance", xsi_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns); if(element_ns) { axiom_namespace_free(element_ns, env); } } } } xsi_ns = axiom_namespace_create (env, "http://www.daisy.org/DRM/2005/KeyExchange", xsi_prefix); xsi_type_attri = axiom_attribute_create (env, "type", "KeyPairType", xsi_ns); axiom_element_add_attribute (parent_element, env, xsi_type_attri, parent); if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2000/09/xmldsig#", AXIS2_HASH_KEY_STRING))) { p_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof (axis2_char_t) * ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT); sprintf(p_prefix, "n%d", (*next_ns_index)++); axutil_hash_set(namespaces, "http://www.w3.org/2000/09/xmldsig#", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://www.w3.org/2000/09/xmldsig#", p_prefix)); } if (!_KeyPairType->is_valid_KeyInfo) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property KeyInfo"); return NULL; } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("KeyInfo"))); /* axutil_strlen("<:>") + 1 = 4 */ end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (5 + axutil_strlen(p_prefix) + axutil_strlen("KeyInfo"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing KeyInfo element */ sprintf(start_input_str, "<%s%sKeyInfo", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sKeyInfo>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); if(!adb_KeyInfoType_is_particle()) { axutil_stream_write(stream, env, start_input_str, start_input_str_len); } adb_KeyInfoType_serialize(_KeyPairType->property_KeyInfo, env, current_node, parent_element, adb_KeyInfoType_is_particle() || AXIS2_FALSE, namespaces, next_ns_index); if(!adb_KeyInfoType_is_particle()) { axutil_stream_write(stream, env, end_input_str, end_input_str_len); } AXIS2_FREE(env->allocator,start_input_str); AXIS2_FREE(env->allocator,end_input_str); } if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/04/xmlenc#", AXIS2_HASH_KEY_STRING))) { p_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof (axis2_char_t) * ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT); sprintf(p_prefix, "n%d", (*next_ns_index)++); axutil_hash_set(namespaces, "http://www.w3.org/2001/04/xmlenc#", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://www.w3.org/2001/04/xmlenc#", p_prefix)); } if (!_KeyPairType->is_valid_EncryptedKey) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property EncryptedKey"); return NULL; } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("EncryptedKey"))); /* axutil_strlen("<:>") + 1 = 4 */ end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (5 + axutil_strlen(p_prefix) + axutil_strlen("EncryptedKey"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing EncryptedKey element */ sprintf(start_input_str, "<%s%sEncryptedKey", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sEncryptedKey>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); if(!adb_EncryptedKeyType_is_particle()) { axutil_stream_write(stream, env, start_input_str, start_input_str_len); } adb_EncryptedKeyType_serialize(_KeyPairType->property_EncryptedKey, env, current_node, parent_element, adb_EncryptedKeyType_is_particle() || AXIS2_FALSE, namespaces, next_ns_index); if(!adb_EncryptedKeyType_is_particle()) { axutil_stream_write(stream, env, end_input_str, end_input_str_len); } AXIS2_FREE(env->allocator,start_input_str); AXIS2_FREE(env->allocator,end_input_str); } return parent; }
axis2_status_t AXIS2_CALL reg_client_rest_client_delete( reg_client_rest_client_t *rest_client, const axutil_env_t *env, const axis2_char_t *url, const axutil_array_list_t *params) { CURL *curl_handle; CURLcode res; int size = 0, i = 0; axis2_char_t *params_str = "?"; axis2_char_t *temp_str = NULL; axis2_status_t status = AXIS2_FAILURE; if(params) { size = axutil_array_list_size((axutil_array_list_t *) params, env); } for(i = 0; i < size; i++) { reg_client_url_param_t *url_param = NULL; axis2_char_t *key = NULL; axis2_char_t *encoded_key = NULL; axis2_char_t *value = NULL; axis2_char_t *encoded_value = NULL; url_param = axutil_array_list_get((axutil_array_list_t *) params, env, i); key = url_param->key; value = url_param->value; encoded_key = (axis2_char_t *) AXIS2_MALLOC (env->allocator, strlen (key)); memset (encoded_key, 0, strlen (key)); encoded_key = axutil_url_encode (env, encoded_key, key, (int)strlen (key)); encoded_value = (axis2_char_t *) AXIS2_MALLOC (env->allocator, strlen (value)); memset (encoded_value, 0, strlen (value)); encoded_value = axutil_url_encode (env, encoded_value, value, (int)strlen (value)); temp_str = params_str; params_str = axutil_strcat(env, temp_str, encoded_key, "=", encoded_value, "&", NULL); if(temp_str) { AXIS2_FREE(env->allocator, temp_str); temp_str = NULL; } if(encoded_key) { AXIS2_FREE(env->allocator, encoded_key); encoded_key = NULL; } if(encoded_value) { AXIS2_FREE(env->allocator, encoded_value); encoded_value = NULL; } } temp_str = (axis2_char_t *) axutil_strdup(env, url); url = axutil_strcat(env, temp_str, params_str, NULL); if(temp_str) { AXIS2_FREE(env->allocator, temp_str); temp_str = NULL; } curl_handle = curl_easy_init(); if(curl_handle) { curl_easy_setopt(curl_handle, CURLOPT_URL, url); curl_easy_setopt(curl_handle, CURLOPT_CUSTOMREQUEST, "DELETE"); /*curl_easy_setopt(curl_handle, CURLOPT_RETURNTRANSFER, 1);*/ curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, REG_CLIENT_USER_AGENT); if(rest_client->username) { axis2_char_t *uname_passwd = NULL; uname_passwd = axutil_strcat(env, rest_client->username, ":", rest_client->password, NULL); curl_easy_setopt(curl_handle, CURLOPT_USERPWD, uname_passwd); } res = curl_easy_perform(curl_handle); if(res == CURLE_OK) { res = curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &rest_client->status); if(res != CURLE_OK) { status = AXIS2_FAILURE; } } /* always cleanup */ curl_easy_cleanup(curl_handle); } return status; }
axiom_node_t* AXIS2_CALL adb_OperationMetaDataWrapper_serialize_obj( adb_OperationMetaDataWrapper_t* _OperationMetaDataWrapper, const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index) { axis2_char_t *string_to_stream; axiom_node_t* current_node = NULL; int tag_closed = 0; axis2_char_t* xsi_prefix = NULL; axis2_char_t* type_attrib = NULL; axiom_namespace_t* xsi_ns = NULL; axiom_attribute_t* xsi_type_attri = NULL; axiom_namespace_t *ns1 = NULL; axis2_char_t *qname_uri = NULL; axis2_char_t *qname_prefix = NULL; axis2_char_t *p_prefix = NULL; axis2_bool_t ns_already_defined; int i = 0; int count = 0; void *element = NULL; axis2_char_t text_value_1[ADB_DEFAULT_DIGIT_LIMIT]; axis2_char_t text_value_2[ADB_DEFAULT_DIGIT_LIMIT]; axis2_char_t *start_input_str = NULL; axis2_char_t *end_input_str = NULL; unsigned int start_input_str_len = 0; unsigned int end_input_str_len = 0; axiom_data_source_t *data_source = NULL; axutil_stream_t *stream = NULL; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _OperationMetaDataWrapper, NULL); current_node = parent; data_source = (axiom_data_source_t *)axiom_node_get_data_element(current_node, env); if (!data_source) return NULL; stream = axiom_data_source_get_stream(data_source, env); /* assume parent is of type data source */ if (!stream) return NULL; if(!parent_tag_closed) { if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING))) { /* it is better to stick with the standard prefix */ xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi"); axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix); if(parent_element) { axiom_namespace_t *element_ns = NULL; element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance", xsi_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns); } } type_attrib = axutil_strcat(env, " ", xsi_prefix, ":type=\"OperationMetaDataWrapper\"", NULL); axutil_stream_write(stream, env, type_attrib, axutil_strlen(type_attrib)); AXIS2_FREE(env->allocator, type_attrib); string_to_stream = ">"; axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); tag_closed = 1; } else { /* if the parent tag closed we would be able to declare the type directly on the parent element */ if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING))) { /* it is better to stick with the standard prefix */ xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi"); axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix); if(parent_element) { axiom_namespace_t *element_ns = NULL; element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance", xsi_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns); } } } xsi_ns = axiom_namespace_create (env, "http://mgt.operation.carbon.wso2.org/xsd", xsi_prefix); xsi_type_attri = axiom_attribute_create (env, "type", "OperationMetaDataWrapper", xsi_ns); axiom_element_add_attribute (parent_element, env, xsi_type_attri, parent); if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://mgt.operation.carbon.wso2.org/xsd", AXIS2_HASH_KEY_STRING))) { p_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof (axis2_char_t) * ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT); sprintf(p_prefix, "n%d", (*next_ns_index)++); axutil_hash_set(namespaces, "http://mgt.operation.carbon.wso2.org/xsd", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://mgt.operation.carbon.wso2.org/xsd", p_prefix)); } if (!_OperationMetaDataWrapper->is_valid_controlOperations) { /* no need to complain for minoccurs=0 element */ } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("controlOperations"))); /* axutil_strlen("<:>") + 1 = 4 */ end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (5 + axutil_strlen(p_prefix) + axutil_strlen("controlOperations"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * Parsing controlOperations array */ if (_OperationMetaDataWrapper->property_controlOperations != NULL) { sprintf(start_input_str, "<%s%scontrolOperations", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%scontrolOperations>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); count = axutil_array_list_size(_OperationMetaDataWrapper->property_controlOperations, env); for(i = 0; i < count; i ++) { element = axutil_array_list_get(_OperationMetaDataWrapper->property_controlOperations, env, i); if(NULL == element) { continue; } /* * parsing controlOperations element */ if(!adb_OperationMetaData_is_particle()) { axutil_stream_write(stream, env, start_input_str, start_input_str_len); } adb_OperationMetaData_serialize((adb_OperationMetaData_t*)element, env, current_node, parent_element, adb_OperationMetaData_is_particle() || AXIS2_FALSE, namespaces, next_ns_index); if(!adb_OperationMetaData_is_particle()) { axutil_stream_write(stream, env, end_input_str, end_input_str_len); } } } AXIS2_FREE(env->allocator,start_input_str); AXIS2_FREE(env->allocator,end_input_str); } if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://mgt.operation.carbon.wso2.org/xsd", AXIS2_HASH_KEY_STRING))) { p_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof (axis2_char_t) * ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT); sprintf(p_prefix, "n%d", (*next_ns_index)++); axutil_hash_set(namespaces, "http://mgt.operation.carbon.wso2.org/xsd", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://mgt.operation.carbon.wso2.org/xsd", p_prefix)); } if (!_OperationMetaDataWrapper->is_valid_publishedOperations) { /* no need to complain for minoccurs=0 element */ } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("publishedOperations"))); /* axutil_strlen("<:>") + 1 = 4 */ end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (5 + axutil_strlen(p_prefix) + axutil_strlen("publishedOperations"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * Parsing publishedOperations array */ if (_OperationMetaDataWrapper->property_publishedOperations != NULL) { sprintf(start_input_str, "<%s%spublishedOperations", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%spublishedOperations>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); count = axutil_array_list_size(_OperationMetaDataWrapper->property_publishedOperations, env); for(i = 0; i < count; i ++) { element = axutil_array_list_get(_OperationMetaDataWrapper->property_publishedOperations, env, i); if(NULL == element) { continue; } /* * parsing publishedOperations element */ if(!adb_OperationMetaData_is_particle()) { axutil_stream_write(stream, env, start_input_str, start_input_str_len); } adb_OperationMetaData_serialize((adb_OperationMetaData_t*)element, env, current_node, parent_element, adb_OperationMetaData_is_particle() || AXIS2_FALSE, namespaces, next_ns_index); if(!adb_OperationMetaData_is_particle()) { axutil_stream_write(stream, env, end_input_str, end_input_str_len); } } } AXIS2_FREE(env->allocator,start_input_str); AXIS2_FREE(env->allocator,end_input_str); } return parent; }
axiom_node_t* AXIS2_CALL adb_lang_type0_serialize_obj( adb_lang_type0_t* _lang_type0, const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index) { axiom_node_t* current_node = NULL; int tag_closed = 0; axis2_char_t* xsi_prefix = NULL; axiom_namespace_t* xsi_ns = NULL; axiom_attribute_t* xsi_type_attri = NULL; axiom_data_source_t *data_source = NULL; axutil_stream_t *stream = NULL; axis2_char_t *text_value; current_node = parent; data_source = (axiom_data_source_t *)axiom_node_get_data_element(current_node, env); if (!data_source) return NULL; stream = axiom_data_source_get_stream(data_source, env); /* assume parent is of type data source */ if (!stream) return NULL; /* here we need to declare the union type in the xsi:type field */ if(axutil_strcmp(_lang_type0->current_value, "")) { if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING))) { /* it is better to stick with the standard prefix */ xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi"); axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix); if(parent_element) { axiom_namespace_t *element_ns = NULL; element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance", xsi_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns); } } if(!axutil_strcmp(_lang_type0->current_value, "language")) { axis2_char_t *ns_prefix = NULL; if(!(ns_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema", AXIS2_HASH_KEY_STRING))) { ns_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof (axis2_char_t) * ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT); sprintf(ns_prefix, "q%d", (*next_ns_index)++); axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema", AXIS2_HASH_KEY_STRING, ns_prefix); if(parent_element) { axiom_namespace_t *element_ns = NULL; element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema", ns_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns); } } /* now we will set the xsi:type="ns:type" value */ if(!parent_tag_closed && !tag_closed) { text_value = axutil_strcat(env, xsi_prefix, ":type=", ns_prefix, ":", _lang_type0->current_value, NULL); axutil_stream_write(stream, env, text_value, axutil_strlen(text_value)); AXIS2_FREE(env->allocator, text_value); } else { /* otherwise set it to the prarent itself */ axiom_namespace_t *ns1 = NULL; axiom_attribute_t *attrib = NULL; ns1 = axiom_namespace_create (env, "http://www.w3.org/2001/XMLSchema-instance", xsi_prefix); text_value = axutil_strcat(env, ns_prefix, ":", _lang_type0->current_value, NULL); attrib = axiom_attribute_create (env, "type", text_value, ns1); axiom_element_add_attribute (parent_element, env, attrib, parent); AXIS2_FREE(env->allocator, text_value); } } } if(!parent_tag_closed && !tag_closed) { text_value = ">"; axutil_stream_write(stream, env, text_value, axutil_strlen(text_value)); } text_value = adb_lang_type0_serialize_to_string(_lang_type0, env, namespaces); if(text_value) { axutil_stream_write(stream, env, text_value, axutil_strlen(text_value)); AXIS2_FREE(env->allocator, text_value); } return parent; }
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; }
/** * 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; }
/** * auto generated function definition signature * for "getKeyStores|http://service.keystore.security.carbon.wso2.org" operation. * @param env environment ( mandatory)* @param MessageContext the outmessage context * * @return adb_getKeyStoresResponse_t* */ adb_getKeyStoresResponse_t* axis2_skel_KeyStoreAdminService_getKeyStores(const axutil_env_t *env , axis2_msg_ctx_t *msg_ctx, axis2_skel_KeyStoreAdminService_getKeyStores_fault *fault ) { axis2_svc_t* svc = NULL; axutil_param_t* param = NULL; axis2_char_t* primary_keystore = NULL; axis2_bool_t is_primary_keystore = AXIS2_FALSE; axis2_conf_ctx_t* conf_ctx = NULL; axis2_conf_t* conf = NULL; axis2_char_t* repo_path = NULL; axutil_array_list_t* keystore_filenames = NULL; int keystore_file_count = 0; int index = 0; adb_getKeyStoresResponse_t* response = NULL; axis2_char_t* keystore_filename = NULL; axis2_char_t* keystore_name = NULL; axis2_char_t* extension = NULL; axis2_char_t* keystore_type = NULL; axis2_char_t* provider = NULL; axis2_bool_t private_store = AXIS2_FALSE; axis2_char_t* tok = NULL; adb_KeyStoreData_t* data = NULL; /* Get primary keystore filename */ svc = axis2_msg_ctx_get_svc(msg_ctx, env); param = axis2_svc_get_param(svc, env, "PrimaryKeystore"); if (param) { primary_keystore = (axis2_char_t*) axutil_param_get_value(param, env); } /* Form keystore directory name*/ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); conf = axis2_conf_ctx_get_conf(conf_ctx, env); repo_path = axis2_conf_get_repo(conf, env); /* Read file names in keystore directory */ keystore_filenames = keystore_admin_util_get_keystore_filenames( env, repo_path); if (!keystore_filenames) return NULL; /* Create response */ response = adb_getKeyStoresResponse_create(env); /* Fill data */ keystore_file_count = axutil_array_list_size(keystore_filenames, env); for (index = 0; index < keystore_file_count; ++index) { axis2_char_t* filename = NULL; keystore_filename = NULL; keystore_name = NULL; extension = NULL; keystore_type = NULL; provider = NULL; private_store = AXIS2_FALSE; tok = NULL; /* Get name */ filename = (axis2_char_t*)axutil_array_list_get(keystore_filenames, env, index); keystore_filename = axutil_strdup(env, filename); tok = strtok(filename, "."); if (tok) /* Keystore name */ { keystore_name = tok; tok = strtok(NULL, " ."); if (tok) /* Extension */ { extension = tok; } } if (NULL == extension) /* No extension found */ { AXIS2_FREE(env->allocator, filename); AXIS2_FREE(env->allocator, keystore_filename); keystore_filename = filename = NULL; continue; } if (0 == axutil_strcmp(extension, "p12")) /* PKCS12 */ { keystore_type = "PKCS12"; } else { AXIS2_FREE(env->allocator, filename); AXIS2_FREE(env->allocator, keystore_filename); keystore_filename = filename = NULL; continue; } is_primary_keystore = (0 == axutil_strcmp(keystore_filename, primary_keystore)) ? AXIS2_TRUE : AXIS2_FALSE; if (is_primary_keystore) { /* Primary keystore */ provider = axutil_strcat(env, " ", NULL); private_store = AXIS2_TRUE; } else { axis2_char_t password_tmp[10]; axis2_char_t provider_tmp[20]; axis2_char_t pvt_key_pass_tmp[10]; /* Get password, provider and pvt_key_pass */ if (!keystore_admin_util_get_keystore_details(env, repo_path, keystore_name, password_tmp, provider_tmp, pvt_key_pass_tmp)) { AXIS2_FREE(env->allocator, filename); AXIS2_FREE(env->allocator, keystore_filename); keystore_filename = filename = NULL; continue; } provider = axutil_strdup(env, provider_tmp); private_store = keystore_admin_util_get_private_store(env, repo_path, keystore_name, password_tmp); } data = adb_KeyStoreData_create(env); adb_KeyStoreData_set_keyStoreName(data, env, keystore_filename); adb_KeyStoreData_set_keyStoreType(data, env, keystore_type); adb_KeyStoreData_set_provider(data, env, provider); adb_KeyStoreData_set_privateStore(data, env, private_store); adb_getKeyStoresResponse_add_return(response, env, data); } axutil_array_list_free(keystore_filenames, env); return response; }
/** * auto generated function definition signature * for "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; }
axiom_node_t* AXIS2_CALL prf_logOnResponseType_serialize_obj( prf_logOnResponseType_t* _logOnResponseType, const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index) { axis2_char_t *string_to_stream; axiom_node_t* current_node = NULL; int tag_closed = 0; axis2_char_t* xsi_prefix = NULL; axiom_namespace_t* xsi_ns = NULL; axiom_attribute_t* xsi_type_attri = NULL; axis2_char_t* type_attrib = NULL; axiom_namespace_t *ns1 = NULL; axis2_char_t *qname_uri = NULL; axis2_char_t *qname_prefix = NULL; axis2_char_t *p_prefix = NULL; axis2_bool_t ns_already_defined; axis2_char_t text_value_1[PRF_DEFAULT_DIGIT_LIMIT]; axis2_char_t *start_input_str = NULL; axis2_char_t *end_input_str = NULL; unsigned int start_input_str_len = 0; unsigned int end_input_str_len = 0; axiom_data_source_t *data_source = NULL; axutil_stream_t *stream = NULL; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _logOnResponseType, NULL); current_node = parent; data_source = (axiom_data_source_t *)axiom_node_get_data_element(current_node, env); if (!data_source) return NULL; stream = axiom_data_source_get_stream(data_source, env); /* assume parent is of type data source */ if (!stream) return NULL; if(!parent_tag_closed) { if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING))) { /* it is better to stick with the standard prefix */ xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi"); axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix); if(parent_element) { axiom_namespace_t *element_ns = NULL; element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance", xsi_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns); if(element_ns) { axiom_namespace_free(element_ns, env); } } } type_attrib = axutil_strcat(env, " ", xsi_prefix, ":type=\"logOnResponseType\"", NULL); axutil_stream_write(stream, env, type_attrib, axutil_strlen(type_attrib)); AXIS2_FREE(env->allocator, type_attrib); string_to_stream = ">"; axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); tag_closed = 1; } else { /* if the parent tag closed we would be able to declare the type directly on the parent element */ if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING))) { /* it is better to stick with the standard prefix */ xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi"); axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix); if(parent_element) { axiom_namespace_t *element_ns = NULL; element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance", xsi_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns); if(element_ns) { axiom_namespace_free(element_ns, env); } } } } xsi_ns = axiom_namespace_create (env, "http://www.pratsam.org/ns/profile/", xsi_prefix); xsi_type_attri = axiom_attribute_create (env, "type", "logOnResponseType", xsi_ns); axiom_element_add_attribute (parent_element, env, xsi_type_attri, parent); if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.pratsam.org/ns/profile/", AXIS2_HASH_KEY_STRING))) { p_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof (axis2_char_t) * PRF_DEFAULT_NAMESPACE_PREFIX_LIMIT); sprintf(p_prefix, "n%d", (*next_ns_index)++); axutil_hash_set(namespaces, "http://www.pratsam.org/ns/profile/", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://www.pratsam.org/ns/profile/", p_prefix)); } if (!_logOnResponseType->is_valid_logOnResult) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property logOnResult"); return NULL; } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("logOnResult"))); /* axutil_strlen("<:>") + 1 = 4 */ end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (5 + axutil_strlen(p_prefix) + axutil_strlen("logOnResult"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing logOnResult element */ sprintf(start_input_str, "<%s%slogOnResult>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%slogOnResult>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); strcpy(text_value_1, (_logOnResponseType->property_logOnResult)?"true":"false"); axutil_stream_write(stream, env, start_input_str, start_input_str_len); axutil_stream_write(stream, env, text_value_1, axutil_strlen(text_value_1)); axutil_stream_write(stream, env, end_input_str, end_input_str_len); AXIS2_FREE(env->allocator,start_input_str); AXIS2_FREE(env->allocator,end_input_str); } return parent; }
axiom_node_t* AXIS2_CALL adb_Exception_serialize_obj( adb_Exception_t* _Exception, const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index) { axis2_char_t *string_to_stream; axiom_node_t* current_node = NULL; int tag_closed = 0; axis2_char_t* xsi_prefix = NULL; axis2_char_t* type_attrib = NULL; axiom_namespace_t* xsi_ns = NULL; axiom_attribute_t* xsi_type_attri = NULL; axiom_namespace_t *ns1 = NULL; axis2_char_t *qname_uri = NULL; axis2_char_t *qname_prefix = NULL; axis2_char_t *p_prefix = NULL; axis2_bool_t ns_already_defined; axis2_char_t *text_value_1; axis2_char_t *text_value_1_temp; axis2_char_t *start_input_str = NULL; axis2_char_t *end_input_str = NULL; unsigned int start_input_str_len = 0; unsigned int end_input_str_len = 0; axiom_data_source_t *data_source = NULL; axutil_stream_t *stream = NULL; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _Exception, NULL); current_node = parent; data_source = (axiom_data_source_t *)axiom_node_get_data_element(current_node, env); if (!data_source) return NULL; stream = axiom_data_source_get_stream(data_source, env); /* assume parent is of type data source */ if (!stream) return NULL; if(!parent_tag_closed) { if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING))) { /* it is better to stick with the standard prefix */ xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi"); axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix); if(parent_element) { axiom_namespace_t *element_ns = NULL; element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance", xsi_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns); } } type_attrib = axutil_strcat(env, " ", xsi_prefix, ":type=\"Exception\"", NULL); axutil_stream_write(stream, env, type_attrib, axutil_strlen(type_attrib)); AXIS2_FREE(env->allocator, type_attrib); string_to_stream = ">"; axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); tag_closed = 1; } else { /* if the parent tag closed we would be able to declare the type directly on the parent element */ if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING))) { /* it is better to stick with the standard prefix */ xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi"); axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix); if(parent_element) { axiom_namespace_t *element_ns = NULL; element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance", xsi_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns); } } } xsi_ns = axiom_namespace_create (env, "http://services.resource.ui.mgt.registry.carbon.wso2.org", xsi_prefix); xsi_type_attri = axiom_attribute_create (env, "type", "Exception", xsi_ns); axiom_element_add_attribute (parent_element, env, xsi_type_attri, parent); if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://services.resource.ui.mgt.registry.carbon.wso2.org", AXIS2_HASH_KEY_STRING))) { p_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof (axis2_char_t) * ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT); sprintf(p_prefix, "n%d", (*next_ns_index)++); axutil_hash_set(namespaces, "http://services.resource.ui.mgt.registry.carbon.wso2.org", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://services.resource.ui.mgt.registry.carbon.wso2.org", p_prefix)); } if (!_Exception->is_valid_Exception) { /* no need to complain for minoccurs=0 element */ } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("Exception"))); /* axutil_strlen("<:>") + 1 = 4 */ end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (5 + axutil_strlen(p_prefix) + axutil_strlen("Exception"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing Exception element */ sprintf(start_input_str, "<%s%sException>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sException>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); text_value_1 = axiom_node_to_string(_Exception->property_Exception, env); axutil_stream_write(stream, env, start_input_str, start_input_str_len); axutil_stream_write(stream, env, text_value_1, axutil_strlen(text_value_1)); axutil_stream_write(stream, env, end_input_str, end_input_str_len); AXIS2_FREE(env->allocator,start_input_str); AXIS2_FREE(env->allocator,end_input_str); } return parent; }
axiom_node_t* AXIS2_CALL adb_choice_type0_serialize_obj( adb_choice_type0_t* _choice_type0, const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index) { axiom_attribute_t *text_attri = NULL; axis2_char_t *string_to_stream; axiom_node_t* current_node = NULL; int tag_closed = 0; axis2_char_t* xsi_prefix = NULL; axiom_namespace_t* xsi_ns = NULL; axiom_attribute_t* xsi_type_attri = NULL; axis2_char_t* type_attrib = NULL; axiom_namespace_t *ns1 = NULL; axis2_char_t *qname_uri = NULL; axis2_char_t *qname_prefix = NULL; axis2_char_t *p_prefix = NULL; axis2_bool_t ns_already_defined; axis2_char_t text_value_1[ADB_DEFAULT_DIGIT_LIMIT]; axis2_char_t *text_value_2; axis2_char_t *text_value_2_temp; axis2_char_t *text_value = NULL; axis2_char_t *start_input_str = NULL; axis2_char_t *end_input_str = NULL; unsigned int start_input_str_len = 0; unsigned int end_input_str_len = 0; axiom_data_source_t *data_source = NULL; axutil_stream_t *stream = NULL; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _choice_type0, NULL); current_node = parent; data_source = (axiom_data_source_t *)axiom_node_get_data_element(current_node, env); if (!data_source) return NULL; stream = axiom_data_source_get_stream(data_source, env); /* assume parent is of type data source */ if (!stream) return NULL; if(!parent_tag_closed) { if(_choice_type0->is_valid_id) { p_prefix = NULL; text_value = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * (5 + ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT + axutil_strlen(_choice_type0->property_id) + axutil_strlen("id"))); sprintf(text_value, " %s%s%s=\"%s\"", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":"", "id", _choice_type0->property_id); axutil_stream_write(stream, env, text_value, axutil_strlen(text_value)); AXIS2_FREE(env-> allocator, text_value); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-optional attribute id"); return NULL; } if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING))) { /* it is better to stick with the standard prefix */ xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi"); axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix); if(parent_element) { axiom_namespace_t *element_ns = NULL; element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance", xsi_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns); if(element_ns) { axiom_namespace_free(element_ns, env); } } } type_attrib = axutil_strcat(env, " ", xsi_prefix, ":type=\"choice_type0\"", NULL); axutil_stream_write(stream, env, type_attrib, axutil_strlen(type_attrib)); AXIS2_FREE(env->allocator, type_attrib); string_to_stream = ">"; axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); tag_closed = 1; } else { /* if the parent tag closed we would be able to declare the type directly on the parent element */ if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING))) { /* it is better to stick with the standard prefix */ xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi"); axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix); if(parent_element) { axiom_namespace_t *element_ns = NULL; element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance", xsi_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns); if(element_ns) { axiom_namespace_free(element_ns, env); } } } } xsi_ns = axiom_namespace_create (env, "http://www.daisy.org/ns/daisy-online/", xsi_prefix); xsi_type_attri = axiom_attribute_create (env, "type", "choice_type0", xsi_ns); axiom_element_add_attribute (parent_element, env, xsi_type_attri, parent); if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.daisy.org/ns/daisy-online/", AXIS2_HASH_KEY_STRING))) { p_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof (axis2_char_t) * ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT); sprintf(p_prefix, "n%d", (*next_ns_index)++); axutil_hash_set(namespaces, "http://www.daisy.org/ns/daisy-online/", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://www.daisy.org/ns/daisy-online/", p_prefix)); } if (!_choice_type0->is_valid_label) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property label"); return NULL; } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("label"))); /* axutil_strlen("<:>") + 1 = 4 */ end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (5 + axutil_strlen(p_prefix) + axutil_strlen("label"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing label element */ sprintf(start_input_str, "<%s%slabel", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%slabel>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); if(!adb_label_type0_is_particle()) { axutil_stream_write(stream, env, start_input_str, start_input_str_len); } adb_label_type0_serialize(_choice_type0->property_label, env, current_node, parent_element, adb_label_type0_is_particle() || AXIS2_FALSE, namespaces, next_ns_index); if(!adb_label_type0_is_particle()) { axutil_stream_write(stream, env, end_input_str, end_input_str_len); } AXIS2_FREE(env->allocator,start_input_str); AXIS2_FREE(env->allocator,end_input_str); } if(parent_tag_closed) { if(_choice_type0->is_valid_id) { p_prefix = NULL; ns1 = NULL; text_value = _choice_type0->property_id; text_attri = axiom_attribute_create (env, "id", text_value, ns1); axiom_element_add_attribute (parent_element, env, text_attri, parent); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-optional attribute id"); return NULL; } } return parent; }
/** * 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; }
int add_subscriber() { remote_registry_t *remote_registry = NULL; const axutil_env_t *env = NULL; axis2_char_t *subscription_id = NULL; axis2_char_t *id = NULL; axis2_char_t *path = NULL; axis2_char_t *index_path = NULL; remote_registry_resource_t *res = NULL; axutil_hash_t *properties = NULL; char *content = (char *) strdup("<subscription><syn:endpoint xmlns:syn=\"http://ws.apache.org/ns/synapse\"><syn:address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" /></syn:endpoint></subscription>"); axis2_char_t *epr_type = "application/vnd.epr"; axis2_char_t *filter = "/weather/4/"; axis2_char_t *reg_url = "http://localhost:9762/registry"; env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE); subscription_id = axutil_strcat(env, "urn:uuid:", axutil_uuid_gen(env), NULL); path = axutil_strcat(env, filter, SUBSCRIPTION_COLLECTION_NAME, "/", subscription_id, NULL); id = axutil_strcat(env, reg_url, filter, SUBSCRIPTION_COLLECTION_NAME, "/", subscription_id, NULL); remote_registry = remote_registry_create(env, reg_url, "admin", "admin"); topic_index_init(); res = remote_registry_resource_create(env); remote_registry_resource_set_content(res, env, content); remote_registry_resource_set_content_len(res, env, axutil_strlen(content)); remote_registry_resource_set_media_type(res, env, epr_type); remote_registry_resource_set_description(res, env, ""); properties = axutil_hash_make(env); if(properties) { axutil_hash_set(properties, axutil_strdup(env, "expires"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "*")); axutil_hash_set(properties, axutil_strdup(env, "staticFlag"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "false")); axutil_hash_set(properties, axutil_strdup(env, "filterValue"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, filter)); axutil_hash_set(properties, axutil_strdup(env, "subManagerURI"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "http://10.100.1.44:8280/services/SampleEventSource")); axutil_hash_set(properties, axutil_strdup(env, "filterDialect"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "http://synapse.apache.org/eventing/dialect/topicFilter")); remote_registry_resource_set_properties(res, env, properties); } remote_registry_put(remote_registry, env, path, res); if(id) { AXIS2_FREE(env->allocator, id); } if(path) { AXIS2_FREE(env->allocator, path); path = NULL; } if(res) { remote_registry_resource_free(res, env); res = NULL; } res = remote_registry_get(remote_registry, env, TOPIC_INDEX, NULL); if(!res) { return 0; } id = axutil_strcat(env, reg_url, TOPIC_INDEX, NULL); properties = remote_registry_resource_get_properties(res, env); if(properties) { path = axutil_strcat(env, filter, SUBSCRIPTION_COLLECTION_NAME, NULL); axutil_hash_set(properties, subscription_id, AXIS2_HASH_KEY_STRING, path); remote_registry_resource_set_properties(res, env, properties); } remote_registry_resource_set_content(res, env, NULL); remote_registry_resource_set_content_len(res, env, 0); index_path = axutil_strcat(env, TOPIC_INDEX, "/TopicIndex", NULL); remote_registry_put(remote_registry, env, TOPIC_INDEX, res); if(id) { AXIS2_FREE(env->allocator, id); } if(res) { remote_registry_resource_free(res, env); res = NULL; } printf("\n"); return 0; }
axis2_status_t AXIS2_CALL reg_client_rest_client_get( reg_client_rest_client_t *rest_client, const axutil_env_t *env, const axis2_char_t *url, const axutil_array_list_t *params) { CURL *curl_handle; CURLcode res; int size = 0, i = 0; axis2_char_t *params_str = "?"; axis2_char_t *temp_str = NULL; axis2_status_t status = AXIS2_FAILURE; if(params) { size = axutil_array_list_size((axutil_array_list_t *) params, env); } for(i = 0; i < size; i++) { reg_client_url_param_t *url_param = NULL; axis2_char_t *key = NULL; axis2_char_t *encoded_key = NULL; axis2_char_t *value = NULL; axis2_char_t *encoded_value = NULL; url_param = axutil_array_list_get((axutil_array_list_t *) params, env, i); key = url_param->key; value = url_param->value; encoded_key = (axis2_char_t *) AXIS2_MALLOC (env->allocator, strlen (key)); memset (encoded_key, 0, strlen (key)); encoded_key = axutil_url_encode (env, encoded_key, key, (int)strlen (key)); encoded_value = (axis2_char_t *) AXIS2_MALLOC (env->allocator, strlen (value)); memset (encoded_value, 0, strlen (value)); encoded_value = axutil_url_encode (env, encoded_value, value, (int)strlen (value)); temp_str = params_str; params_str = axutil_strcat(env, temp_str, encoded_key, "=", encoded_value, "&", NULL); if(temp_str) { AXIS2_FREE(env->allocator, temp_str); temp_str = NULL; } if(encoded_key) { AXIS2_FREE(env->allocator, encoded_key); encoded_key = NULL; } if(encoded_value) { AXIS2_FREE(env->allocator, encoded_value); encoded_value = NULL; } } temp_str = (axis2_char_t *) axutil_strdup(env, url); url = axutil_strcat(env, temp_str, params_str, NULL); if(temp_str) { AXIS2_FREE(env->allocator, temp_str); temp_str = NULL; } curl_handle = curl_easy_init(); if(curl_handle) { const char *datafilename = (const char *) REG_CLIENT_ATOM_DATA_FILE_NAME; FILE *datafile; curl_easy_setopt(curl_handle, CURLOPT_URL, url); curl_easy_setopt(curl_handle, CURLOPT_HTTPGET, 1); /*curl_easy_setopt(curl_handle, CURLOPT_RETURNTRANSFER, 1);*/ curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, REG_CLIENT_USER_AGENT); if(rest_client->username) { axis2_char_t *uname_passwd = NULL; uname_passwd = axutil_strcat(env, rest_client->username, ":", rest_client->password, NULL); curl_easy_setopt(curl_handle, CURLOPT_USERPWD, uname_passwd); } /* Send all data to this function */ curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, reg_client_rest_client_write_data); /* Open the files */ datafile = fopen(datafilename,"w"); if (!datafile) { curl_easy_cleanup(curl_handle); return AXIS2_FAILURE; } /* We want the data to this file handle */ curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, datafile); res = curl_easy_perform(curl_handle); if(res == CURLE_OK) { res = curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &rest_client->status); if(res != CURLE_OK) { status = AXIS2_FAILURE; } } /* always cleanup */ fclose(datafile); curl_easy_cleanup(curl_handle); } return status; }