axis2_status_t AXIS2_CALL axutil_log_out_handler_invoke( struct axis2_handler * handler, const axutil_env_t * env, struct axis2_msg_ctx * msg_ctx) { axiom_soap_envelope_t *soap_envelope = NULL; axiom_node_t *ret_node = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE); AXIS2_LOG_INFO(env->log, "Starting logging out handler ........."); soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env); if (soap_envelope) { ret_node = axiom_soap_envelope_get_base_node(soap_envelope, env); if (ret_node) { axis2_char_t *om_str = NULL; om_str = axiom_node_to_string(ret_node, env); if (om_str) { AXIS2_LOG_INFO(env->log, "Output message: %s", om_str); } } } return AXIS2_SUCCESS; }
void sig_handler( int signal) { switch(signal) { case SIGINT: { AXIS2_LOG_INFO(system_env->log, "Received signal SIGINT. Server " "shutting down"); axis2_tcp_server_stop(server, system_env); AXIS2_LOG_INFO(system_env->log, "Shutdown complete ..."); system_exit(system_env, 0); } case SIGPIPE: { AXIS2_LOG_INFO(system_env->log, "Received signal SIGPIPE. Client " "request serve aborted"); return; } case SIGSEGV: { fprintf(stderr, "Received deadly signal SIGSEGV. Terminating\n"); _exit(-1); } } }
axis2_char_t* AXIS2_CALL get_ht_password(rampart_callback_t *rcb, const axutil_env_t *env, const axis2_char_t *username, void *param) { axis2_char_t * password = NULL; FILE *file = NULL; /*The default location is the following. But this will be overridden by the property values set in the msg_ctx*/ axis2_char_t *filename = "/usr/local/apache2/passwd/passwords"; if(param){ filename = (axis2_char_t *)param; }else{ AXIS2_LOG_INFO(env->log, "Using the default password file location %s", filename); } file = fopen ( filename, "r" ); if ( file != NULL ) { axis2_char_t line [ 128 ]; axis2_char_t ch = 0; axis2_char_t *res = NULL; axis2_char_t *un = NULL; axis2_char_t *pw = NULL; while ( fgets ( line, sizeof line, file ) != NULL ) { res = axutil_strstr(line, ":"); ch = res[0]; res[0] = '\0'; un = (axis2_char_t *) axutil_strdup(env, line); res[0] = ch; if(0 == axutil_strcmp(un, username)){ pw = (axis2_char_t *) axutil_strdup( env, &(res[1])); password = axutil_strndup(env, pw, axutil_strlen(pw)-1); /*We need to remove the end of line character*/ break; } } AXIS2_FREE(env->allocator, un); AXIS2_FREE(env->allocator, pw); fclose ( file ); }else { AXIS2_LOG_INFO(env->log, "Cannot load the password file %s in the callback module", filename); perror ( filename ); } return password; };
axis2_char_t * wsclient_get_password (const axutil_env_t *env, const axis2_char_t *username, axis2_char_t *password_file_name) { axis2_char_t *filename = NULL; axis2_char_t * password = NULL; FILE *file = NULL; if(password_file_name) { filename = password_file_name; }else { AXIS2_LOG_INFO(env->log, "Using the default password file location %s", filename); } file = fopen ( filename, "r" ); if ( file != NULL ) { axis2_char_t line [ 128 ]; axis2_char_t ch = 0; axis2_char_t *res = NULL; axis2_char_t *un = NULL; axis2_char_t *pw = NULL; while ( fgets ( line, sizeof line, file ) != NULL ) { res = axutil_strstr(line, ":"); ch = res[0]; res[0] = '\0'; un = (axis2_char_t *) axutil_strdup(env, line); res[0] = ch; if(0 == axutil_strcmp(un, username)){ pw = (axis2_char_t *) axutil_strdup(env, &(res[1])); password = axutil_strndup(env, pw, axutil_strlen(pw)-1); break; } } AXIS2_FREE(env->allocator, un); AXIS2_FREE(env->allocator, pw); fclose ( file ); }else { AXIS2_LOG_INFO(env->log, "Cannot load the password file %s in the callback module", filename); perror ( filename ); } return password; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL axis2_tcp_server_stop( axis2_transport_receiver_t * server, const axutil_env_t * env) { AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_LOG_INFO(env->log, "Terminating TCP server thread"); if(AXIS2_INTF_TO_IMPL(server)->svr_thread) { axis2_tcp_svr_thread_destroy(AXIS2_INTF_TO_IMPL(server)->svr_thread, env); } AXIS2_LOG_INFO(env->log, "Successfully terminated TCP server" " thread"); return AXIS2_SUCCESS; }
axis2_status_t AXIS2_CALL axis2_xmpp_server_start( axis2_transport_receiver_t *server, const axutil_env_t *env) { axis2_xmpp_server_impl_t *impl = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); impl = AXIS2_INTF_TO_IMPL(server); impl->svr_thread = axis2_xmpp_svr_thread_create(env, impl->port, impl->conf_ctx, impl->use_sasl, impl->use_tls, impl->subscribe); if (!impl->svr_thread) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); return AXIS2_FAILURE; } AXIS2_LOG_INFO(env->log, "Starting XMPP server thread..."); AXIS2_XMPP_SVR_THREAD_RUN(impl->svr_thread, env); return AXIS2_SUCCESS; }
axis2_status_t AXIS2_CALL axis2_tcp_server_start( axis2_transport_receiver_t * server, const axutil_env_t * env) { axis2_tcp_server_impl_t *server_impl = NULL; axis2_tcp_worker_t *worker = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); server_impl = AXIS2_INTF_TO_IMPL(server); server_impl->svr_thread = axis2_tcp_svr_thread_create(env, server_impl->port); if (!server_impl->svr_thread) { return AXIS2_FAILURE; } worker = axis2_tcp_worker_create(env, server_impl->conf_ctx); axis2_tcp_worker_set_svr_port(worker, env, server_impl->port); if (!worker) { axis2_tcp_svr_thread_free(server_impl->svr_thread, env); return AXIS2_FAILURE; } AXIS2_LOG_INFO(env->log, "Starting TCP server thread"); axis2_tcp_svr_thread_set_worker(server_impl->svr_thread, env, worker); axis2_tcp_svr_thread_run(server_impl->svr_thread, env); return AXIS2_SUCCESS; }
axis2_status_t AXIS2_CALL axis2_xmpp_server_stop( axis2_transport_receiver_t *server, const axutil_env_t *env) { AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_LOG_INFO(env->log, "Terminating XMPP server thread"); if (AXIS2_INTF_TO_IMPL(server)->svr_thread) { AXIS2_XMPP_SVR_THREAD_DESTROY(AXIS2_INTF_TO_IMPL(server)->svr_thread, env); } AXIS2_LOG_INFO(env->log, "Successfully terminated XMPP server" " thread"); return AXIS2_SUCCESS; }
int calculateOptimizedPortfolioSSD(const axutil_env_t* env,axutil_array_list_t* symbols,axis2_char_t* benchmark,axutil_date_time_t* start,axutil_date_time_t* end, double solutions[],double& optValue) { int retCode = 0; int numSymbols = axutil_array_list_size(symbols,env); ostringstream oss(ostringstream::out); AlmDataWriter* writer = new AlmDataWriter(); for(int i=0;i<numSymbols;i++) { axis2_char_t* symbol = (axis2_char_t*)axutil_array_list_get(symbols,env,i); buildURLYahoo(env,symbol,start,end,oss); string url = oss.str(); //oss.str(""); vector<double> returns; AXIS2_LOG_INFO(env->log,"retrieving data from [%s]",url.c_str()); DataRetriever::getReturnDataVector(url,returns); string stock = symbol; retCode = writer->addReturnData(stock,returns); } buildURLYahoo(env,benchmark,start,end,oss); string url = oss.str(); oss.str(""); AXIS2_LOG_INFO(env->log,"retrieving benchmark data from [%s]",url.c_str()); vector<double> returns; DataRetriever::getReturnDataVector(url,returns); string stock = benchmark; writer->addBenchmarkReturnData(stock,returns); oss<<GlobalVariables::ALM_SSD_MOD<<"_"<<getpid()<<".dat"; string dataFilename = oss.str(); oss.str(""); writer->writeSMLDataFileSSD(dataFilename); double nouse = -1; if(retCode == 0) { retCode = executeSMLOOPS(env,GlobalVariables::ALM_SSD_MOD,dataFilename,solutions,optValue,nouse); AXIS2_LOG_INFO(env->log,"returned from executeSMLOOPS"); } else { AXIS2_LOG_INFO(env->log,"error happens -- not calling oops anymore..."); } return retCode; }
void axis2_xmpp_client_on_log( void *user_data, const char* data, size_t size, int is_incoming) { axis2_xmpp_session_data_t *session = NULL; session = (axis2_xmpp_session_data_t*) user_data; char *buf = (char*) AXIS2_MALLOC(session->env->allocator, (size + 1)); memcpy(buf, data, size); buf[size] = 0; if(is_incoming) AXIS2_LOG_INFO(session->env->log, "\n[xmpp client]INCOMING : %s\n", buf); else AXIS2_LOG_INFO(session->env->log, "\n[xmpp client]OUTGOING : %s\n", buf); AXIS2_FREE(session->env->allocator, buf); }
AXIS2_EXTERN axis2_status_t AXIS2_CALL axis2_phase_remove_handler( axis2_phase_t * phase, const axutil_env_t * env, axis2_handler_t * handler) { AXIS2_LOG_INFO(env->log, "Handler %s romoved from phase %s", axutil_string_get_buffer( axis2_handler_get_name(handler, env), env), phase->name); return axis2_phase_remove_unique(env, phase->handlers, handler); }
int axis2_xmpp_client_on_iq( void *user_data, ikspak *pak) { axis2_xmpp_session_data_t *session = NULL; axutil_env_t *env = NULL; session = (axis2_xmpp_session_data_t*) user_data; env = session->env; if(pak->subtype == IKS_TYPE_RESULT) { if(pak->ns) { if(!axutil_strcmp(pak->ns, IKS_NS_XMPP_BIND)) { session->bind = 1; AXIS2_LOG_INFO(env->log, "[xmpp]Bind iq recieved"); } else if(!axutil_strcmp(pak->ns, IKS_NS_XMPP_SESSION)) { session->session = 1; AXIS2_LOG_INFO(env->log, "[xmpp]Session iq recieved"); } } else if(pak->id) { if(!axutil_strcmp(pak->id, "auth")) { session->session = 1; AXIS2_LOG_INFO(env->log, "[xmpp]Session iq recieved"); } } } if(session->session) iks_send(session->parser, iks_make_pres(IKS_SHOW_AVAILABLE, "Online")); return IKS_FILTER_EAT; /* no need to pass to other filters */ }
void* AXIS2_THREAD_FUNC axis2_amqp_request_processor_thread_function( axutil_thread_t* thread, void* request_data) { axis2_status_t status = AXIS2_FAILURE; axutil_env_t* env = NULL; axutil_env_t* thread_env = NULL; axis2_amqp_request_processor_resource_pack_t* request_resource_pack = NULL; #ifndef WIN32 #ifdef AXIS2_SVR_MULTI_THREADED signal(SIGPIPE, SIG_IGN); #endif #endif request_resource_pack = (axis2_amqp_request_processor_resource_pack_t*)request_data; env = request_resource_pack->env; thread_env = axutil_init_thread_env(env); /* Process Request */ status = axis2_amqp_process_request(thread_env, request_resource_pack); if(status == AXIS2_SUCCESS) { AXIS2_LOG_INFO(thread_env->log, "Request Processed Successfully"); } else { AXIS2_LOG_WARNING(thread_env->log, AXIS2_LOG_SI, "Error while Processing Request"); } AXIS2_FREE(thread_env->allocator, request_resource_pack->request_content); AXIS2_FREE(thread_env->allocator, request_resource_pack->reply_to); AXIS2_FREE(thread_env->allocator, request_resource_pack->content_type); AXIS2_FREE(thread_env->allocator, request_resource_pack->soap_action); AXIS2_FREE(thread_env->allocator, request_resource_pack); if(thread_env) { thread_env = NULL; } #ifdef AXIS2_SVR_MULTI_THREADED axutil_thread_pool_exit_thread(env->thread_pool, thread); #endif return NULL; }
void buildURLGoogle(const axutil_env_t* env,axis2_char_t* symbol,axutil_date_time_t* start, axutil_date_time_t* end,ostringstream& oss) { int syear = axutil_date_time_get_year(start,env); int smonth = axutil_date_time_get_month(start,env); int sdate = axutil_date_time_get_date(start,env); int eyear = axutil_date_time_get_year(end,env); int emonth = axutil_date_time_get_month(end,env); int edate = axutil_date_time_get_date(end,env); oss.str(""); oss<<"http://www.google.com/finance/historical?q="; oss<<symbol<<"&startdate="; oss<<GlobalVariables::m_months[smonth]<<"+"<<sdate<<"%2C+"<<syear<<"&enddate="; oss<<GlobalVariables::m_months[emonth]<<"+"<<edate<<"%2C+"<<eyear<<"&histperiod=weekly&num=30&output=csv"; AXIS2_LOG_INFO(env->log,"build url google version [%s]",oss.str().c_str()); }
/* * This method invokes the right service method */ axiom_node_t* AXIS2_CALL echo_invoke(axis2_svc_skeleton_t *svc_skeleton, const axutil_env_t *env, axiom_node_t *node, axis2_msg_ctx_t *msg_ctx) { /* Invoke the business logic. * Depending on the function name invoke the correct impl method. * We have only echo in this sample, hence invoke echo method. * To see how to deal with multiple impl methods, have a look at the * math sample. */ AXIS2_LOG_INFO(env->log,"%s:%d",__FILE__, __LINE__); return axis2_echo_echo(env, node, msg_ctx); }
/*Two sample implementations*/ rampart_authn_provider_status_t AXIS2_CALL rampart_sample_authn_provider_check_password(rampart_authn_provider_t *authn_provider, const axutil_env_t* env, axis2_msg_ctx_t *msg_ctx, const axis2_char_t *username, const axis2_char_t *password) { axis2_char_t *local_pw = NULL; local_pw = rampart_authn_get_sample_password(env, username); AXIS2_LOG_INFO(env->log, "[rampart][authn_provider_sample] Load the password - default impl"); if(local_pw) { /*Compare passwords*/ if(0 == axutil_strcmp(password, local_pw)) { AXIS2_LOG_INFO(env->log, "[rampart][authn_provider_sample] Access granted"); return RAMPART_AUTHN_PROVIDER_GRANTED; } else { AXIS2_LOG_INFO(env->log, "[rampart][authn_provider_sample] Access denied"); return RAMPART_AUTHN_PROVIDER_DENIED; } } else { AXIS2_LOG_INFO(env->log, "[rampart][authn_provider_sample] User not found"); return RAMPART_AUTHN_PROVIDER_USER_NOT_FOUND; } }
int axis2_xmpp_client_on_subscription( void *user_data, ikspak *pak) { axis2_xmpp_session_data_t *session = NULL; axutil_env_t *env = NULL; session = (axis2_xmpp_session_data_t*) user_data; env = session->env; if(pak->subtype == IKS_TYPE_SUBSCRIBED) { AXIS2_LOG_INFO(env->log, "[xmpp]Subscription successful"); } return IKS_FILTER_EAT; /* no need to pass to other filters */ }
void test_log_write( ) { char msg[20]; printf("start of test_log_write\n\n"); axutil_allocator_t *allocator = axutil_allocator_init(NULL); if (!allocator) { printf("allocator is NULL\n"); return; } axutil_error_t *error = axutil_error_create(allocator); if (!error) { printf("cannot create error\n"); return; } axutil_log_t *log22 = axutil_log_create(allocator, NULL, NULL); if (!log22) { printf("cannot create log\n"); return; } log22->level = AXIS2_LOG_LEVEL_DEBUG; const axutil_env_t *env = axutil_env_create_with_error_log(allocator, error, log22); if (!env) { printf("cannot create env with error and log\n"); return; } strcpy(msg, "abcd test123"); AXIS2_LOG_CRITICAL(env->log, AXIS2_LOG_SI, "log1 %s", "test1"); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "log2 %d", 2); AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, "log3 %s", "test3"); AXIS2_LOG_INFO(env->log, AXIS2_LOG_SI, "log4 %s %s", "info1", "info2"); AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "log5 %s %d", "test", 5); printf("end of test_log_write \n\n"); }
/* Get the client certificate from key manager by giving * issuer and serial number of the certificate */ static oxs_x509_cert_t * rampart_token_process_issuer_serial( const axutil_env_t *env, rampart_context_t *rampart_ctx, axiom_node_t *x509_data_node) { oxs_x509_cert_t *cert = NULL; axiom_node_t *issuer_serial_node = NULL; axiom_element_t *issuer_serial_ele = NULL; axiom_child_element_iterator_t *child_itr = NULL; axiom_node_t *child_node = NULL; axiom_element_t *child_ele = NULL; axis2_char_t *ele_name = NULL; axis2_char_t *issuer_name_str = NULL; axis2_char_t *serial_num_str = NULL; int serial_num = -1; oxs_key_mgr_t *key_mgr = NULL; if((cert = rampart_context_get_receiver_certificate(rampart_ctx, env))) { /* In the client side, it is preferred to use certificate files instead * of key store, because one client normally interact with only one * service. To handle this scenario, if we found receiver certificate file * specified in rampart_context we directly call the get_reciever_certificate. */ return cert; } issuer_serial_node = axiom_node_get_first_child(x509_data_node, env); issuer_serial_ele = axiom_node_get_data_element(issuer_serial_node, env); child_itr = axiom_element_get_child_elements(issuer_serial_ele, env, issuer_serial_node); while(axiom_child_element_iterator_has_next(child_itr, env)) { child_node = axiom_child_element_iterator_next(child_itr, env); child_ele = axiom_node_get_data_element(child_node, env); ele_name = axiom_element_get_localname(child_ele, env); if(axutil_strcmp(ele_name, OXS_NODE_X509_ISSUER_NAME) == 0) { issuer_name_str = axiom_element_get_text(child_ele, env, child_node); if(!issuer_name_str) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Issuer Name cannot be NULL."); return NULL; } AXIS2_LOG_INFO(env->log, AXIS2_LOG_SI, "X509 Certificate Issuer Name Found: %s", issuer_name_str); } else if(axutil_strcmp(ele_name, OXS_NODE_X509_SERIAL_NUMBER) == 0) { serial_num_str = axiom_element_get_text(child_ele, env, child_node); if(!serial_num_str) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Serial number cannot be null."); } AXIS2_LOG_INFO(env->log, AXIS2_LOG_SI, "X509 Certificate Serial Number Found: %s", serial_num_str); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in incoming key info. These types not supported: %", ele_name); return NULL; } } serial_num = atoi(serial_num_str); key_mgr = rampart_context_get_key_mgr(rampart_ctx, env); cert = oxs_key_mgr_get_receiver_certificate_from_issuer_serial(key_mgr, env, issuer_name_str, serial_num); return cert; }
int executeSMLOOPS(const axutil_env_t* env,string modFilename,string dataFilename,double solutions[],double& optValue, double& expReturn) { int retCode = 0; //oss<<"mpiexec -np 1 "; //-- mpiexec not exiting.. ostringstream oss(ostringstream::out); oss<<GlobalVariables::ALM_SERVICE_HOME<<GlobalVariables::SMLOOPS_EXEC<<" "; oss<<GlobalVariables::ALM_SERVICE_HOME<<modFilename<<" "; oss<<GlobalVariables::ALM_SERVICE_HOME<<dataFilename; string cmd = oss.str(); AXIS2_LOG_INFO(env->log,"executing smloops [%s]",cmd.c_str()); //string result = exec(cmd.c_str(),env); FILE* pipe = popen(cmd.c_str(),"r"); if(!pipe) { retCode = -1; AXIS2_LOG_INFO(env->log,"can't create pipe to smloops"); } else { char buffer[256]; string line = ""; int solIndex = 0; while(!feof(pipe)) { if(fgets(buffer,256,pipe)!=NULL) { line = buffer; //AXIS2_LOG_INFO(env->log,"executing smloops [%s]",buffer); if(string::npos!=line.find("Excess Iters Limit")) { AXIS2_LOG_INFO(env->log,"object value line - [%s]",line.c_str()); retCode = 2; //iteration limit excess optValue = 0; AXIS2_LOG_INFO(env->log,"problem excess iteration limit"); } else if(string::npos!=line.find("Exit")) { AXIS2_LOG_INFO(env->log,"object value line - [%s]",line.c_str()); retCode = 1; //infeasible or unbounded optValue = 0; AXIS2_LOG_INFO(env->log,"problem infeasible or unbounded"); } else if(string::npos!=line.find("root_E")) { AXIS2_LOG_INFO(env->log,"expected return line - [%s]",line.c_str()); int start = line.find("Value")+6; int end = line.find("Reduced"); string value = line.substr(start,end-start); AXIS2_LOG_INFO(env->log,"value - [%s]",value.c_str()); expReturn = atof(value.c_str()); AXIS2_LOG_INFO(env->log,"setting expReturn to [%f]",expReturn); } else if(string::npos!=line.find("x_hold")) { AXIS2_LOG_INFO(env->log,"solution line - [%s]",line.c_str()); int start = line.find("Value")+6; int end = line.find("Reduced"); string value = line.substr(start,end-start); AXIS2_LOG_INFO(env->log,"value - [%s]",value.c_str()); double x_val = atof(value.c_str()); solutions[solIndex] = x_val; solIndex++; AXIS2_LOG_INFO(env->log,"setting x_hold to [%f]",optValue); } else if(string::npos!=line.find("Opt Sol")) { AXIS2_LOG_INFO(env->log,"object value line - [%s]",line.c_str()); retCode = 0; //opt value found. string value = line.substr(8,line.find(" ",9)); optValue = atof(value.c_str()); AXIS2_LOG_INFO(env->log,"value - [%s]",value.c_str()); AXIS2_LOG_INFO(env->log,"setting optValue to [%f]",optValue); } else { //AXIS2_LOG_INFO(env->log,"other line skip [%s]",line.c_str()); } } } } AXIS2_LOG_INFO(env->log,"Before return executeSMLOOPS "); return retCode; }
axis2_status_t AXIS2_CALL axis2_addr_out_handler_invoke( struct axis2_handler * handler, const axutil_env_t * env, axis2_msg_ctx_t * msg_ctx) { axis2_char_t *addr_ver_from_msg_ctx = NULL; const axis2_char_t *addr_ns = NULL; axis2_msg_info_headers_t *msg_info_headers = NULL; axis2_ctx_t *ctx = NULL; axiom_soap_envelope_t *soap_envelope = NULL; axiom_soap_header_t *soap_header = NULL; axiom_node_t *soap_header_node = NULL; axiom_element_t *soap_header_ele = NULL; axis2_endpoint_ref_t *epr_to = NULL; axis2_endpoint_ref_t *epr_reply_to = NULL; axis2_endpoint_ref_t *epr_from = NULL; axis2_endpoint_ref_t *epr_fault_to = NULL; axutil_property_t *property = NULL; const axis2_char_t *wsa_action = NULL; axis2_bool_t set_must_understand = AXIS2_FALSE; axutil_property_t *must_understand_prop; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE); AXIS2_LOG_INFO(env->log, "Starting addressing out handler"); soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env); if(!soap_envelope) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No SOAP envelope. Stop processing addressing"); return AXIS2_SUCCESS; /* Can happen in case of ONE-WAY services/clients */ } msg_info_headers = axis2_msg_ctx_get_msg_info_headers(msg_ctx, env); if(msg_info_headers) { wsa_action = axis2_msg_info_headers_get_action(msg_info_headers, env); } else { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No addressing in use"); return AXIS2_SUCCESS; /* No addressing in use */ } if(!wsa_action || !*wsa_action) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No action present. Stop processing addressing"); return AXIS2_SUCCESS; /* If no action present, assume no addressing in use */ } ctx = axis2_msg_ctx_get_base(msg_ctx, env); property = axis2_ctx_get_property(ctx, env, AXIS2_WSA_VERSION); if(property) { addr_ver_from_msg_ctx = axutil_property_get_value(property, env); property = NULL; } must_understand_prop = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_ADDR_ADD_MUST_UNDERSTAND_TO_ADDR_HEADERS); if(must_understand_prop) { axis2_char_t *value = axutil_property_get_value(must_understand_prop, env); if(axutil_strcmp(value, AXIS2_VALUE_TRUE) == 0) set_must_understand = AXIS2_TRUE; } /* Setting version 1.0 as the default addressing namespace */ addr_ns = AXIS2_WSA_NAMESPACE; if(addr_ver_from_msg_ctx) { if(!axutil_strcmp(AXIS2_WSA_NAMESPACE_SUBMISSION, addr_ver_from_msg_ctx)) { addr_ns = AXIS2_WSA_NAMESPACE_SUBMISSION; } } else if(axis2_msg_ctx_get_op_ctx(msg_ctx, env)) { axis2_op_ctx_t *op_ctx = NULL; axis2_msg_ctx_t *in_msg_ctx = NULL; op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env); if(op_ctx) { in_msg_ctx = axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN); } if(in_msg_ctx) { axis2_ctx_t *in_ctx = NULL; in_ctx = axis2_msg_ctx_get_base(in_msg_ctx, env); property = axis2_ctx_get_property(in_ctx, env, AXIS2_WSA_VERSION); if(property) { addr_ns = axutil_property_get_value(property, env); property = NULL; } if(!addr_ns || !*addr_ns) { addr_ns = AXIS2_WSA_NAMESPACE; } } } soap_header = axiom_soap_envelope_get_header(soap_envelope, env); if(!soap_header) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No SOAP header. Stop processing addressing"); return AXIS2_SUCCESS; /* No SOAP header, so no point proceeding */ } else { /* By this time, we definitely have some addressing information to be sent. This is because, * we have tested at the start of this whether msg_info_headers are null or not. * So rather than declaring addressing namespace in each and every addressing header, lets * define that in the Header itself. */ const axis2_char_t *action = NULL; const axis2_char_t *address = NULL; const axis2_char_t *svc_group_context_id = NULL; const axis2_char_t *message_id = NULL; axis2_relates_to_t *relates_to = NULL; axiom_node_t *relates_to_header_node = NULL; axiom_element_t *relates_to_header_ele = NULL; axiom_namespace_t *addressing_namespace = NULL; soap_header_node = axiom_soap_header_get_base_node(soap_header, env); soap_header_ele = (axiom_element_t *)axiom_node_get_data_element(soap_header_node, env); addressing_namespace = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX); axiom_element_declare_namespace(soap_header_ele, env, soap_header_node, addressing_namespace); epr_to = axis2_msg_info_headers_get_to(msg_info_headers, env); if(epr_to) { axiom_soap_body_t *body = axiom_soap_envelope_get_body(soap_envelope, env); if(body) { /* In case of a SOAP fault, we got to send the response to the adress specified by FaultTo */ if(axiom_soap_body_has_fault(body, env)) { axis2_endpoint_ref_t *epr_fault_to = axis2_msg_info_headers_get_fault_to( msg_info_headers, env); if(epr_fault_to) { const axis2_char_t *fault_to_address = axis2_endpoint_ref_get_address( epr_fault_to, env); if(fault_to_address) { if(axutil_strcmp(AXIS2_WSA_NONE_URL, fault_to_address) && axutil_strcmp(AXIS2_WSA_NONE_URL_SUBMISSION, fault_to_address)) { axis2_endpoint_ref_set_address(epr_to, env, fault_to_address); } } } } } address = axis2_endpoint_ref_get_address(epr_to, env); if(address && *address) { axiom_node_t *to_header_block_node = NULL; axiom_soap_header_block_t *to_header_block = NULL; axutil_array_list_t *ref_param_list = NULL; int size = 0; to_header_block = axiom_soap_header_add_header_block(soap_header, env, AXIS2_WSA_TO, addressing_namespace); if(set_must_understand == AXIS2_TRUE) { axiom_soap_header_block_set_must_understand_with_bool(to_header_block, env, AXIS2_TRUE); } to_header_block_node = axiom_soap_header_block_get_base_node(to_header_block, env); if(to_header_block_node) { axiom_element_t *to_header_block_element = NULL; to_header_block_element = (axiom_element_t *)axiom_node_get_data_element( to_header_block_node, env); if(to_header_block_element) { axiom_element_set_text(to_header_block_element, env, address, to_header_block_node); } } ref_param_list = axis2_endpoint_ref_get_ref_param_list(epr_to, env); size = axutil_array_list_size(ref_param_list, env); if(ref_param_list && size > 0) { axiom_soap_header_block_t *reference_header_block = NULL; axiom_node_t *reference_node = NULL; int i = 0; for(i = 0; i < size; i++) { axiom_node_t *temp_node = NULL; temp_node = (axiom_node_t *)axutil_array_list_get(ref_param_list, env, i); if(temp_node) { axiom_element_t *temp_ele = NULL; temp_ele = axiom_node_get_data_element(temp_node, env); if(temp_ele) { reference_header_block = axiom_soap_header_add_header_block( soap_header, env, axiom_element_get_localname(temp_ele, env), axiom_element_get_namespace(temp_ele, env, temp_node)); if(set_must_understand) { axiom_soap_header_block_set_must_understand_with_bool(reference_header_block, env, AXIS2_TRUE); } reference_node = axiom_soap_header_block_get_base_node( reference_header_block, env); if(reference_node) { axiom_element_t *reference_ele = NULL; reference_ele = (axiom_element_t *)axiom_node_get_data_element( reference_node, env); if(reference_ele) { axiom_namespace_t *addr_ns_obj = NULL; axiom_attribute_t *reference_attr = NULL; addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX); reference_attr = axiom_attribute_create(env, /*"isReferenceParameter"*/ AXIS2_WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE, "true", addr_ns_obj); axiom_element_add_attribute(reference_ele, env, reference_attr, reference_node); axiom_element_set_text(reference_ele, env, axiom_element_get_text(temp_ele, env, temp_node), reference_node); } } } } } } } }/* if(epr_to) */ axiom_namespace_free(addressing_namespace, env); action = axis2_msg_info_headers_get_action(msg_info_headers, env); if(action && *action) { axis2_addr_out_handler_process_string_info(env, action, AXIS2_WSA_ACTION, &soap_header, addr_ns, set_must_understand); } epr_reply_to = axis2_msg_info_headers_get_reply_to(msg_info_headers, env); if(!epr_reply_to) { const axis2_char_t *anonymous_uri = NULL; axis2_bool_t anonymous = axis2_msg_info_headers_get_reply_to_anonymous( msg_info_headers, env); axis2_bool_t none = axis2_msg_info_headers_get_reply_to_none(msg_info_headers, env); if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION)) { if(none) { anonymous_uri = AXIS2_WSA_NONE_URL_SUBMISSION; } else if(anonymous) { anonymous_uri = AXIS2_WSA_ANONYMOUS_URL_SUBMISSION; } } else { if(none) { anonymous_uri = AXIS2_WSA_NONE_URL; } else if(anonymous) { anonymous_uri = AXIS2_WSA_ANONYMOUS_URL; } } if(anonymous_uri) { epr_reply_to = axis2_endpoint_ref_create(env, anonymous_uri); } if(epr_reply_to) { axis2_msg_info_headers_set_reply_to(msg_info_headers, env, epr_reply_to); } } /* add the service group id as a reference parameter */ svc_group_context_id = axutil_string_get_buffer(axis2_msg_ctx_get_svc_grp_ctx_id(msg_ctx, env), env); axis2_addr_out_handler_add_to_soap_header(env, epr_reply_to, AXIS2_WSA_REPLY_TO, soap_header, addr_ns); epr_from = axis2_msg_info_headers_get_from(msg_info_headers, env); if(epr_from) { axis2_addr_out_handler_add_to_soap_header(env, epr_from, AXIS2_WSA_FROM, soap_header, addr_ns); } epr_fault_to = axis2_msg_info_headers_get_fault_to(msg_info_headers, env); if(!epr_fault_to) { const axis2_char_t *anonymous_uri = NULL; axis2_bool_t anonymous = axis2_msg_info_headers_get_fault_to_anonymous( msg_info_headers, env); axis2_bool_t none = axis2_msg_info_headers_get_fault_to_none(msg_info_headers, env); if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION)) { if(none) { anonymous_uri = AXIS2_WSA_NONE_URL_SUBMISSION; } else if(anonymous) { anonymous_uri = AXIS2_WSA_ANONYMOUS_URL_SUBMISSION; } } else { if(none) anonymous_uri = AXIS2_WSA_NONE_URL; else if(anonymous) anonymous_uri = AXIS2_WSA_ANONYMOUS_URL; } if(anonymous_uri) { epr_fault_to = axis2_endpoint_ref_create(env, anonymous_uri); } } if(epr_fault_to) { /* optional */ axis2_addr_out_handler_add_to_soap_header(env, epr_fault_to, AXIS2_WSA_FAULT_TO, soap_header, addr_ns); } message_id = axis2_msg_info_headers_get_message_id(msg_info_headers, env); if(message_id) { axis2_addr_out_handler_process_string_info(env, message_id, AXIS2_WSA_MESSAGE_ID, &soap_header, addr_ns, set_must_understand); } relates_to = axis2_msg_info_headers_get_relates_to(msg_info_headers, env); if(relates_to) { const axis2_char_t *value = NULL; value = axis2_relates_to_get_value(relates_to, env); relates_to_header_node = axis2_addr_out_handler_process_string_info(env, value, AXIS2_WSA_RELATES_TO, &soap_header, addr_ns, set_must_understand); } if(relates_to_header_node) { const axis2_char_t *relationship_type = NULL; relationship_type = axis2_relates_to_get_relationship_type(relates_to, env); if(relationship_type && *relationship_type) { axiom_attribute_t *om_attr = NULL; axiom_namespace_t *addr_ns_obj = NULL; axiom_namespace_t *dec_ns = NULL; relates_to_header_ele = (axiom_element_t *)axiom_node_get_data_element( relates_to_header_node, env); if(relates_to_header_ele) { dec_ns = axiom_element_find_declared_namespace(relates_to_header_ele, env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX); if(dec_ns) { addr_ns_obj = dec_ns; } else { addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX); } if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION)) { om_attr = axiom_attribute_create(env, AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE, AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE_SUBMISSION, addr_ns_obj); } else { om_attr = axiom_attribute_create(env, AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE, AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE, addr_ns_obj); } axiom_element_add_attribute(relates_to_header_ele, env, om_attr, relates_to_header_node); dec_ns = axiom_element_find_declared_namespace(relates_to_header_ele, env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX); if(!dec_ns) { dec_ns = axiom_element_find_namespace(relates_to_header_ele, env, relates_to_header_node, addr_ns, AXIS2_WSA_DEFAULT_PREFIX); if(dec_ns) { axiom_namespace_free(addr_ns_obj, env); addr_ns_obj = NULL; axiom_attribute_set_namespace(om_attr, env, dec_ns); } } } } } } return AXIS2_SUCCESS; }
int main( int argc, char *argv[]) { axutil_allocator_t *allocator = NULL; axutil_env_t *env = NULL; extern char *optarg; extern int optopt; int c; int log_file_size = AXUTIL_LOG_FILE_SIZE; axutil_log_levels_t log_level = AXIS2_LOG_LEVEL_DEBUG; const axis2_char_t *log_file = AXIS2_TCP_SERVER_LOG_FILE_NAME; int port = AXIS2_TCP_SERVER_PORT; const axis2_char_t *repo_path = AXIS2_TCP_SERVER_REPO_PATH; while((c = AXIS2_GETOPT(argc, argv, ":p:r:ht:l:s:f:")) != -1) { switch(c) { case 'p': port = AXIS2_ATOI(optarg); break; case 'r': repo_path = optarg; break; case 't': axis2_tcp_socket_read_timeout = AXIS2_ATOI(optarg) * 1000; break; case 'l': log_level = AXIS2_ATOI(optarg); if(log_level < AXIS2_LOG_LEVEL_CRITICAL) log_level = AXIS2_LOG_LEVEL_CRITICAL; if(log_level > AXIS2_LOG_LEVEL_TRACE) log_level = AXIS2_LOG_LEVEL_TRACE; break; case 's': log_file_size = 1024 * 1024 * AXIS2_ATOI(optarg); break; case 'f': log_file = optarg; break; case 'h': usage(argv[0]); return 0; case ':': fprintf(stderr, "\nOption -%c requires an operand\n", optopt); usage(argv[0]); return -1; case '?': if(isprint(optopt)) fprintf(stderr, "\nUnknown option `-%c'.\n", optopt); usage(argv[0]); return -1; } } allocator = axutil_allocator_init(NULL); if(!allocator) { system_exit(NULL, -1); } env = init_syetem_env(allocator, log_file); env->log->level = log_level; env->log->size = log_file_size; axutil_error_init(); system_env = env; #ifndef WIN32 signal(SIGINT, sig_handler); signal(SIGPIPE, sig_handler); #endif AXIS2_LOG_INFO(env->log, "Starting Axis2 TCP server...."); AXIS2_LOG_INFO(env->log, "Server port : %d", port); AXIS2_LOG_INFO(env->log, "Repo location : %s", repo_path); AXIS2_LOG_INFO(env->log, "Read Timeout : %d ms", axis2_tcp_socket_read_timeout); server = axis2_tcp_server_create(env, repo_path, port); if(!server) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Server creation failed: Error code:" " %d :: %s", env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error)); system_exit(env, -1); } printf("Started Simple Axis2 TCP Server ...\n"); if(axis2_transport_receiver_start(server, env) == AXIS2_FAILURE) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Server start failed: Error code:" " %d :: %s", env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error)); system_exit(env, -1); } return 0; }
axis2_status_t AXIS2_CALL axis2_addr_in_handler_invoke( struct axis2_handler * handler, const axutil_env_t * env, struct axis2_msg_ctx * msg_ctx) { axiom_soap_envelope_t *soap_envelope = NULL; axiom_soap_header_t *soap_header = NULL; axutil_property_t *property = NULL; axis2_status_t status = AXIS2_FAILURE; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE); AXIS2_LOG_INFO(env->log, "Starting addressing in handler"); soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env); if (soap_envelope) { soap_header = axiom_soap_envelope_get_header(soap_envelope, env); if (soap_header) { axutil_array_list_t *addr_headers = NULL; axis2_ctx_t *ctx = NULL; axis2_char_t *addr_ns_str = NULL; axis2_msg_info_headers_t *msg_info_headers = axis2_msg_ctx_get_msg_info_headers(msg_ctx, env); addr_headers = axiom_soap_header_get_header_blocks_with_namespace_uri (soap_header, env, AXIS2_WSA_NAMESPACE_SUBMISSION); if (addr_headers) { addr_ns_str = axutil_strdup(env, AXIS2_WSA_NAMESPACE_SUBMISSION); /*status = axis2_addr_in_extract_addr_submission_info(env, soap_header, &msg_info_headers, addr_headers, msg_ctx);*/ status = axis2_addr_in_extract_addr_params(env, soap_header, &msg_info_headers, addr_headers, AXIS2_WSA_NAMESPACE_SUBMISSION, msg_ctx); } else { addr_headers = axiom_soap_header_get_header_blocks_with_namespace_uri (soap_header, env, AXIS2_WSA_NAMESPACE); if (addr_headers) { addr_ns_str = axutil_strdup(env, AXIS2_WSA_NAMESPACE); /*status = axis2_addr_in_extract_addr_final_info(env, soap_header, &msg_info_headers, addr_headers, msg_ctx);*/ status = axis2_addr_in_extract_addr_params(env, soap_header, &msg_info_headers, addr_headers, AXIS2_WSA_NAMESPACE, msg_ctx); axis2_addr_in_extract_ref_params(env, soap_header, axis2_msg_ctx_get_msg_info_headers (msg_ctx, env)); } else { /* addressing headers are not present in the SOAP message */ AXIS2_LOG_INFO(env->log, AXIS2_LOG_SI, "No Addressing Headers present in the IN message. Addressing In Handler cannot do anything."); return AXIS2_SUCCESS; /* no addressing heades means addressing not in use */ } } ctx = axis2_msg_ctx_get_base(msg_ctx, env); if (ctx) { property = axutil_property_create(env); axutil_property_set_scope(property, env, AXIS2_SCOPE_REQUEST); axutil_property_set_value(property, env, addr_ns_str); axis2_ctx_set_property(ctx, env, AXIS2_WSA_VERSION, property); } /* extract service group context, if available */ axis2_addr_in_extract_svc_grp_ctx_id(env, soap_header, msg_ctx); axutil_array_list_free(addr_headers, env); return status; } } return AXIS2_SUCCESS; }
int axis2_xmpp_client_on_normal_node( axis2_xmpp_session_data_t *session, iks* node) { if(!strcmp("stream:features", iks_name(node))) { session->features = iks_stream_features(node); if(session->use_sasl) { if(session->use_tls && !iks_is_secure(session->parser)) { if(!session->authorized) { /* we might be in the process of establishing TLS. so should return OK */ return IKS_OK; } return IKS_HOOK; } if(session->authorized) { /* Bind a resource if required */ xmpp_process_msg(session, node); } else { if(session->features & IKS_STREAM_SASL_MD5) { iks_start_sasl(session->parser, IKS_SASL_DIGEST_MD5, session->jid->user, session->password); } else if(session->features & IKS_STREAM_SASL_PLAIN) { iks_start_sasl(session->parser, IKS_SASL_PLAIN, session->jid->user, session->password); } #ifdef AXIS2_XMPP_GSSAPI else if (session->features & IKS_STREAM_SASL_GSSAPI) { iks_start_sasl (session->parser, IKS_SASL_GSSAPI, session->jid->user, session->password); } #endif /* AXIS2_XMPP_GSSAPI */ } } else { /* features node */ if(!strcmp("stream:features", iks_name(node))) { if(session->authorized) xmpp_process_msg(session, node); } } } else if(!strcmp("failure", iks_name(node))) { AXIS2_LOG_ERROR(session->env->log, AXIS2_LOG_SI, "[xmpp]Authentication failed."); return IKS_HOOK; } else if(!strcmp("success", iks_name(node))) { AXIS2_LOG_INFO(session->env->log, "[xmpp]Authentication successful."); session->authorized = 1; iks_send_header(session->parser, session->server); } else { ikspak *pak; pak = iks_packet(node); iks_filter_packet(session->filter, pak); } return IKS_OK; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL axis2_phase_invoke( axis2_phase_t * phase, const axutil_env_t * env, axis2_msg_ctx_t * msg_ctx) { int idx = 0, size = 0; axis2_status_t status = AXIS2_SUCCESS; AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:axis2_phase_invoke"); axis2_msg_ctx_set_paused_phase_name(msg_ctx, env, phase->name); if(phase->first_handler) { if(axis2_msg_ctx_is_paused(msg_ctx, env)) { AXIS2_LOG_INFO(env->log, "Message context is paused in the phase %s", phase->name); return AXIS2_SUCCESS; } else { const axis2_char_t *handler_name = axutil_string_get_buffer(axis2_handler_get_name( phase->first_handler, env), env); AXIS2_LOG_INFO(env->log, "Invoke the first handler %s within the phase %s", handler_name, phase->name); status = axis2_handler_invoke(phase->first_handler, env, msg_ctx); if(!status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Handler %s invoke failed within phase %s", handler_name, phase->name); return status; } } } /* Invoking the rest of handlers except first_handler and last_handler */ size = axutil_array_list_size(phase->handlers, env); while(idx < size) { if(axis2_msg_ctx_is_paused(msg_ctx, env)) { break; } else { axis2_handler_t *handler = (axis2_handler_t *)axutil_array_list_get(phase->handlers, env, idx); if(handler) { const axis2_char_t *handler_name = axutil_string_get_buffer(axis2_handler_get_name( handler, env), env); AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Invoke the handler %s within the phase %s", handler_name, phase->name); /* Test code. This is used when valgrind is used to find leaks in Axis2/C modules.*/ /*if(!axutil_strcmp(handler_name, "SandeshaGlobalInHandler") || !axutil_strcmp( handler_name, "SandeshaInHandler")) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "dam_handler_name %s. dam_phase_name %s", handler_name, phase->name); if(!axutil_strcmp(handler_name, "SandeshaGlobalInHandler")) { status = sandesha2_global_in_handler_invoke(phase->first_handler, env, msg_ctx); } if(!axutil_strcmp(handler_name, "SandeshaInHandler")) { status = sandesha2_in_handler_invoke(phase->first_handler, env, msg_ctx); } } else*/ status = axis2_handler_invoke(handler, env, msg_ctx); if(!status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Handler %s invoke failed within phase %s", handler_name, phase->name); return status; } /* idx increment should be done after the invoke function. If the invocation failed this handler is taken care of and no need to revoke again */ idx++; axis2_msg_ctx_set_current_handler_index(msg_ctx, env, idx); } } } /* If phase last handler is there invoke it here */ if(phase->last_handler) { if(axis2_msg_ctx_is_paused(msg_ctx, env)) { AXIS2_LOG_INFO(env->log, "Message context is paused in the phase %s", phase->name); return AXIS2_SUCCESS; } else { const axis2_char_t *handler_name = axutil_string_get_buffer(axis2_handler_get_name( phase->last_handler, env), env); AXIS2_LOG_INFO(env->log, "Invoke the last handler %s within the phase %s", handler_name, phase->name); status = axis2_handler_invoke(phase->last_handler, env, msg_ctx); if(!status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Handler %s invoke failed within phase %s", handler_name, phase->name); return status; } } } AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_phase_invoke"); return AXIS2_SUCCESS; }
axis2_status_t AXIS2_CALL axis2_udp_receiver_start( axis2_transport_receiver_t *tr_receiver, const axutil_env_t * env) { axis2_status_t status; axis2_udp_receiver_impl_t *receiver = NULL; receiver = AXIS2_INTF_TO_IMPL(tr_receiver); AXIS2_LOG_INFO(env->log, "Started the UDP server"); if (receiver->socket == AXIS2_INVALID_SOCKET) { /* socket not set, we should create one */ if (receiver->is_multicast && receiver->multicast_group) { /* Setup a socket to receive multicast packets */ receiver->socket = axutil_network_hadler_create_multicast_svr_socket( env, receiver->port, receiver->multicast_group); } else { axis2_ctx_t *ctx = NULL; /* Setup a socket to receive unicast packets */ receiver->socket = axutil_network_handler_create_dgram_svr_socket( env, receiver->port); receiver->owns_socket = AXIS2_TRUE; /* bind the socket to a unique address */ /*axutil_network_handler_bind_socket(env, receiver->socket, 0);*/ ctx = axis2_conf_ctx_get_base(receiver->conf_ctx, env); axis2_udp_transport_add_backchannel_info(env, ctx, receiver->socket); } receiver->owns_socket = AXIS2_TRUE; } if (receiver->socket == AXIS2_INVALID_SOCKET) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Socket creation faild on socket"); return AXIS2_FAILURE; } /* We are using a seperate socket to send the request */ receiver->send_socket = axutil_network_handler_open_dgram_socket(env); if (receiver->send_socket == AXIS2_INVALID_SOCKET) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Socket creation faild on socket"); return AXIS2_FAILURE; } receiver->stop = AXIS2_FALSE; axutil_thread_mutex_unlock(receiver->mutex); while (!receiver->stop) { axis2_udp_recv_thd_args_t *args = NULL; axutil_thread_t *worker_thread = NULL; axis2_char_t *addr = NULL; int port = receiver->port; int buf_len = AXIS2_UDP_PACKET_MAX_SIZE; axis2_char_t *in_buff = NULL; in_buff = AXIS2_MALLOC(env->allocator, sizeof(char) * receiver->max_packet_size); /* This is a blocking call. This will block until data is available in the socket */ status = axutil_network_handler_read_dgram(env, receiver->socket, in_buff, &buf_len, &addr, &port); if (status == AXIS2_FAILURE) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in reading data from the datagram."); return AXIS2_FAILURE; } args = (axis2_udp_recv_thd_args_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_udp_recv_thd_args_t)); if (!args) { AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); return AXIS2_FAILURE; } /* Set the data required by the thread */ args->env = axutil_init_thread_env(env); args->socket = receiver->socket; args->send_socket = receiver->send_socket; args->conf_ctx = receiver->conf_ctx; args->req_addr = addr; args->req_port = port; args->request.buff = in_buff; args->request.buf_size = buf_len; args->request.op = NULL; args->request.svc = NULL; args->is_multicast = receiver->is_multicast; #ifdef AXIS2_SVR_MULTI_THREADED worker_thread = axutil_thread_pool_get_thread(env->thread_pool, axis2_udp_receiver_thread_worker_func, (void *) args); if (!worker_thread) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Thread creation failed" "server thread loop"); continue; } axutil_thread_pool_thread_detach(env->thread_pool, worker_thread); #else axis2_udp_receiver_thread_worker_func(NULL, (void *)args); #endif } return AXIS2_SUCCESS; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL openssl_sig_verify(const axutil_env_t *env, openssl_pkey_t *pubkey, oxs_buffer_t *input_buf, oxs_buffer_t *sig_buf) { axis2_status_t status = AXIS2_FAILURE; const EVP_MD* digest; EVP_MD_CTX md_ctx; EVP_PKEY* pkey = NULL; int ret; /*Get the publickey*/ pkey = openssl_pkey_get_key(pubkey, env); if(!pkey){ oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_SIG_VERIFICATION_FAILED,"Cannot load the public key" ); } /*TODO Set the digest according to the signature method*/ digest = EVP_sha1(); /*Init MD Ctx*/ EVP_MD_CTX_init(&md_ctx); /*Intialize verification*/ ret = EVP_VerifyInit(&md_ctx, digest); if(ret != 1) { /*Error*/ oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_SIG_VERIFICATION_FAILED,"EVP_VerifyInit failed" ); return AXIS2_FAILURE; } ret = EVP_VerifyUpdate(&md_ctx, oxs_buffer_get_data(input_buf, env), oxs_buffer_get_size(input_buf, env)); if(ret != 1) { /*Error*/ oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_SIG_VERIFICATION_FAILED,"EVP_VerifyUpdate failed" ); return AXIS2_FAILURE; } ret = EVP_VerifyFinal(&md_ctx, oxs_buffer_get_data(sig_buf, env), oxs_buffer_get_size(sig_buf, env), pkey); if(ret == 0){ /*Error. Signature verification FAILED */ oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_SIG_VERIFICATION_FAILED,"Signature verification FAILED." ); status = AXIS2_FAILURE; }else if(ret < 0){ /*Erorr. Some other error*/ oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_SIG_VERIFICATION_FAILED,"Error occured while verifying the signature." ); status = AXIS2_FAILURE; }else{ /*SUCCESS. */ AXIS2_LOG_INFO(env->log, "[openssl][sig] Signature verification SUCCESS " ); status = AXIS2_SUCCESS; } EVP_MD_CTX_cleanup(&md_ctx); return status; }