⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cimserver.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 4 页
字号:
            }        }        if (handleShutdownSignal)        {            Tracer::trace(TRC_SERVER, Tracer::LEVEL3,                "CIMServer::runForever - signal received.  Shutting down.");            ShutdownService::getInstance(this)->shutdown(true, 10, false);            // Set to false must be after call to shutdown.  See            // stopClientConnection.            handleShutdownSignal = false;        }    }}void CIMServer::stopClientConnection(){    PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::stopClientConnection()");    // tell Monitor to stop listening for client connections    if (handleShutdownSignal)        // If shutting down, this is in the same thread as runForever.        // No need to wait for the thread to see the stop flag.        _monitor->stopListeningForConnections(false);    else        // If not shutting down, this is not in the same thread as runForever.        // Need to wait for the thread to see the stop flag.        _monitor->stopListeningForConnections(true);    //    // Wait 150 milliseconds to allow time for the Monitor to stop    // listening for client connections.    //    // This wait time is the timeout value for the select() call    // in the Monitor's run() method (currently set to 100    // milliseconds) plus a delta of 50 milliseconds.  The reason    // for the wait here is to make sure that the Monitor entries    // are updated before closing the connection sockets.    //    // PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL4, "Wait 150 milliseconds.");    //  Threads::sleep(150);  not needed anymore due to the semaphore    // in the monitor    for (Uint32 i=0; i<_acceptors.size(); i++)    {        _acceptors[i]->closeConnectionSocket();    }    PEG_METHOD_EXIT();}void CIMServer::shutdown(){    PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::shutdown()");#ifdef PEGASUS_DEBUG    _repository->DisplayCacheStatistics();#endif    _dieNow = true;    _cimserver->tickle_monitor();    PEG_METHOD_EXIT();}void CIMServer::resume(){    PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::resume()");    for (Uint32 i=0; i<_acceptors.size(); i++)    {        _acceptors[i]->reopenConnectionSocket();    }    PEG_METHOD_EXIT();}void CIMServer::setState(Uint32 state){    PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::setState()");    _serverState->setState(state);    //    // get the configured authentication and authorization flags    //    ConfigManager* configManager = ConfigManager::getInstance();    Boolean enableAuthentication = ConfigManager::parseBooleanValue(        configManager->getCurrentValue("enableAuthentication"));    Boolean enableNamespaceAuthorization = ConfigManager::parseBooleanValue(        configManager->getCurrentValue("enableNamespaceAuthorization"));    if (state == CIMServerState::TERMINATING)    {        // tell decoder that CIMServer is terminating        _cimOperationRequestDecoder->setServerTerminating(true);        _cimExportRequestDecoder->setServerTerminating(true);        // tell authorizer that CIMServer is terminating ONLY if        // authentication and authorization are enabled        //        if ( enableAuthentication && enableNamespaceAuthorization )        {            _cimOperationRequestAuthorizer->setServerTerminating(true);        }    }    else    {        // tell decoder that CIMServer is not terminating        _cimOperationRequestDecoder->setServerTerminating(false);        _cimExportRequestDecoder->setServerTerminating(false);        // tell authorizer that CIMServer is terminating ONLY if        // authentication and authorization are enabled        //        if ( enableAuthentication && enableNamespaceAuthorization )        {            _cimOperationRequestAuthorizer->setServerTerminating(false);        }    }    PEG_METHOD_EXIT();}Uint32 CIMServer::getOutstandingRequestCount(){    PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::getOutstandingRequestCount()");    Uint32 requestCount = 0;    for (Uint32 i=0; i<_acceptors.size(); i++)    {        requestCount += _acceptors[i]->getOutstandingRequestCount();    }    PEG_METHOD_EXIT();    return requestCount;}//SSLContext* CIMServer::_getSSLContext(){    PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::_getSSLContext()");    static const String PROPERTY_NAME__SSL_CERT_FILEPATH =        "sslCertificateFilePath";    static const String PROPERTY_NAME__SSL_KEY_FILEPATH = "sslKeyFilePath";    static const String PROPERTY_NAME__SSL_TRUST_STORE = "sslTrustStore";    static const String PROPERTY_NAME__SSL_CRL_STORE = "crlStore";    static const String PROPERTY_NAME__SSL_CLIENT_VERIFICATION =        "sslClientVerificationMode";    static const String PROPERTY_NAME__SSL_AUTO_TRUST_STORE_UPDATE =        "enableSSLTrustStoreAutoUpdate";    static const String PROPERTY_NAME__SSL_TRUST_STORE_USERNAME =        "sslTrustStoreUserName";    static const String PROPERTY_NAME__HTTP_ENABLED =        "enableHttpConnection";    String verifyClient = String::EMPTY;    String trustStore = String::EMPTY;    SSLContext* sslContext = 0;    //    // Get a config manager instance    //    ConfigManager* configManager = ConfigManager::getInstance();    // Note that if invalid values were set for either sslKeyFilePath,    // sslCertificateFilePath, crlStore or sslTrustStore, the invalid    // paths would have been detected in SecurityPropertyOwner and    // terminated the server startup. This happens regardless of whether    // or not HTTPS is enabled (not a great design, but that seems to    // be how other properties are validated as well)    //    // Get the sslClientVerificationMode property from the Config    // Manager.    //    verifyClient = configManager->getCurrentValue(        PROPERTY_NAME__SSL_CLIENT_VERIFICATION);    //    // Get the sslTrustStore property from the Config Manager.    //    trustStore = configManager->getCurrentValue(        PROPERTY_NAME__SSL_TRUST_STORE);    if (trustStore != String::EMPTY)    {        trustStore = ConfigManager::getHomedPath(trustStore);    }    PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL4,        "Server trust store name: " + trustStore);    //    // Get the sslTrustStoreUserName property from the Config Manager.    //    String trustStoreUserName = String::EMPTY;    trustStoreUserName = configManager->getCurrentValue(        PROPERTY_NAME__SSL_TRUST_STORE_USERNAME);    if (!String::equal(verifyClient, "disabled"))    {        //        // 'required' and 'optional' settings must have a valid truststore        //        if (trustStore == String::EMPTY)        {            MessageLoaderParms parms(                "Pegasus.Server.CIMServer."                    "SSL_CLIENT_VERIFICATION_EMPTY_TRUSTSTORE",                "The \"sslTrustStore\" configuration property must be set "                    "if \"sslClientVerificationMode\" is 'required' or "                    "'optional'. cimserver not started.");            PEG_METHOD_EXIT();            throw SSLException(parms);        }#ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET        //        // ATTN: 'required' setting must have http port enabled.        // If only https is enabled, and a call to shutdown the        // cimserver is given, the call will hang and a forced shutdown        // will ensue. This is because the CIMClient::connectLocal call        // cannot specify a certificate for authentication against        // the local server.  This limitation is being investigated.        // See Bugzilla 2995.        //        if (String::equal(verifyClient, "required"))        {            if (!ConfigManager::parseBooleanValue(                configManager->getCurrentValue(                    PROPERTY_NAME__HTTP_ENABLED)))            {                MessageLoaderParms parms(                    "Pegasus.Server.SSLContextManager."                        "INVALID_CONF_HTTPS_REQUIRED",                    "The \"sslClientVerificationMode\" property cannot be "                        "set to \"required\" if HTTP is disabled, as the "                        "cimserver will be unable to properly shutdown.  "                        "The recommended course of action is to change "                        "the property value to \"optional\".  cimserver "                        "not started.");                PEG_METHOD_EXIT();                throw SSLException(parms);            }        }#endif        //        // A truststore username must be specified if        // sslClientVerificationMode is enabled and the truststore is a        // single CA file.  If the truststore is a directory, then the        // CertificateProvider should be used to register users with        // certificates.        //        if ((trustStore != String::EMPTY) &&            (!FileSystem::isDirectory(trustStore)))        {            if (trustStoreUserName == String::EMPTY)            {                MessageLoaderParms parms(                    "Pegasus.Server.CIMServer."                        "SSL_CLIENT_VERIFICATION_EMPTY_USERNAME",                    "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.");                PEG_METHOD_EXIT();                throw SSLException(parms);            }        }    }#ifdef PEGASUS_ENABLE_SSL_CRL_VERIFICATION    //    // Get the crlStore property from the Config Manager.    //    String crlStore = configManager->getCurrentValue(        PROPERTY_NAME__SSL_CRL_STORE);    if (crlStore != String::EMPTY)    {        crlStore = ConfigManager::getHomedPath(crlStore);    }#else    String crlStore;#endif    //    // Get the sslCertificateFilePath property from the Config Manager.    //    String certPath;    certPath = ConfigManager::getHomedPath(        configManager->getCurrentValue(PROPERTY_NAME__SSL_CERT_FILEPATH));    //    // Get the sslKeyFilePath property from the Config Manager.    //    String keyPath;    keyPath = ConfigManager::getHomedPath(        configManager->getCurrentValue(PROPERTY_NAME__SSL_KEY_FILEPATH));    String randFile = String::EMPTY;#ifdef PEGASUS_SSL_RANDOMFILE    // NOTE: It is technically not necessary to set up a random file on    // the server side, but it is easier to use a consistent interface    // on the client and server than to optimize out the random file on    // the server side.    randFile = ConfigManager::getHomedPath(PEGASUS_SSLSERVER_RANDOMFILE);#endif    //    // Create the SSLContext defined by the configuration properties    //    if (String::equal(verifyClient, "required"))    {        PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2,            "SSL Client verification REQUIRED.");        _sslContextMgr->createSSLContext(            trustStore, certPath, keyPath, crlStore, false, randFile);    }    else if (String::equal(verifyClient, "optional"))    {        PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2,            "SSL Client verification OPTIONAL.");        _sslContextMgr->createSSLContext(            trustStore, certPath, keyPath, crlStore, true, randFile);    }    else if (String::equal(verifyClient, "disabled") ||             verifyClient == String::EMPTY)    {        PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2,            "SSL Client verification DISABLED.");        _sslContextMgr->createSSLContext(            String::EMPTY, certPath, keyPath, crlStore, false, randFile);    }    sslContext = _sslContextMgr->getSSLContext();    PEG_METHOD_EXIT();    return sslContext;}void CIMServer::auditLogInitializeCallback(){#ifndef PEGASUS_DISABLE_AUDIT_LOGGER    Array<String> propertyNames;    Array<String> propertyValues;    // Get all current property names and values    ConfigManager* configManager = ConfigManager::getInstance();    configManager->getAllPropertyNames(propertyNames, false);    for (Uint32 i = 0; i < propertyNames.size(); i++)    {        propertyValues.append(configManager->getCurrentValue(propertyNames[i]));    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -