OW_ProviderAgentProviderEnvironment.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2001-2004 Vintela, Inc. All rights reserved.
00003 * Copyright (C) 2004 Novell, Inc. All rights reserved.
00004 *
00005 * Redistribution and use in source and binary forms, with or without
00006 * modification, are permitted provided that the following conditions are met:
00007 *
00008 *  - Redistributions of source code must retain the above copyright notice,
00009 *    this list of conditions and the following disclaimer.
00010 *
00011 *  - Redistributions in binary form must reproduce the above copyright notice,
00012 *    this list of conditions and the following disclaimer in the documentation
00013 *    and/or other materials provided with the distribution.
00014 *
00015 *  - Neither the name of Vintela, Inc. nor the names of its
00016 *    contributors may be used to endorse or promote products derived from this
00017 *    software without specific prior written permission.
00018 *
00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00022 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc. OR THE CONTRIBUTORS
00023 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00024 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00025 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00026 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00027 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00028 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00029 * POSSIBILITY OF SUCH DAMAGE.
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 // This function returns a regular cimom handle that does access checking and may call providers.
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 // This function returns a cimom handle that directly accesses the repository (CIMServer is bypassed).
00132 // no providers will be called.  This function should only be called if getCIMOMHandle()
00133 // is insufficent.
00134 CIMOMHandleIFCRef
00135 ProviderAgentProviderEnvironment::getRepositoryCIMOMHandle() const
00136 {
00137    OW_ASSERTMSG(0, "not implemented");
00138    return CIMOMHandleIFCRef();
00139 }
00141 // This function returns a reference to the repository.  This function should only
00142 // be called if getCIMOMHandle() and getRepositoryCIMOMHandle() are insufficient.
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 } // end namespace OW_NAMESPACE
00188 

Generated on Thu Feb 9 08:48:08 2006 for openwbem by  doxygen 1.4.6