Example #1
0
int
ns__poller_data_read_queue(soap* soap, int sessionID, int count, struct RadarDataInfoArray* result)
{
	DarxendClient* client = client_manager_get_client(sessionID);
	if (!client)
		return die_bad_client(soap);

	RadarDataInfo* infos = darxend_client_read_queue(client, count);
	if (infos)
	{
		result->__size = count;

		result->array = (RadarDataInfo*)soap_malloc(soap, sizeof(RadarDataInfo) * count);
		int i;
		for (i = 0; i < count; i++)
		{
			result->array[i] = infos[i];
			result->array[i].site = soap_strdup(soap, result->array[i].site);
			result->array[i].product = soap_strdup(soap, result->array[i].product);
			free(infos[i].site);
			free(infos[i].product);
		}
		free(infos);
	}
	else
	{
		result->__size = -1;
	}
	return SOAP_OK;
}
struct soap_dom_element*
bes_InvalidActivityFaultDOM(struct soap *s,
        const char *faultstring, const char *message)
{
    struct soap_dom_element *fault, *besdetail, *messageElt;
    
    fault = createBESFaultElement(s, "InvalidActivityIdentifierFault", faultstring, &besdetail);
    if (fault == NULL) {
        return NULL;
    }

    messageElt = (struct soap_dom_element*)soap_malloc(s, sizeof(struct soap_dom_element));
    if (messageElt == NULL) {
        return NULL;
    }
    memset(messageElt, 0, sizeof(struct soap_dom_element));
    
    messageElt->name = soap_strdup(s, "Message");
    messageElt->nstr = soap_strdup(s, BES_NS);
    messageElt->data = soap_strdup(s, message);
    messageElt->prnt = besdetail;
    messageElt->soap = s;
    besdetail->elts = messageElt;
    
    return fault;
}
soap_dom_element::soap_dom_element(struct soap *soap, const char *nstr, const char *name, void *node, int type)
{ soap_default_xsd__anyType(soap, this);
  this->nstr = soap_strdup(soap, nstr);
  this->name = soap_strdup(soap, name);
  this->node = node;
  this->type = type;
}
static struct SOAP_ENV__Fault*
allocate_fault(struct soap *s,
        const char *faultcode, const char *faultstring)
{
    struct SOAP_ENV__Fault *fault;

    /* require a faultcode */
    if (faultcode == NULL) {
        return NULL;
    }

    fault = (struct SOAP_ENV__Fault*)soap_malloc(s,
            sizeof(struct SOAP_ENV__Fault));
    if (fault == NULL) {
        return NULL;
    }
    soap_default_SOAP_ENV__Fault(s, fault);

    fault->faultcode = soap_strdup(s, faultcode);

    if (faultstring) {
        fault->faultstring = soap_strdup(s, faultstring);
    }

    fault->detail = (struct SOAP_ENV__Detail*)soap_malloc(s,
            sizeof(struct SOAP_ENV__Detail));
    if (fault->detail) {
        soap_default_SOAP_ENV__Detail(s, fault->detail);
    }

    return fault;
}
Example #5
0
static void http_da_session_start(const char *realm, const char *nonce, const char *opaque)
{
  struct http_da_session *session;
  time_t now = time(NULL);

  if (now % 10 == 0) /* don't do this all the time to improve efficiency */
    http_da_session_cleanup();

#ifdef SOAP_DEBUG
  fprintf(stderr, "Starting session realm=%s nonce=%s\n", realm, nonce);
#endif

  MUTEX_LOCK(http_da_session_lock);

  session = (struct http_da_session*)malloc(sizeof(struct http_da_session));
  if (session)
  {
    session->next = http_da_session;
    session->modified = now;
    session->realm = soap_strdup(NULL, realm);
    session->nonce = soap_strdup(NULL, nonce);
    session->opaque = soap_strdup(NULL, opaque);
    session->nc = 0;
    http_da_session = session;
  }

  MUTEX_UNLOCK(http_da_session_lock);
}
soap_dom_attribute::soap_dom_attribute(struct soap *soap, const char *nstr, const char *name, const char *data)
{ this->soap = soap;
  this->next = NULL;
  this->nstr = soap_strdup(soap, nstr);
  this->name = soap_strdup(soap, name);
  this->data = soap_strdup(soap, data);
  this->wide = NULL;
}
Example #7
0
GMI_RESULT ONVIF_FAULT(struct soap *soap_ptr, const char *Object, const char *Value1, const char *Value2, const char *Reason)
{
    //fault code
    soap_ptr->fault = (struct SOAP_ENV__Fault*)soap_malloc_zero(soap_ptr, (sizeof(struct SOAP_ENV__Fault)));
    soap_ptr->fault->SOAP_ENV__Code = (struct SOAP_ENV__Code*)soap_malloc_zero(soap_ptr, (sizeof(struct SOAP_ENV__Code)));
    if (NULL == soap_ptr->fault->SOAP_ENV__Code)
    {
        return GMI_OUT_OF_MEMORY;
    }
    soap_ptr->fault->SOAP_ENV__Code->SOAP_ENV__Value = soap_strdup(soap_ptr, Object);
    //fault subcode
    soap_ptr->fault->SOAP_ENV__Code->SOAP_ENV__Subcode = (struct SOAP_ENV__Code*)soap_malloc_zero(soap_ptr, (sizeof(struct SOAP_ENV__Code)));
    if (NULL == soap_ptr->fault->SOAP_ENV__Code->SOAP_ENV__Subcode)
    {
        return GMI_OUT_OF_MEMORY;
    }
    soap_ptr->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Value = soap_strdup(soap_ptr, Value1);
    //fault subcode subcode
    if (NULL != Value2)
    {
        soap_ptr->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Subcode = (struct SOAP_ENV__Code*)soap_malloc_zero(soap_ptr, (sizeof(struct SOAP_ENV__Code)));
        if (NULL == soap_ptr->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Subcode)
        {
            return GMI_OUT_OF_MEMORY;
        }
        soap_ptr->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Subcode->SOAP_ENV__Value   = soap_strdup(soap_ptr, Value2);
        soap_ptr->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Subcode->SOAP_ENV__Subcode = NULL;
    }
    else
    {
        soap_ptr->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Subcode = NULL;
    }

    soap_ptr->fault->faultcode = NULL;
    soap_ptr->fault->faultstring = NULL;
    soap_ptr->fault->faultactor = NULL;
    soap_ptr->fault->detail = NULL;
    //fault reason
    if (NULL != Reason)
    {
        soap_ptr->fault->SOAP_ENV__Reason = (struct SOAP_ENV__Reason *)soap_malloc_zero(soap_ptr, sizeof(struct SOAP_ENV__Reason));
        if (NULL == soap_ptr->fault->SOAP_ENV__Reason)
        {
            return GMI_OUT_OF_MEMORY;
        }
        soap_ptr->fault->SOAP_ENV__Reason->SOAP_ENV__Text = soap_strdup(soap_ptr, Reason);
    }
    else
    {
        soap_ptr->fault->SOAP_ENV__Reason = NULL;
    }
    soap_ptr->fault->SOAP_ENV__Node = NULL;
    soap_ptr->fault->SOAP_ENV__Role = NULL;
    soap_ptr->fault->SOAP_ENV__Detail = NULL;

    return GMI_SUCCESS;
}
Example #8
0
static void *dime_write_open(struct soap *soap, const char *id, const char *type, const char *options)
{
	DBG("\n");
	// we can return NULL without setting soap->error if we don't want to use the streaming callback for this DIME attachment
	struct dime_write_handle *handle = (struct dime_write_handle*)soap_malloc(soap, sizeof(struct dime_write_handle));
	if (!handle)
	{
		soap->error = SOAP_EOM;
		return NULL;
	}


#if 0
	char *name = tempnam(TMPDIR, "data");
	fprintf(stderr, "Saving file %s\n", name);
	handle->name = soap_strdup(soap, name);
	free(name);
#else
	time_t t = time(NULL);
	struct tm tm = *localtime(&t);

	char name[64];
	memset(name, '\0', sizeof(name));

	switch(bkev){
	case EVENT_SET_FILENAME_CONFIG:
		sprintf(name, "configuration-%d-%d-%d-%d-%d-%d.conf",
				tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
				tm.tm_hour,	tm.tm_min, tm.tm_sec);
		break;
	case EVENT_SET_FILENAME_FIRMWARE:
		sprintf(name, "firmware-%d-%d-%d-%d-%d-%d.ctfw",
				tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
				tm.tm_hour,	tm.tm_min, tm.tm_sec);
		break;
	default:
		sprintf(name, "%d-%d-%d-%d-%d-%d",
				tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
				tm.tm_hour,	tm.tm_min, tm.tm_sec);
		break;
	}

	DBG("tmpname: %s\n", name);

	handle->name = soap_strdup(soap, name);
#endif


	handle->fd = fopen(handle->name, "wb");
	if (!handle->fd)
	{
		soap->error = SOAP_EOF; // could not open file for writing
		soap->errnum = errno; // get reason
		return NULL;
	}
	return (void*)handle;
}
Example #9
0
/**
@fn _wsse__Security* soap_wsse_add_Security_actor(struct soap *soap, const char *actor)
@brief Adds Security header element with actor or role attribute.
@param soap context
@param actor string
@return _wsse__Security object
*/
struct _wsse__Security*
soap_wsse_add_Security_actor(struct soap *soap, const char *actor)
{ _wsse__Security *security = soap_wsse_add_Security(soap);
  DBGFUN1("soap_wsse_add_Security_actor", "actor=%s", actor);
  if (soap->namespaces && !strcmp(soap->namespaces[0].ns, "http://schemas.xmlsoap.org/soap/envelope/"))
    security->SOAP_ENV__actor = soap_strdup(soap, actor);
  else
    security->SOAP_ENV__role = soap_strdup(soap, actor);
  return security;
}
Example #10
0
static int my_soap_copy_fault(struct soap *soap, const char *faultcode,
		const char *faultsubcodeQName, const char *faultstring,
		const char *faultdetailXML) {
	char *r = NULL, *s = NULL, *t = NULL;
	if (faultsubcodeQName)
		r = soap_strdup(soap, faultsubcodeQName);
	if (faultstring)
		s = soap_strdup(soap, faultstring);
	if (faultdetailXML)
		t = soap_strdup(soap, faultdetailXML);
	return my_soap_set_error(soap, faultcode, r, s, t, SOAP_FAULT);
}
Example #11
0
soap_dom_element::soap_dom_element(struct soap *soap, const char *nstr, const char *name, const char *data)
{ this->soap = soap;
  this->next = NULL;
  this->prnt = NULL;
  this->nstr = soap_strdup(soap, nstr);
  this->name = soap_strdup(soap, name);
  this->data = soap_strdup(soap, data);
  this->wide = NULL;
  this->atts = NULL;
  this->elts = NULL;
  this->node = NULL;
  this->type = 0;
}
Example #12
0
soap_dom_element::soap_dom_element(struct soap *soap, const char *nstr, const char *name, void *node, int type)
{ this->soap = soap;
  this->next = NULL;
  this->prnt = NULL;
  this->nstr = soap_strdup(soap, nstr);
  this->name = soap_strdup(soap, name);
  this->data = NULL;
  this->wide = NULL;
  this->atts = NULL;
  this->elts = NULL;
  this->node = node;
  this->type = type;
}
Example #13
0
static struct jptype__genericFault* jp2s_error(struct soap *soap, const glite_jp_error_t *err)
{
	struct jptype__genericFault *ret = NULL;
	if (err) {
		ret = soap_malloc(soap,sizeof *ret);
		memset(ret,0,sizeof *ret);
		ret->code = err->code;
		ret->source = soap_strdup(soap,err->source);
		ret->text = soap_strdup(soap,strerror(err->code));
		ret->description = err->desc ? soap_strdup(soap,err->desc) : NULL;
		ret->reason = jp2s_error(soap,err->reason);
	}
	return ret;
}
static struct soap_dom_element*
createBESFaultElement(struct soap *s, 
        const char *bescode, const char *faultstring,
        struct soap_dom_element **besdetailpp)
{
    struct soap_dom_element *fault, *faultcode, *faultstr;
    struct soap_dom_element *detail, *besdetail;
    
    if (!s || !bescode || !faultstring || !besdetailpp) {
        return NULL;
    }
    
    fault = (struct soap_dom_element*)soap_malloc(s, sizeof(struct soap_dom_element));
    faultcode = (struct soap_dom_element*)soap_malloc(s, sizeof(struct soap_dom_element));
    faultstr = (struct soap_dom_element*)soap_malloc(s, sizeof(struct soap_dom_element));
    detail = (struct soap_dom_element*)soap_malloc(s, sizeof(struct soap_dom_element));
    besdetail = (struct soap_dom_element*)soap_malloc(s, sizeof(struct soap_dom_element));
    if (!fault || !faultcode || !faultstr || !detail || !besdetail) {
        return NULL;
    }
    memset(fault, 0, sizeof(struct soap_dom_element));
    memset(faultcode, 0, sizeof(struct soap_dom_element));
    memset(faultstr, 0, sizeof(struct soap_dom_element));
    memset(detail, 0, sizeof(struct soap_dom_element));
    memset(besdetail, 0, sizeof(struct soap_dom_element));
    
    faultcode->name = soap_strdup(s, "faultcode");
    faultcode->data = (char*)soap_malloc(s, strlen("bes:") + strlen(bescode) + 1);
    sprintf(faultcode->data, "bes:%s", bescode);
    faultcode->prnt = fault;
    faultcode->next = faultstr;
    faultcode->soap = s;
    
    faultstr->name = soap_strdup(s, "faultstring");
    faultstr->data = soap_strdup(s, faultstring);
    faultstr->prnt = fault;
    faultstr->next = detail;
    faultstr->soap = s;
    
    detail->name = soap_strdup(s, "detail");
    detail->elts = besdetail;
    detail->prnt = fault;
    detail->soap = s;

    besdetail->name = soap_strdup(s, bescode);
    besdetail->nstr = soap_strdup(s, BES_NS);
    besdetail->prnt = detail;
    besdetail->soap = s;
    
    fault->nstr = soap_strdup(s, BES_NS);
    fault->name = soap_strdup(s, "Fault");
    fault->elts = faultcode;
    fault->soap = s;
    
    *besdetailpp = besdetail;
    
    return fault;
}
Example #15
0
/*
Code used for generating stubs:

int ns1__executeCommand(char* command, char** result);
*/
int ns1__executeCommand(soap* soap, char* command, char** result)
{
    // security check
    if (!soap->userid || !soap->passwd)
    {
        DEBUG_LOG("MaNGOSsoap: Client didn't provide login information");
        return 401;
    }

    uint32 accountId = sAccountMgr.GetId(soap->userid);
    if(!accountId)
    {
        DEBUG_LOG("MaNGOSsoap: Client used invalid username '%s'", soap->userid);
        return 401;
    }

    if(!sAccountMgr.CheckPassword(accountId, soap->passwd))
    {
        DEBUG_LOG("MaNGOSsoap: invalid password for account '%s'", soap->userid);
        return 401;
    }

    if(sAccountMgr.GetSecurity(accountId) < SECURITY_ADMINISTRATOR)
    {
        DEBUG_LOG("MaNGOSsoap: %s's gmlevel is too low", soap->userid);
        return 403;
    }

    if(!command || !*command)
        return soap_sender_fault(soap, "Command mustn't be empty", "The supplied command was an empty string");

    DEBUG_LOG("MaNGOSsoap: got command '%s'", command);
    SOAPCommand connection;

    // commands are executed in the world thread. We have to wait for them to be completed
    {
        // CliCommandHolder will be deleted from world, accessing after queueing is NOT save
        CliCommandHolder* cmd = new CliCommandHolder(accountId, SECURITY_CONSOLE, &connection, command, &SOAPCommand::print, &SOAPCommand::commandFinished);
        sWorld.QueueCliCommand(cmd);
    }

    // wait for callback to complete command

    int acc = connection.pendingCommands.acquire();
    if(acc)
    {
        sLog.outError("MaNGOSsoap: Error while acquiring lock, acc = %i, errno = %u", acc, errno);
    }

    // alright, command finished

    char* printBuffer = soap_strdup(soap, connection.m_printBuffer.c_str());
    if(connection.hasCommandSucceeded())
    {
        *result = printBuffer;
        return SOAP_OK;
    }
    else
        return soap_sender_fault(soap, printBuffer, printBuffer);
}
struct SOAP_ENV__Fault*
bes_UnsupportedFault(struct soap* s,
        const char *faultstring, const char *element)
{
    struct SOAP_ENV__Fault *fault;

    fault = allocate_fault(s, BES_FAULT_UNSUPPORTED, faultstring);
    if (fault == NULL) {
        return NULL;
    }

    if (fault->detail) {
        fault->detail->bes__UnsupportedFeatureFault
                = (struct bes__UnsupportedFeatureFaultType*)soap_malloc(s,
                        sizeof(struct bes__UnsupportedFeatureFaultType));
        if (fault->detail->bes__UnsupportedFeatureFault) {
            memset(fault->detail->bes__UnsupportedFeatureFault, 0,
                    sizeof(struct bes__UnsupportedFeatureFaultType));
        }
        fault->detail->bes__UnsupportedFeatureFault->Feature = (char**)soap_malloc(s, sizeof(char*));
        if (!fault->detail->bes__UnsupportedFeatureFault->Feature) {
            return NULL;
        }
        *fault->detail->bes__UnsupportedFeatureFault->Feature = soap_strdup(s, 
                element?element:"");
        if (!*fault->detail->bes__UnsupportedFeatureFault->Feature) {
            return NULL;
        }
        fault->detail->bes__UnsupportedFeatureFault->__sizeFeature = 1;
    }

    return fault;
}
Example #17
0
void *mime_server_write_open(struct soap *soap, void *unused_handle,
		const char *id, const char *type, const char *description,
		enum soap_mime_encoding encoding) { /* Note: the 'unused_handle' is always NULL */
	/* Return NULL without setting soap->error if we don't want to use the streaming callback for this DIME attachment */
	const char *file;
	struct mime_server_handle *handle = soap_malloc(soap,
			sizeof(struct mime_server_handle));
	if (!handle) {
		soap->error = SOAP_EOM;
		return NULL;
	}
	/* Create a new file */
	file = tempnam(TMPDIR, "data");
	/* The file name is also the key */
	handle->key = soap_strdup(soap, file);
	handle->fd = fopen(file, "wb");
	free((void*) file);
	if (!handle->fd) {
		soap->error = soap_sender_fault(soap,
				"Cannot save data to file", handle->key);
		soap->errnum = errno; /* get reason */
		return NULL;
	}
	fprintf(stderr, "Saving file %s type %s\n", handle->key,
			type ? type : "");
	return (void*) handle;
}
struct SOAP_ENV__Fault*
bes_InvalidRequestFault(struct soap* s,
        const char *faultstring, const char *element)
{
    struct SOAP_ENV__Fault *fault;

    fault = allocate_fault(s, BES_FAULT_INVALID_REQUEST, faultstring);
    if (fault == NULL) {
        return NULL;
    }

    if (fault->detail) {
        fault->detail->bes__InvalidRequestMessageFault
                = (struct bes__InvalidRequestMessageFaultType*)soap_malloc(s,
                        sizeof(struct bes__InvalidRequestMessageFaultType));
        if (fault->detail->bes__InvalidRequestMessageFault) {
            memset(fault->detail->bes__InvalidRequestMessageFault, 0,
                    sizeof(struct bes__InvalidRequestMessageFaultType));
            fault->detail->bes__InvalidRequestMessageFault->InvalidElement = (char**)soap_malloc(s, sizeof(char*));
            if (!fault->detail->bes__InvalidRequestMessageFault->InvalidElement) {
                return NULL;
            }
            *fault->detail->bes__InvalidRequestMessageFault->InvalidElement = soap_strdup(s, 
                    element?element:"");
            if (!*fault->detail->bes__InvalidRequestMessageFault->InvalidElement) {
                return NULL;
            }
            fault->detail->bes__InvalidRequestMessageFault->__sizeInvalidElement = 1;
        }
    }

    return fault;
}
Example #19
0
int MyFeedRefresh(struct soap *soap, glite_jpis_context_t ctx, long int uniqueid, const char *dest, int status, const char *feedid)
{
	struct _jpelem__FeedIndexRefresh		in;
	struct _jpelem__FeedIndexRefreshResponse 	out;

	lprintf("(%ld) for %s called, status = %d\n", uniqueid, feedid, status);

	if (refresh_gsoap(ctx, soap) != 0)
		return glite_jpis_stack_error(ctx->jpctx, EINVAL, "can't refresh credentials");

	soap_begin(soap);
	memset(&in, 0, sizeof(in));
	in.feedId = soap_strdup(soap, feedid);
	if (check_fault(soap,soap_call___jpsrv__FeedIndexRefresh(soap,dest,"", &in, &out)) != 0) {
		fprintf(stderr, "\n");
		glite_jpis_unlockFeed(ctx, uniqueid);
		glite_jpis_stack_error(ctx->jpctx, EIO, "soap_call___jpsrv__FeedRefresh() returned error %d", soap->error);
		soap_end(soap);
		return EIO;
	}
	else {
		status &= (~GLITE_JP_IS_STATE_ERROR);
		lprintf("(%ld) FeedId: %s\n", uniqueid, feedid);
		lprintf("(%ld) Expires: %s", uniqueid, ctime(&out.feedExpires));
		glite_jpis_initFeed(ctx, uniqueid, feedid, time(NULL) + (out.feedExpires - time(NULL)) / 2, status);
		glite_jpis_unlockFeed(ctx, uniqueid);
	}

	soap_end(soap);
	return 0;
}
Example #20
0
int glite_delegation_destroy(glite_delegation_ctx *ctx, const char *delegationID)
{
    char *sdelegationID = "";
    struct delegation__destroyResponse dest_resp;

    if(!ctx)
        return -1;

    /* error is already set */
    if (!ctx->soap) 
        return -1;

    if (delegationID)
    {
        sdelegationID = soap_strdup(ctx->soap, delegationID);
        if (!sdelegationID)
        {
            glite_delegation_set_error(ctx, "glite_delegation_destroy: soap_strdup()"
                           " of delegationID failed!");
            return -1;
        }
    }
    
    if (SOAP_OK != soap_call_delegation__destroy(ctx->soap, ctx->endpoint, NULL,
                                                  sdelegationID, &dest_resp))
    {
            _fault_to_error(ctx, __func__);
            return -1;
    }

    return 0;
}
Example #21
0
int zkcfg__getAllKeys(struct soap *soap, void *notused, struct zkcfg__Keys *keys)
{
	struct dbhlpColumn desc[1] = {
		{ { 0 }, DBT_STRING },
	};
    sqlite3 *db = db_get();
	struct dbhlpColumn **all = 0;
	int rows = 0, i;

	db_exec_select2(db, "SELECT key FROM config", desc, 1, &all, &rows);
	if (rows > 0) {
		keys->__ptr = (char**)soap_malloc(soap, rows * sizeof(char*));
		keys->__size = rows;

		for (i = 0; i < rows; i++) {
			keys->__ptr[i] = soap_strdup(soap, all[i][0].data.s);
		}
	}
	else {
		keys->__ptr = 0;
		keys->__size = 0;
	}

	db_free_select2(desc, 1, all, rows);
    db_release(db);
    
	return SOAP_OK;
}
Example #22
0
int storm::PurgeFromSpaceRequest::buildResponse()
{
    srmlogit(STORM_LOG_DEBUG, "storm::PurgeFromSpaceRequest::buildResponse()", "called.\n");
	if(m_builtResponse != NULL)
	{
		return 0;
	}
	try
	{
		m_builtResponse = storm::soap_calloc<ns1__srmPurgeFromSpaceResponse>(m_soapRequest);
		if(m_builtResponse == NULL)
		{
			srmlogit(STORM_LOG_ERROR, "storm::PurgeFromSpaceRequest::buildResponse()", "Unable to allocate memory for the response\n");
			return SOAP_EOM;
		}
		m_builtResponse->returnStatus = storm::soap_calloc<ns1__TReturnStatus>(m_soapRequest);
		if(m_builtResponse->returnStatus == NULL)
		{
			srmlogit(STORM_LOG_ERROR, "storm::PurgeFromSpaceRequest::buildResponse()", "Unable to allocate memory for the return status\n");
			return SOAP_EOM;
		}
	} catch (std::invalid_argument& exc) {
		throw std::logic_error("Unable to allocate memory for the response. invalid_argument Exception: "
				+ std::string(exc.what()));
	}
	m_builtResponse->returnStatus->statusCode = m_status;
  	if (!m_explanation.empty()) {
  		m_builtResponse->returnStatus->explanation = soap_strdup(m_soapRequest, m_explanation.c_str());
  	}
    return 0;
}
Example #23
0
int zkcfg__getValue(struct soap *soap, char *key, struct zkcfg__Ret *res)
{
	struct dbhlpColumn desc[1] = {
		{{ 0 }, DBT_STRING },
	};
    sqlite3 *db = db_get();
	struct dbhlpColumn **all = 0;
	int rows = 0, i, rc;
	char *sql = (char*)alloca(1024);

	snprintf(sql, 1024, "SELECT value FROM config WHERE key='%s'", key);

	rc = db_exec_select2(db, sql, desc, 1, &all, &rows);
	if (rc >= 0) {
		if (rows == 0) {
			res->value = 0;
			res->result = -1;
		}
		else {
			res->value = soap_strdup(soap, all[0][0].data.s);
			res->result = 0;
		}

		db_free_select2(desc, 1, all, rows);
	}
    db_release(db);
    
	return SOAP_OK;
}
struct SOAP_ENV__Fault*
bes_InvalidActivityFault(struct soap* s,
        const char *faultstring, const char *message)
{
    struct SOAP_ENV__Fault *fault;

    fault = allocate_fault(s, BES_FAULT_INVALID_ACTIVITY, faultstring);
    if (fault == NULL) {
        return NULL;
    }

    if (fault->detail) {
        fault->detail->bes__InvalidActivityIdentifierFault
                = (struct bes__InvalidActivityIdentifierFaultType*)soap_malloc(
                        s,
                        sizeof(struct bes__InvalidActivityIdentifierFaultType));
        if (fault->detail->bes__InvalidActivityIdentifierFault) {
            memset(fault->detail->bes__InvalidActivityIdentifierFault, 0,
                    sizeof(struct bes__InvalidActivityIdentifierFaultType));
            fault->detail->bes__InvalidActivityIdentifierFault->Message = soap_strdup(s, 
                    message?message:"");
            if (!fault->detail->bes__InvalidActivityIdentifierFault->Message) {
                return NULL;
            }
        }
    }
    
    return fault;
}
Example #25
0
int glite_delegation_info(glite_delegation_ctx *ctx,
    const char *delegationID, time_t *expiration)
{
    char *sdelegationID = "";
    struct delegation__getTerminationTimeResponse resp;

    if(!ctx)
        return -1;

    /* error is already set */
    if (!ctx->soap) 
        return -1;

    if (delegationID)
    {
        sdelegationID = soap_strdup(ctx->soap, delegationID);
        if (!sdelegationID)
        {
            glite_delegation_set_error(ctx, "glite_delegation_info: soap_strdup()"
                           " of delegationID failed!");
            return -1;
        }
    }
    
    if (SOAP_OK != soap_call_delegation__getTerminationTime(ctx->soap, 
                        ctx->endpoint, NULL, sdelegationID, &resp))
    {
            _fault_to_error(ctx, __func__);
            return -1;
    }

    *expiration = resp._getTerminationTimeReturn;    

    return 0;
}
Example #26
0
int ns__echoString(struct soap *soap, char *str, char **res)
{ /* Get Header info and setup response Header */
  if (check_header(soap))
  { printf("Malformed header\n");
    return SOAP_FAULT; /* there was a problem */
  }

  /* If message with MessageID already received, ignore it */
  if (check_received(soap->header->wsa__MessageID))
  { printf("Request message %s already received\n", soap->header->wsa__MessageID);
    return SOAP_STOP;
  }

  printf("Request message %s accepted\n", soap->header->wsa__MessageID);

  /* Check ReplyTo has Address */
  if (!soap->header->wsa__ReplyTo || !soap->header->wsa__ReplyTo->Address)
    return soap_sender_fault(soap, "No WS-Addressing ReplyTo address", NULL);
  /* Copy Header info into response Header */
  soap->header->wsa__To = soap->header->wsa__ReplyTo->Address;

  /* Add info to response Header */
  soap->header->wsa__MessageID = soap_strdup(soap, soap_int2s(soap, id_count++));
  soap->header->wsa__Action = "http://genivia.com/udp/echoStringResponse";

  /* Copy request string into response string */
  printf("Response message %s returned\n", soap->header->wsa__MessageID);
  *res = str;

  return SOAP_OK;
}
Example #27
0
void addSecurity(struct soap* soap) {
  struct _ns1__CAPHeaderTypeDef* CAPheader;
  int* CogId;

  soap_wsse_add_Security(soap);
  if (soap_wsse_sign_body(soap, SOAP_SMD_SIGN_RSA_SHA256, rsa_private_key, 0)) {
    printf("Error signing body\n");
    exit(EXIT_FAILURE);
  }

  if (soap_wsse_add_BinarySecurityTokenX509(soap, "X509Token", cert)) {
    printf("Error adding security token\n");
    exit(EXIT_FAILURE);
  }
  if (soap_wsse_add_KeyInfo_SecurityTokenReferenceX509(soap, "X509TokenReference")) {
    printf("Error adding security token reference\n");
    exit(EXIT_FAILURE);
  }

  CAPheader = (struct _ns1__CAPHeaderTypeDef*) soap_malloc(soap, sizeof(struct _ns1__CAPHeaderTypeDef));
  CogId = (int*) soap_malloc(soap, sizeof(int));
  *CogId = 100014;

  soap_default__ns1__CAPHeaderTypeDef(soap, CAPheader);
  CAPheader->logonUser = soap_strdup(soap, "dmopentester");
  CAPheader->logonCogId = CogId;

  soap->header->ns1__CAPHeaderTypeDef = CAPheader;
}
int save_options(const char *file, const char *name, struct option *options)
{ struct soap soap;
  soap_init1(&soap, SOAP_XML_TREE);
  soap.namespaces = NULL;
  soap.encodingStyle = NULL;
  if (file)
  { soap.sendfd = open(file, O_CREAT | O_WRONLY);
    if (soap.sendfd < 0)
    { soap_done(&soap);
      return EOF;
    }
  }
  if (!soap_begin_send(&soap) && !soap_element_begin_out(&soap, name, 0, NULL))
  { struct option *p;
    struct t__Option t;
    for (p = options; p->name; p++)
    { t.val = NULL;
      if (!p->name[0])
      { if (!p->value)
          continue;
	t.key = NULL;
	t.val = p->value;
      }
      else if (p->name[1] == '.')
        t.key = (char*)p->name + 2;
      else
        t.key = (char*)p->name;
      if (p->selections && strchr(p->selections, ' '))
      { const char *s = p->selections - 1;
        char *r;
	int i;
        for (i = p->selected; i > 0; i--)
        { s = strchr(s + 1, ' ');
	  if (!s)
	    break;
	}
        if (s)
	{ t.val = soap_strdup(&soap, s + 1);
          r = strchr(t.val, ' ');
	  if (r)
	    *r = '\0';
        }
      }
      else if (p->value)
        t.val = p->value;
      else if (!p->selected)
        continue;
      if (soap_out_t__Option(&soap, "option", 0, &t, NULL))
        break;
    }
    if (!soap_element_end_out(&soap, name))
      soap_end_send(&soap);
  }
  if (file)
    close(soap.sendfd);
  soap_end(&soap);
  soap_done(&soap);
  return soap.error;
}
Example #29
0
/*
Code used for generating stubs:

int ns1__executeCommand(char* command, char** result);
*/
int ns1__executeCommand(soap* soap, char* command, char** result)
{
    // security check
    if (!soap->userid || !soap->passwd)
    {
        TC_LOG_INFO("network.soap", "Client didn't provide login information");
        return 401;
    }

    uint32 accountId = AccountMgr::GetId(soap->userid);
    if (!accountId)
    {
        TC_LOG_INFO("network.soap", "Client used invalid username '%s'", soap->userid);
        return 401;
    }

    if (!AccountMgr::CheckPassword(accountId, soap->passwd))
    {
        TC_LOG_INFO("network.soap", "Invalid password for account '%s'", soap->userid);
        return 401;
    }

    if (AccountMgr::GetSecurity(accountId) < SEC_ADMINISTRATOR)
    {
        TC_LOG_INFO("network.soap", "%s's gmlevel is too low", soap->userid);
        return 403;
    }

    if (!command || !*command)
        return soap_sender_fault(soap, "Command can not be empty", "The supplied command was an empty string");

    TC_LOG_INFO("network.soap", "Received command '%s'", command);
    SOAPCommand connection;

    // commands are executed in the world thread. We have to wait for them to be completed
    {
        // CliCommandHolder will be deleted from world, accessing after queueing is NOT save
        CliCommandHolder* cmd = new CliCommandHolder(&connection, command, &SOAPCommand::print, &SOAPCommand::commandFinished);
        sWorld->QueueCliCommand(cmd);
    }

    // wait for callback to complete command

    int acc = connection.pendingCommands.acquire();
    if (acc)
        TC_LOG_ERROR("network.soap", "Error while acquiring lock, acc = %i, errno = %u", acc, errno);

    // alright, command finished

    char* printBuffer = soap_strdup(soap, connection.m_printBuffer.c_str());
    if (connection.hasCommandSucceeded())
    {
        *result = printBuffer;
        return SOAP_OK;
    }
    else
        return soap_sender_fault(soap, printBuffer, printBuffer);
}
Example #30
0
void storm::BolStatusRequest::addMissingSurls()
{
	int index = (m_turls.empty() ? 0 : m_turls.size() - 1);

	std::set<SurlPtr>::const_iterator const surlVectorEnd = m_surls.end();
	for (std::set<SurlPtr>::const_iterator i = m_surls.begin(); i != surlVectorEnd; ++i) {

		storm::Surl* current = i->get();

		if(!current)
		{
			throw std::logic_error("Unable to cast SurlPtr to Surl, cast failure");
		}
		if(this->checkSurl(current->getSurl()))
		{
			continue;
		}
		ns1__TBringOnlineRequestFileStatus *fileStatus;
		try
		{
			fileStatus = storm::soap_calloc<ns1__TBringOnlineRequestFileStatus>(m_soapRequest);
		} catch (std::invalid_argument& exc) {
				throw std::logic_error("Unable to allocate memory for a file status. invalid_argument Exception: " + std::string(exc.what()));
		}
		if(index >= m_builtResponse->arrayOfFileStatuses->__sizestatusArray)
		{
			throw std::logic_error("Attempt to add more Put Request File Status than allocated!");
		}
		m_builtResponse->arrayOfFileStatuses->statusArray[index] = fileStatus;

		fileStatus->fileSize = NULL;
		fileStatus->remainingPinTime = NULL;
		fileStatus->estimatedWaitTime = NULL;
		fileStatus->sourceSURL = soap_strdup(m_soapRequest, current->getSurl().c_str());
		try
		{
			fileStatus->status = storm::soap_calloc<ns1__TReturnStatus>(m_soapRequest);
		} catch (std::invalid_argument& exc) {
				throw std::logic_error("Unable to allocate memory for a return status. invalid_argument Exception: " + std::string(exc.what()));
		}
		fileStatus->status->statusCode = SRM_USCOREINVALID_USCOREPATH;
		fileStatus->status->explanation = soap_strdup(m_soapRequest, "No information about this SURL");
		++index;
	}
}