87 lines
2.3 KiB
C++
87 lines
2.3 KiB
C++
//----------------------------------------------------------------------------
|
|
//
|
|
// Copyright (C) Intel Corporation, 2006 - 2007.
|
|
//
|
|
// File: SOAPCommunicator.cpp
|
|
//
|
|
// Contents: Allows communication of Soap messages.
|
|
//
|
|
// Notes:
|
|
//----------------------------------------------------------------------------
|
|
|
|
#include "SOAPCommunicator.h"
|
|
#include "SoapCommonDefinitions.h"
|
|
#ifdef _WIN32
|
|
SOAPCommunicator::SOAPCommunicator(const char* host, bool tls, const char* user,
|
|
const char* pass, const char* certName, bool kerberos)
|
|
#else
|
|
SOAPCommunicator::SOAPCommunicator(const char* host, bool tls, const char* user,
|
|
const char* pass, const char* certPass, const char* certName,
|
|
bool kerberos)
|
|
#endif
|
|
{
|
|
is_tls = tls;
|
|
setURLFromIP(host);
|
|
#ifdef _WIN32
|
|
soap = new Soap(enTarget.c_str(), (const CHAR*)certName, user, pass, false, kerberos);
|
|
#else
|
|
soap = new Soap(enTarget.c_str(), (const CHAR*)certName, NULL, user, pass);
|
|
#endif
|
|
}
|
|
|
|
SOAPCommunicator::~SOAPCommunicator()
|
|
{
|
|
if(soap)
|
|
{
|
|
delete soap;
|
|
}
|
|
}
|
|
|
|
// Set the Managment-Console IP for the next notification
|
|
void SOAPCommunicator::SetTarget(const char *url)
|
|
{
|
|
if (soap)
|
|
{
|
|
setURLFromIP(url);
|
|
soap->SetIp(enTarget.c_str());
|
|
}
|
|
}
|
|
int SOAPCommunicator::SendEvent(string MEAddress ,
|
|
unsigned short MEPort,
|
|
string ME_UUID,
|
|
string MPSAddress,
|
|
unsigned short MPSHttpPort,
|
|
unsigned short MPSSocksPort,
|
|
mps__ConnectionStateTypeDefinition state)
|
|
{
|
|
int status = 0;
|
|
mps__EventNotificationType eventNotification;
|
|
eventNotification.DeviceFqdn = MEAddress;
|
|
eventNotification.State = state;
|
|
eventNotification.DevicePort.push_back(MEPort);
|
|
eventNotification.DeviceUuid = ME_UUID;
|
|
eventNotification.MpsAddress = MPSAddress;
|
|
eventNotification.MpsHttpPort = MPSHttpPort;
|
|
eventNotification.MpsSocksPort = MPSSocksPort;
|
|
eventNotification.WantReply = false;
|
|
soap->Init();
|
|
_mps__EventNotificationRequest request;
|
|
_mps__MPSAlertResponse response;
|
|
request.MPSEvent = &eventNotification;
|
|
if(soap_call___mps__MPSAlert(soap->GetSoap(),soap->GetIp(),
|
|
NULL,&request,response))
|
|
{
|
|
status = -1;
|
|
}
|
|
else
|
|
{
|
|
status = (int)response.KeepConnection;
|
|
}
|
|
return status;
|
|
|
|
}
|
|
void SOAPCommunicator::setURLFromIP(string ip)
|
|
{
|
|
enTarget = ip;
|
|
}
|