void PG_TestPropertyTypes::enumerateInstanceNames( const OperationContext& context, const CIMObjectPath& classReference, ObjectPathResponseHandler& handler) { // ensure the Namespace is valid if (!classReference.getNameSpace().equal ("test/static")) { throw CIMException(CIM_ERR_INVALID_NAMESPACE); } // ensure the class existing in the specified namespace if (!classReference.getClassName().equal ("PG_TestPropertyTypes")) { throw CIMException(CIM_ERR_INVALID_CLASS); } // begin processing the request handler.processing(); Array<CIMObjectPath> instanceNames; instanceNames = _enumerateInstanceNames(context, classReference); handler.deliver(instanceNames); // complete processing the request handler.complete(); }
void TimingProvider::enumerateInstanceNames( const OperationContext & context, const CIMObjectPath & classReference, ObjectPathResponseHandler & handler) { // begin processing the request handler.processing(); cout <<"TimingProvider::enumerateInstanceNames" << endl; CIMName clName = classReference.getClassName(); sleep(10); if (clName == "TimeOne") { for(Uint32 i = 0, n = _instances.size(); i < n; i++) // deliver reference handler.deliver(_instanceNames[i]); } else if (clName == "TimeTwo") { for(Uint32 i = 0, n = _instances_2.size(); i < n; i++) // deliver reference handler.deliver(_instanceNames_2[i]); } // complete processing the request cout <<"TimingProvider::enumerateInstanceNames" << endl; handler.complete(); }
void ComputerSystemProvider::enumerateInstanceNames( const OperationContext& context, const CIMObjectPath &ref, ObjectPathResponseHandler& handler) { CIMName className = ref.getClassName(); _checkClass(className); handler.processing(); // Deliver instance only if request was for leaf class if (className.equal(CLASS_EXTENDED_COMPUTER_SYSTEM)) { Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding( PROPERTY_CREATION_CLASS_NAME, CLASS_EXTENDED_COMPUTER_SYSTEM, CIMKeyBinding::STRING)); keys.append(CIMKeyBinding( PROPERTY_NAME, _cs.getHostName(), CIMKeyBinding::STRING)); handler.deliver(CIMObjectPath( _cs.getHostName(), ref.getNameSpace(), CLASS_EXTENDED_COMPUTER_SYSTEM, keys)); } handler.complete(); return; }
void ParserTestProvider::enumerateInstanceNames( const OperationContext & context, const CIMObjectPath & classReference, ObjectPathResponseHandler & handler) { //DEBUG("enumerateInstanceNames()"); // begin processing the request CIMName className = classReference.getClassName(); CIMNamespaceName nameSpace = classReference.getNameSpace(); //DEBUG("[className: "<<className<<"], [in namespace: "<<nameSpace<<"]"); handler.processing(); Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding("CName", String(CLASS_NAME), CIMKeyBinding::STRING)); keys.append(CIMKeyBinding("BadStr", String(BADSTR_1), CIMKeyBinding::STRING)); CIMObjectPath obj_path = CIMObjectPath(String(), nameSpace, className, keys); handler.deliver(obj_path); // complete processing the request handler.complete(); }
void benchmarkProvider::enumerateInstanceNames( const OperationContext & context, const CIMObjectPath & classReference, ObjectPathResponseHandler & handler) { CIMObjectPath _instanceName; Uint32 numberOfProperties; Uint32 sizeOfPropertyValue; Uint32 numberOfInstances; CIMName className = classReference.getClassName(); test.getConfiguration(className, numberOfProperties, sizeOfPropertyValue, numberOfInstances); // begin processing the request handler.processing(); for (Uint32 i = 1; i <= numberOfInstances; i++) { _instanceName = _buildObjectPath(className, CIMKeyBinding(CIMName("Identifier"), CIMValue(i))); handler.deliver(_instanceName); } // complete processing the request handler.complete(); }
void OperatingSystemProvider::enumerateInstanceNames( const OperationContext& context, const CIMObjectPath &ref, ObjectPathResponseHandler& handler ) { CIMObjectPath newref; CIMName className; // only return instances when enumerate on our subclass, CIMOM // will call us as natural part of recursing through subtree on // enumerate - if we return instances on enumerate of our superclass, // there would be dups className = ref.getClassName(); if (className.equal (STANDARDOPERATINGSYSTEMCLASS)) { handler.processing(); handler.complete(); return; } else if (!className.equal (EXTENDEDOPERATINGSYSTEMCLASS)) { throw CIMNotSupportedException("OperatingSystemProvider " "does not support class " + className.getString()); } // so we know it is for EXTENDEDOPERATINGSYSTEMCLASS handler.processing(); // in terms of the class we use, want to set to what was requested newref = _fill_reference(ref.getNameSpace(), className); handler.deliver(newref); handler.complete(); return; }
void InstanceProvider::createInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance & instanceObject, ObjectPathResponseHandler & handler) { // Validate the class name if (!instanceObject.getClassName().equal("Sample_InstanceProviderClass")) { throw CIMNotSupportedException( instanceObject.getClassName().getString()); } // Find the key property Uint32 idIndex = instanceObject.findProperty("Identifier"); if (idIndex == PEG_NOT_FOUND) { throw CIMInvalidParameterException("Missing key value"); } CIMInstance cimInstance = instanceObject.clone(); // Create the new instance name CIMValue idValue = instanceObject.getProperty(idIndex).getValue(); Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding("Identifier", idValue)); CIMObjectPath instanceName = CIMObjectPath( String(), CIMNamespaceName(), instanceObject.getClassName(), keys); cimInstance.setPath(instanceName); // Determine whether this instance already exists for(Uint32 i = 0, n = _instances.size(); i < n; i++) { if(instanceName == _instances[i].getPath()) { throw CIMObjectAlreadyExistsException(instanceName.toString()); } } // begin processing the request handler.processing(); // add the new instance to the array _instances.append(cimInstance); // deliver the new instance name handler.deliver(instanceName); // complete processing the request handler.complete(); }
void DefaultInstanceProvider::enumerateInstanceNames( const OperationContext & context, const CIMObjectPath & classReference, ObjectPathResponseHandler & handler) { CIMNamespaceName nameSpace = classReference.getNameSpace(); CIMName className = classReference.getClassName(); // create the namespace if necessary if (!_nameSpaceExists(nameSpace)) { _copyNameSpace(nameSpace.getString(), className.getString()); } // check to see if class already exists // if not, copy the class // try { CIMClass cimClass = _repository->getClass(nameSpace, className); } catch (Exception&) { // class does not exist // // copy the class // _copyClass(nameSpace.getString(), className.getString()); } Array<CIMObjectPath> instanceNames; try { instanceNames = _repository->enumerateInstanceNamesForClass( nameSpace, className, true); } catch (Exception & ex) { const String msg = "Enumerate InstanceNames failed. " + ex.getMessage(); throw CIMOperationFailedException( msg ); } // begin processing the request handler.processing(); for(Uint32 i = 0, n = instanceNames.size(); i < n; i++) { // deliver reference handler.deliver(instanceNames[i]); } // complete processing the request handler.complete(); }
void DefaultInstanceProvider::createInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance & instanceObject, ObjectPathResponseHandler & handler) { CIMNamespaceName nameSpace = instanceReference.getNameSpace(); // get the class name CIMName className = instanceReference.getClassName(); // create the namespace if necessary if (!_nameSpaceExists(nameSpace)) { _copyNameSpace(nameSpace.getString(), className.getString()); } // check to see if class already exists // if not, copy the class // try { CIMClass cimClass = _repository->getClass(nameSpace, className); } catch (Exception&) { // class does not exist // // copy the class // _copyClass(nameSpace.getString(), className.getString()); } CIMObjectPath cimRef; // begin processing the request handler.processing(); try { cimRef = _repository->createInstance(nameSpace, instanceObject); } catch (Exception & ex) { const String msg = "create Instance failed. " + ex.getMessage(); throw CIMOperationFailedException( msg ); } // deliver the new instance handler.deliver(cimRef); // complete processing the request handler.complete(); }
void ANHProvider::referenceNames( const OperationContext& context, const CIMObjectPath& objectName, const CIMName& resultClass, const String& role, ObjectPathResponseHandler& handler) { // validate namespace const CIMNamespaceName& nameSpace = objectName.getNameSpace(); if (!nameSpace.equal(NAMESPACE)) { throw CIMNotSupportedException( nameSpace.getString() + " not supported."); } // Build a host and namespace independent object path CIMObjectPath localObjectPath = CIMObjectPath( String(), CIMNamespaceName(), objectName.getClassName(), objectName.getKeyBindings()); // begin processing the request handler.processing(); // Filter the instances from the list of association instances against // the specified role filter // Array<CIMInstance> resultInstances; if (resultClass == CLASS_PG_ASSOCIATED_NEXT_HOP) { resultInstances = _filterAssociationInstancesByRole( _AssociationInstances, localObjectPath, role); } else { throw CIMNotSupportedException( resultClass.getString() + " is not supported"); } // return the instance names for (Uint32 i = 0, n = resultInstances.size(); i < n; i++) { CIMObjectPath objectPath = resultInstances[i].getPath(); handler.deliver(objectPath); } // complete processing the request handler.complete(); }
/***************************************************************************** * * Implementation of AssociationProvider referenceNames method * *****************************************************************************/ void InteropProvider::referenceNames( const OperationContext & context, const CIMObjectPath & objectName, const CIMName & resultClass, const String & role, ObjectPathResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::referenceNames()"); initProvider(); 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) { handler.deliver(refs[j].getPath()); } if (numIterations == 2) { tmpRole = String("Dependent"); tmpTarget = String("Antecedent"); } } handler.complete(); PEG_METHOD_EXIT(); }
/** Returns the instance names of the errorInstance or indicationInstance stored in this class. */ void EmbeddedInstanceProvider::enumerateInstanceNames( const OperationContext& context, const CIMObjectPath& ref, ObjectPathResponseHandler& handler) { handler.processing(); if (ref.getClassName().equal(CIMName("PG_EmbeddedError"))) { CIMObjectPath errorInstancePath = errorInstance->getPath(); handler.deliver(errorInstancePath); handler.deliver(errorInstancePath); handler.deliver(errorInstancePath); handler.deliver(errorInstancePath); handler.deliver(errorInstancePath); } else if (ref.getClassName().equal(CIMName("PG_InstMethodIndication"))) { CIMObjectPath indicationInstancePath = indicationInstance->getPath(); handler.deliver(indicationInstancePath); handler.deliver(indicationInstancePath); handler.deliver(indicationInstancePath); handler.deliver(indicationInstancePath); handler.deliver(indicationInstancePath); } handler.complete(); }
void ANHProvider::_associatorNames( const Array<CIMInstance>& associationInstances, const CIMObjectPath& localReference, const String& role, const CIMName& resultClass, const String& resultRole, ObjectPathResponseHandler& handler) { // Filter the instances from the list of association instances against // the specified role filter // Array<CIMInstance> assocInstances; assocInstances= _filterAssociationInstancesByRole(associationInstances, localReference, role); // Now filter the result association instances against the specified // resultClass and resultRole filters // for (Uint32 i = 0, n = assocInstances.size(); i < n; i++) { Array<CIMObjectPath> resultPaths; resultPaths = _filterAssociationInstances(assocInstances[i], localReference, resultClass, resultRole); for (Uint32 j = 0, m = resultPaths.size(); j < m; j++) { handler.deliver(resultPaths[j]); } } }
void InstanceProvider::enumerateInstanceNames( const OperationContext & context, const CIMObjectPath & classReference, ObjectPathResponseHandler & handler) { // begin processing the request handler.processing(); for(Uint32 i = 0, n = _instances.size(); i < n; i++) { // deliver reference handler.deliver(_instances[i].getPath()); } // complete processing the request handler.complete(); }
void ANHProvider::associatorNames( const OperationContext& context, const CIMObjectPath& objectName, const CIMName& associationClass, const CIMName& resultClass, const String& role, const String& resultRole, ObjectPathResponseHandler& handler) { // validate namespace const CIMNamespaceName& nameSpace = objectName.getNameSpace(); if (!nameSpace.equal(NAMESPACE)) { throw CIMNotSupportedException( nameSpace.getString() + " not supported."); } // Build a host and namespace independent object path CIMObjectPath localObjectPath = CIMObjectPath( String(), CIMNamespaceName(), objectName.getClassName(), objectName.getKeyBindings()); // begin processing the request handler.processing(); if (associationClass == CLASS_PG_ASSOCIATED_NEXT_HOP) { _associatorNames( _AssociationInstances, localObjectPath, role, resultClass, resultRole, handler); } else { throw CIMNotSupportedException( associationClass.getString() + " is not supported"); } // complete processing the request handler.complete(); }
/** Stores a copy of the provided instance locally in the errorInstance class property, and also creates a copy of the instance in the static repository namespace. The instance is then read back out of the repository and compared against the one stored by the class. */ void EmbeddedInstanceProvider::createInstance( const OperationContext& context, const CIMObjectPath& ref, const CIMInstance& obj, ObjectPathResponseHandler& handler) { handler.processing(); errorInstance.reset(new CIMInstance(obj)); Array<CIMName> propNameList; propNameList.append(CIMName("errorKey")); propNameList.append(CIMName("EmbeddedInst")); CIMPropertyList propList(propNameList); CIMClass objClass = cimom.getClass( context, STATIC_REPOSITORY, obj.getClassName(), false, true, false, propList); CIMObjectPath objPath = obj.buildPath(objClass); errorInstance->setPath(objPath); repositoryPath = cimom.createInstance( context, STATIC_REPOSITORY, *errorInstance); CIMInstance repositoryInstance = cimom.getInstance( context, STATIC_REPOSITORY, repositoryPath, false, false, false, propList); repositoryInstance.setPath(repositoryPath); if (!errorInstance->identical(repositoryInstance)) { throw Exception( "Repository instance and local instance for embedded error not " "identical"); } handler.deliver(objPath); handler.complete(); }
void IBM_CIMOMStatDataProvider::enumerateInstanceNames( const OperationContext & context, const CIMObjectPath & classReference, ObjectPathResponseHandler & handler) { // begin processing the request handler.processing(); for(Uint32 i = 0; i < StatisticalData::NUMBER_OF_TYPES; i++) { // deliver reference handler.deliver(_references[i]); } // complete processing the request handler.complete(); }
/* ================================================================================ NAME : enumerateInstanceNames DESCRIPTION : Enumerates all of the IPProtocolEndpoint instance names. : An array of instance references is returned. ASSUMPTIONS : None PRE-CONDITIONS : POST-CONDITIONS : NOTES : Localization is not supported by this provider. PARAMETERS : ================================================================================ */ void BIPTLEpProvider::enumerateInstanceNames(const OperationContext &ctx, const CIMObjectPath &ref, ObjectPathResponseHandler &handler) { #ifdef DEBUG cout << "BIPTLEpProvider::enumerateInstanceNames()" << endl; #endif CIMName className = ref.getClassName(); CIMNamespaceName nameSpace = ref.getNameSpace(); // Validate the classname _checkClass(className); // Notify processing is starting handler.processing(); int i; InterfaceList _ifList; #ifdef DEBUG cout << "BIPTLEpProvider::enumerateInstanceNames() _ifList Initialized" << endl; #endif for (i = 0; i < _ifList.size(); i++) { IPInterface _ipif = _ifList.getInterface(i); if (_ipif.bindsToLANInterface()) { // Deliver the names handler.deliver( CIMObjectPath(String::EMPTY, // hostname nameSpace, CLASS_PG_BINDS_IP_TO_LAN_ENDPOINT, _constructKeyBindings(nameSpace, _ipif) ) ); } } // Notify processing is complete handler.complete(); return; } // enumerateInstanceNames
void LargeDataProvider::enumerateInstanceNames( const OperationContext & context, const CIMObjectPath & classReference, ObjectPathResponseHandler & handler) { cout << "-----------------------------------------" << endl; cout << "LargeDataProvider::enumerateInstanceNames" << endl; cout << "-----------------------------------------" << endl; // begin processing the request handler.processing(); cout << "_instances.size = " << _instances.size() << endl; for(Uint32 i = 0; i < _instances.size(); i++) // deliver references handler.deliver(_instanceNames[i]); // complete processing the request handler.complete(); }
void UNIX_PROVIDER::enumerateInstanceNames(const OperationContext &ctx, const CIMObjectPath &ref, ObjectPathResponseHandler &handler) { int pIndex; CLASS_IMPLEMENTATION _p; CIMName className = ref.getClassName(); CIMNamespaceName nameSpace = ref.getNameSpace(); // Validate the classname _checkClass(className); // Notify processing is starting handler.processing(); // We are only going to respond to enumeration requests on // CLASS_UNIX_PROCESS if (className.equal (_getBaseClassCimName()) || className.equal(_getClassCimName())) { // Get the process information and deliver an ObjectPath for // each process // Note that loadProcessInfo modifies pIndex to point to the // next process structure before the loop increments it! _p.initialize(); for (pIndex = 0; _p.load(pIndex); pIndex++) { // Deliver the names handler.deliver(CIMObjectPath(String(""), // hostname nameSpace, _getClassCimName(), _constructKeyBindings(_p))); } _p.finalize(); } // Notify processing is complete handler.complete(); return; } // enumerateInstanceNames
void LinuxNetworkAdapterProvider::enumerateInstanceNames( const OperationContext& context, const CIMObjectPath& ref, ObjectPathResponseHandler& handler ) { int i; vector<String> adapter_names; NetworkAdapterData *iface; CIMName className; enum network_provider_types classType; className = ref.getClassName(); if (className.equal("Linux_EthernetAdapter")) { classType = NETWORK_ADAPTER_PROVIDER_ETHERNET; } else if (className.equal("Linux_NetworkAdapter")) { classType = NETWORK_ADAPTER_PROVIDER_OTHER; } else { throw CIMNotSupportedException(className.getString() + "::enumerateInstanceNames"); } adapter_names = NetworkAdapterData::list_all_adapters(); handler.processing(); for (i = 0; i < (int) adapter_names.size(); i++) { iface = LocateInterface(adapter_names[i]); if (iface != NULL && interface_is_my_type(classType, iface)) handler.deliver(fill_reference(ref.getNameSpace(), className, iface)); delete iface; } handler.complete(); }
void TestFaultyInstanceProvider::enumerateInstanceNames( const OperationContext& context, const CIMObjectPath& classReference, ObjectPathResponseHandler& handler) { _requestCount.inc(); Uint32 sleepDuration=0; if(_requestCount.get() % 2) { //few requets will respond after cimserver cleanup time. sleepDuration = CIMSERVER_CLEANUP_TIME * 1000 ; } else if(_requestCount.get() % 16) { // respond correctly. } else { //few requests will respond after client connections have timed out //but before cimserver cleanup time. sleepDuration = CONN_TIME_OUT *1000; } handler.processing(); Threads::sleep(sleepDuration); for (Uint32 i = 0, n = _instances.size(); i < n; i++) { try { handler.deliver(_instances[i].getPath()); } catch (CIMException&) { // suppress error } } handler.complete(); }
void LargeDataProvider::createInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance & instanceObject, ObjectPathResponseHandler & handler) { cout << "---------------------------------" << endl; cout << "LargeDataProvider::createInstance" << endl; cout << "---------------------------------" << endl; // convert a potential fully qualified reference into a local reference // (class name and keys only). CIMObjectPath localReference = CIMObjectPath( String(), String(), instanceReference.getClassName(), instanceReference.getKeyBindings()); // instance index corresponds to reference index for(Uint32 i = 0, n = _instanceNames.size(); i < n; i++) { if(localReference == _instanceNames[i]) { throw CIMObjectAlreadyExistsException( localReference.toString()); } } // begin processing the request handler.processing(); // add the new instance to the array _instances.append(instanceObject); _instanceNames.append(instanceReference); // deliver the new instance handler.deliver(_instanceNames[_instanceNames.size() - 1]); // complete processing the request handler.complete(); }
void LifecycleIndicationProvider::enumerateInstanceNames( const OperationContext & context, const CIMObjectPath & classReference, ObjectPathResponseHandler & handler) { // cout << "LifecycleIndicationProvider::enumerateInstanceNames()" << endl; handler.processing(); for(Uint32 i = 0, n = _instances.size(); i < n; i++) { // cout << "delivering " << _instances[i].getPath().toString() << endl; handler.deliver(_instances[i].getPath()); } // Do you consider enumerateInstanceNames() to be the "read" of an instance? // If so, then you might want to generate a lifecycle indication here for // InstRead_for_Sample_LifecycleIndicationProviderClass, for each instance // whose name is returned. See LifecycleIndicationProviderR.mof. handler.complete(); }
/***************************************************************************** * * Implementation of InstanceProvider enumerateInstanceNames method * *****************************************************************************/ void InteropProvider::enumerateInstanceNames( const OperationContext & context, const CIMObjectPath & classReference, ObjectPathResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::enumerateInstanceNames()"); initProvider(); PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4, "%s enumerateInstanceNames. classReference= %s", thisProvider, (const char *) classReference.toString().getCString())); // test for legal namespace for this provider. Exception if not // namespaceSupported(classReference); // NOTE: Above is commented out because the routing tables will always // do the right thing and that's the only way requests get here. // begin processing the request handler.processing(); // Utilize the local enumeration method to retrieve the instances and // extract the instance names. Array<CIMInstance> instances = localEnumerateInstances( context, classReference, CIMPropertyList()); for (Uint32 i = 0 ; i < instances.size() ; i++) { handler.deliver(instances[i].getPath()); } handler.complete(); PEG_METHOD_EXIT(); }
void ExceptionsTest::enumerateInstanceNames( const OperationContext & context, const CIMObjectPath & classReference, ObjectPathResponseHandler & handler) { // begin processing the request handler.processing(); cout <<"Calling Exception ExceptionsTest::enumerateInstanceNames 1" << endl; CheckExceptionType(EXCEPTION_TYPE); CIMName clName = classReference.getClassName(); String className = clName.getString(); if (className == "FirstClass") { for(Uint32 i = 0, n = _instances.size(); i < n; i++) // deliver reference handler.deliver(_instanceNames[i]); } else if (className == "SecondClass") { for(Uint32 i = 0, n = _instances_second.size(); i < n; i++) // deliver reference handler.deliver(_instanceNames_second[i]); } else if (className == "ThirdClass") { for(Uint32 i = 0, n = _instances_third.size(); i < n; i++) // deliver reference handler.deliver(_instanceNames_third[i]); } // complete processing the request cout <<"Calling Exception ExceptionsTest::enumerateInstanceNames 2" << endl; CheckExceptionType(EXCEPTION_TYPE); handler.complete(); }
void LinuxDiskDriveProvider::enumerateInstanceNames( const OperationContext& context, const CIMObjectPath& ref, ObjectPathResponseHandler& handler ) { DiskDriveData diskdriveData; MediaAccessDeviceInformation *curDiskDrive; handler.processing(); curDiskDrive = diskdriveData.GetFirstDiskDrive(); while (curDiskDrive) { handler.deliver(fill_reference(ref.getNameSpace(), DISKDRIVECLASSNAME, curDiskDrive)); delete curDiskDrive; curDiskDrive = diskdriveData.GetNextDiskDrive(); } diskdriveData.EndGetDiskDrive(); handler.complete(); }
// // 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; }
// // Creates a new instance. // void UserAuthProvider::createInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance & myInstance, ObjectPathResponseHandler & handler) { PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::createInstance"); CIMValue userName; CIMValue password; String userNameStr; String passwordStr; String namespaceStr; String authorizationStr; // // get userName // String user; try { const IdentityContainer container = context.get(IdentityContainer::NAME); user= container.getUserName(); } catch (...) { user= String::EMPTY; } // // verify user authorizations // if ( user != String::EMPTY || user != "" ) { _verifyAuthorization(user); } CIMInstance modifiedInst = myInstance; // begin processing the request handler.processing(); #ifndef PEGASUS_NO_PASSWORDFILE // // check if the class name requested is PG_User // if (CLASS_NAME_PG_USER.equal (instanceReference.getClassName())) { try { // // Get the user name from the instance // Uint32 pos = myInstance.findProperty ( PROPERTY_NAME_USERNAME ); CIMProperty prop = (CIMProperty)modifiedInst.getProperty(pos); userName = prop.getValue(); userName.get(userNameStr); // // Get the password from the instance // pos = myInstance.findProperty ( PROPERTY_NAME_PASSWORD ); prop = (CIMProperty) modifiedInst.getProperty(pos); password = prop.getValue(); password.get(passwordStr); // // Add the user to the User Manager // _userManager->addUser( userNameStr, passwordStr); } 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 (instanceReference.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION)) #else if (instanceReference.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION)) #endif { try { // // Get the user name from the instance // Uint32 pos = myInstance.findProperty ( PROPERTY_NAME_USERNAME ); CIMProperty prop = (CIMProperty)modifiedInst.getProperty(pos); prop.getValue().get(userNameStr); // // Get the namespace from the instance // pos = myInstance.findProperty ( PROPERTY_NAME_NAMESPACE ); prop = (CIMProperty)modifiedInst.getProperty(pos); prop.getValue().get(namespaceStr); // // Get the authorization from the instance // pos = myInstance.findProperty ( PROPERTY_NAME_AUTHORIZATION ); prop = (CIMProperty)modifiedInst.getProperty(pos); prop.getValue().get(authorizationStr); // // Check if the user is a valid system user // if ( !System::isSystemUser( userNameStr.getCString() ) ) { InvalidSystemUser isu(userNameStr); throw isu; } #ifndef PEGASUS_NO_PASSWORDFILE // // check if the user is a valid CIM user // if ( !_userManager->verifyCIMUser( userNameStr ) ) { InvalidUser iu(userNameStr); throw iu; } #endif _repository->createInstance( instanceReference.getNameSpace(), myInstance); // // set authorization in the UserManager // _userManager->setAuthorization( userNameStr, namespaceStr, authorizationStr ); } catch ( InvalidUser &iu ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER, iu.getMessage()); } catch ( InvalidSystemUser &isu ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER, isu.getMessage()); } catch ( InvalidNamespace &ins ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER, ins.getMessage()); } catch ( CIMException &e ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } catch ( Exception &e ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } } else { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION ( CIM_ERR_NOT_SUPPORTED, instanceReference.getClassName().getString()); } handler.deliver(instanceReference); // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return; }
/***************************************************************************** * * 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(); }