(file) Return to CIMServer.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Server

   1 karl  1.177 //%2006////////////////////////////////////////////////////////////////////////
   2 mike  1.42  //
   3 karl  1.152 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
   4             // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
   5             // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
   6 karl  1.124 // IBM Corp.; EMC Corporation, The Open Group.
   7 karl  1.152 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   8             // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   9 karl  1.160 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
  10             // EMC Corporation; VERITAS Software Corporation; The Open Group.
  11 karl  1.177 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
  12             // EMC Corporation; Symantec Corporation; The Open Group.
  13 mike  1.42  //
  14             // Permission is hereby granted, free of charge, to any person obtaining a copy
  15 mike  1.50  // of this software and associated documentation files (the "Software"), to
  16             // deal in the Software without restriction, including without limitation the
  17             // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  18 mike  1.42  // sell copies of the Software, and to permit persons to whom the Software is
  19             // furnished to do so, subject to the following conditions:
  20 karl  1.124 // 
  21 mike  1.50  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
  22 mike  1.42  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
  23             // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  24 mike  1.50  // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  25             // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  26             // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  27 mike  1.42  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28             // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29             //
  30             //==============================================================================
  31             //
  32             //%/////////////////////////////////////////////////////////////////////////////
  33             
  34 mike  1.50  #include <Pegasus/Common/Config.h>
  35             
  36 mike  1.42  #include <cstdio>
  37             #include <cctype>
  38 mike  1.50  #include <ctime>
  39 kumpf 1.169 
  40             #if (defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX)) \
  41                 && defined(PEGASUS_USE_RELEASE_DIRS)
  42             # include <unistd.h>
  43 kumpf 1.115 #endif
  44 kumpf 1.169 
  45 kumpf 1.75  #include <Pegasus/Common/Constants.h>
  46 mike  1.42  #include <Pegasus/Common/FileSystem.h>
  47 mike  1.183 #include <Pegasus/Common/Signal.h>
  48 mike  1.50  #include <Pegasus/Common/HTTPAcceptor.h>
  49 kumpf 1.54  #include <Pegasus/Common/Tracer.h>
  50 mday  1.58  #include <Pegasus/Common/Cimom.h>
  51 kumpf 1.78  #include <Pegasus/Common/PegasusVersion.h>
  52 nag.boranna 1.163 #include <Pegasus/Common/SSLContextManager.h>
  53 kumpf       1.188 #include <Pegasus/Common/Time.h>
  54 kumpf       1.78  
  55 mike        1.42  #include <Pegasus/Repository/CIMRepository.h>
  56 mike        1.50  #include <Pegasus/ExportServer/CIMExportRequestDispatcher.h>
  57                   #include <Pegasus/ExportServer/CIMExportResponseEncoder.h>
  58                   #include <Pegasus/ExportServer/CIMExportRequestDecoder.h>
  59 kumpf       1.54  #include <Pegasus/Config/ConfigManager.h>
  60 mike        1.50  #include <Pegasus/Security/UserManager/UserManager.h>
  61 kumpf       1.62  #include <Pegasus/HandlerService/IndicationHandlerService.h>
  62                   #include <Pegasus/IndicationService/IndicationService.h>
  63 kumpf       1.184 #include <Pegasus/ProviderManagerService/ProviderManagerService.h>
  64 mike        1.179 #include <Pegasus/ProviderManager2/Default/DefaultProviderManager.h>
  65 chip        1.114 
  66 tony        1.134 #ifdef PEGASUS_ENABLE_SLP
  67                   #include <Pegasus/Client/CIMClient.h>
  68                   #endif
  69                   
  70 mreddy      1.190.2.1 #ifdef PEGASUS_SLP_REG_TIMEOUT
  71                       #include "SLPAttrib.h"
  72                       #endif
  73                       
  74 mike        1.47      #include "CIMServer.h"
  75 mike        1.50      #include "CIMOperationRequestDispatcher.h"
  76                       #include "CIMOperationResponseEncoder.h"
  77                       #include "CIMOperationRequestDecoder.h"
  78 kumpf       1.54      #include "CIMOperationRequestAuthorizer.h"
  79 mike        1.50      #include "HTTPAuthenticatorDelegator.h"
  80 kumpf       1.79      #include "ShutdownProvider.h"
  81 kumpf       1.101     #include "ShutdownService.h"
  82 mday        1.103     #include "BinaryMessageHandler.h"
  83 kumpf       1.69      #include <Pegasus/Common/ModuleController.h>
  84 kumpf       1.70      #include <Pegasus/ControlProviders/ConfigSettingProvider/ConfigSettingProvider.h>
  85 kumpf       1.71      #include <Pegasus/ControlProviders/UserAuthProvider/UserAuthProvider.h>
  86 kumpf       1.74      #include <Pegasus/ControlProviders/ProviderRegistrationProvider/ProviderRegistrationProvider.h>
  87 karl        1.80      #include <Pegasus/ControlProviders/NamespaceProvider/NamespaceProvider.h>
  88 humberto    1.110     
  89 karl        1.158     #ifndef PEGASUS_DISABLE_PERFINST
  90 w.white     1.142     #include <Pegasus/ControlProviders/Statistic/CIMOMStatDataProvider.h>
  91                       #endif
  92                       
  93 h.sterling  1.154     #ifdef PEGASUS_HAS_SSL
  94                       #include <Pegasus/ControlProviders/CertificateProvider/CertificateProvider.h>
  95                       #endif
  96 w.white     1.142     
  97 a.arora     1.156     #ifndef PEGASUS_DISABLE_CQL
  98                       #include <Pegasus/ControlProviders/QueryCapabilitiesProvider/CIMQueryCapabilitiesProvider.h>
  99                       #endif
 100                       
 101 karl        1.158     #if !defined(PEGASUS_DISABLE_PERFINST) ||  defined(PEGASUS_ENABLE_SLP)
 102 tony        1.134     #include <Pegasus/ControlProviders/InteropProvider/InteropProvider.h>
 103                       #endif
 104                       
 105 mreddy      1.190.2.8 #ifdef PEGASUS_SLP_REG_TIMEOUT
 106                       #include <slp/slp_client/src/cmd-utils/slp_client/lslp-linux.h>
 107                       #include <slp/slp_client/src/cmd-utils/slp_client/lslp.h>
 108                       #include <slp/slp_client/src/cmd-utils/slp_client/lslp-common-defs.h>
 109                       #include <slp/slp_client/src/cmd-utils/slp_client/slp_client.h>
 110                       #endif
 111                       
 112 humberto    1.110     // l10n
 113                       #include <Pegasus/Common/MessageLoader.h>
 114                       
 115 mike        1.42      PEGASUS_NAMESPACE_BEGIN
 116 mreddy      1.190.2.1 #ifdef PEGASUS_SLP_REG_TIMEOUT
 117                       ThreadReturnType PEGASUS_THREAD_CDECL _advertisePegasus(void *parm);
 118 mreddy      1.190.2.6 //Definig maximum life of registration as the reregistration interval
 119 mreddy      1.190.2.7 # define MAX_LIFE PEGASUS_SLP_REG_TIMEOUT * 60 
 120 mreddy      1.190.2.1 # define SLP_PORT 427
 121                       # define LOCALHOST_IP "127.0.0.1"
 122                       #endif
 123 mreddy      1.190.2.8 
 124 a.arora     1.143     static CIMServer *_cimserver = NULL;
 125                       
 126 kumpf       1.100     // Need a static method to act as a callback for the control provider.
 127                       // This doesn't belong here, but I don't have a better place to put it.
 128 kumpf       1.73      static Message * controlProviderReceiveMessageCallback(
 129                           Message * message,
 130                           void * instance)
 131 kumpf       1.69      {
 132 kumpf       1.185         CIMRequestMessage* request = dynamic_cast<CIMRequestMessage*>(message);
 133                           PEGASUS_ASSERT(request != 0);
 134                       
 135                           AcceptLanguageList* langs = new AcceptLanguageList(
 136                               ((AcceptLanguageListContainer) request->operationContext.get(
 137                                   AcceptLanguageListContainer::NAME)).getLanguages());
 138                           Thread::setLanguages(langs);
 139                       
 140                           ProviderMessageHandler* pmh =
 141                               reinterpret_cast<ProviderMessageHandler*>(instance);
 142                           return pmh->processMessage(request);
 143 kumpf       1.73      }
 144 kumpf       1.71      
 145 kumpf       1.137     //
 146                       // Signal handler for shutdown signals, currently SIGHUP and SIGTERM
 147                       //
 148 kumpf       1.108     Boolean handleShutdownSignal = false;
 149                       void shutdownSignalHandler(int s_n, PEGASUS_SIGINFO_T * s_info, void * sig)
 150 kumpf       1.101     {
 151 kumpf       1.108         PEG_METHOD_ENTER(TRC_SERVER, "shutdownSignalHandler");
 152                           Tracer::trace(TRC_SERVER, Tracer::LEVEL2, "Signal %d received.", s_n);
 153 kumpf       1.101     
 154 a.arora     1.143         CIMServer::shutdownSignal();
 155 kumpf       1.101     
 156                           PEG_METHOD_EXIT();
 157                       }
 158                       
 159 s.hills     1.123     void CIMServer::shutdownSignal()
 160                       {
 161                           PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::shutdownSignal()");
 162                           handleShutdownSignal = true;
 163 a.arora     1.143         _cimserver->tickle_monitor();
 164 s.hills     1.123         PEG_METHOD_EXIT();
 165                       }
 166                       
 167                       
 168 kumpf       1.101     CIMServer::CIMServer(Monitor* monitor)
 169 kumpf       1.157       : _dieNow(false), _monitor(monitor)
 170 mike        1.43      {
 171 kumpf       1.75          PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::CIMServer()");
 172 mday        1.111         _init();
 173 a.arora     1.143         _cimserver = this;
 174 mday        1.111         PEG_METHOD_EXIT();
 175                       }
 176                       
 177                       
 178 a.arora     1.143     void CIMServer::tickle_monitor(){
 179                           _monitor->tickle();
 180                       }
 181 mike        1.179     
 182 mday        1.111     void CIMServer::_init(void)
 183                       {
 184 kumpf       1.54      
 185 kumpf       1.60          String repositoryRootPath = String::EMPTY;
 186 jim.wunderlich 1.162         int binaryMode;
 187                              CIMRepository_Mode Mode;
 188 mike           1.50      
 189 tony           1.134     #ifdef PEGASUS_ENABLE_SLP
 190                              _runSLP = true;         // Boolean cannot be set in definition.
 191                          #endif
 192 kumpf          1.115     
 193 kumpf          1.167     #if (defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX)) \
 194                              && defined(PEGASUS_USE_RELEASE_DIRS)
 195                              chdir(PEGASUS_CORE_DIR);
 196 kumpf          1.115     #endif
 197 mike           1.50          // -- Save the monitor or create a new one:
 198 kumpf          1.60          repositoryRootPath =
 199 nag.boranna    1.161             ConfigManager::getHomedPath(ConfigManager::getInstance()->getCurrentValue("repositoryDir"));
 200 kumpf          1.60      
 201 mike           1.43          // -- Create a repository:
 202                          
 203 kumpf          1.81      #ifdef DO_NOT_CREATE_REPOSITORY_ON_STARTUP
 204                              // If this code is enable, the CIMServer will fail to start
 205                              // if the repository directory does not exit. If called,
 206                              // the Repository will create an empty repository.
 207                          
 208 chip           1.112         // This check has been disabled to allow cimmof to call
 209 kumpf          1.81          // the CIMServer to build the initial repository.
 210 kumpf          1.60          if (!FileSystem::isDirectory(repositoryRootPath))
 211 kumpf          1.54          {
 212 kumpf          1.75              PEG_METHOD_EXIT();
 213 nag.boranna    1.161         throw NoSuchDirectory(repositoryRootPath);
 214 humberto       1.110     
 215 kumpf          1.54          }
 216 kumpf          1.81      #endif
 217 mike           1.43      
 218 kumpf          1.182         binaryMode = ConfigManager::parseBooleanValue(
 219                                  ConfigManager::getInstance()->getCurrentValue(
 220                                      "enableBinaryRepository"));
 221 jim.wunderlich 1.162     
 222                              Mode.flag = CIMRepository_Mode::NONE;
 223                              if (binaryMode) 
 224                                Mode.flag |= CIMRepository_Mode::BIN;
 225                          
 226                              _repository = new CIMRepository(repositoryRootPath, Mode);
 227 mike           1.50      
 228 kumpf          1.76          // -- Create a UserManager object:
 229                          
 230                              UserManager* userManager = UserManager::getInstance(_repository);
 231                          
 232 mike           1.50          // -- Create a CIMServerState object:
 233                          
 234 a.arora        1.133         _serverState.reset(new CIMServerState());
 235 mike           1.50      
 236 kumpf          1.67          _providerRegistrationManager = new ProviderRegistrationManager(_repository);
 237                          
 238 mike           1.50          // -- Create queue inter-connections:
 239 schuur         1.127     
 240 mike           1.179         _providerManager = new ProviderManagerService(
 241                          	_providerRegistrationManager,
 242                          	_repository,
 243                          	DefaultProviderManager::createDefaultProviderManagerCallback);
 244                          
 245                              // Create IndicationHandlerService:
 246 kumpf          1.159     
 247 kumpf          1.67          _handlerService = new IndicationHandlerService(_repository);
 248 kumpf          1.69      
 249 kumpf          1.71          // Create the control service
 250 kumpf          1.99          _controlService = new ModuleController(PEGASUS_QUEUENAME_CONTROLSERVICE);
 251 kumpf          1.71      
 252 konrad.r       1.171     	// Jump this number up when there are more control providers.
 253                          	_controlProviders.reserveCapacity(16);
 254 kumpf          1.185     
 255 kumpf          1.71          // Create the Configuration control provider
 256 kumpf          1.185         ProviderMessageHandler* configProvider = new ProviderMessageHandler(
 257                                  "ConfigSettingProvider", new ConfigSettingProvider(), 0, 0, false);
 258 konrad.r       1.171     
 259 kumpf          1.185         _controlProviders.append(configProvider);
 260 kumpf          1.77          ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,
 261 kumpf          1.75                                            PEGASUS_MODULENAME_CONFIGPROVIDER,
 262 kumpf          1.69                                            configProvider,
 263 kumpf          1.73                                            controlProviderReceiveMessageCallback,
 264 kumpf          1.181                                           0);
 265 kumpf          1.71      
 266                              // Create the User/Authorization control provider
 267 kumpf          1.185         ProviderMessageHandler* userAuthProvider = new ProviderMessageHandler(
 268                                  "UserAuthProvider", new UserAuthProvider(_repository), 0, 0, false);
 269                              _controlProviders.append(userAuthProvider);
 270 kumpf          1.77          ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,
 271 kumpf          1.75                                            PEGASUS_MODULENAME_USERAUTHPROVIDER,
 272 kumpf          1.71                                            userAuthProvider,
 273 kumpf          1.73                                            controlProviderReceiveMessageCallback,
 274 kumpf          1.181                                           0);
 275 mike           1.50      
 276 kumpf          1.74          // Create the Provider Registration control provider
 277 kumpf          1.185         ProviderMessageHandler* provRegProvider = new ProviderMessageHandler(
 278                                  "ProviderRegistrationProvider",
 279                                  new ProviderRegistrationProvider(_providerRegistrationManager),
 280                                  0, 0, false);
 281                              // Warning: The ProviderRegistrationProvider destructor deletes
 282                              // _providerRegistrationManager
 283                              _controlProviders.append(provRegProvider);
 284 kumpf          1.77          ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,
 285 kumpf          1.75                                            PEGASUS_MODULENAME_PROVREGPROVIDER,
 286 kumpf          1.74                                            provRegProvider,
 287                                                                controlProviderReceiveMessageCallback,
 288 kumpf          1.181                                           0);
 289 kumpf          1.79      
 290 kumpf          1.185         // Create the Shutdown control provider
 291                              ProviderMessageHandler* shutdownProvider = new ProviderMessageHandler(
 292                                  "ShutdownProvider", new ShutdownProvider(this), 0, 0, false);
 293                              _controlProviders.append(shutdownProvider);
 294 kumpf          1.79           ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,
 295                                                                 PEGASUS_MODULENAME_SHUTDOWNPROVIDER,
 296                                                                 shutdownProvider,
 297 karl           1.80                                             controlProviderReceiveMessageCallback,
 298 kumpf          1.181                                            0);
 299 karl           1.80      
 300 kumpf          1.185         // Create the namespace control provider
 301                              ProviderMessageHandler* namespaceProvider = new ProviderMessageHandler(
 302                                  "NamespaceProvider", new NamespaceProvider(_repository), 0, 0, false);
 303                              _controlProviders.append(namespaceProvider);
 304 karl           1.80           ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,
 305                                                                 PEGASUS_MODULENAME_NAMESPACEPROVIDER,
 306                                                                 namespaceProvider,
 307 kumpf          1.79                                             controlProviderReceiveMessageCallback,
 308 kumpf          1.181                                            0);
 309 nag.boranna    1.161     
 310                               //
 311                               // Create a SSLContextManager object
 312                               //
 313                               _sslContextMgr = new SSLContextManager();
 314                          
 315 h.sterling     1.154     #ifdef PEGASUS_HAS_SSL
 316 sushma.fernandes 1.189             // Because this provider allows management of the cimserver truststore
 317                                    // it needs to be available regardless of the value 
 318                                    // of sslClientVerificationMode config property.
 319 kumpf            1.185         ProviderMessageHandler* certificateProvider = new ProviderMessageHandler(
 320                                    "CertificateProvider",
 321                                    new CertificateProvider(_repository, _sslContextMgr),
 322                                    0, 0, false);
 323                                _controlProviders.append(certificateProvider);
 324 nag.boranna      1.161             ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,
 325                                                                      PEGASUS_MODULENAME_CERTIFICATEPROVIDER,
 326                                                                      certificateProvider,
 327                                                                      controlProviderReceiveMessageCallback,
 328 kumpf            1.181                                               0);
 329 h.sterling       1.154     #endif
 330 h.sterling       1.153     
 331 karl             1.158     #ifndef PEGASUS_DISABLE_PERFINST
 332 kumpf            1.185         // Create the Statistical Data control provider
 333                                ProviderMessageHandler* cimomstatdataProvider = new ProviderMessageHandler(
 334                                    "CIMOMStatDataProvider", new CIMOMStatDataProvider(), 0, 0, false);
 335                                _controlProviders.append(cimomstatdataProvider);
 336 w.white          1.142          ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,
 337                                                                   PEGASUS_MODULENAME_CIMOMSTATDATAPROVIDER,                                       cimomstatdataProvider,
 338                                                                   controlProviderReceiveMessageCallback,
 339 kumpf            1.181                                            0);
 340 w.white          1.142     #endif
 341                            
 342 a.arora          1.156     #ifndef PEGASUS_DISABLE_CQL
 343                            
 344 kumpf            1.185         // Create the Query Capabilities control provider
 345                                ProviderMessageHandler* cimquerycapprovider = new ProviderMessageHandler(
 346                                    "CIMQueryCapabilitiesProvider",
 347                                    new CIMQueryCapabilitiesProvider(),
 348                                    0, 0, false);
 349                                _controlProviders.append(cimquerycapprovider);
 350 a.arora          1.156          ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,
 351                                                                   PEGASUS_MODULENAME_CIMQUERYCAPPROVIDER,
 352                                                                   cimquerycapprovider,
 353                                                                   controlProviderReceiveMessageCallback,
 354 kumpf            1.181                                            0);
 355 a.arora          1.156     #endif
 356                            
 357 w.white          1.142     
 358 karl             1.158     #if !defined(PEGASUS_DISABLE_PERFINST) ||  defined(PEGASUS_ENABLE_SLP)
 359 w.white          1.149     
 360 kumpf            1.185         // Create the interop control provider
 361                                ProviderMessageHandler* interopProvider = new ProviderMessageHandler(
 362                                    "InteropProvider", new InteropProvider(_repository), 0, 0, false);
 363                                _controlProviders.append(interopProvider);
 364 tony             1.134          ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,
 365                                                                   PEGASUS_MODULENAME_INTEROPPROVIDER,
 366                                                                   interopProvider,
 367                                                                   controlProviderReceiveMessageCallback,
 368 kumpf            1.181                                            0);
 369 tony             1.134     #endif
 370 kumpf            1.74      
 371 mike             1.50          _cimOperationRequestDispatcher
 372 nag.boranna      1.161         = new CIMOperationRequestDispatcher(_repository,
 373 kumpf            1.74                                                  _providerRegistrationManager);
 374 chip             1.112         _binaryMessageHandler =
 375 mday             1.103            new BinaryMessageHandler(_cimOperationRequestDispatcher);
 376 chip             1.112     
 377 mike             1.50          _cimOperationResponseEncoder
 378 nag.boranna      1.161         = new CIMOperationResponseEncoder;
 379 mike             1.50      
 380 kumpf            1.54          //
 381                                // get the configured authentication and authorization flags
 382                                //
 383                                ConfigManager* configManager = ConfigManager::getInstance();
 384                            
 385 kumpf            1.182         Boolean enableAuthentication = ConfigManager::parseBooleanValue(
 386                                    configManager->getCurrentValue("enableAuthentication"));
 387 kumpf            1.54      
 388                                //
 389 kumpf            1.104         // Create Authorization queue only if authentication is enabled
 390 kumpf            1.54          //
 391 kumpf            1.104         if ( enableAuthentication )
 392 kumpf            1.54          {
 393                                    _cimOperationRequestAuthorizer = new CIMOperationRequestAuthorizer(
 394                                        _cimOperationRequestDispatcher);
 395                            
 396                                    _cimOperationRequestDecoder = new CIMOperationRequestDecoder(
 397                                        _cimOperationRequestAuthorizer,
 398                                        _cimOperationResponseEncoder->getQueueId());
 399                                }
 400                                else
 401                                {
 402 kumpf            1.99              _cimOperationRequestAuthorizer = 0;
 403                            
 404 kumpf            1.54              _cimOperationRequestDecoder = new CIMOperationRequestDecoder(
 405                                        _cimOperationRequestDispatcher,
 406                                        _cimOperationResponseEncoder->getQueueId());
 407                            
 408                                }
 409 mike             1.43      
 410 mike             1.50          _cimExportRequestDispatcher
 411 nag.boranna      1.161         = new CIMExportRequestDispatcher();
 412 mike             1.43      
 413 mike             1.50          _cimExportResponseEncoder
 414 nag.boranna      1.161         = new CIMExportResponseEncoder;
 415 mike             1.43      
 416 mike             1.50          _cimExportRequestDecoder = new CIMExportRequestDecoder(
 417 nag.boranna      1.161         _cimExportRequestDispatcher,
 418                                _cimExportResponseEncoder->getQueueId());
 419 mike             1.43      
 420 kumpf            1.99          _httpAuthenticatorDelegator = new HTTPAuthenticatorDelegator(
 421 mike             1.50              _cimOperationRequestDecoder->getQueueId(),
 422 h.sterling       1.153             _cimExportRequestDecoder->getQueueId(),
 423 nag.boranna      1.161             _repository);
 424 mike             1.43      
 425 kumpf            1.82          // IMPORTANT-NU-20020513: Indication service must start after ExportService
 426                                // otherwise HandlerService started by indicationService will never
 427                                // get ExportQueue to export indications for existing subscriptions
 428                            
 429 kumpf            1.90          _indicationService = 0;
 430 kumpf            1.182         if (ConfigManager::parseBooleanValue(
 431                                    configManager->getCurrentValue("enableIndicationService")))
 432 kumpf            1.90          {
 433                                    _indicationService = new IndicationService
 434                                        (_repository, _providerRegistrationManager);
 435                                }
 436 mike             1.50      
 437 kumpf            1.108         // Enable the signal handler to shutdown gracefully on SIGHUP and SIGTERM
 438                                getSigHandle()->registerHandler(PEGASUS_SIGHUP, shutdownSignalHandler);
 439 kumpf            1.107         getSigHandle()->activate(PEGASUS_SIGHUP);
 440 kumpf            1.108         getSigHandle()->registerHandler(PEGASUS_SIGTERM, shutdownSignalHandler);
 441                                getSigHandle()->activate(PEGASUS_SIGTERM);
 442 mike             1.50      
 443 kumpf            1.132         // Load and initialize providers registed with AutoStart = true
 444                                _providerRegistrationManager->initializeProviders();
 445                            
 446 mike             1.43      }
 447                            
 448 mday             1.111     
 449 konrad.r         1.171     CIMServer::~CIMServer ()
 450                            {
 451 kumpf            1.175         PEG_METHOD_ENTER (TRC_SERVER, "CIMServer::~CIMServer()");
 452 mday             1.111     
 453 kumpf            1.175         // Wait until the Shutdown provider request has cleared through the
 454                                // system. 
 455                                ShutdownService::getInstance(this)->waitUntilNoMoreRequests(false);
 456 mday             1.111     
 457 kumpf            1.175         // Ok, shutdown all the MQSs. This shuts their communication channel.
 458                                ShutdownService::getInstance(this)->shutdownCimomServices();
 459 kumpf            1.54      
 460 kumpf            1.175         // Start deleting the objects.
 461                                // The order is very important.
 462                            
 463                                // The HTTPAcceptor depends on HTTPAuthenticationDelegator
 464                                for (Uint32 i = 0, n = _acceptors.size (); i < n; i++)
 465 konrad.r         1.171         {
 466 kumpf            1.175             HTTPAcceptor *p = _acceptors[i];
 467                                    delete p;
 468 konrad.r         1.171         }
 469 kumpf            1.99      
 470 kumpf            1.175         // IndicationService depends on ProviderManagerService,
 471                                // IndicationHandlerService, and ProviderRegistrationManager, and thus
 472                                // should be deleted before the ProviderManagerService,
 473                                // IndicationHandlerService, and ProviderRegistrationManager are deleted.
 474                                delete _indicationService;
 475                            
 476                                // HTTPAuthenticationDelegator depends on CIMRepository,
 477                                // CIMOperationRequestDecoder and CIMExportRequestDecoder
 478                                delete _httpAuthenticatorDelegator;
 479                            
 480                                delete _cimExportRequestDecoder;
 481                            
 482                                delete _cimExportResponseEncoder;
 483                            
 484                                delete _cimExportRequestDispatcher;
 485                            
 486                                // CIMOperationRequestDecoder depends on CIMOperationRequestAuthorizer
 487                                // and CIMOperationResponseEncoder
 488                                delete _cimOperationRequestDecoder;
 489                            
 490                                delete _cimOperationResponseEncoder;
 491 kumpf            1.175     
 492                                // BinaryMessageHandler depends on CIMOperationRequestDispatcher
 493                                delete _binaryMessageHandler;
 494                            
 495                                // CIMOperationRequestAuthorizer depends on
 496                                // CIMOperationRequestDispatcher
 497                                delete _cimOperationRequestAuthorizer;
 498                            
 499                                // IndicationHandlerService uses CIMOperationRequestDispatcher
 500                                delete _handlerService;
 501                            
 502                                // CIMOperationRequestDispatcher depends on 
 503                                // CIMRepository and ProviderRegistrationManager.
 504                                // CIMOperationRequestDispatcher keeps an internal list of control
 505                                // providers. Must delete this before ModuleController.
 506                                delete _cimOperationRequestDispatcher;
 507                            
 508                                // ModuleController takes care of deleting all wrappers around
 509                                // the control providers.
 510                                delete _controlService;
 511                            
 512 kumpf            1.175         // Find all of the control providers (module)
 513                                // Must delete CIMOperationRequestDispatcher _before_ deleting each
 514                                // of the control provider. The CIMOperationRequestDispatcher keeps
 515                                // its own table of the internal providers (pointers).
 516                                for (Uint32 i = 0, n = _controlProviders.size(); i < n; i++)
 517 konrad.r         1.171         {
 518 kumpf            1.185             ProviderMessageHandler *p = _controlProviders[i];
 519                                    p->terminate();
 520 kumpf            1.175             delete p;
 521 konrad.r         1.171         }
 522                            
 523 kumpf            1.175         // The SSL control providers use the SSL context manager. 
 524                                delete _sslContextMgr;
 525                            
 526                                // ProviderManagerService depends on ProviderRegistrationManager.
 527                                // Note that deleting the ProviderManagerService causes the
 528                                // DefaultProviderManager (if loaded) to get unloaded.  Dynamically
 529                                // unloading the DefaultProviderManager library affects (on HP-UX, at
 530                                // least) the statically loaded version of this library used by the
 531 kumpf            1.185         // ProviderMessageHandler wrapper for the control providers.  Deleting
 532 kumpf            1.175         // the ProviderManagerService after the control providers is a
 533                                // workaround for this problem.
 534                                delete _providerManager;
 535                            
 536                                delete _providerRegistrationManager;
 537 konrad.r         1.171     
 538 kumpf            1.175         // Almost everybody uses the CIMRepository.
 539                                delete _repository;
 540 kumpf            1.99      
 541 kumpf            1.175         // Destroy the singleton services
 542                                ConfigManager::destroy();
 543                                UserManager::destroy();
 544                                ShutdownService::destroy();
 545 konrad.r         1.172     
 546 kumpf            1.175         PEG_METHOD_EXIT ();
 547 mike             1.43      }
 548                            
 549 kumpf            1.101     void CIMServer::addAcceptor(
 550                                Boolean localConnection,
 551                                Uint32 portNumber,
 552 sushma.fernandes 1.189         Boolean useSSL)
 553 kumpf            1.101     {
 554                                HTTPAcceptor* acceptor;
 555 sushma.fernandes 1.189     
 556                                acceptor = new HTTPAcceptor(
 557 nag.boranna      1.161               _monitor,
 558                                      _httpAuthenticatorDelegator,
 559                                      localConnection,
 560                                      portNumber,
 561 sushma.fernandes 1.189               useSSL ? _getSSLContext() : 0,
 562 nag.boranna      1.164               useSSL ? _sslContextMgr->getSSLContextObjectLock() : 0 );
 563 marek            1.180     
 564                                ConfigManager* configManager = ConfigManager::getInstance();
 565                                String socketWriteConfigTimeout = 
 566                                    configManager->getCurrentValue("socketWriteTimeout");
 567                                // Set timeout value for server socket timeouts
 568                                // depending on config option
 569                                Uint32 socketWriteTimeout = 
 570                                    strtol(socketWriteConfigTimeout.getCString(), (char **)0, 10);
 571                                // equal what went wrong, there has to be a timeout
 572                                if (socketWriteTimeout == 0) socketWriteTimeout = 20;
 573                                acceptor->setSocketWriteTimeout(socketWriteTimeout);
 574                            
 575 kumpf            1.101         _acceptors.append(acceptor);
 576                            }
 577                            
 578                            void CIMServer::bind()
 579 mike             1.43      {
 580 kumpf            1.75          PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::bind()");
 581 kumpf            1.54      
 582 kumpf            1.157         if (_acceptors.size() == 0)
 583                                {
 584                                    MessageLoaderParms mlp = MessageLoaderParms(
 585                                        "Server.CIMServer.BIND_FAILED",
 586                                        "No CIM Server connections are enabled.");
 587 chip             1.112     
 588 kumpf            1.157             throw BindFailedException(mlp);
 589                                }
 590 chip             1.112     
 591 kumpf            1.157         for (Uint32 i=0; i<_acceptors.size(); i++)
 592                                {
 593                                    _acceptors[i]->bind();
 594 kumpf            1.101         }
 595 chip             1.112     
 596 kumpf            1.75          PEG_METHOD_EXIT();
 597 mike             1.43      }
 598                            
 599                            void CIMServer::runForever()
 600                            {
 601 mday             1.111         // Note: Trace code in this method will be invoked frequently.
 602                                if(!_dieNow)
 603 kumpf            1.157         {
 604 mreddy           1.190.2.8         struct timeval now;
 605                                    Time::gettimeofday(&now);
 606 a.arora          1.143     #ifdef PEGASUS_ENABLE_SLP
 607 mreddy           1.190.2.8 #ifdef PEGASUS_SLP_REG_TIMEOUT 
 608                                    static struct timeval lastReregistrationTime = {0,0};
 609                                    // units of PEGASUS_SLP_REG_TIMEOUT is minutes. Multiplying PEGASUS_SLP_REG_TIMEOUT
 610                                    // to convert in to seconds. 
 611                                    if (now.tv_sec - lastReregistrationTime.tv_sec > (PEGASUS_SLP_REG_TIMEOUT * 60))
 612                                    {
 613                                        lastReregistrationTime.tv_sec = now.tv_sec;
 614                            #endif
 615                                        startSLPProvider();
 616                            #ifdef PEGASUS_SLP_REG_TIMEOUT 
 617                                    }
 618                            #endif
 619 a.arora          1.143     #endif
 620 kumpf            1.186         _monitor->run(500000);
 621                            
 622                                static struct timeval lastIdleCleanupTime = {0, 0};
 623 mreddy           1.190.2.2 
 624 mreddy           1.190.2.9     if (now.tv_sec - lastIdleCleanupTime.tv_sec > 300)
 625 nag.boranna      1.161         {
 626 kumpf            1.186           lastIdleCleanupTime.tv_sec = now.tv_sec;
 627 nag.boranna      1.161           try
 628                                  {
 629                                    _providerManager->unloadIdleProviders();
 630 kumpf            1.190             MessageQueueService::get_thread_pool()->cleanupIdleThreads();
 631 nag.boranna      1.161           }
 632                                  catch(...)
 633                                  {
 634                                  }
 635                                }
 636                                if (handleShutdownSignal)
 637                                {
 638                                  Tracer::trace(TRC_SERVER, Tracer::LEVEL3,
 639                                        "CIMServer::runForever - signal received.  Shutting down.");
 640                                  ShutdownService::getInstance(this)->shutdown(true, 10, false);
 641                                  // Set to false must be after call to shutdown.  See
 642                                  // stopClientConnection.
 643                                  handleShutdownSignal = false;
 644                                }
 645 kumpf            1.157         }
 646 mike             1.50      }
 647 mday             1.118     
 648 mike             1.50      void CIMServer::stopClientConnection()
 649                            {
 650 kumpf            1.75          PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::stopClientConnection()");
 651 kumpf            1.54      
 652 kumpf            1.157         // tell Monitor to stop listening for client connections
 653                                if (handleShutdownSignal)
 654                                    // If shutting down, this is in the same thread as runForever.
 655                                    // No need to wait for the thread to see the stop flag.
 656                                    _monitor->stopListeningForConnections(false);
 657                                else
 658                                    // If not shutting down, this is not in the same thread as runForever.
 659                                    // Need to wait for the thread to see the stop flag.
 660                                    _monitor->stopListeningForConnections(true);
 661                            
 662                                //
 663                                // Wait 150 milliseconds to allow time for the Monitor to stop 
 664                                // listening for client connections.  
 665                                //
 666                                // This wait time is the timeout value for the select() call
 667                                // in the Monitor's run() method (currently set to 100 
 668                                // milliseconds) plus a delta of 50 milliseconds.  The reason
 669                                // for the wait here is to make sure that the Monitor entries
 670                                // are updated before closing the connection sockets.
 671                                //
 672                                // PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL4, "Wait 150 milliseconds.");
 673 mike             1.183         //  Threads::sleep(150);  not needed anymore due to the semaphore
 674 kumpf            1.157         // in the monitor
 675                            
 676                                for (Uint32 i=0; i<_acceptors.size(); i++)
 677 kumpf            1.117         {
 678 kumpf            1.157             _acceptors[i]->closeConnectionSocket();
 679 kumpf            1.101         }
 680 chip             1.112     
 681 kumpf            1.75          PEG_METHOD_EXIT();
 682 mike             1.50      }
 683                            
 684                            void CIMServer::shutdown()
 685                            {
 686 mreddy           1.190.2.1      PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::shutdown()");
 687 dave.sudlik      1.176     #ifdef PEGASUS_DEBUG
 688                                _repository->DisplayCacheStatistics();
 689                            #endif
 690                            
 691 mike             1.50          _dieNow = true;
 692 kumpf            1.157         _cimserver->tickle_monitor();
 693 kumpf            1.54      
 694 kumpf            1.75          PEG_METHOD_EXIT();
 695 mike             1.50      }
 696                            
 697                            void CIMServer::resume()
 698                            {
 699 kumpf            1.75          PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::resume()");
 700 kumpf            1.54      
 701 kumpf            1.101         for (Uint32 i=0; i<_acceptors.size(); i++)
 702                                {
 703                                    _acceptors[i]->reopenConnectionSocket();
 704                                }
 705 kumpf            1.54      
 706 kumpf            1.75          PEG_METHOD_EXIT();
 707 mike             1.50      }
 708                            
 709                            void CIMServer::setState(Uint32 state)
 710                            {
 711 kumpf            1.75          PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::setState()");
 712 kumpf            1.54      
 713 mike             1.50          _serverState->setState(state);
 714 chip             1.53      
 715 kumpf            1.85          //
 716                                // get the configured authentication and authorization flags
 717                                //
 718                                ConfigManager* configManager = ConfigManager::getInstance();
 719                            
 720 kumpf            1.182         Boolean enableAuthentication = ConfigManager::parseBooleanValue(
 721                                    configManager->getCurrentValue("enableAuthentication"));
 722                                Boolean enableNamespaceAuthorization = ConfigManager::parseBooleanValue(
 723                                    configManager->getCurrentValue("enableNamespaceAuthorization"));
 724 kumpf            1.85      
 725 mike             1.50          if (state == CIMServerState::TERMINATING)
 726                                {
 727                                    // tell decoder that CIMServer is terminating
 728                                    _cimOperationRequestDecoder->setServerTerminating(true);
 729                                    _cimExportRequestDecoder->setServerTerminating(true);
 730 kumpf            1.85      
 731                                    // tell authorizer that CIMServer is terminating ONLY if
 732                                    // authentication and authorization are enabled
 733                                    //
 734 kumpf            1.87              if ( enableAuthentication && enableNamespaceAuthorization )
 735 kumpf            1.85              {
 736                                        _cimOperationRequestAuthorizer->setServerTerminating(true);
 737                                    }
 738 mike             1.50          }
 739                                else
 740                                {
 741                                    // tell decoder that CIMServer is not terminating
 742                                    _cimOperationRequestDecoder->setServerTerminating(false);
 743                                    _cimExportRequestDecoder->setServerTerminating(false);
 744 kumpf            1.85      
 745                                    // tell authorizer that CIMServer is terminating ONLY if
 746                                    // authentication and authorization are enabled
 747                                    //
 748 kumpf            1.87              if ( enableAuthentication && enableNamespaceAuthorization )
 749 kumpf            1.85              {
 750                                        _cimOperationRequestAuthorizer->setServerTerminating(false);
 751                                    }
 752 mike             1.50          }
 753 kumpf            1.75          PEG_METHOD_EXIT();
 754 mike             1.50      }
 755                            
 756                            Uint32 CIMServer::getOutstandingRequestCount()
 757                            {
 758 kumpf            1.75          PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::getOutstandingRequestCount()");
 759 kumpf            1.54      
 760 kumpf            1.101         Uint32 requestCount = 0;
 761 mday             1.111     
 762 kumpf            1.157         for (Uint32 i=0; i<_acceptors.size(); i++)
 763                                {
 764                                    requestCount += _acceptors[i]->getOutstandingRequestCount();
 765 kumpf            1.101         }
 766 chip             1.112     
 767 kumpf            1.75          PEG_METHOD_EXIT();
 768                                return requestCount;
 769 kumpf            1.101     }
 770                            
 771 nag.boranna      1.163     //
 772 sushma.fernandes 1.189     SSLContext* CIMServer::_getSSLContext()
 773 nag.boranna      1.163     {
 774                                PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::_getSSLContext()");
 775                            
 776                                static const String PROPERTY_NAME__SSL_CERT_FILEPATH =
 777                                                                       "sslCertificateFilePath";
 778                                static const String PROPERTY_NAME__SSL_KEY_FILEPATH  = "sslKeyFilePath";
 779                                static const String PROPERTY_NAME__SSL_TRUST_STORE  = "sslTrustStore";
 780                                static const String PROPERTY_NAME__SSL_CRL_STORE  = "crlStore";
 781                                static const String PROPERTY_NAME__SSL_CLIENT_VERIFICATION =
 782                                                                       "sslClientVerificationMode";
 783                                static const String PROPERTY_NAME__SSL_AUTO_TRUST_STORE_UPDATE =
 784                                                                       "enableSSLTrustStoreAutoUpdate";
 785                                static const String PROPERTY_NAME__SSL_TRUST_STORE_USERNAME =
 786                                                                       "sslTrustStoreUserName";
 787                                static const String PROPERTY_NAME__HTTP_ENABLED =
 788                                                                       "enableHttpConnection";
 789                            
 790                                String verifyClient = String::EMPTY;
 791                                String trustStore = String::EMPTY;
 792                                SSLContext* sslContext = 0;
 793                            
 794 nag.boranna      1.163         //
 795                                // Get a config manager instance
 796                                //
 797                                ConfigManager* configManager = ConfigManager::getInstance();
 798                            
 799 sushma.fernandes 1.189         // Note that if invalid values were set for either sslKeyFilePath,
 800                                // sslCertificateFilePath, crlStore or sslTrustStore, the invalid
 801                                // paths would have been detected in SecurityPropertyOwner and
 802                                // terminated the server startup. This happens regardless of whether
 803                                // or not HTTPS is enabled (not a great design, but that seems to
 804                                // be how other properties are validated as well)
 805                                //
 806                                // Get the sslClientVerificationMode property from the Config
 807                                // Manager.
 808                                //
 809                                verifyClient = configManager->getCurrentValue(
 810                                                          PROPERTY_NAME__SSL_CLIENT_VERIFICATION);
 811                            
 812                                //
 813                                // Get the sslTrustStore property from the Config Manager.
 814                                //
 815                                trustStore = configManager->getCurrentValue(
 816                                                         PROPERTY_NAME__SSL_TRUST_STORE);
 817                            
 818                                if (trustStore != String::EMPTY)
 819 nag.boranna      1.163         {
 820 sushma.fernandes 1.189             trustStore = ConfigManager::getHomedPath(trustStore);
 821                                }
 822 nag.boranna      1.163     
 823 sushma.fernandes 1.189         PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL4,
 824                                    "Server trust store name: " + trustStore);
 825 nag.boranna      1.163     
 826 sushma.fernandes 1.189         //
 827                                // Get the sslTrustStoreUserName property from the Config Manager.
 828                                //
 829                                String trustStoreUserName = String::EMPTY;
 830                                trustStoreUserName = configManager->getCurrentValue(
 831                                                          PROPERTY_NAME__SSL_TRUST_STORE_USERNAME);
 832 nag.boranna      1.163     
 833 sushma.fernandes 1.189         if (!String::equal(verifyClient, "disabled"))
 834                                {
 835 nag.boranna      1.163             //
 836 sushma.fernandes 1.189             // 'required' setting must have a valid truststore
 837                                    // 'optional' setting can be used with or without a truststore;
 838                                    // log a warning if a truststore is not specified
 839 nag.boranna      1.163             //
 840 sushma.fernandes 1.189             if (trustStore == String::EMPTY)
 841 nag.boranna      1.163             {
 842 sushma.fernandes 1.189                 if (String::equal(verifyClient, "required"))
 843                                        {
 844                                            MessageLoaderParms parms(
 845                                                "Pegasus.Server.CIMServer.SSL_CLIENT_VERIFICATION_EMPTY_TRUSTSTORE",
 846                                                "The \"sslTrustStore\" configuration property must be set if \"sslClientVerificationMode\" is 'required'. cimserver not started.");
 847                                            PEG_METHOD_EXIT();
 848                                            throw SSLException(parms);
 849                                        }
 850                                        else if (String::equal(verifyClient, "optional"))
 851 nag.boranna      1.163                 {
 852 sushma.fernandes 1.189                     Logger::put(Logger::STANDARD_LOG, System::CIMSERVER,
 853                                                Logger::WARNING,
 854                                                "SSL client verification is enabled but no truststore was specified.");
 855 nag.boranna      1.163                 }
 856 sushma.fernandes 1.189             }
 857 h.sterling       1.165     
 858 h.sterling       1.168     #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
 859 sushma.fernandes 1.189             //
 860                                    // ATTN: 'required' setting must have http port enabled.
 861                                    // If only https is enabled, and a call to shutdown the
 862                                    // cimserver is given, the call will hang and a forced shutdown
 863                                    // will ensue. This is because the CIMClient::connectLocal call
 864                                    // cannot specify a certificate for authentication against
 865                                    // the local server.  This limitation is being investigated.
 866                                    // See Bugzilla 2995.
 867                                    //
 868                                    if (String::equal(verifyClient, "required"))
 869                                    {
 870                                        if (!ConfigManager::parseBooleanValue(
 871                                            configManager->getCurrentValue(
 872                                                PROPERTY_NAME__HTTP_ENABLED)))
 873 nag.boranna      1.163                 {
 874 sushma.fernandes 1.189                     MessageLoaderParms parms(
 875                                                "Pegasus.Server.SSLContextManager.INVALID_CONF_HTTPS_REQUIRED",
 876                                                "The \"sslClientVerificationMode\" property cannot be "
 877                                                    "set to \"required\" if HTTP is disabled, as the "
 878                                                    "cimserver will be unable to properly shutdown.  "
 879                                                    "The recommended course of action is to change "
 880                                                    "the property value to \"optional\".  cimserver "
 881                                                    "not started.");
 882                                            PEG_METHOD_EXIT();
 883                                            throw SSLException(parms);
 884 nag.boranna      1.163                 }
 885 sushma.fernandes 1.189             }
 886 h.sterling       1.165     #endif
 887 nag.boranna      1.163             //
 888 sushma.fernandes 1.189             // A truststore username must be specified if
 889                                    // sslClientVerificationMode is enabled and the truststore is a
 890                                    // single CA file.  If the truststore is a directory, then the
 891                                    // CertificateProvider should be used to register users with
 892                                    // certificates.
 893 nag.boranna      1.163             //
 894 sushma.fernandes 1.189             if ((trustStore != String::EMPTY) &&
 895                                        (!FileSystem::isDirectory(trustStore)))
 896 nag.boranna      1.163             {
 897 sushma.fernandes 1.189                 if (trustStoreUserName == String::EMPTY)
 898                                        {
 899                                            MessageLoaderParms parms(
 900                                                "Pegasus.Server.CIMServer.SSL_CLIENT_VERIFICATION_EMPTY_USERNAME",
 901                                                "The \"sslTrustStoreUserName\" property must specify a valid username if \"sslClientVerificationMode\" is 'required' or 'optional' and the truststore is a single CA file. To register individual certificates to users, you must use a truststore directory along with the CertificateProvider.  cimserver not started.");
 902                                            PEG_METHOD_EXIT();
 903                                            throw SSLException(parms);
 904                                        }
 905 nag.boranna      1.163             }
 906                                }
 907                            
 908 sushma.fernandes 1.178     #ifdef PEGASUS_ENABLE_SSL_CRL_VERIFICATION
 909 nag.boranna      1.163         //
 910                                // Get the crlStore property from the Config Manager.
 911                                //
 912                                String crlStore = configManager->getCurrentValue(
 913                                                           PROPERTY_NAME__SSL_CRL_STORE);
 914                            
 915                                if (crlStore != String::EMPTY)
 916                                {
 917                                    crlStore = ConfigManager::getHomedPath(crlStore);
 918                                }
 919 sushma.fernandes 1.178     #else
 920                                String crlStore = String::EMPTY;
 921                            #endif
 922 nag.boranna      1.163     
 923                                //
 924                                // Get the sslCertificateFilePath property from the Config Manager.
 925                                //
 926                                String certPath;
 927                                certPath = ConfigManager::getHomedPath(
 928                                    configManager->getCurrentValue(PROPERTY_NAME__SSL_CERT_FILEPATH));
 929                            
 930                                //
 931                                // Get the sslKeyFilePath property from the Config Manager.
 932                                //
 933                                String keyPath;
 934                                keyPath = ConfigManager::getHomedPath(
 935                                    configManager->getCurrentValue(PROPERTY_NAME__SSL_KEY_FILEPATH));
 936                            
 937                                String randFile = String::EMPTY;
 938                            
 939                            #ifdef PEGASUS_SSL_RANDOMFILE
 940                                // NOTE: It is technically not necessary to set up a random file on
 941                                // the server side, but it is easier to use a consistent interface
 942                                // on the client and server than to optimize out the random file on
 943 nag.boranna      1.163         // the server side.
 944                                randFile = ConfigManager::getHomedPath(PEGASUS_SSLSERVER_RANDOMFILE);
 945                            #endif
 946                            
 947 sushma.fernandes 1.189         //
 948                                // Create the SSLContext defined by the configuration properties
 949                                //
 950                                if (String::equal(verifyClient, "required"))
 951 nag.boranna      1.163         {
 952 sushma.fernandes 1.189             PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2,
 953                                        "SSL Client verification REQUIRED.");
 954 nag.boranna      1.163     
 955 sushma.fernandes 1.189             _sslContextMgr->createSSLContext(
 956                                        trustStore, certPath, keyPath, crlStore, false, randFile);
 957                                }
 958                                else if (String::equal(verifyClient, "optional"))
 959                                {
 960                                    PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2,
 961                                        "SSL Client verification OPTIONAL.");
 962 nag.boranna      1.163     
 963 sushma.fernandes 1.189             _sslContextMgr->createSSLContext(
 964                                        trustStore, certPath, keyPath, crlStore, true, randFile);
 965 nag.boranna      1.163         }
 966 sushma.fernandes 1.189         else if (String::equal(verifyClient, "disabled") ||
 967                                         verifyClient == String::EMPTY)
 968 nag.boranna      1.163         {
 969 sushma.fernandes 1.189             PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2,
 970                                        "SSL Client verification DISABLED.");
 971 nag.boranna      1.163     
 972 sushma.fernandes 1.189             _sslContextMgr->createSSLContext(
 973                                        String::EMPTY, certPath, keyPath, crlStore, false, randFile);
 974 nag.boranna      1.163         }
 975 sushma.fernandes 1.189         sslContext = _sslContextMgr->getSSLContext();
 976 nag.boranna      1.163     
 977                                PEG_METHOD_EXIT();
 978                                return sslContext;
 979                            }
 980 h.sterling       1.130     
 981 tony             1.134     #ifdef PEGASUS_ENABLE_SLP
 982 mike             1.183     ThreadReturnType PEGASUS_THREAD_CDECL _callSLPProvider(void *parm);
 983 tony             1.134     
 984                            
 985                            // This is a control function that starts a new thread which issues a
 986                            // cim operation to start the slp provider.
 987                            void CIMServer::startSLPProvider()
 988                            {
 989                            
 990                               PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "CIMServer::startSLPProvider");
 991 mreddy           1.190.2.8    #ifndef PEGASUS_SLP_REG_TIMEOUT
 992                               // This is a onetime function.  If already issued, or config is not to use simply
 993                               // return
 994                               if (!_runSLP)
 995                               {
 996                                  return;
 997                               }
 998                               #endif 
 999 mreddy           1.190.2.5     // Get Config parameter to determine if we should start SLP.
1000                                ConfigManager* configManager = ConfigManager::getInstance();
1001                                _runSLP = ConfigManager::parseBooleanValue(
1002                                               configManager->getCurrentValue("slp"));
1003 mreddy           1.190.2.1 
1004 mreddy           1.190.2.5     // If false, do not start slp provider
1005                                if (!_runSLP)
1006                                {
1007                                   return;
1008                                }
1009 mreddy           1.190.2.8     #ifndef PEGASUS_SLP_REG_TIMEOUT
1010 mreddy           1.190.2.5     //SLP startup is onetime function; reset the switch so this
1011                                // function does not get called a second time.
1012                                _runSLP = false;
1013 mreddy           1.190.2.8     #endif
1014 mreddy           1.190.2.6     // Start SLPProvider for Built-in SA and Open SLP SA. If the 
1015                                // PEGASUS_SLP_REG_TIMEOUT is defined and if Open SLP is not used, start a
1016                                // thread which advertises CIMOM with a external SLP SA( i.e . IBM SA).
1017                            #if defined( PEGASUS_SLP_REG_TIMEOUT ) && !defined( PEGASUS_USE_OPENSLP )
1018 mreddy           1.190.2.1     Thread SLPThread(_advertisePegasus,0,true);
1019                                SLPThread.run();
1020                            #else 
1021 tony             1.134         // Create a separate thread, detach and call function to execute the startup.
1022                                Thread t( _callSLPProvider, 0, true );
1023                                t.run();
1024 mreddy           1.190.2.1 #endif
1025 tony             1.134     
1026                                PEG_METHOD_EXIT();
1027                                return;
1028                            }
1029                            
1030                            
1031 mreddy           1.190.2.6 
1032 tony             1.134     // startSLPProvider is a function to get the slp provider kicked off
1033                            // during startup.  It is placed in the provider manager simply because 
1034                            // the provider manager is the only component of the system is
1035                            // driven by a timer after startup.  It should never be here and must be
1036                            // moved to somewhere more logical or really replaced. We simply needed
1037                            // something that was run shortly after system startup.
1038                            // This function is assumed to operate in a separate thread and 
1039                            // KS 15 February 2004.
1040                            
1041 mike             1.183     ThreadReturnType PEGASUS_THREAD_CDECL _callSLPProvider(void* parm )
1042 tony             1.134     {
1043                                //
1044                                PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::_callSLPProvider()");
1045                                // Create CIMClient object
1046                                //
1047                                CIMClient client;
1048                                //
1049                                // open connection to CIMOM 
1050                                //
1051                                String hostStr = System::getHostName();
1052                                try
1053                                {
1054                                    //
1055                                    client.connectLocal();
1056                            
1057                                    //
1058                                    // set client timeout to 2 seconds
1059                                    //
1060                                    client.setTimeout(40000);
1061                                    // construct CIMObjectPath
1062                                    //
1063 tony             1.134             String referenceStr = "//";
1064                                    referenceStr.append(hostStr);
1065                                    referenceStr.append("/");  
1066                                    referenceStr.append(PEGASUS_NAMESPACENAME_INTERNAL.getString());
1067                                    referenceStr.append(":");
1068                                    referenceStr.append(PEGASUS_CLASSNAME_WBEMSLPTEMPLATE.getString());
1069                                    CIMObjectPath reference(referenceStr);
1070                            
1071                                    //
1072                                    // issue the invokeMethod request on the register method
1073                                    //
1074                                    Array<CIMParamValue> inParams;
1075                                    Array<CIMParamValue> outParams;
1076                            
1077                                    CIMValue retValue = client.invokeMethod(
1078                                        PEGASUS_NAMESPACENAME_INTERNAL,
1079                                        reference,
1080                                        CIMName("register"),
1081                                        inParams,
1082                                        outParams
1083                                        );
1084 tony             1.134         }
1085                            
1086                                catch(CIMException& e)
1087                                {
1088                                    Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1089                                        "SLP Registration Failed. CIMException. $0", e.getMessage());
1090                                }
1091                            
1092                                catch(Exception& e)
1093                                {
1094                                    Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1095                                        "SLP Registration Failed Startup: CIMServer exception. $0", e.getMessage());
1096                                }
1097                            
1098                                client.disconnect();
1099                            
1100                                Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1101                                    "SLP Registration Initiated");
1102                            
1103                                PEG_METHOD_EXIT();
1104 mike             1.183         return( (ThreadReturnType)32 );
1105 tony             1.134     }
1106                            
1107 mreddy           1.190.2.1  // This thread advertises pegasus to a listening SA. The attributes for
1108                             // the Pegasus advertisement is obtained from CIM classes with the help
1109                             // of SLPAttrib class methods.
1110                            ThreadReturnType PEGASUS_THREAD_CDECL _advertisePegasus(void* parm)
1111                            {
1112 tony             1.134     
1113 mreddy           1.190.2.1     PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::_advertisePegasus()");
1114 mreddy           1.190.2.6     SLPAttrib SLPHttpAttribObj;
1115                                SLPAttrib SLPHttpsAttribObj;
1116 mreddy           1.190.2.1     struct slp_client *client;
1117                                time_t now,last;
1118                                lslpMsg msg_list;
1119                                char *scopes;
1120                                Uint16 life = MAX_LIFE, port=SLP_PORT;
1121                                char *addr = strdup(LOCALHOST_IP);
1122                                char *type = (char *)NULL;;
1123                                char *iface = NULL;
1124                                char *httpUrl = (char *)NULL;;
1125                                char *httpsUrl = (char *)NULL;;
1126                                char *httpAttrs  = (char *)NULL;
1127                                char *httpsAttrs  = (char *)NULL;
1128                            
1129                                   // Comes here only if the cimserver is not terminated.
1130                                   // Get all the SLP attributes and data for the Pegasus cimserver.
1131                                   SLPHttpAttribObj.fillData("http");
1132                                   SLPHttpsAttribObj.fillData("https");
1133                                   SLPHttpAttribObj.formAttributes();
1134                                   SLPHttpsAttribObj.formAttributes();
1135                            
1136                                scopes = strdup("DEFAULT");
1137 mreddy           1.190.2.1 
1138 mreddy           1.190.2.6     //Populate datastructures required for registering  a service with External SLP SA (i.e IBM SLP SA)
1139 mreddy           1.190.2.1     type = strdup(SLPHttpAttribObj.getServiceType().getCString());
1140                                httpUrl = strdup(SLPHttpAttribObj.getServiceUrl().getCString());
1141                                httpsUrl = strdup(SLPHttpsAttribObj.getServiceUrl().getCString());
1142                                httpAttrs = strdup(SLPHttpAttribObj.getAttributes().getCString());
1143                                httpsAttrs = strdup(SLPHttpsAttribObj.getAttributes().getCString());
1144                                if(NULL != (client = create_slp_client(addr,
1145                                                                      iface,
1146                                                                      SLP_PORT,
1147                                                                      "DSA",
1148                                                                      scopes,
1149                                                                      FALSE,
1150                                                                      FALSE)))
1151                                {
1152 mreddy           1.190.2.6           int rc_http = client->srv_reg_local(client, httpUrl, httpAttrs, type, scopes, life);
1153                                      int rc_https = client->srv_reg_local(client, httpsUrl, httpsAttrs, type, scopes, life);
1154                                      if (!rc_http)
1155                                      {
1156 mreddy           1.190.2.8               PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2,
1157                                                              "CIMServer http registration is FAILED with External SLP");
1158 mreddy           1.190.2.6           } 
1159                                      if (!rc_https)
1160                                      {
1161 mreddy           1.190.2.8               PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2,
1162                                                              "CIMServer https registration is FAILED with External SLP");
1163 mreddy           1.190.2.6           } 
1164 mreddy           1.190.2.1        destroy_slp_client(client);
1165                                }
1166                                
1167                                if(type != NULL)
1168                                   free(type);
1169                                if(httpUrl != NULL)
1170                                    free(httpUrl);
1171                                if(httpsUrl != NULL)
1172                                    free(httpsUrl);
1173                                if(httpAttrs != NULL)
1174                                    free(httpAttrs);
1175                                if(httpsAttrs != NULL)
1176                                    free(httpsAttrs);
1177                                if(addr != NULL)
1178                                    free(addr);
1179                                if(scopes != NULL)
1180                                    free(scopes);
1181                                if(iface != NULL)
1182                                    free(iface);
1183 h.sterling       1.150     
1184 mreddy           1.190.2.1     PEG_METHOD_EXIT();
1185                                return( (ThreadReturnType)32 );
1186                             }
1187                            
1188                            // This routine deregisters the CIM Server registration with external SLP SA.
1189                            
1190 mreddy           1.190.2.8 void  deregPegasus()
1191 mreddy           1.190.2.1 {
1192                            
1193                               PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::deregPegasus()");
1194                            
1195 mreddy           1.190.2.6    SLPAttrib SLPHttpAttribObj1;
1196                               SLPAttrib SLPHttpsAttribObj1;
1197 mreddy           1.190.2.1    struct slp_client *client;
1198                               time_t now,last;
1199                               lslpMsg msg_list;
1200                               char *scopes;
1201                               Uint16 life = MAX_LIFE, port=SLP_PORT;
1202                               char *addr = strdup(LOCALHOST_IP);
1203                               char *type = (char *)NULL;;
1204                               char *iface = NULL;
1205                               char *httpUrl = (char *)NULL;;
1206                               char *httpsUrl = (char *)NULL;;
1207                               char *httpAttrs  = (char *)NULL;
1208                               char *httpsAttrs  = (char *)NULL;
1209                            
1210                              
1211                             // Get all the SLP attributes and data for the Pegasus cimserver.
1212                               SLPHttpAttribObj1.fillData("http");
1213                               SLPHttpsAttribObj1.fillData("https");
1214                               SLPHttpAttribObj1.formAttributes();
1215                               SLPHttpsAttribObj1.formAttributes();
1216                            
1217                               scopes = strdup("DEFAULT");
1218 mreddy           1.190.2.1 
1219                               type = strdup(SLPHttpAttribObj1.getServiceType().getCString());
1220                               httpUrl = strdup(SLPHttpAttribObj1.getServiceUrl().getCString());
1221                               httpsUrl = strdup(SLPHttpsAttribObj1.getServiceUrl().getCString());
1222                               httpAttrs = strdup(SLPHttpAttribObj1.getAttributes().getCString());
1223                               httpsAttrs = strdup(SLPHttpsAttribObj1.getAttributes().getCString());
1224                               if(NULL != (client = create_slp_client(addr,
1225                                                                      iface,
1226                                                                      SLP_PORT,
1227                                                                      "DSA",
1228                                                                      scopes,
1229                                                                      FALSE,
1230                                                                      FALSE)))
1231                               {
1232                                  client->srv_reg_local(client, httpUrl, httpAttrs, type, scopes, 0);
1233                                  client->srv_reg_local(client, httpsUrl, httpsAttrs, type, scopes,0);
1234                                  destroy_slp_client(client);
1235                               }
1236                               if(type != NULL)
1237                                  free(type);
1238                               if(httpUrl != NULL)
1239 mreddy           1.190.2.1       free(httpUrl);
1240                               if(httpsUrl != NULL)
1241                                  free(httpsUrl);
1242                               if(httpAttrs != NULL)
1243                                  free(httpAttrs);
1244                               if(httpsAttrs != NULL)
1245                                  free(httpsAttrs);
1246                               if(addr != NULL)
1247                                  free(addr);
1248                               if(scopes != NULL)
1249                                  free(scopes);
1250                               if(iface != NULL)
1251                                  free(iface);
1252                            
1253                               PEG_METHOD_EXIT();
1254 mreddy           1.190.2.8    return;
1255 mreddy           1.190.2.1 }
1256                            #endif
1257                            PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2