00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00037 #include "OW_config.h"
00038 #include "OW_ProviderAgentProviderEnvironment.hpp"
00039 #include "OW_Assertion.hpp"
00040 #include "OW_ClientCIMOMHandle.hpp"
00041 #include "OW_HTTPClient.hpp"
00042 #include "OW_Logger.hpp"
00043 #include "OW_RepositoryIFC.hpp"
00044 
00045 namespace OW_NAMESPACE
00046 {
00047 
00049 ProviderAgentProviderEnvironment::ProviderAgentProviderEnvironment(
00050    const LoggerRef& logger,
00051    const ConfigFile::ConfigMap& configMap,
00052    OperationContext& operationContext,
00053    const String& callbackURL,
00054    ClientCIMOMHandleConnectionPool& pool,
00055    ProviderAgentEnvironment::EConnectionCredentialsUsageFlag useConnectionCredentials)
00056    : m_logger(logger)
00057    , m_configMap(configMap)
00058    , m_operationContext(operationContext)
00059    , m_callbackURL(callbackURL)
00060    , m_connectionPool(pool)
00061    , m_CIMOMHandleRA()
00062    , m_useConnectionCredentials(useConnectionCredentials)
00063 {
00064 }
00066 ProviderAgentProviderEnvironment::~ProviderAgentProviderEnvironment()
00067 {
00068    for (Array<ClientCIMOMHandleRef>::const_iterator iter = m_CIMOMHandleRA.begin();
00069         iter < m_CIMOMHandleRA.end(); ++iter)
00070    {
00071       m_connectionPool.addConnectionToPool(*iter, m_callbackURL);
00072    }
00073 }
00074 
00076 
00077 CIMOMHandleIFCRef
00078 ProviderAgentProviderEnvironment::getCIMOMHandle() const
00079 {
00080    if (m_callbackURL.empty())
00081    {
00082       return CIMOMHandleIFCRef(0);
00083    }
00084 
00085    String callbackURL(m_callbackURL);
00086    if (m_useConnectionCredentials)
00087    {
00088       URL url(m_callbackURL);
00089       try
00090       {
00091          url.principal = m_operationContext.getStringData(OperationContext::USER_NAME);
00092          url.credential = m_operationContext.getStringData(OperationContext::USER_PASSWD);
00093       }
00094       catch (ContextDataNotFoundException& e)
00095       {
00096       }
00097       callbackURL = url.toString();
00098    }
00099 
00100    ClientCIMOMHandleRef client = m_connectionPool.getConnection(callbackURL);
00101 
00102    CIMProtocolIFCRef tmp = client->getWBEMProtocolHandler();
00103    if (tmp)
00104    {
00105       IntrusiveReference<HTTPClient> httpClient = tmp.cast_to<HTTPClient>();
00106       if (httpClient)
00107       {
00108          httpClient->addCustomHeader(HTTPUtils::Header_BypassLocker,
00109                               HTTPUtils::HeaderValue_true);
00110       }
00111    }
00112    m_CIMOMHandleRA.push_back(client);
00113    return client;
00114 }
00116 String
00117 ProviderAgentProviderEnvironment::getConfigItem(const String &name, const String &defRetVal) const
00118 {
00119    return ConfigFile::getConfigItem(m_configMap, name, defRetVal);
00120 }
00121 
00123 StringArray
00124 ProviderAgentProviderEnvironment::getMultiConfigItem(const String &itemName, 
00125    const StringArray& defRetVal, const char* tokenizeSeparator) const
00126 {
00127    return ConfigFile::getMultiConfigItem(m_configMap, itemName, defRetVal, tokenizeSeparator);
00128 }
00129 
00131 
00132 
00133 
00134 CIMOMHandleIFCRef
00135 ProviderAgentProviderEnvironment::getRepositoryCIMOMHandle() const
00136 {
00137    OW_ASSERTMSG(0, "not implemented");
00138    return CIMOMHandleIFCRef();
00139 }
00141 
00142 
00143 RepositoryIFCRef
00144 ProviderAgentProviderEnvironment::getRepository() const
00145 {
00146    OW_ASSERTMSG(0, "not implemented");
00147    return RepositoryIFCRef();
00148 }
00150 LoggerRef
00151 ProviderAgentProviderEnvironment::getLogger() const
00152 {
00153    return m_logger->clone();
00154 }
00156 LoggerRef
00157 ProviderAgentProviderEnvironment::getLogger(const String& componentName) const
00158 {
00159    LoggerRef rv = m_logger->clone();
00160    rv->setDefaultComponent(componentName);
00161    return rv;
00162 }
00164 String
00165 ProviderAgentProviderEnvironment::getUserName() const
00166 {
00167    OW_ASSERTMSG(0, "not implemented");
00168    return String();
00169 }
00171 OperationContext&
00172 ProviderAgentProviderEnvironment::getOperationContext()
00173 {
00174    return m_operationContext;
00175 }
00176 
00178 ProviderEnvironmentIFCRef
00179 ProviderAgentProviderEnvironment::clone() const
00180 {
00181    OW_ASSERTMSG(0, "not implemented");
00182    return ProviderEnvironmentIFCRef();
00183 }
00184 
00186 
00187 } 
00188