version 1.15, 2003/08/01 23:24:36
|
version 1.16, 2003/08/06 21:57:18
|
|
|
// Modified By: Carol Ann Krug Graves, Hewlett-Packard Company | // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company |
// (carolann_graves@hp.com) | // (carolann_graves@hp.com) |
// Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com) | // Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com) |
|
// Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
#include <Pegasus/Repository/CIMRepository.h> | #include <Pegasus/Repository/CIMRepository.h> |
#include <Pegasus/Common/SSLContext.h> | #include <Pegasus/Common/SSLContext.h> |
#include <Pegasus/Config/ConfigManager.h> | #include <Pegasus/Config/ConfigManager.h> |
|
#include <Pegasus/Common/Constants.h> |
|
#include <Pegasus/Common/System.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
CIMExportClient exportclient( &monitor, &httpConnector ); | CIMExportClient exportclient( &monitor, &httpConnector ); |
| |
Uint32 colon = dest.find (":"); | Uint32 colon = dest.find (":"); |
Uint32 doubleSlash = dest.find ("//"); |
|
Uint32 portNumber = 0; | Uint32 portNumber = 0; |
Boolean useHttps = false; | Boolean useHttps = false; |
String destStr = dest; | String destStr = dest; |
|
String hostName; |
| |
// | // |
// If the URL has https (https://hostname:port/...) then use SSL |
// If the URL has https (https://hostname:port/... or |
// for Indication delivery. If it has http (http://hostname:port/...) |
// https://hostname/...) then use SSL |
// or none (hostname:port/...) then do not use SSL. |
// for Indication delivery. If it has http (http://hostname:port/... |
|
// or http://hostname/...) then do not use SSL. |
// | // |
if ((colon != PEG_NOT_FOUND) && (doubleSlash != PEG_NOT_FOUND)) |
if (colon != PEG_NOT_FOUND) |
{ | { |
String httpStr = dest.subString(0, colon); | String httpStr = dest.subString(0, colon); |
if (String::equalNoCase(httpStr, "https")) | if (String::equalNoCase(httpStr, "https")) |
{ | { |
useHttps = true; | useHttps = true; |
} | } |
destStr = dest.subString(doubleSlash + 2, PEG_NOT_FOUND); |
else if (String::equalNoCase(httpStr, "http")) |
|
{ |
|
useHttps = false; |
|
} |
|
else |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, httpStr); |
|
} |
|
} |
|
else |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, dest); |
|
} |
|
|
|
String doubleSlash = dest.subString(colon + 1, 2); |
|
|
|
if (String::equalNoCase(doubleSlash, "//")) |
|
{ |
|
destStr = dest.subString(colon + 3, PEG_NOT_FOUND); |
|
} |
|
else |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, dest); |
} | } |
| |
colon = destStr.find (":"); | colon = destStr.find (":"); |
|
|
|
// |
|
// get hostname and port number from destination string |
|
// |
|
if (colon != PEG_NOT_FOUND) |
|
{ |
|
hostName = destStr.subString (0, colon); |
|
destStr = destStr.subString(colon + 1, PEG_NOT_FOUND); |
|
|
Uint32 slash = destStr.find ("/"); | Uint32 slash = destStr.find ("/"); |
|
String portStr; |
| |
if ((colon != PEG_NOT_FOUND) && (slash != PEG_NOT_FOUND)) |
if (slash != PEG_NOT_FOUND) |
|
{ |
|
portStr = destStr.subString (0, slash); |
|
} |
|
else |
{ | { |
String portStr = destStr.subString (colon + 1, slash); |
portStr = destStr.subString (0, PEG_NOT_FOUND); |
|
} |
|
|
sscanf (portStr.getCString (), "%u", &portNumber); | sscanf (portStr.getCString (), "%u", &portNumber); |
} | } |
|
// |
|
// There is no port number in the destination string, |
|
// get port number from system |
|
// |
|
else |
|
{ |
|
Uint32 slash = destStr.find ("/"); |
|
if (slash != PEG_NOT_FOUND) |
|
{ |
|
hostName = destStr.subString (0, slash); |
|
} |
|
else |
|
{ |
|
hostName = destStr.subString (0, PEG_NOT_FOUND); |
|
} |
|
if (useHttps) |
|
{ |
|
portNumber = System::lookupPort(WBEM_HTTPS_SERVICE_NAME, |
|
WBEM_DEFAULT_HTTPS_PORT); |
|
} |
|
else |
|
{ |
|
portNumber = System::lookupPort(WBEM_HTTP_SERVICE_NAME, |
|
WBEM_DEFAULT_HTTP_PORT); |
|
} |
|
} |
| |
if (useHttps) | if (useHttps) |
{ | { |
#ifdef PEGASUS_HAS_SSL | #ifdef PEGASUS_HAS_SSL |
exportclient.connect (destStr.subString (0, colon), |
exportclient.connect (hostName, portNumber, sslcontext); |
portNumber, sslcontext); |
|
#else | #else |
PEGASUS_STD(cerr) << "CIMxmlIndicationHandler Error: " | PEGASUS_STD(cerr) << "CIMxmlIndicationHandler Error: " |
<< "Cannot do https connection." << PEGASUS_STD(endl); | << "Cannot do https connection." << PEGASUS_STD(endl); |
|
|
} | } |
else | else |
{ | { |
exportclient.connect (destStr.subString (0, colon), portNumber); |
exportclient.connect (hostName, portNumber); |
} | } |
| |
// l10n | // l10n |