// // Modify instance based on modifiedInstance. // void UserAuthProvider::modifyInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance& modifiedIns, const Boolean includeQualifiers, const CIMPropertyList & propertyList, ResponseHandler & handler) { PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::modifyInstance"); // // get userName // String user; try { IdentityContainer container = context.get(IdentityContainer::NAME); user= container.getUserName(); } catch (...) { user= String::EMPTY; } // // verify user authorizations // if ( user != String::EMPTY || user != "" ) { _verifyAuthorization(user); } // // check if the class name requested is PG_Authorization // if (!instanceReference.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION)) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION ( CIM_ERR_NOT_SUPPORTED, instanceReference.getClassName().getString()); } CIMInstance newInstance = modifiedIns; // begin processing the request handler.processing(); try { // // Get the user name from the instance // String userNameStr; String namespaceStr; String authorizationStr; Uint32 pos = modifiedIns.findProperty ( PROPERTY_NAME_USERNAME ); CIMProperty prop = (CIMProperty)newInstance.getProperty(pos); prop.getValue().get(userNameStr); // // Get the namespace from the instance // pos = modifiedIns.findProperty ( PROPERTY_NAME_NAMESPACE ); prop = (CIMProperty)newInstance.getProperty(pos); prop.getValue().get(namespaceStr); // // Get the authorization from the instance // pos = modifiedIns.findProperty ( PROPERTY_NAME_AUTHORIZATION ); prop = (CIMProperty)newInstance.getProperty(pos); prop.getValue().get(authorizationStr); // // ATTN: Note that the following is a hack, because // modifyInstance() in repository does not like // the hostname and namespace included in the CIMObjectPath // passed to it as a parameter. // CIMObjectPath ref("", CIMNamespaceName (), modifiedIns.getClassName(), instanceReference.getKeyBindings()); CIMInstance newModifiedIns = modifiedIns.clone (); newModifiedIns.setPath (ref); // // call modifyInstances of the repository // _repository->modifyInstance( instanceReference.getNameSpace(), newModifiedIns); // // set authorization in the UserManager // _userManager->setAuthorization( userNameStr, namespaceStr, authorizationStr ); } catch(Exception& e) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return; }
PEGASUS_NAMESPACE_BEGIN /***************************************************************************** * * Implementation of AssociationProvider associators method * *****************************************************************************/ void InteropProvider::associators( const OperationContext & context, const CIMObjectPath & objectName, const CIMName & associationClass, const CIMName & resultClass, const String & role, const String & resultRole, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList & propertyList, ObjectResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::associators()"); initProvider(); PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4, "%s associators. objectName= %s, assocClass= %s resultClass= %s " "role= %s resultRole %s, includeQualifiers= %s, " "includeClassOrigin= %s, PropertyList= %s", thisProvider, (const char *)objectName.toString().getCString(), (const char *)associationClass.getString().getCString(), (const char *)resultClass.getString().getCString(), (const char *)role.getCString(), (const char *)resultRole.getCString(), boolToString(includeQualifiers), boolToString(includeClassOrigin), (const char *)propertyListToString(propertyList).getCString())); handler.processing(); String originRole = role; String targetRole = resultRole; Uint32 numIterations = 1; // // The localReferences call retrieves instances of the desired association // class and sets the originRole and targetRole properties if currently // empty. // if (associationClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE)) { if (originRole.size() == 0 && targetRole.size() == 0) { originRole = String("Antecedent"); targetRole = String("Dependent"); numIterations = 2; } } for (Uint32 i = 0; i < numIterations; ++i) { Array<CIMInstance> refs = localReferences( context, objectName, associationClass, originRole, targetRole, CIMPropertyList(), resultClass); if( refs.size() ) { Array<CIMInstance> refObjs = getReferencedInstances(refs,targetRole,context,propertyList); ConstArrayIterator<CIMInstance> refsIterator(refObjs); for(Uint32 i = 0; i < refsIterator.size(); i++) { handler.deliver(refsIterator[i]); } } if (numIterations == 2) { originRole = String("Dependent"); targetRole = String("Antecedent"); } } handler.complete(); PEG_METHOD_EXIT(); }
// // create a file and make a random token data entry to it. // send the file name back to caller // String LocalAuthFile::create() { PEG_METHOD_ENTER(TRC_AUTHENTICATION, "LocalAuthFile::create()"); Uint32 secs, milliSecs; Uint32 mySequenceNumber; System::getCurrentTime(secs, milliSecs); // // extension size is username plus the sequence count // { AutoMutex autoMut(sequenceCountLock); mySequenceNumber = sequenceCount++; } // mutex unlocks here char extension[2*INT_BUFFER_SIZE]; sprintf(extension,"_%u_%u", mySequenceNumber, milliSecs); extension[strlen(extension)] = 0; String filePath; // Check to see whether a domain was specified. If so, strip the domain // from the local auth file name, since the backslash and '@' are invalid // filename characters. Store this in another variable, since we need to // keep the domain around for the rest of the operations. String fileUserName = _userName; Uint32 index = _userName.find('\\'); if (index != PEG_NOT_FOUND) { fileUserName = _userName.subString(index + 1); } else { index = _userName.find('@'); if (index != PEG_NOT_FOUND) { fileUserName = _userName.subString(0, index); } } filePath.append(_authFilePath); filePath.append(fileUserName);//_userName); filePath.append(extension); CString filePathCString = filePath.getCString(); // // 1. Create a file name for authentication. // ofstream outfs(filePathCString); if (!outfs) { // unable to create file Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, MessageLoaderParms( "Security.Authentication.LocalAuthFile.NO_CREATE", "Creation of the local authentication security file" " $0 failed: $1", filePath, strerror(errno))); PEG_METHOD_EXIT(); throw CannotOpenFile (filePath); } outfs.clear(); // // 2. Set file permission to read/write by the owner only. // #if defined(PEGASUS_OS_TYPE_WINDOWS) Boolean success = FileSystem::changeFilePermissions(filePath, _S_IREAD | _S_IWRITE); #else Boolean success = FileSystem::changeFilePermissions(filePath, S_IRUSR | S_IWUSR); #endif if (!success) { // Unable to change the local auth file permissions, remove the file // and throw CannotOpenFile error. Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, MessageLoaderParms( "Security.Authentication.LocalAuthFile.NO_CHMOD", "Changing permissions of the local authentication security " "file $0 failed: $1", filePath, strerror(errno))); if (filePath.size()) { if (FileSystem::exists(filePath)) { FileSystem::removeFile(filePath); } } PEG_METHOD_EXIT(); throw CannotOpenFile (filePath); } // // 3. Generate random token and write the token to the file. // String randomToken = _generateRandomTokenString(); outfs << randomToken; // test if the write was successful if (outfs.fail()) { Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, MessageLoaderParms( "Security.Authentication.LocalAuthFile.NO_WRITE", "Cannot write security token to the local authentication " "security file $0.", filePath)); if (filePath.size()) { if (FileSystem::exists(filePath)) { FileSystem::removeFile(filePath); } } PEG_METHOD_EXIT(); throw CannotOpenFile (filePath); } outfs.close(); // // 4. Set file permission to read only by the owner. // #if defined(PEGASUS_OS_TYPE_WINDOWS) success = FileSystem::changeFilePermissions(filePath, _S_IREAD); #else success = FileSystem::changeFilePermissions(filePath, S_IRUSR); #endif if (!success) { // Unable to change the local auth file permissions, remove the file // and throw CannotOpenFile error. Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, MessageLoaderParms( "Security.Authentication.LocalAuthFile.NO_CHMOD", "Changing permissions of the local authentication security " "file $0 failed: $1", filePath, strerror(errno))); if (filePath.size()) { if (FileSystem::exists(filePath)) { FileSystem::removeFile(filePath); } } PEG_METHOD_EXIT(); throw CannotOpenFile (filePath); } // // 5. Change the file owner to the requesting user. // if (!FileSystem::changeFileOwner(filePath,_userName)) { // Unable to change owner on local auth file, remove the file // and throw CannotOpenFile error. Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, MessageLoaderParms( "Security.Authentication.LocalAuthFile.NO_CHOWN_REQUSER", "Changing ownership of the local authentication " "security file $0 to the requesting user failed: $1", filePath, strerror(errno))); if (filePath.size()) { if (FileSystem::exists(filePath)) { FileSystem::removeFile(filePath); } } PEG_METHOD_EXIT(); throw CannotOpenFile (filePath); } _secret = randomToken; _filePathName = filePath; PEG_METHOD_EXIT(); return _filePathName; }
Sint16 DefaultProviderManager::_disableProvider( const String& moduleName, const String& providerName) { PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "DefaultProviderManager::_disableProvider"); ProviderMessageHandler* pr = _lookupProvider(moduleName, providerName); if (!pr->status.isInitialized()) { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL2, "Provider %s is not loaded", (const char*)providerName.getCString())); PEG_METHOD_EXIT(); return 1; } PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4,"Disable Provider %s", (const char*)pr->getName().getCString())); // // Check to see if there are pending requests. If there are pending // requests and the disable timeout has not expired, loop and wait one // second until either there is no pending requests or until timeout // expires. // Uint32 waitTime = PROVIDER_DISABLE_TIMEOUT; while ((pr->status.numCurrentOperations() > 0) && (waitTime > 0)) { Threads::sleep(1000); waitTime = waitTime - 1; } // There are still pending requests, do not disable if (pr->status.numCurrentOperations() > 0) { PEG_TRACE_CSTRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Disable failed since there are pending requests."); PEG_METHOD_EXIT(); return 0; } try { AutoMutex lock(pr->status.getStatusMutex()); if (pr->status.isInitialized()) { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Unloading Provider %s", (const char*)pr->getName().getCString())); _unloadProvider(pr); } } catch (...) { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL2, "Unload provider failed %s", (const char*)pr->getName().getCString())); PEG_METHOD_EXIT(); return -1; } PEG_METHOD_EXIT(); return 1; }
/***************************************************************************** * * Implementation of AssociationProvider associatorNames method * *****************************************************************************/ void InteropProvider::associatorNames( const OperationContext & context, const CIMObjectPath & objectName, const CIMName & associationClass, const CIMName & resultClass, const String & role, const String & resultRole, ObjectPathResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::associatorNames()"); initProvider(); PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4, "%s associatorNames.objectName= %s, assocClass= %s resultClass= %s " "role= %s resultRole = %s", thisProvider, (const char *)objectName.toString().getCString(), (const char *)associationClass.getString().getCString(), (const char *)resultClass.getString().getCString(), (const char *)role.getCString(), (const char *)resultRole.getCString())); handler.processing(); String originRole = role; String targetRole = resultRole; Uint32 numIterations = 1; // // The localReferences call retrieves instances of the desired association // class and sets the originRole and targetRole properties if currently // empty. // if (associationClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE)) { if (originRole.size() == 0 && targetRole.size() == 0) { originRole = String("Antecedent"); targetRole = String("Dependent"); numIterations = 2; } } for (Uint32 i = 0; i < numIterations; ++i) { Array<CIMInstance> refs = localReferences( context, objectName, associationClass, originRole, targetRole, CIMPropertyList(), resultClass); for (Uint32 j = 0, n = refs.size(); j < n; ++j) { CIMInstance & currentRef = refs[j]; CIMObjectPath currentTarget = getRequiredValue<CIMObjectPath>( currentRef, targetRole); handler.deliver(currentTarget); } if (numIterations == 2) { originRole = String("Dependent"); targetRole = String("Antecedent"); } } handler.complete(); PEG_METHOD_EXIT(); }
void ProviderAgent::run() { PEG_METHOD_ENTER(TRC_PROVIDERAGENT, "ProviderAgent::run"); // Enable the signal handler to terminate gracefully on SIGHUP and SIGTERM getSigHandle()->registerHandler(PEGASUS_SIGHUP, _terminateSignalHandler); getSigHandle()->activate(PEGASUS_SIGHUP); getSigHandle()->registerHandler(PEGASUS_SIGTERM, _terminateSignalHandler); getSigHandle()->activate(PEGASUS_SIGTERM); // Restore the SIGCHLD signal behavior to its default action getSigHandle()->defaultAction(PEGASUS_SIGCHLD); #ifdef PEGASUS_OS_ZOS // Establish handling signal send to us on USS shutdown getSigHandle()->registerHandler(PEGASUS_SIGDANGER, _terminateSignalHandler); getSigHandle()->activate(PEGASUS_SIGDANGER); // enable process to receive SIGDANGER on USS shutdown __shutdown_registration(_SDR_NOTIFY, _SDR_REGPROCESS, _SDR_SENDSIGDANGER); #endif #ifdef PEGASUS_OS_PASE // PASE environment need more signal handler getSigHandle()->registerHandler(SIGFPE, _synchronousSignalHandler); getSigHandle()->activate(SIGFPE); getSigHandle()->registerHandler(SIGILL, _synchronousSignalHandler); getSigHandle()->activate(SIGILL); getSigHandle()->registerHandler(SIGSEGV, _synchronousSignalHandler); getSigHandle()->activate(SIGSEGV); getSigHandle()->registerHandler(SIGIO, _asynchronousSignalHandler); getSigHandle()->activate(SIGIO); #endif while (!_terminating) { Boolean active = true; try { // // Read and process the next request // active = _readAndProcessRequest(); } catch (Exception& e) { PEG_TRACE((TRC_PROVIDERAGENT, Tracer::LEVEL1, "Unexpected Exception from _readAndProcessRequest(): %s", (const char*)e.getMessage().getCString())); _terminating = true; } catch (...) { PEG_TRACE_CSTRING(TRC_PROVIDERAGENT, Tracer::LEVEL1, "Unexpected exception from _readAndProcessRequest()."); _terminating = true; } if (_terminating) { if (!_providersStopped) { // // Stop all providers // CIMStopAllProvidersRequestMessage stopRequest("0", QueueIdStack(0)); AutoPtr<Message> stopResponse(_processRequest(&stopRequest)); // If there are agent threads running exit from here.If provider // is not responding cimprovagt may loop forever in ThreadPool // destructor waiting for running threads to become idle. if (_threadPool.runningCount()) { PEG_TRACE_CSTRING(TRC_PROVIDERAGENT, Tracer::LEVEL1, "Agent threads are running, terminating forcibly."); exit(1); } } } else if (!active) { // // Stop agent process when no more providers are loaded // try { if (!_providerManagerRouter.hasActiveProviders() && (_threadPool.runningCount() == 0)) { PEG_TRACE_CSTRING(TRC_PROVIDERAGENT, Tracer::LEVEL2, "No active providers. Exiting."); _terminating = true; } else { _threadPool.cleanupIdleThreads(); } } catch (...) { // Do not terminate the agent on this exception PEG_TRACE_CSTRING(TRC_PROVIDERAGENT, Tracer::LEVEL1, "Unexpected exception from hasActiveProviders()"); } } } // Notify the cimserver that the provider agent is exiting cleanly. Uint32 messageLength = 0; _pipeToServer->writeBuffer((const char*)&messageLength, sizeof(Uint32)); PEG_METHOD_EXIT(); }
CIMResponseMessage* DefaultProviderManager::_handleDisableModuleRequest( CIMRequestMessage* message) { PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "DefaultProviderManager::_handleDisableModuleRequest"); CIMDisableModuleRequestMessage* request = dynamic_cast<CIMDisableModuleRequestMessage*>(message); PEGASUS_ASSERT(request != 0); Array<Uint16> operationalStatus; CIMException cimException; try { // get provider module name String moduleName; CIMInstance mInstance = request->providerModule; Uint32 pos = mInstance.findProperty(PEGASUS_PROPERTYNAME_NAME); PEGASUS_ASSERT(pos != PEG_NOT_FOUND); mInstance.getProperty(pos).getValue().get(moduleName); // // Unload providers // Array<CIMInstance> providerInstances = request->providers; for (Uint32 i = 0, n = providerInstances.size(); i < n; i++) { String pName; providerInstances[i].getProperty( providerInstances[i].findProperty(PEGASUS_PROPERTYNAME_NAME)). getValue().get(pName); Sint16 ret_value = _disableProvider(moduleName, pName); if (ret_value == 0) { // disable failed since there are pending requests, // stop trying to disable other providers in this module. operationalStatus.append(CIM_MSE_OPSTATUS_VALUE_OK); break; } else if (ret_value != 1) // Not success { // disable failed for other reason, throw exception throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_FAILED, MessageLoaderParms( "ProviderManager.ProviderManagerService." "DISABLE_PROVIDER_FAILED", "Failed to disable the provider.")); } } } catch (CIMException& e) { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL1,"CIMException: %s", (const char*)e.getMessage().getCString())); cimException = e; } catch (Exception& e) { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL1,"Exception: %s", (const char*)e.getMessage().getCString())); cimException = CIMException(CIM_ERR_FAILED, e.getMessage()); } catch (...) { PEG_TRACE_CSTRING(TRC_PROVIDERMANAGER, Tracer::LEVEL1, "Exception: Unknown"); cimException = PEGASUS_CIM_EXCEPTION_L( CIM_ERR_FAILED, MessageLoaderParms( "ProviderManager.ProviderManagerService.UNKNOWN_ERROR", "Unknown Error")); } if (cimException.getCode() == CIM_ERR_SUCCESS) { // Status is set to OK if a provider was busy if (operationalStatus.size() == 0) { operationalStatus.append(CIM_MSE_OPSTATUS_VALUE_STOPPED); } } else { // If exception occurs, module is not stopped operationalStatus.append(CIM_MSE_OPSTATUS_VALUE_OK); } CIMDisableModuleResponseMessage* response = dynamic_cast<CIMDisableModuleResponseMessage*>( request->buildResponse()); PEGASUS_ASSERT(response != 0); response->operationalStatus = operationalStatus; PEG_METHOD_EXIT(); return response; }
// // Destructor // UserManager::~UserManager() { PEG_METHOD_ENTER(TRC_USER_MANAGER, "UserManager::~UserManager"); PEG_METHOD_EXIT(); }
void CIMOperationRequestAuthorizer::handleEnqueue(Message* request) { PEG_METHOD_ENTER(TRC_SERVER, "CIMOperationRequestAuthorizer::handleEnqueue"); if (!request) { PEG_METHOD_EXIT(); return; } CIMOperationRequestMessage* tmp = dynamic_cast<CIMOperationRequestMessage*>(request); AutoPtr<CIMOperationRequestMessage> req(tmp); PEGASUS_ASSERT(req.get()); // // Get the HTTPConnection queue id // QueueIdStack qis = req->queueIds.copyAndPop(); Uint32 queueId = qis.top(); // Set the client's requested language into this service thread. // This will allow functions in this service to return messages // in the correct language. req->updateThreadLanguages(); // // If CIMOM is shutting down, return "Service Unavailable" response // if (_serverTerminating) { Buffer message; message = XmlWriter::formatHttpErrorRspMessage( HTTP_STATUS_SERVICEUNAVAILABLE, String::EMPTY, "CIM Server is shutting down."); sendResponse(queueId, message); PEG_METHOD_EXIT(); return; } String userName = ((IdentityContainer)(req->operationContext.get( IdentityContainer::NAME))).getUserName(); String authType = req->authType; CIMNamespaceName nameSpace = req->nameSpace; String cimMethodName; switch (req->getType()) { case CIM_GET_CLASS_REQUEST_MESSAGE: cimMethodName = "GetClass"; break; case CIM_GET_INSTANCE_REQUEST_MESSAGE: cimMethodName = "GetInstance"; break; case CIM_DELETE_CLASS_REQUEST_MESSAGE: cimMethodName = "DeleteClass"; break; case CIM_DELETE_INSTANCE_REQUEST_MESSAGE: cimMethodName = "DeleteInstance"; break; case CIM_CREATE_CLASS_REQUEST_MESSAGE: cimMethodName = "CreateClass"; break; case CIM_CREATE_INSTANCE_REQUEST_MESSAGE: cimMethodName = "CreateInstance"; break; case CIM_MODIFY_CLASS_REQUEST_MESSAGE: cimMethodName = "ModifyClass"; break; case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE: cimMethodName = "ModifyInstance"; break; case CIM_ENUMERATE_CLASSES_REQUEST_MESSAGE: cimMethodName = "EnumerateClasses"; break; case CIM_ENUMERATE_CLASS_NAMES_REQUEST_MESSAGE: cimMethodName = "EnumerateClassNames"; break; case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE: cimMethodName = "EnumerateInstances"; break; case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE: cimMethodName = "EnumerateInstanceNames"; break; case CIM_EXEC_QUERY_REQUEST_MESSAGE: cimMethodName = "ExecQuery"; break; case CIM_ASSOCIATORS_REQUEST_MESSAGE: cimMethodName = "Associators"; break; case CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE: cimMethodName = "AssociatorNames"; break; case CIM_REFERENCES_REQUEST_MESSAGE: cimMethodName = "References"; break; case CIM_REFERENCE_NAMES_REQUEST_MESSAGE: cimMethodName = "ReferenceNames"; break; case CIM_GET_PROPERTY_REQUEST_MESSAGE: cimMethodName = "GetProperty"; break; case CIM_SET_PROPERTY_REQUEST_MESSAGE: cimMethodName = "SetProperty"; break; case CIM_GET_QUALIFIER_REQUEST_MESSAGE: cimMethodName = "GetQualifier"; break; case CIM_SET_QUALIFIER_REQUEST_MESSAGE: cimMethodName = "SetQualifier"; break; case CIM_DELETE_QUALIFIER_REQUEST_MESSAGE: cimMethodName = "DeleteQualifier"; break; case CIM_ENUMERATE_QUALIFIERS_REQUEST_MESSAGE: cimMethodName = "EnumerateQualifiers"; break; case CIM_INVOKE_METHOD_REQUEST_MESSAGE: cimMethodName = "InvokeMethod"; break; default: PEGASUS_ASSERT(0); break; } #ifdef PEGASUS_ZOS_SECURITY if (checkRequestTypeAuthorizationZOS( req->getType(), userName, nameSpace) == false) { // // user is not authorized, send an // error message to the requesting client. // if (cimMethodName == "InvokeMethod") { sendMethodError( queueId, req->getHttpMethod(), req->messageId, ((CIMInvokeMethodRequestMessage*)req.get())->methodName, PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED, MessageLoaderParms( "Server.CIMOperationRequestAuthorizer." "NAMESPACE_AUTHORIZATION_FAILED", "User '$0' is not authorized to run '$1' in the " "namespace '$2'", userName, cimMethodName, nameSpace.getString()))); } else { sendIMethodError( queueId, req->getHttpMethod(), req->messageId, cimMethodName, PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED, MessageLoaderParms( "Server.CIMOperationRequestAuthorizer." "NAMESPACE_AUTHORIZATION_FAILED", "User '$0' is not authorized to run '$1' in the " "namespace '$2'", userName, cimMethodName, nameSpace.getString()))); } PEG_METHOD_EXIT(); return; } #endif #ifdef PEGASUS_ENABLE_USERGROUP_AUTHORIZATION // // If the user is not privileged and authorized user group is specified, // then perform the user group authorization check. // try { if ( ! System::isPrivilegedUser(userName) ) { Uint32 size = _authorizedUserGroups.size(); if (size > 0) { Boolean authorized = false; // // Check if the user name is in the authorized user groups. // for (Uint32 i = 0; i < size; i++) { // // Check if the user is a member of the group // if (System::isGroupMember(userName.getCString(), _authorizedUserGroups[i].getCString())) { authorized = true; break; } } // // If the user is not a member of any of the authorized // user groups then generate error response. // if (!authorized) { PEG_TRACE((TRC_SERVER, Tracer::LEVEL1, "Authorization Failed: User '%s' " "is not a member of the authorized groups", (const char*)userName.getCString())); MessageLoaderParms msgLoaderParms( "Server.CIMOperationRequestAuthorizer." "NOT_IN_AUTHORIZED_GRP", "User '$0' is not authorized to access CIM data.", userName); // // user is not in the authorized user groups, send an // error message to the requesting client. // if (cimMethodName == "InvokeMethod") { sendMethodError( queueId, req->getHttpMethod(), req->messageId, ((CIMInvokeMethodRequestMessage*)req.get())-> methodName, PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED, msgLoaderParms)); PEG_METHOD_EXIT(); return; } else { sendIMethodError( queueId, req->getHttpMethod(), req->messageId, cimMethodName, PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED, msgLoaderParms)); PEG_METHOD_EXIT(); return; } } } } } catch (InternalSystemError& ise) { sendIMethodError( queueId, req->getHttpMethod(), req->messageId, cimMethodName, PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED, ise.getMessage())); PEG_METHOD_EXIT(); return; } #endif // #ifdef PEGASUS_ENABLE_USERGROUP_AUTHORIZATION // // Get a config manager instance // ConfigManager* configManager = ConfigManager::getInstance(); // // Do namespace authorization verification // if (ConfigManager::parseBooleanValue( configManager->getCurrentValue("enableNamespaceAuthorization"))) { // // If the user is not privileged, perform the authorization check. // if (!System::isPrivilegedUser(userName)) { UserManager* userManager = UserManager::getInstance(); if (!userManager || !userManager->verifyAuthorization( userName, nameSpace, cimMethodName)) { if (cimMethodName == "InvokeMethod") { sendMethodError( queueId, req->getHttpMethod(), req->messageId, ((CIMInvokeMethodRequestMessage*)req.get())->methodName, PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED, MessageLoaderParms( "Server.CIMOperationRequestAuthorizer." "NAMESPACE_AUTHORIZATION_FAILED", "User '$0' is not authorized to run '$1' in the " "namespace '$2'", userName, cimMethodName, nameSpace.getString()))); } else { sendIMethodError( queueId, req->getHttpMethod(), req->messageId, cimMethodName, PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED, MessageLoaderParms( "Server.CIMOperationRequestAuthorizer." "NAMESPACE_AUTHORIZATION_FAILED", "User '$0' is not authorized to run '$1' in " "the namespace '$2'", userName, cimMethodName, nameSpace.getString()))); } PEG_METHOD_EXIT(); return; } } } // // Enqueue the request // _outputQueue->enqueue(req.release()); PEG_METHOD_EXIT(); }
HTTPConnection* HTTPConnector::connect( const String& host, const Uint32 portNumber, SSLContext * sslContext, Uint32 timeoutMilliseconds, MessageQueue* outputMessageQueue) { PEG_METHOD_ENTER(TRC_HTTP, "HTTPConnector::connect()"); #ifdef PEGASUS_OS_PASE AutoPtr<PaseCcsid> ccsid; #endif SocketHandle socket = PEGASUS_INVALID_SOCKET; // Use an AutoPtr to ensure the socket handle is closed on exception AutoPtr<SocketHandle, CloseSocketHandle> socketPtr(&socket); #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET if (0 == host.size()) { // Set up the domain socket for a local connection sockaddr_un address; #ifdef PEGASUS_OS_PASE // PASE needs ccsid 819 to perform domain socket operation int orig_ccsid; orig_ccsid = _SETCCSID(-1); if (orig_ccsid == -1) { PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL2, "HTTPConnector::connect() Can not get current PASE CCSID."); orig_ccsid = 1208; } ccsid.reset(new PaseCcsid(819, orig_ccsid)); #endif memset(&address, 0, sizeof(address)); address.sun_family = AF_UNIX; strcpy(address.sun_path, PEGASUS_LOCAL_DOMAIN_SOCKET_PATH); socket = Socket::createSocket(AF_UNIX, SOCK_STREAM, 0); if (socket == PEGASUS_INVALID_SOCKET) { PEG_METHOD_EXIT(); throw CannotCreateSocketException(); } Socket::disableBlocking(socket); // Connect the socket to the address: if (!Socket::timedConnect( socket, reinterpret_cast<sockaddr*>(&address), sizeof(address), timeoutMilliseconds)) { MessageLoaderParms parms( "Common.HTTPConnector.CONNECTION_FAILED_LOCAL_CIM_SERVER", "Cannot connect to local CIM server. Connection failed."); PEG_METHOD_EXIT(); throw CannotConnectException(parms); } } else #endif { // Set up the IP socket connection // Make the internet address: #ifdef PEGASUS_ENABLE_IPV6 struct addrinfo *addrInfo, *addrInfoRoot = NULL; #else sockaddr_in address; #endif #ifdef PEGASUS_ENABLE_IPV6 if (!_MakeAddress( (const char*)host.getCString(), portNumber, (void**)(void*)&addrInfoRoot)) #else if (!_MakeAddress((const char*)host.getCString(), portNumber, address)) #endif { char scratch[22]; Uint32 n; const char * portStr = Uint32ToString(scratch, portNumber, n); PEG_METHOD_EXIT(); throw InvalidLocatorException(host+":"+String(portStr,n)); } #ifdef PEGASUS_ENABLE_IPV6 addrInfo = addrInfoRoot; while (addrInfo) { // Create the socket: socket = Socket::createSocket(addrInfo->ai_family, addrInfo->ai_socktype, addrInfo->ai_protocol); #else socket = Socket::createSocket(PF_INET, SOCK_STREAM, IPPROTO_TCP); #endif if (socket == PEGASUS_INVALID_SOCKET) { #ifdef PEGASUS_ENABLE_IPV6 freeaddrinfo(addrInfoRoot); #endif PEG_METHOD_EXIT(); throw CannotCreateSocketException(); } #ifndef PEGASUS_OS_TYPE_WINDOWS // We need to ensure that the socket number is not higher than // what fits into FD_SETSIZE,because we else won't be able to select // on it and won't ever communicate correct on that socket. if (socket >= FD_SETSIZE) { # ifdef PEGASUS_ENABLE_IPV6 freeaddrinfo(addrInfoRoot); # endif // the socket is useless to us, close it Socket::close(socket); PEG_TRACE( (TRC_DISCARDED_DATA, Tracer::LEVEL1, "createSocket() returned too large socket number %d." "Cannot connect to %s:%d. Connection failed.", socket, (const char*) host.getCString(), portNumber)); PEG_METHOD_EXIT(); throw CannotCreateSocketException(); } #endif Socket::disableBlocking(socket); // Connect the socket to the address: if (!Socket::timedConnect( socket, #ifdef PEGASUS_ENABLE_IPV6 reinterpret_cast<sockaddr*>(addrInfo->ai_addr), addrInfo->ai_addrlen, #else reinterpret_cast<sockaddr*>(&address), sizeof(address), #endif timeoutMilliseconds)) { #ifdef PEGASUS_ENABLE_IPV6 addrInfo = addrInfo->ai_next; if (addrInfo) { Socket::close(socket); continue; } #endif char scratch[22]; Uint32 n; const char * portStr = Uint32ToString(scratch, portNumber, n); MessageLoaderParms parms( "Common.HTTPConnector.CONNECTION_FAILED_TO", "Cannot connect to $0:$1. Connection failed.", host, portStr); #ifdef PEGASUS_ENABLE_IPV6 freeaddrinfo(addrInfoRoot); #endif PEG_METHOD_EXIT(); throw CannotConnectException(parms); } #ifdef PEGASUS_ENABLE_IPV6 break; } freeaddrinfo(addrInfoRoot); #endif } // Create HTTPConnection object: SharedPtr<MP_Socket> mp_socket(new MP_Socket(socket, sslContext, 0)); // mp_socket now has responsibility for closing the socket handle socketPtr.release(); if (mp_socket->connect(timeoutMilliseconds) < 0) { char scratch[22]; Uint32 n; const char * portStr = Uint32ToString(scratch, portNumber, n); MessageLoaderParms parms( "Common.HTTPConnector.CONNECTION_FAILED_TO", "Cannot connect to $0:$1. Connection failed.", host, portStr); PEG_METHOD_EXIT(); throw CannotConnectException(parms); } AutoPtr<HTTPConnection> connection(new HTTPConnection( _monitor, mp_socket, String::EMPTY, 0, outputMessageQueue)); // Solicit events on this new connection's socket: int index; if (-1 == (index = _monitor->solicitSocketMessages( connection->getSocket(), connection->getQueueId(), MonitorEntry::TYPE_CONNECTION))) { PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, "HTTPConnector::connect: Attempt to allocate entry in " "_entries table failed."); (connection->getMPSocket()).close(); } connection->_entry_index = index; _rep->connections.append(connection.get()); PEG_METHOD_EXIT(); return connection.release(); }
SoapResponse* WsmResponseEncoder::encode(WsmResponse* response) { PEG_METHOD_ENTER(TRC_WSMSERVER, "WsmResponseEncoder::format()"); PEGASUS_ASSERT(response); PEG_TRACE((TRC_WSMSERVER, Tracer::LEVEL4, "WsmResponseEncoder::enqueue()- " "response->getHttpCloseConnect() returned %d", response->getHttpCloseConnect())); try { switch (response->getType()) { case WS_TRANSFER_GET: return _encodeWxfGetResponse((WxfGetResponse*)response); case WS_TRANSFER_PUT: return _encodeWxfPutResponse((WxfPutResponse*)response); case WS_TRANSFER_CREATE: return _encodeWxfCreateResponse((WxfCreateResponse*)response); case WS_TRANSFER_DELETE: return _encodeWxfDeleteResponse((WxfDeleteResponse*)response); case WS_ENUMERATION_ENUMERATE: return _encodeWsenEnumerateResponse( (WsenEnumerateResponse*)response); case WS_ENUMERATION_PULL: return _encodeWsenPullResponse((WsenPullResponse*)response); case WS_ENUMERATION_RELEASE: return _encodeWsenReleaseResponse( (WsenReleaseResponse*)response); case WSM_FAULT: return _encodeWsmFaultResponse((WsmFaultResponse*)response); case SOAP_FAULT: return _encodeSoapFaultResponse((SoapFaultResponse*)response); case WS_INVOKE: return _encodeWsInvokeResponse((WsInvokeResponse*)response); default: // Unexpected message type PEGASUS_ASSERT(0); break; } } catch (PEGASUS_STD(bad_alloc)&) { WsmFault fault(WsmFault::wsman_InternalError, MessageLoaderParms( "WsmServer.WsmResponseEncoder.OUT_OF_MEMORY", "A System error has occurred. Please retry the " "WS-Management operation at a later time.")); WsmFaultResponse outofmem( response->getRelatesTo(), response->getQueueId(), response->getHttpMethod(), response->getHttpCloseConnect(), response->getOmitXMLProcessingInstruction(), fault); return _encodeWsmFaultResponse(&outofmem); } PEG_METHOD_EXIT(); // Unreachable! return 0; }
// // Invoke Method, used to modify user's password // void UserAuthProvider::invokeMethod( const OperationContext & context, const CIMObjectPath & ref, const CIMName & methodName, const Array<CIMParamValue> & inParams, MethodResultResponseHandler & handler) { PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::invokeMethod"); // // get userName // String user; try { IdentityContainer container = context.get(IdentityContainer::NAME); user= container.getUserName(); } catch (...) { user= String::EMPTY; } // // verify user authorizations // if ( user != String::EMPTY || user != "" ) { _verifyAuthorization(user); } #ifndef PEGASUS_NO_PASSWORDFILE String userName; String password; String newPassword; Array<CIMKeyBinding> kbArray; // Begin processing the request handler.processing(); // Check if the class name is PG_USER if (!ref.getClassName().equal (CLASS_NAME_PG_USER)) { handler.complete(); throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, ref.getClassName().getString()); } // Check if the method name is correct if (!methodName.equal (METHOD_NAME_MODIFY_PASSWORD)) { handler.complete(); PEG_METHOD_EXIT(); //l10n //throw PEGASUS_CIM_EXCEPTION ( //CIM_ERR_FAILED, //"Unsupported method name, " + methodName.getString()); MessageLoaderParms parms("ControlProviders.UserAuthProvider.UNSUPPORTED_METHOD_NAME", "Unsupported method name, $0", methodName.getString()); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,parms); } // Check if all the input parameters are passed. if ( inParams.size() < 2 ) { handler.complete(); PEG_METHOD_EXIT(); //l10n // throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER, // "Input parameters are not valid."); MessageLoaderParms parms("ControlProviders.UserAuthProvider.INPUT_PARAMETERS_NOT_VALID", "Input parameters are not valid."); throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_INVALID_PARAMETER, parms); } try { kbArray = ref.getKeyBindings(); if ( !kbArray.size() ) { PEG_METHOD_EXIT(); //l10n //throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER, // "Unable to find Key Property Username"); MessageLoaderParms parms("ControlProviders.UserAuthProvider.UNABLE_TO_FIND_KEY_PROPERTY_USERNAME", "Unable to find Key Property Username"); throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_INVALID_PARAMETER,parms); } // // Get the user name // if ( kbArray[0].getName() == PROPERTY_NAME_USERNAME ) { userName = kbArray[0].getValue(); } else { PEG_METHOD_EXIT(); MessageLoaderParms parms( "ControlProviders.UserAuthProvider.UNEXPECTED_KEY_PROPERTY", "Unexpected key property"); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER, parms); } // // Get the old and the new password params // for ( Uint32 i=0; i < 2; i++) { // // check the param name // if ( inParams[i].getParameterName() == OLD_PASSWORD ) { inParams[i].getValue().get(password); } if ( inParams[i].getParameterName() == NEW_PASSWORD ) { inParams[i].getValue().get(newPassword); } } // Modify the user's password in User Manager _userManager->modifyUser( userName, password, newPassword); } catch ( const CIMException& ) { handler.complete(); PEG_METHOD_EXIT(); throw; } catch (const Exception& e) { handler.complete(); PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } // Return zero as there is no error Uint32 retCode = 0; handler.deliver(CIMValue(retCode)); // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return; #else PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, ref.getClassName().getString()); #endif }
// // Enumerates all the user names. // void UserAuthProvider::enumerateInstanceNames( const OperationContext & context, const CIMObjectPath & classReference, ObjectPathResponseHandler & handler) { PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::enumerateInstanceNames"); Array<CIMObjectPath> instanceRefs; Array<String> userNames; Array<CIMKeyBinding> keyBindings; CIMKeyBinding kb; String hostName; // // get userName // String user; try { IdentityContainer container = context.get(IdentityContainer::NAME); user= container.getUserName(); } catch (...) { user= String::EMPTY; } // // verify user authorizations // if ( user != String::EMPTY || user != "" ) { _verifyAuthorization(user); } const CIMName& className = classReference.getClassName(); const CIMNamespaceName& nameSpace = classReference.getNameSpace(); // begin processing the request handler.processing(); #ifndef PEGASUS_NO_PASSWORDFILE // // check if the class name requested is PG_User // if (className.equal (CLASS_NAME_PG_USER)) { try { hostName.assign(System::getHostName()); _userManager->getAllUserNames(userNames); Uint32 size = userNames.size(); for (Uint32 i = 0; i < size; i++) { keyBindings.append(CIMKeyBinding(PROPERTY_NAME_USERNAME, userNames[i], CIMKeyBinding::STRING)); // // Convert instance names to References // CIMObjectPath ref(hostName, nameSpace, className, keyBindings); handler.deliver(ref); keyBindings.clear(); } } catch( const CIMException& ) { handler.complete(); PEG_METHOD_EXIT(); throw; } catch(const Exception& e) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } } // // check if the class name requested is PG_Authorization // else if (className.equal (CLASS_NAME_PG_AUTHORIZATION)) #else if (className.equal (CLASS_NAME_PG_AUTHORIZATION)) #endif { try { // // call enumerateInstanceNames of the repository // instanceRefs = _repository->enumerateInstanceNames( nameSpace, className); handler.deliver(instanceRefs); } catch ( CIMException &e ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } } else { handler.complete(); PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, className.getString()); } // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return; }
// // Enumerates instances. // void UserAuthProvider::enumerateInstances( const OperationContext & context, const CIMObjectPath & ref, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList& propertyList, InstanceResponseHandler & handler) { PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::enumerateInstances"); Array<CIMInstance> instanceArray; Array<CIMInstance> namedInstances; // // get userName // String user; try { IdentityContainer container = context.get(IdentityContainer::NAME); user= container.getUserName(); } catch (...) { user= String::EMPTY; } // // verify user authorizations // if ( user != String::EMPTY || user != "" ) { _verifyAuthorization(user); } // // check if the class name requested is PG_Authorization // if (!ref.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION)) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, ref.getClassName().getString()); } // begin processing the request handler.processing(); try { // // call enumerateInstances of the repository // namedInstances = _repository->enumerateInstances( ref.getNameSpace(), ref.getClassName()); } catch(Exception& e) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } for(Uint32 i = 0, n = namedInstances.size(); i < n; i++) { handler.deliver(namedInstances[i]); } // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return; }
/** The shutdown method to be called by the ShutdownProvider to process a shutdown request from the cimcli client. */ void ShutdownService::shutdown( Boolean force, Uint32 timeout, Boolean requestPending) { PEG_METHOD_ENTER(TRC_SHUTDOWN, "ShutdownService::shutdown"); _shutdownTimeout = timeout; try { // // set CIMServer state to TERMINATING // _cimserver->setState(CIMServerState::TERMINATING); PEG_TRACE_CSTRING( TRC_SHUTDOWN, Tracer::LEVEL4, "ShutdownService::shutdown - CIM server state set to " "CIMServerState::TERMINATING"); // // Tell the CIMServer to stop accepting new client connection requests. // _cimserver->stopClientConnection(); PEG_TRACE_CSTRING( TRC_SHUTDOWN, Tracer::LEVEL3, "ShutdownService::shutdown - No longer accepting new client " "connection requests."); // // Determine if there are any outstanding CIM operation requests // (take into account that one of the request is the shutdown request). // Boolean noMoreRequests = waitUntilNoMoreRequests(requestPending); PEG_TRACE(( TRC_SHUTDOWN, Tracer::LEVEL4, "ShutdownService::shutdown - All outstanding CIM operations " "complete = %s", (noMoreRequests) ? "true" : "false")); // // Send a shutdown signal to the CIMServer. CIMServer itself will take // care of shutting down the CimomServices and deleting them. In other // words, _DO_ _NOT_ call 'shutdownCimomServices' from a provider. // _cimserver->shutdown(); PEG_TRACE_CSTRING(TRC_SHUTDOWN, Tracer::LEVEL3, "ShutdownService::shutdown - CIMServer instructed to shut down."); } catch (Exception& e) { PEG_TRACE((TRC_SHUTDOWN, Tracer::LEVEL2, "Error occurred during CIMServer shutdown: %s", (const char*)e.getMessage().getCString())); } catch (...) { PEG_TRACE_CSTRING(TRC_SHUTDOWN, Tracer::LEVEL2, "Unexpected error occurred during CIMServer shutdown. "); } PEG_METHOD_EXIT(); }
void CMPI_Wql2Dnf::_buildEvalHeap(const WQLSelectStatement * wqs) { PEG_METHOD_ENTER( TRC_CMPIPROVIDERINTERFACE, "CMPI_Wql2Dnf::_buildEvalHeap()"); //WQLSelectStatement* that = (WQLSelectStatement*)wqs; WQLSelectStatementRep* wqsrep = wqs->_rep; WQLOperand dummy; dummy.clear(); Stack<CMPI_stack_el> stack; // Counter for Operands Uint32 j = 0; //cerr << "Build eval heap\n"; for( Uint32 i = 0, n = wqsrep->_operations.size(); i < n; i++ ) { WQLOperation op = wqsrep->_operations[i]; switch( op ) { case WQL_OR: case WQL_AND: { PEGASUS_ASSERT(stack.size() >= 2); CMPI_stack_el op1 = stack.top(); stack.pop(); CMPI_stack_el op2 = stack.top(); // generate Eval expression eval_heap.append(CMPI_eval_el( 0, op , op1.opn, op1.is_terminal,op2.opn , op2.is_terminal)); stack.top() = CMPI_stack_el(eval_heap.size()-1, false); break; } case WQL_NOT: case WQL_IS_FALSE: case WQL_IS_NOT_TRUE: { PEGASUS_ASSERT(stack.size() >= 1); CMPI_stack_el op1 = stack.top(); // generate Eval expression eval_heap.append(CMPI_eval_el( 0, op , op1.opn, op1.is_terminal,-1, true)); stack.top() = CMPI_stack_el(eval_heap.size()-1, false); break; } case WQL_EQ: case WQL_NE: case WQL_LT: case WQL_LE: case WQL_GT: case WQL_GE: { PEGASUS_ASSERT(wqsrep->_operands.size() >= 2); WQLOperand lhs = wqsrep->_operands[j++]; WQLOperand rhs = wqsrep->_operands[j++]; terminal_heap.push(term_el_WQL(false, op, lhs, rhs)); stack.push(CMPI_stack_el(terminal_heap.size()-1, true)); break; } case WQL_IS_TRUE: case WQL_IS_NOT_FALSE: { PEGASUS_ASSERT(stack.size() >= 1); break; } case WQL_IS_NULL: { PEGASUS_ASSERT(wqsrep->_operands.size() >= 1); WQLOperand operand = wqsrep->_operands[j++]; terminal_heap.push( term_el_WQL(false, WQL_EQ, operand, dummy)); stack.push(CMPI_stack_el(terminal_heap.size()-1, true)); break; } case WQL_IS_NOT_NULL: { PEGASUS_ASSERT(wqsrep->_operands.size() >= 1); WQLOperand operand = wqsrep->_operands[j++]; terminal_heap.push( term_el_WQL(false, WQL_NE, operand, dummy)); stack.push(CMPI_stack_el(terminal_heap.size()-1, true)); break; } } } PEGASUS_ASSERT(stack.size() == 1); PEG_METHOD_EXIT(); }
void ShutdownService::shutdownProviders() { PEG_METHOD_ENTER(TRC_SHUTDOWN, "ShutdownService::shutdownProviders"); // // get provider manager service // MessageQueue* queue = MessageQueue::lookup(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP); if (queue == 0) { PEG_METHOD_EXIT(); return; } MessageQueueService* _service = dynamic_cast<MessageQueueService*>(queue); PEGASUS_ASSERT(_service != 0); Uint32 _queueId = _service->getQueueId(); // // create stop all providers request // CIMStopAllProvidersRequestMessage* stopRequest = new CIMStopAllProvidersRequestMessage( XmlWriter::getNextMessageId(), QueueIdStack(_queueId)); // // create async request message // AsyncLegacyOperationStart* asyncRequest = new AsyncLegacyOperationStart( NULL, _queueId, stopRequest); // Use SendWait, which is serialized and waits. Do not use asynchronous // callback as the response might be received _after_ the provider or // this service has been deleted. AsyncReply* asyncReply = _controller->ClientSendWait(_queueId, asyncRequest); CIMStopAllProvidersResponseMessage* response = reinterpret_cast<CIMStopAllProvidersResponseMessage*>( (static_cast<AsyncLegacyOperationResult*>(asyncReply))->get_result()); if (response->cimException.getCode() != CIM_ERR_SUCCESS) { Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, MessageLoaderParms( "Server.ShutdownService.CIM_PROVIDER_SHUTDOWN", "$0 - CIM provider shutdown exception has occurred.", "ShutdownService::shutdownProviders")); CIMException e = response->cimException; delete asyncRequest; delete asyncReply; delete response; PEG_METHOD_EXIT(); throw e; } delete asyncRequest; delete asyncReply; delete response; PEG_METHOD_EXIT(); }
void CMPI_Wql2Dnf::_pushNOTDown() { PEG_METHOD_ENTER( TRC_CMPIPROVIDERINTERFACE, "CMPI_Wql2Dnf::_pushNOTDown()"); for( int i=eval_heap.size()-1; i >= 0; i-- ) { Boolean _found = false; // Order all operators, so that op1 > op2 for non-terminals // and terminals appear as second operand eval_heap[i].order(); // First solve the unary NOT operator if( eval_heap[i].op == WQL_NOT || eval_heap[i].op == WQL_IS_FALSE || eval_heap[i].op == WQL_IS_NOT_TRUE ) { // This serves as the equivalent of an empty operator eval_heap[i].op = WQL_IS_TRUE; // Substitute this expression in all higher order eval statements // so that this node becomes disconnected from the tree for( int j=eval_heap.size()-1; j > i;j-- ) { // Test first operand if( (!eval_heap[j].is_terminal1) && (eval_heap[j].opn1 == i) ) { eval_heap[j].assign_unary_to_first(eval_heap[i]); } // Test second operand if( (!eval_heap[j].is_terminal2) && (eval_heap[j].opn2 == i) ) { eval_heap[j].assign_unary_to_second(eval_heap[i]); } } // Test: Double NOT created by moving down if( eval_heap[i].mark ) { eval_heap[i].mark = false; } else { _found = true; } // else indicate a pending NOT to be pushed down further } // Simple NOT created by moving down if( eval_heap[i].mark ) { // Remove the mark, indicate a pending NOT to be pushed down // further and switch operators (AND / OR) eval_heap[i].mark=false; if( eval_heap[i].op == WQL_OR ) { eval_heap[i].op = WQL_AND; } else { if( eval_heap[i].op == WQL_AND ) { eval_heap[i].op = WQL_OR; } } // NOT operator is already ruled out _found = true; } // Push a pending NOT further down if( _found ) { // First operand int j = eval_heap[i].opn1; if( eval_heap[i].is_terminal1 ) { // Flip NOT mark terminal_heap[j].negate(); } else { eval_heap[j].mark = !(eval_heap[j].mark); } //Second operand (if it exists) if( (j = eval_heap[i].opn2) >= 0 ) { if( eval_heap[i].is_terminal2 ) { // Flip NOT mark terminal_heap[j].negate(); } else { eval_heap[j].mark = !(eval_heap[j].mark); } } } } PEG_METHOD_EXIT(); }
Boolean ProviderAgent::_readAndProcessRequest() { PEG_METHOD_ENTER(TRC_PROVIDERAGENT, "ProviderAgent::_readAndProcessRequest"); CIMRequestMessage* request; // // Read the request from CIM Server // CIMMessage* cimMessage; AnonymousPipe::Status readStatus = _pipeFromServer->readMessage(cimMessage); request = dynamic_cast<CIMRequestMessage*>(cimMessage); // Read operation was interrupted if (readStatus == AnonymousPipe::STATUS_INTERRUPT) { PEG_TRACE_CSTRING(TRC_PROVIDERAGENT, Tracer::LEVEL1, "Read operation was interrupted."); PEG_METHOD_EXIT(); return false; } if (readStatus == AnonymousPipe::STATUS_CLOSED) { // The CIM Server connection is closed PEG_TRACE_CSTRING(TRC_PROVIDERAGENT, Tracer::LEVEL2, "CIMServer connection closed. Exiting."); _terminating = true; PEG_METHOD_EXIT(); return false; } if (readStatus == AnonymousPipe::STATUS_ERROR) { PEG_TRACE_CSTRING(TRC_PROVIDERAGENT, Tracer::LEVEL1, "Error reading from pipe. Exiting."); Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::WARNING, MessageLoaderParms( "ProviderManager.ProviderAgent.ProviderAgent." "CIMSERVER_COMMUNICATION_FAILED", "cimprovagt \"$0\" communication with CIM Server failed. " "Exiting.", _agentId)); _terminating = true; PEG_METHOD_EXIT(); return false; } // The message was not a request message. if (request == 0) { // The message was not empty. if (0 != cimMessage ) { // The message was not a "wake up" message. if (cimMessage->getType() == PROVAGT_GET_SCMOCLASS_RESPONSE_MESSAGE) { PEG_TRACE_CSTRING(TRC_PROVIDERAGENT, Tracer::LEVEL3, "Processing a SCMOClassResponseMessage."); AutoPtr<ProvAgtGetScmoClassResponseMessage> response( dynamic_cast<ProvAgtGetScmoClassResponseMessage*> (cimMessage)); PEGASUS_DEBUG_ASSERT(response.get()); _processGetSCMOClassResponse(response.get()); // The provider agent is still busy. PEG_METHOD_EXIT(); return true; } } // A "wake up" message means we should unload idle providers PEG_TRACE_CSTRING(TRC_PROVIDERAGENT, Tracer::LEVEL4, "Got a wake up message."); if (!_providerManagerRouter.hasActiveProviders()) { // No active providers, so do not start an idle unload thread return false; } try { _unloadIdleProviders(); } catch (...) { // Ignore exceptions from idle provider unloading PEG_TRACE_CSTRING(TRC_PROVIDERAGENT, Tracer::LEVEL2, "Ignoring exception from _unloadIdleProviders()"); } PEG_METHOD_EXIT(); return false; } PEG_TRACE((TRC_PROVIDERAGENT, Tracer::LEVEL3, "Received request from server with messageId %s", (const char*)request->messageId.getCString())); const AcceptLanguageListContainer acceptLang = request->operationContext.get(AcceptLanguageListContainer::NAME); Thread::setLanguages(acceptLang.getLanguages()); // Get the ProviderIdContainer to complete the provider module instance // optimization. If the provider module instance is blank (optimized // out), fill it in from our cache. If it is not blank, update our // cache. (See the _providerModuleCache member description.) if (request->operationContext.contains(ProviderIdContainer::NAME)) { ProviderIdContainer pidc = request->operationContext.get( ProviderIdContainer::NAME); if (pidc.getModule().isUninitialized()) { // Provider module is optimized out. Fill it in from the cache. request->operationContext.set(ProviderIdContainer( _providerModuleCache, pidc.getProvider(), pidc.isRemoteNameSpace(), pidc.getRemoteInfo())); } else { // Update the cache with the new provider module instance. _providerModuleCache = pidc.getModule(); } } // // It never should be possible to receive a request other than "initialise" // before the provider agent is in state isInitialised // // Bail out. // if (!_isInitialised && (request->getType() != CIM_INITIALIZE_PROVIDER_AGENT_REQUEST_MESSAGE)) { Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::WARNING, MessageLoaderParms( "ProviderManager.ProviderAgent.ProviderAgent." "PROVIDERAGENT_NOT_INITIALIZED", "cimprovagt \"$0\" was not yet initialized " "prior to receiving a request message. Exiting.", _agentId)); _terminating = true; PEG_METHOD_EXIT(); return false; } // // Check for messages to be handled by the Agent itself. // if (request->getType() == CIM_INITIALIZE_PROVIDER_AGENT_REQUEST_MESSAGE) { // Process the request in this thread AutoPtr<CIMInitializeProviderAgentRequestMessage> ipaRequest( dynamic_cast<CIMInitializeProviderAgentRequestMessage*>(request)); PEGASUS_ASSERT(ipaRequest.get() != 0); ConfigManager::setPegasusHome(ipaRequest->pegasusHome); ConfigManager* configManager = ConfigManager::getInstance(); // Initialize the configuration properties for (Uint32 i = 0; i < ipaRequest->configProperties.size(); i++) { configManager->initCurrentValue( ipaRequest->configProperties[i].first, ipaRequest->configProperties[i].second); } // Set the default resource bundle directory for the MessageLoader MessageLoader::setPegasusMsgHome(ConfigManager::getHomedPath( configManager->getCurrentValue("messageDir"))); // Set the log file directory #if !defined(PEGASUS_USE_SYSLOGS) Logger::setHomeDirectory(ConfigManager::getHomedPath( configManager->getCurrentValue("logdir"))); #endif System::bindVerbose = ipaRequest->bindVerbose; // // Set _subscriptionInitComplete from value in // InitializeProviderAgent request // _providerManagerRouter.setSubscriptionInitComplete (ipaRequest->subscriptionInitComplete); PEG_TRACE_CSTRING(TRC_PROVIDERAGENT, Tracer::LEVEL2, "Processed the agent initialization message."); // Notify the cimserver that the provider agent is initialized. Uint32 messageLength = 0; _pipeToServer->writeBuffer((const char*)&messageLength, sizeof(Uint32)); #if defined(PEGASUS_OS_ZOS) && defined(PEGASUS_ZOS_SECURITY) // prepare and setup the thread-level security environment on z/OS // if security initialization fails startupCheckBPXServer(false); startupCheckMSC(); if (!isZOSSecuritySetup()) { Logger::put_l(Logger::ERROR_LOG, ZOS_SECURITY_NAME, Logger::FATAL, MessageLoaderParms( "ProviderManager.ProviderAgent.ProviderAgent." "UNINITIALIZED_SECURITY_SETUP.PEGASUS_OS_ZOS", "Security environment could not be initialised. " "Assume security fraud. Stopping Provider Agent.")); exit(1); } #endif // provider agent is initialised and ready to go _isInitialised = true; } else if (request->getType() == CIM_NOTIFY_CONFIG_CHANGE_REQUEST_MESSAGE) { // Process the request in this thread AutoPtr<CIMNotifyConfigChangeRequestMessage> notifyRequest( dynamic_cast<CIMNotifyConfigChangeRequestMessage*>(request)); PEGASUS_ASSERT(notifyRequest.get() != 0); // // Update the ConfigManager with the new property value // ConfigManager* configManager = ConfigManager::getInstance(); CIMException responseException; try { if (notifyRequest->currentValueModified) { String userName = ((IdentityContainer) request->operationContext.get( IdentityContainer::NAME)).getUserName(); configManager->updateCurrentValue( notifyRequest->propertyName, notifyRequest->newPropertyValue, userName, 0, false); } else { configManager->updatePlannedValue( notifyRequest->propertyName, notifyRequest->newPropertyValue, true); } } catch (Exception& e) { responseException = PEGASUS_CIM_EXCEPTION( CIM_ERR_FAILED, e.getMessage()); } AutoPtr<CIMResponseMessage> response(notifyRequest->buildResponse()); response->cimException = responseException; // Return response to CIM Server _writeResponse(response.get()); } else if ((request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE) || (request->getType() == CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE)) { // Process the request in this thread AutoPtr<Message> response(_processRequest(request)); _writeResponse(response.get()); CIMResponseMessage * respMsg = dynamic_cast<CIMResponseMessage*>(response.get()); // If StopAllProviders, terminate the agent process. // If DisableModule not successful, leave agent process running. if ((request->getType() == CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE) || ((request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE) && (!dynamic_cast<CIMDisableModuleRequestMessage*>(request)-> disableProviderOnly) && (respMsg->cimException.getCode() == CIM_ERR_SUCCESS))) { // Operation is successful. End the agent process. _providersStopped = true; _terminating = true; } delete request; } else if (request->getType () == CIM_SUBSCRIPTION_INIT_COMPLETE_REQUEST_MESSAGE || request->getType () == CIM_INDICATION_SERVICE_DISABLED_REQUEST_MESSAGE) { // // Process the request in this thread // AutoPtr <Message> response (_processRequest (request)); _writeResponse (response.get ()); // // Note: the response does not contain interesting data // delete request; } else { // Start a new thread to process the request ProviderAgentRequest* agentRequest = new ProviderAgentRequest(this, request); ThreadStatus rtn = PEGASUS_THREAD_OK; while ((rtn = _threadPool.allocate_and_awaken(agentRequest, ProviderAgent::_processRequestAndWriteResponse)) != PEGASUS_THREAD_OK) { if (rtn == PEGASUS_THREAD_INSUFFICIENT_RESOURCES) { Threads::yield(); } else { PEG_TRACE_CSTRING(TRC_PROVIDERAGENT, Tracer::LEVEL1, "Could not allocate thread to process agent request."); AutoPtr<CIMResponseMessage> response(request->buildResponse()); response->cimException = PEGASUS_CIM_EXCEPTION_L( CIM_ERR_FAILED, MessageLoaderParms( "ProviderManager.ProviderAgent.ProviderAgent." "THREAD_ALLOCATION_FAILED", "Failed to allocate a thread in cimprovagt \"$0\".", _agentId)); // Return response to CIM Server _writeResponse(response.get()); delete agentRequest; delete request; break; } } } PEG_METHOD_EXIT(); return true; }
void CMPI_Wql2Dnf::_factoring(void) { PEG_METHOD_ENTER(TRC_CMPIPROVIDERINTERFACE, "CMPI_Wql2Dnf::_factoring()"); int i = 0,n = eval_heap.size(); //for (int i=eval_heap.size()-1; i >= 0; i--) while( i < n ) { int _found = 0; int index = 0; // look for expressions (A | B) & C ---> A & C | A & B if( eval_heap[i].op == WQL_AND ) { if( !eval_heap[i].is_terminal1 ) { index = eval_heap[i].opn1; // remember the index if( eval_heap[index].op == WQL_OR ) { _found = 1; } } if( (_found == 0) && (!eval_heap[i].is_terminal2) ) { index = eval_heap[i].opn2; // remember the index if( eval_heap[index].op == WQL_OR ) { _found = 2; } } if( _found != 0 ) { //int u1,u1_t,u2,u2_t,u3,u3_t; CMPI_stack_el s; if( _found == 1 ) { s = eval_heap[i].getSecond(); } else { s = eval_heap[i].getFirst(); } // insert two new expression before entry i CMPI_eval_el evl; evl = CMPI_eval_el(false, WQL_OR, i+1, false, i, false); if( (Uint32 )i < eval_heap.size()-1 ) { eval_heap.insert(i+1, evl); } else { eval_heap.append(evl); } eval_heap.insert(i+1, evl); for( int j=eval_heap.size()-1; j > i + 2; j-- ) { //eval_heap[j] = eval_heap[j-2]; // adjust pointers if( (!eval_heap[j].is_terminal1)&& (eval_heap[j].opn1 >= i) ) { eval_heap[j].opn1 += 2; } if( (!eval_heap[j].is_terminal2)&& (eval_heap[j].opn2 >= i) ) { eval_heap[j].opn2 += 2; } } n+=2; // increase size of array // generate the new expressions : new OR expression // first new AND expression eval_heap[i+1].mark = false; eval_heap[i+1].op = WQL_AND; eval_heap[i+1].setFirst(s); eval_heap[i+1].setSecond( eval_heap[index].getFirst()); eval_heap[i+1].order(); // second new AND expression eval_heap[i].mark = false; eval_heap[i].op = WQL_AND; eval_heap[i].setFirst(s); eval_heap[i].setSecond( eval_heap[index].getSecond()); eval_heap[i].order(); // mark the indexed expression as inactive //eval_heap[index].op = WQL_IS_TRUE; possible disconnects i--; } /* endif _found > 0 */ } /* endif found AND operator */ i++; // increase pointer } // end of while loop PEG_METHOD_EXIT(); }
ProviderMessageHandler* DefaultProviderManager::_initProvider( ProviderMessageHandler* provider, const String& moduleFileName) { PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "DefaultProviderManager::_initProvider"); ProviderModule* module = 0; CIMProvider* base; // lookup provider module module = _lookupModule(moduleFileName); // lock the provider status mutex AutoMutex lock(provider->status.getStatusMutex()); if (provider->status.isInitialized()) { // Initialization is already complete return provider; } PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Loading/Linking Provider Module %s", (const char*)moduleFileName.getCString())); // load the provider try { base = module->load(provider->getName()); } catch (...) { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL1, "Exception caught Loading/Linking Provider Module %s", (const char*)moduleFileName.getCString())); PEG_METHOD_EXIT(); throw; } // initialize the provider PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL2, "Initializing Provider %s", (const char*)provider->getName().getCString())); CIMOMHandle* cimomHandle = new CIMOMHandle(); provider->status.setCIMOMHandle(cimomHandle); provider->status.setModule(module); provider->setProvider(base); Boolean initializeError = false; try { provider->initialize(*cimomHandle); } catch (...) { initializeError = true; } // The cleanup code executed when an exception occurs was previously // included in the catch block above. Unloading the provider module // from inside the catch block resulted in a crash when an exception // was thrown from a provider's initialize() method. The issue is that // when an exception is thrown, the program maintains internal // pointers related to the code that threw the exception. In the case // of an exception thrown from a provider during the initialize() // method, those pointers point into the provider library, so when // the DefaultProviderManager unloads the library, the pointers into // the library that the program was holding are invalid. if (initializeError == true) { // Allow the provider to clean up provider->terminate(); // delete the cimom handle delete cimomHandle; provider->setProvider(0); // unload provider module module->unloadModule(); } provider->status.setInitialized(!initializeError); PEG_METHOD_EXIT(); return provider; }
void CMPI_Wql2Dnf::_gather( Array<CMPI_stack_el>& stk, CMPI_stack_el sel, Boolean or_flag) { PEG_METHOD_ENTER(TRC_CMPIPROVIDERINTERFACE, "CMPI_Wql2Dnf::_gather()"); Uint32 i = 0; stk.clear(); stk.reserveCapacity(16); if( (i = eval_heap.size()) == 0 ) { PEG_METHOD_EXIT(); return; } while( eval_heap[i-1].op == WQL_IS_TRUE ) { eval_heap.remove(i-1); i--; if( i == 0 ) { PEG_METHOD_EXIT(); return; } } //if (i == 0) return; if( or_flag ) { stk.append(CMPI_stack_el(i-1,false)); } else { if( sel.is_terminal ) { PEG_METHOD_EXIT(); return; } stk.append(sel); } i = 0; while( i<stk.size() ) { int k = stk[i].opn; if( (k < 0) || (stk[i].is_terminal) ) { i++; } else { if ( ((eval_heap[k].op != WQL_OR) && (or_flag)) || ((eval_heap[k].op != WQL_AND) && (!or_flag)) ) { i++; } else { // replace the element with disjunction stk[i] = eval_heap[k].getSecond(); stk.insert(i, eval_heap[k].getFirst()); if (or_flag) { eval_heap[k].op = WQL_IS_TRUE; } } } } PEG_METHOD_EXIT(); }
Message* DefaultProviderManager::processMessage(Message* message) { PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "DefaultProviderManager::processMessage()"); CIMRequestMessage* request = dynamic_cast<CIMRequestMessage*>(message); PEGASUS_ASSERT(request != 0); CIMResponseMessage* response = 0; try { // pass the request message to a handler method based on message type switch(request->getType()) { case CIM_GET_INSTANCE_REQUEST_MESSAGE: case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE: case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE: case CIM_CREATE_INSTANCE_REQUEST_MESSAGE: case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE: case CIM_DELETE_INSTANCE_REQUEST_MESSAGE: case CIM_EXEC_QUERY_REQUEST_MESSAGE: case CIM_ASSOCIATORS_REQUEST_MESSAGE: case CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE: case CIM_REFERENCES_REQUEST_MESSAGE: case CIM_REFERENCE_NAMES_REQUEST_MESSAGE: case CIM_GET_PROPERTY_REQUEST_MESSAGE: case CIM_SET_PROPERTY_REQUEST_MESSAGE: case CIM_INVOKE_METHOD_REQUEST_MESSAGE: case CIM_CREATE_SUBSCRIPTION_REQUEST_MESSAGE: case CIM_MODIFY_SUBSCRIPTION_REQUEST_MESSAGE: case CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE: case CIM_EXPORT_INDICATION_REQUEST_MESSAGE: { ProviderIdContainer providerId = request->operationContext.get(ProviderIdContainer::NAME); // resolve provider name ProviderName name = _resolveProviderName(providerId); // get cached or load new provider module ProviderOperationCounter poc( _getProvider( name.getPhysicalName(), name.getModuleName(), name.getLogicalName())); response = poc.GetProvider().processMessage(request); break; } case CIM_DISABLE_MODULE_REQUEST_MESSAGE: response = _handleDisableModuleRequest(request); break; case CIM_ENABLE_MODULE_REQUEST_MESSAGE: response = _handleEnableModuleRequest(request); break; case CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE: // tell the provider manager to shutdown all the providers _shutdownAllProviders(); response = request->buildResponse(); break; case CIM_SUBSCRIPTION_INIT_COMPLETE_REQUEST_MESSAGE: response = _handleSubscriptionInitCompleteRequest(request); break; case CIM_INDICATION_SERVICE_DISABLED_REQUEST_MESSAGE: response = _handleIndicationServiceDisabledRequest(request); break; default: PEGASUS_UNREACHABLE(PEGASUS_ASSERT(0);) break; } } catch (CIMException& e) { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL1,"CIMException: %s", (const char*)e.getMessage().getCString())); response = request->buildResponse(); response->cimException = PEGASUS_CIM_EXCEPTION_LANG( e.getContentLanguages(), e.getCode(), e.getMessage()); } catch (Exception& e) { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL1,"Exception: %s", (const char*)e.getMessage().getCString())); response = request->buildResponse(); response->cimException = PEGASUS_CIM_EXCEPTION_LANG( e.getContentLanguages(), CIM_ERR_FAILED, e.getMessage()); } catch (...) { PEG_TRACE_CSTRING(TRC_PROVIDERMANAGER, Tracer::LEVEL1, "Exception: Unknown"); response = request->buildResponse(); response->cimException = PEGASUS_CIM_EXCEPTION( CIM_ERR_FAILED, "Unknown error."); } PEG_METHOD_EXIT(); return response; }
void JMPILocalProviderManager::shutdownAllProviders(void) { PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderManager::shutdownAllProviders"); _provider_ctrl(UNLOAD_ALL_PROVIDERS, (void *)this, (void *)0); PEG_METHOD_EXIT(); }
/***************************************************************************** * * Implementation of AssociationProvider references method * *****************************************************************************/ void InteropProvider::references( const OperationContext & context, const CIMObjectPath & objectName, const CIMName & resultClass, const String & role, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList & propertyList, ObjectResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::references()"); initProvider(); PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4, "%s references. objectName= %s, resultClass= %s role= %s " "includeQualifiers= %s, includeClassOrigin= %s, PropertyList= %s", thisProvider, (const char *)objectName.toString().getCString(), (const char *)resultClass.getString().getCString(), (const char *)role.getCString(), boolToString(includeQualifiers), boolToString(includeClassOrigin), (const char *)propertyListToString(propertyList).getCString())); handler.processing(); String tmpRole = role; String tmpTarget; Uint32 numIterations = 1; // // Makes call to internal references method to get result, supplying the // role parameter, but obviously not setting a resultRole/target parameter. // if (resultClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE)) { if (tmpRole.size() == 0) { tmpRole = String("Antecedent"); tmpTarget = String("Dependent"); numIterations = 2; } } for (Uint32 i = 0; i < numIterations; ++i) { Array<CIMInstance> refs = localReferences( context, objectName, resultClass, tmpRole, tmpTarget); for (Uint32 j = 0, n = refs.size(); j < n; ++j) { refs[j].filter(includeQualifiers, includeClassOrigin, propertyList); handler.deliver((CIMObject)refs[j]); } if (numIterations == 2) { tmpRole = String("Dependent"); tmpTarget = String("Antecedent"); } } handler.complete(); PEG_METHOD_EXIT(); }
Sint32 JMPILocalProviderManager::_provider_ctrl(CTRL code, void *parm, void *ret) { static Uint32 quantum; PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "_provider_ctrl"); Sint32 ccode = 0; CTRL_STRINGS *parms = reinterpret_cast<CTRL_STRINGS *>(parm); switch(code) { case GET_PROVIDER: { PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, "_provider_ctrl::GET_PROVIDER"); String providerName = *(parms->providerName); String moduleFileName = *(parms->fileName); String interfaceName = *(parms->interfaceName); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl: GET_PROVIDER " <<providerName <<PEGASUS_STD(endl)); JMPIProvider::OpProviderHolder* ph = reinterpret_cast< JMPIProvider::OpProviderHolder* >( ret ); JMPIProviderModule *newModule = NULL; JMPIProviderModule *module = NULL; JMPIProvider *newProvider = NULL; JMPIProvider *provider = NULL; ProviderVector base; try { { AutoMutex lock (_providerTableMutex); if (true == _providers.lookup(providerName, provider)) { PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Found JMPIProvider " + providerName + " in JMPIProvider Manager Cache"); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl: Found " <<providerName <<" in JMPIProvider Manager Cache" <<PEGASUS_STD(endl)); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl:" " setting provider to " <<PEGASUS_STD(hex) <<(int)provider <<PEGASUS_STD(dec) <<PEGASUS_STD(endl)); ph->SetProvider(provider); //////////////////////ph->GetProvider().update_idle_timer(); break; } PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Creating JMPIProvider " + providerName ); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl: Creating " <<providerName <<PEGASUS_STD(endl)); if (false == _modules.lookup(moduleFileName, module)) { PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Creating JMPIProvider Module " + moduleFileName ); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl: " "Creating module " <<moduleFileName <<PEGASUS_STD(endl)); newModule = new JMPIProviderModule(moduleFileName, interfaceName); if (0 == newModule) { PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, "new JMPIProviderModule is NULL!"); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl:" " new JMPIProviderModule is NULL!" <<PEGASUS_STD(endl)); throw NullPointer(); } module = newModule; _modules.insert(moduleFileName, module); } else { PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Using Cached JMPIProvider Module " + moduleFileName); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl: " "Using cached " <<moduleFileName <<PEGASUS_STD(endl)); } } PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Loading/Linking JMPIProvider Module " + moduleFileName ); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl:" " Loading/Linking module " <<moduleFileName <<PEGASUS_STD(endl)); try { base = module->load(moduleFileName); } catch(...) { PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Exception caught Loading/Linking" " JMPIProvider Module " + moduleFileName ); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl: " "Exception caught Loading/Linking module " <<moduleFileName <<PEGASUS_STD(endl)); throw; } // create provider module newProvider = new JMPIProvider(providerName, module, &base); if (0 == newProvider) { PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, "new JMPIProvider is NULL!"); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl: " "new JMPIProvider is NULL!" <<PEGASUS_STD(endl)); throw NullPointer(); } provider = newProvider; if (0 == (provider->_cimom_handle = new CIMOMHandle())) { PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, "_cimom_handle is NULL!"); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl:" " _cimom_handle is NULL!" <<PEGASUS_STD(endl)); throw NullPointer(); } provider->_quantum = 0; { AutoMutex lock(provider->_statusMutex); PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, "Loading JMPIProvider " + provider->_name); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl:" " Loading " <<provider->_name <<PEGASUS_STD(endl)); try { provider->initialize(*(provider->_cimom_handle)); } catch(...) { PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Exception caught calling initialize!"); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl:" " Exception caught calling initialize!" <<PEGASUS_STD(endl)); throw UninitializedObjectException(); } } } catch (...) { if (newModule) { _modules.remove(moduleFileName); } delete newModule; if (newProvider) { delete newProvider->_cimom_handle; } delete newProvider; throw; } // provider->update_idle_timer(); _providers.insert(providerName, provider); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl:" "setting provider to " <<PEGASUS_STD(hex) <<(int)provider <<PEGASUS_STD(dec) <<PEGASUS_STD(endl)); ph->SetProvider( provider ); break; } case UNLOAD_PROVIDER: { DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl: " "UNLOAD_PROVIDER" <<PEGASUS_STD(endl)); break; } case LOOKUP_PROVIDER: { PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, "_provider_ctrl::LOOKUP_PROVIDER"); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl: " "LOOKUP_PROVIDER " <<*(parms->providerName) <<PEGASUS_STD(endl)); AutoMutex lock (_providerTableMutex); if (true == _providers.lookup(*(parms->providerName), *(reinterpret_cast<JMPIProvider * *>(ret)))) { PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Found JMPIProvider in cache: " + *(parms->providerName)); ////////////////(*(reinterpret_cast<JMPIProvider * *>(ret)))->update_idle_timer(); } else { PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Could not find JMPIProvider in cache: " + *(parms->providerName)); ccode = -1; } break; } case LOOKUP_MODULE: { PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, "_provider_ctrl::LOOKUP_MODULE"); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl: " "LOOKUP_MODULE " <<*(parms->fileName) <<PEGASUS_STD(endl)); AutoMutex lock (_providerTableMutex); if (false == _modules.lookup(*(parms->fileName), *(reinterpret_cast<JMPIProviderModule * *>(ret)))) { PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Could not find JMPIProvider Module in cache: " + *(parms->fileName)); ccode = -1; } break; } case INSERT_PROVIDER: { PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, "_provider_ctrl::INSERT_PROVIDER"); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl: " "INSERT_PROVIDER " <<*(parms->providerName) <<PEGASUS_STD(endl)); AutoMutex lock (_providerTableMutex); if (false == _providers.insert(*(parms->providerName), *reinterpret_cast<JMPIProvider * *>(parm))) ccode = -1; break; } case INSERT_MODULE: { PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, "_provider_ctrl::INSERT_MODULE"); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl: " "INSERT_MODULE " <<*(parms->fileName) <<PEGASUS_STD(endl)); AutoMutex lock (_providerTableMutex); if(false == _modules.insert(*(parms->fileName), *reinterpret_cast<JMPIProviderModule * *>(parm))) ccode = -1; break; } case REMOVE_PROVIDER: { PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, "_provider_ctrl::REMOVE_PROVIDER"); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl: " "REMOVE_PROVIDER " <<*(parms->providerName) <<PEGASUS_STD(endl)); AutoMutex lock (_providerTableMutex); if (false == _providers.remove(*(parms->providerName))) ccode = -1; break; } case REMOVE_MODULE: { PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, "_provider_ctrl::REMOVE_MODULE"); DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl: REMOVE_MODULE " <<*(parms->fileName) <<PEGASUS_STD(endl)); AutoMutex lock (_providerTableMutex); if (false == _modules.remove(*(parms->fileName))) ccode = -1; break; } case UNLOAD_ALL_PROVIDERS: { DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl: " "UNLOAD_ALL_PROVIDERS" <<PEGASUS_STD(endl)); JMPIjvm::destroyJVM(); break; } case UNLOAD_IDLE_PROVIDERS: { DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl: " "UNLOAD_IDLE_PROVIDERS" <<PEGASUS_STD(endl)); break; } case UNLOAD_IDLE_MODULES: { DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl: " "UNLOAD_IDLE_MODULES" <<PEGASUS_STD(endl)); break; } default: { DDD(PEGASUS_STD(cout) <<"--- JMPILocalProviderManager::_provider_ctrl: unknown! " <<code <<PEGASUS_STD(endl)); ccode = -1; break; } } PEG_METHOD_EXIT(); return(ccode); }
LocalAuthFile::~LocalAuthFile() { PEG_METHOD_ENTER(TRC_AUTHENTICATION, "LocalAuthFile::~LocalAuthFile()"); PEG_METHOD_EXIT(); }
void CIMQualifierList::resolve( DeclContext* declContext, const CIMNamespaceName & nameSpace, CIMScope scope, // Scope of the entity being resolved. Boolean isInstancePart, CIMQualifierList& inheritedQualifiers, Boolean propagateQualifiers) { _keyIndex = PEGASUS_ORDEREDSET_INDEX_UNKNOWN; PEG_METHOD_ENTER(TRC_OBJECTRESOLUTION, "CIMQualifierList::resolve()"); // For each qualifier in the qualifiers array, the following // is checked: // // 1. Whether it is declared (can be obtained from the declContext). // // 2. Whether it has the same type as the declaration. // // 3. Whether the qualifier is valid for the given scope. // // 4. Whether the qualifier can be overriden (the flavor is // ENABLEOVERRIDE on the corresponding reference qualifier). // // 5. Whether the qualifier should be propagated to the subclass. // // If the qualifier should be overriden, then it is injected into the // qualifiers array (from the inheritedQualifiers array). for (Uint32 i = 0, n = _qualifiers.size(); i < n; i++) { CIMQualifier q = _qualifiers[i]; //---------------------------------------------------------------------- // 1. Check to see if it's declared. //---------------------------------------------------------------------- // set this back to CIMConstQualifierDecl CIMQualifierDecl qd = declContext->lookupQualifierDecl( nameSpace, q.getName()); if (qd.isUninitialized()) { PEG_METHOD_EXIT(); throw UndeclaredQualifier(q.getName().getString ()); } //---------------------------------------------------------------------- // 2. Check the type and isArray. Must be the same: //---------------------------------------------------------------------- if (!(q.getType() == qd.getType() && q.isArray() == qd.isArray())) { PEG_METHOD_EXIT(); throw BadQualifierType(q.getName().getString ()); } //---------------------------------------------------------------------- // 3. If the qualifier is the EmbeddedInstance qualifier, then check // that the class specified by the qualifier exists in the namespace. //---------------------------------------------------------------------- if (q.getName().equal(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE)) { String className; q.getValue().get(className); CIMClass classDef = declContext->lookupClass(nameSpace, CIMName(className)); if (classDef.isUninitialized()) { String embeddedInstType("EmbeddedInstance(\""); embeddedInstType = embeddedInstType + className + "\")"; PEG_METHOD_EXIT(); throw BadQualifierType(embeddedInstType); } } //---------------------------------------------------------------------- // 4. Check the scope: Must be legal for this qualifier //---------------------------------------------------------------------- // ATTN: These lines throw a bogus exception if the qualifier has // a valid scope (such as Scope::ASSOCIATION) which is not Scope::CLASS // ks Mar 2002. Reinstalled 23 March 2002 to test. if (!(qd.getScope().hasScope (scope))) { PEG_METHOD_EXIT(); throw BadQualifierScope (qd.getName().getString (), scope.toString ()); } //---------------------------------------------------------------------- // Resolve the qualifierflavor. Since Flavors are a combination of // inheritance and input characteristics, resolve the inherited // characteristics against those provided with the creation. If // there is a superclass the flavor is resolved against that // superclass. If not, it is resolved against the declaration. If // the flavor is disableoverride and tosubclass the resolved // qualifier value must be identical to the original //---------------------------------------------------------------------- // Test for Qualifier found in SuperClass. If found and qualifier // is not overridable. // Abstract (not Overridable and restricted) can be found in subclasses // Can have nonabstracts below abstracts. That is function of // nottosubclass Association (notOverridable and tosubclass) can be // found in subclasses but cannot be changed. No non-associatons below // associations. In other words once a class becomes an association, // no subclass can override that definition apparently // Throw exception if DisableOverride and tosubclass and different // value. Gets the source from superclass if qualifier exists or from // declaraction. // If we do not throw the exception, resolve the flavor from the // inheritance point and resolve against current input. // Diableoverride is defined in the CIM Spec to mean that the value // cannot change. // The other characteristics including the flavor can change // apparently. Thus, we need only confirm that the value is the same // (2.2 pp 33). Strange since we would think that override implies // that you cannot override any of the characteristics (value, type, // flavor, etc.) This also leaves the question of NULL or no values. // The implication is that we must move the value from the superclass // or declaration. Uint32 index = inheritedQualifiers.find(q.getName()); if (index == PEG_NOT_FOUND) { // Qualifier does not exist in superclass /* If from declaration, we can override the default value. However, we need some way to get the value if we have a Null. if (!qd.getFlavor().hasFlavor(CIMFlavor::OVERRIDABLE) && qd.getFlavor().hasFlavor(CIMFlavor::TOSUBCLASS)) { //throw BadQualifierOverride(q.getName()); } */ // Do not allow change from disable override to enable override. if ((!qd.getFlavor ().hasFlavor(CIMFlavor::OVERRIDABLE)) && (q.getFlavor ().hasFlavor(CIMFlavor::OVERRIDABLE))) { PEG_METHOD_EXIT(); throw BadQualifierOverride(q.getName().getString ()); } Resolver::resolveQualifierFlavor( q, CIMFlavor (qd.getFlavor ()), false); } else // qualifier exists in superclass { ////// Make Const again CIMQualifier iq = inheritedQualifiers.getQualifier(index); // don't allow change override to notoverride. if (!(iq.getFlavor ().hasFlavor(CIMFlavor::OVERRIDABLE)) && q.getFlavor ().hasFlavor (CIMFlavor::OVERRIDABLE)) { PEG_METHOD_EXIT(); throw BadQualifierOverride(q.getName().getString ()); } if (!(iq.getFlavor ().hasFlavor(CIMFlavor::OVERRIDABLE)) && iq.getFlavor ().hasFlavor(CIMFlavor::TOSUBCLASS)) { // test if values the same. CIMValue qv = q.getValue(); CIMValue iqv = iq.getValue(); if (!(qv == iqv)) { PEG_METHOD_EXIT(); throw BadQualifierOverride(q.getName().getString()); } } Resolver::resolveQualifierFlavor( q, CIMFlavor(iq.getFlavor()), true); } } // end of this objects qualifier loop //-------------------------------------------------------------------------- // Propagate qualifiers to subclass or to instance that do not have // already have those qualifiers: //-------------------------------------------------------------------------- if (propagateQualifiers) { for (Uint32 i = 0, n = inheritedQualifiers.getCount(); i < n; i++) { CIMQualifier iq = inheritedQualifiers.getQualifier(i); if (isInstancePart) { if (!(iq.getFlavor().hasFlavor(CIMFlavor::TOINSTANCE))) continue; } else { if (!(iq.getFlavor().hasFlavor(CIMFlavor::TOSUBCLASS))) continue; } // If the qualifiers list does not already contain this qualifier, // then propagate it (and set the propagated flag to true). Else // we keep current value. Note we have already eliminated any // possibility that a nonoverridable qualifier can be in the list. if (find(iq.getName()) != PEG_NOT_FOUND) continue; CIMQualifier q = iq.clone(); q.setPropagated(true); _qualifiers.insert(0, q); } } PEG_METHOD_EXIT(); }
Boolean BasicAuthenticationHandler::authenticate( const String& authHeader, AuthenticationInfo* authInfo) { PEG_METHOD_ENTER( TRC_AUTHENTICATION, "BasicAuthenticationHandler::authenticate()"); Boolean authenticated = false; // // copy userPass string to char array for decoding // Array<char> userPassArray; Uint32 length = authHeader.size(); userPassArray.reserveCapacity( length ); userPassArray.clear(); for( Uint32 i = 0; i < length; i++ ) { userPassArray.append( static_cast<char>(authHeader[i]) ); } // // base64 decode the userPass array // Array<char> decodedArray; decodedArray = Base64::decode( userPassArray ); String decodedStr = String( (const char*)decodedArray.getData(), decodedArray.size() ); Uint32 pos = decodedStr.find(':'); if (pos == PEG_NOT_FOUND) { PEG_METHOD_EXIT(); return (authenticated); } String userName = decodedStr.subString(0, pos); String password = decodedStr.subString(pos + 1); #ifdef PEGASUS_OS_OS400 // OS400 APIs require user profile to be uppercase for(int i=0; i < userName.size(); i++) { userName[i] = toupper(userName[i]); } #endif #ifdef PEGASUS_WMIMAPPER authenticated = true; authInfo->setAuthenticatedUser(userName); authInfo->setAuthenticatedPassword(password); #else authenticated = _basicAuthenticator->authenticate(userName, password); if (authenticated) { authInfo->setAuthenticatedUser(userName); } #endif PEG_METHOD_EXIT(); return (authenticated); }
// // Deletes the specified instance. // void UserAuthProvider::deleteInstance( const OperationContext & context, const CIMObjectPath& myInstance, ResponseHandler & handler) { CIMValue userName ; String userNameStr; String namespaceStr; Array<CIMKeyBinding> kbArray; PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::deleteInstance"); // // get userName // String user; try { IdentityContainer container = context.get(IdentityContainer::NAME); user= container.getUserName(); } catch (...) { user= String::EMPTY; } // // verify user authorizations // if ( user != String::EMPTY || user != "" ) { _verifyAuthorization(user); } // begin processing the request handler.processing(); #ifndef PEGASUS_NO_PASSWORDFILE // // check if the class name requested is PG_User // if (myInstance.getClassName().equal (CLASS_NAME_PG_USER)) { // // Get the user name from the instance // try { kbArray = myInstance.getKeyBindings(); if ( ! kbArray.size() ) { //l10n //throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER, //"Unable to find Key Property Username"); MessageLoaderParms parms("ControlProviders.UserAuthProvider.UNABLE_TO_FIND_KEY_PROPERTY_USERNAME", "Unable to find Key Property Username"); throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_INVALID_PARAMETER,parms); } if ( kbArray[0].getName() == PROPERTY_NAME_USERNAME ) { userNameStr = kbArray[0].getValue(); } else { //l10n //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, //"Unexpected Key property"); MessageLoaderParms parms("ControlProviders.UserAuthProvider.UNEXPECTED_KEY_PROPERTY", "Unexpected Key property"); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,parms); } // // Remove the user from User Manager // _userManager->removeUser(userNameStr); } catch ( const CIMException & ) { handler.complete(); PEG_METHOD_EXIT(); throw; } catch ( const Exception &e ) { handler.complete(); PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } } // // check if the class name requested is PG_Authorization // else if (myInstance.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION)) #else if (myInstance.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION)) #endif { try { // // Get the user name and namespace from the instance // kbArray = myInstance.getKeyBindings(); for (Uint32 i = 0; i < kbArray.size(); i++) { if ( kbArray[i].getName() == PROPERTY_NAME_USERNAME ) { userNameStr = kbArray[i].getValue(); } else if ( kbArray[i].getName() == PROPERTY_NAME_NAMESPACE ) { namespaceStr = kbArray[i].getValue(); } } } catch ( CIMException &e ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } if ( !userNameStr.size() ) { PEG_METHOD_EXIT(); //l10n //throw PEGASUS_CIM_EXCEPTION ( //CIM_ERR_INVALID_PARAMETER, //"Username property can not be empty.") ; MessageLoaderParms parms("ControlProviders.UserAuthProvider.USERNAME_PROPERTY_CANNOT_BE_EMPTY", "Username property can not be empty."); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,parms); } else if ( !namespaceStr.size() ) { PEG_METHOD_EXIT(); //l10n //throw PEGASUS_CIM_EXCEPTION ( //CIM_ERR_INVALID_PARAMETER, //"Namespace property can not be empty.") ; MessageLoaderParms parms("ControlProviders.UserAuthProvider.NAMESPACE_PROPERTY_CANNOT_BE_EMPTY", "Namespace property can not be empty."); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,parms); } try { // // ATTN: Note that the following is a hack, because // deleteInstance() in repository does not like // the hostname and namespace included in the CIMObjectPath // passed to it as a parameter. // CIMObjectPath ref("", CIMNamespaceName (), myInstance.getClassName(), myInstance.getKeyBindings()); _repository->deleteInstance( myInstance.getNameSpace(), ref); // // remove authorization in the UserManager // _userManager->removeAuthorization( userNameStr, namespaceStr ); } catch ( CIMException &e ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } } else { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION( CIM_ERR_NOT_FOUND, myInstance.getClassName().getString()); } // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return; }