void get_all_policy( axis2_char_t * element_name, const axutil_env_t * env, axutil_array_list_t * policy_node_list, axis2_char_t * wsdl_name) { axutil_hash_t *attr_hash = NULL; axutil_hash_index_t *hi = NULL; axiom_element_t *element = NULL; axiom_attribute_t *attribute = NULL; axis2_char_t *attribute_val = NULL; axiom_node_t *parent_policy_node = NULL, *parent_node = NULL; parent_node = return_policy_element(element_name, env, wsdl_name); if (!parent_node) return; parent_policy_node = return_policy_element(get_policy_ref(parent_node, env), env, wsdl_name); axutil_array_list_add(policy_node_list, env, parent_policy_node); if (axiom_node_get_node_type(parent_node, env) == AXIOM_ELEMENT) { element = (axiom_element_t *) axiom_node_get_data_element(parent_node, env); attr_hash = axiom_element_get_all_attributes(element, env); if (attr_hash) { hi = axutil_hash_next(env, axutil_hash_first(attr_hash, env)); do { if (hi) { axutil_hash_this(hi, NULL, NULL, &attribute); attribute_val = axiom_attribute_get_value(attribute, env); attribute_val = axutil_rindex(attribute_val, ':'); attribute_val = axutil_string_substring_starting_at(attribute_val, 1); get_all_policy(attribute_val, env, policy_node_list, wsdl_name); hi = axutil_hash_next(env, hi); } } while (hi); } } return; }
AXIS2_EXTERN oxs_key_mgr_format_t AXIS2_CALL oxs_util_get_format_by_file_extension(const axutil_env_t *env, axis2_char_t *file_name) { axis2_char_t *extension = NULL; if(!file_name){ return OXS_ASYM_CTX_FORMAT_UNKNOWN; } extension = axutil_rindex(file_name, '.'); if(!extension){ /*No extension*/ /*Its safe to assume that PEM can be without extension*/ return OXS_ASYM_CTX_FORMAT_PEM; } if((strcmp(extension, ".pfx") == 0) || (strcmp(extension, ".p12") == 0) ){ return OXS_ASYM_CTX_FORMAT_PKCS12; }else{ /*Its safe to assume that PEM can be in any extensions. e.g. .cert, .cer, .pem*/ return OXS_ASYM_CTX_FORMAT_PEM; } }
AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL axis2_svc_get_rest_op_list_with_method_and_location( const axis2_svc_t * svc, const axutil_env_t * env, const axis2_char_t * method, const axis2_char_t * location) { axutil_array_list_t *op_list = NULL; axis2_char_t *key = NULL; axis2_char_t *loc_str = NULL; axis2_char_t *loc_str_tmp = NULL; axis2_char_t *r_idx = NULL; size_t plen; AXIS2_PARAM_CHECK(env->error, method, NULL); AXIS2_PARAM_CHECK(env->error, location, NULL); loc_str_tmp = (axis2_char_t *)location; /* Casted to facilitate loop */ if(loc_str_tmp[1] == '/') { loc_str_tmp++; } /* ignore any '/' at the beginning */ if(strchr(loc_str_tmp, '?')) { axis2_char_t *temp = NULL; temp = strchr(loc_str_tmp, '?'); temp[0] = '\0'; } /* ignore block after '?' */ do { axis2_char_t *temp = NULL; temp = strchr(loc_str_tmp, '{'); if(temp) { loc_str_tmp = temp; } else { loc_str_tmp += strlen(loc_str_tmp); break; } } while(loc_str_tmp[1] && loc_str_tmp[1] == '{'); loc_str = (axis2_char_t *)axutil_strmemdup(location, (size_t)(loc_str_tmp - location), env); r_idx = axutil_rindex(loc_str, '/'); if(r_idx && *r_idx) { loc_str_tmp = axutil_string_substring_ending_at(loc_str, (int)(r_idx - loc_str)); /* We are sure that the difference lies within the int range */ } else { loc_str_tmp = loc_str; } plen = axutil_strlen(method) + axutil_strlen(loc_str_tmp) + 2; key = (axis2_char_t *)(AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * plen)); sprintf(key, "%s:%s", method, loc_str_tmp); AXIS2_FREE(env->allocator, loc_str); op_list = (axutil_array_list_t *)axutil_hash_get(svc->op_rest_map, key, AXIS2_HASH_KEY_STRING); AXIS2_FREE(env->allocator, key); return op_list; }
AXIS2_EXTERN axutil_log_t *AXIS2_CALL axutil_log_create( axutil_allocator_t *allocator, axutil_log_ops_t *ops, const axis2_char_t *stream_name) { axutil_log_impl_t *log_impl; axis2_char_t *path_home; axis2_char_t log_file_name[AXUTIL_LOG_FILE_NAME_SIZE]; axis2_char_t log_dir[AXUTIL_LOG_FILE_NAME_SIZE]; axis2_char_t tmp_filename[AXUTIL_LOG_FILE_NAME_SIZE]; if (!allocator) return NULL; log_impl = (axutil_log_impl_t *) AXIS2_MALLOC(allocator, sizeof(axutil_log_impl_t)); if (!log_impl) return NULL; log_impl->mutex = axutil_thread_mutex_create(allocator, AXIS2_THREAD_MUTEX_DEFAULT); if (!log_impl->mutex) { fprintf(stderr, "cannot create log mutex \n"); return NULL; } #ifndef WIN32 signal(SIGXFSZ, SIG_IGN); #endif /* default log file is axis2.log */ if (stream_name) AXIS2_SNPRINTF(tmp_filename, AXUTIL_LOG_FILE_NAME_SIZE, "%s", stream_name); else AXIS2_SNPRINTF(tmp_filename, AXUTIL_LOG_FILE_NAME_SIZE, "%s", "axis2.log"); /* we write all logs to AXIS2C_HOME/logs if it is set otherwise * to the working dir */ if (stream_name && !(axutil_rindex(stream_name, AXIS2_PATH_SEP_CHAR))) { path_home = AXIS2_GETENV("AXIS2C_HOME"); if (path_home) { AXIS2_SNPRINTF(log_dir, AXUTIL_LOG_FILE_NAME_SIZE, "%s%c%s", path_home, AXIS2_PATH_SEP_CHAR, "logs"); if (AXIS2_SUCCESS == axutil_file_handler_access(log_dir, AXIS2_F_OK)) { AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s%c%s", log_dir, AXIS2_PATH_SEP_CHAR, tmp_filename); } else { fprintf(stderr, "log folder %s does not exist - log file %s "\ "is written to . dir\n", log_dir, tmp_filename); AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s", tmp_filename); } } else { fprintf(stderr, "AXIS2C_HOME is not set - log is written to . dir\n"); AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s", tmp_filename); } } else { AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s", tmp_filename); } log_impl->file_name = AXIS2_MALLOC(allocator, AXUTIL_LOG_FILE_NAME_SIZE); log_impl->log.size = AXUTIL_LOG_FILE_SIZE; sprintf(log_impl->file_name, "%s", log_file_name); axutil_thread_mutex_lock(log_impl->mutex); log_impl->stream = axutil_file_handler_open(log_file_name, "a+"); axutil_log_impl_rotate((axutil_log_t *) log_impl); axutil_thread_mutex_unlock(log_impl->mutex); if (!log_impl->stream) log_impl->stream = stderr; /* by default, log is enabled */ log_impl->log.enabled = 1; log_impl->log.level = AXIS2_LOG_LEVEL_DEBUG; if (ops) { log_impl->log.ops = ops; } else { log_impl->log.ops = &axutil_log_ops_var; } return &(log_impl->log); }