Пример #1
0
void RUEpProvider::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_ROUTE_USES_ENDPOINT)
    {
        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();
}
/**
    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();
}
Пример #4
0
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();
}
Пример #5
0
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();
}
Пример #6
0
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();
}
Пример #7
0
/*
================================================================================
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
Пример #8
0
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 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();
}
Пример #11
0
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();
}
Пример #12
0
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();
}
Пример #14
0
/*****************************************************************************
 *
 * 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();
}
Пример #15
0
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();
}
Пример #16
0
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();
}
Пример #17
0
void ConfigSettingProvider::enumerateInstanceNames(
    const OperationContext & context,
    const CIMObjectPath & classReference,
    ObjectPathResponseHandler & handler)
    {
        PEG_METHOD_ENTER(TRC_CONFIG,
            "ConfigSettingProvider::enumerateInstanceNames()");

        Array<CIMObjectPath> instanceRefs;
        Array<String>       propertyNames;
        Array<CIMKeyBinding>   keyBindings;
        CIMKeyBinding          kb;
        String              hostName;

        hostName.assign(System::getHostName());

        const CIMName& className = classReference.getClassName();
        const CIMNamespaceName& nameSpace = classReference.getNameSpace();

        if (!className.equal (PG_CONFIG_SETTING))
        {
            PEG_METHOD_EXIT();
            throw PEGASUS_CIM_EXCEPTION( CIM_ERR_NOT_SUPPORTED,
                className.getString());
        }

        // begin processing the request
        handler.processing();

        try
        {
            _configManager->getAllPropertyNames(propertyNames, false);

            Uint32 size = propertyNames.size();

            for (Uint32 i = 0; i < size; i++)
            {
                 keyBindings.append(
                              CIMKeyBinding(PROPERTY_NAME, propertyNames[i],
                              CIMKeyBinding::STRING));

                 //
                 // Convert instance names to References
                 //
                 CIMObjectPath ref(hostName, nameSpace, className,
                                    keyBindings);

                 instanceRefs.append(ref);
                 keyBindings.clear();

            }
        }
        catch(Exception& e)
        {
            PEG_METHOD_EXIT();
            throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
        }

        handler.deliver(instanceRefs);

        // complete processing the request
        handler.complete();

        PEG_METHOD_EXIT();
    }
void LifecycleIndicationProvider::createInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    const CIMInstance & instanceObject,
    ObjectPathResponseHandler & handler)
{
//  cout << "LifecycleIndicationProvider::createInstance()" << endl;
    // Validate the class name
    if(!instanceObject.getClassName().equal(
           "Sample_LifecycleIndicationProviderClass"))
    {
        throw CIMNotSupportedException(
            instanceObject.getClassName().getString());
    }

    // Find the key property
    Uint32 idIndex = instanceObject.findProperty("uniqueId");

    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("uniqueId", 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();

    // If there is at least one subscription active for the lifecycle indication
    // InstCreation_for_Sample_LifecycleIndicationProviderClass, then generate
    // that indication here, embedding the newly-created instance as
    // the SourceInstance property. See LifecycleIndicationProviderR.mof.
    if (_lifecycle_indications_enabled)
    {
        CIMInstance indicationInstance(
            CIMName(
                "InstCreation_for_Sample_LifecycleIndicationProviderClass"));
        CIMObjectPath path;
        path.setNameSpace("root/SampleProvider");
        path.setClassName(
            "InstCreation_for_Sample_LifecycleIndicationProviderClass");
        indicationInstance.setPath(path);

        char buffer[32];
        sprintf(buffer, "%d", _nextUID++);
        indicationInstance.addProperty
            (CIMProperty ("IndicationIdentifier",String(buffer)));

        CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime ();
        indicationInstance.addProperty
            (CIMProperty ("IndicationTime", currentDateTime));

        indicationInstance.addProperty
            (CIMProperty ("SourceInstance",CIMObject(cimInstance)));

        _indication_handler->deliver (indicationInstance);

//      cout << "LifecycleIndicationProvider::createInstance() sent "
//                  "InstCreation_for_Sample_LifecycleIndicationProviderClass"
//           << endl;
    }
}
Пример #19
0
void PG_TestPropertyTypes::createInstance(
    const OperationContext& context,
    const CIMObjectPath& instanceReference,
    const CIMInstance& instanceObject,
    ObjectPathResponseHandler& handler)
{
    // synchronously get references
    Array<CIMObjectPath> references =
        _enumerateInstanceNames(context, instanceReference);

    // ensure the Namespace is valid

    if (!instanceReference.getNameSpace().equal("test/static"))
    {
        throw CIMException(CIM_ERR_INVALID_NAMESPACE);
    }

    // ensure the class existing in the specified namespace
    if (!instanceReference.getClassName().equal("PG_TestPropertyTypes"))
    {
        throw CIMException(CIM_ERR_INVALID_CLASS);
    }

    // ensure the InstanceId key is valid
    Uint32 propIndex = instanceObject.findProperty("InstanceId");
    if (propIndex == PEG_NOT_FOUND)
    {
        throw CIMException(CIM_ERR_INVALID_PARAMETER);
    }

//    Uint32 i;
//    for (i=0; i<keys.size() && keys[i].getName() != "InstanceId"; i++);

//    if (i==keys.size())
//    {
//        throw CIMException(CIM_ERR_INVALID_PARAMETER);
//    }

    // create the CIMObjectPath to return
    Array<CIMKeyBinding> keys;
    keys.append(CIMKeyBinding(
        instanceObject.getProperty(propIndex).getName(),
        instanceObject.getProperty(propIndex).getValue().toString(),
        CIMKeyBinding::NUMERIC));
    keys.append(CIMKeyBinding(
        "CreationClassName",
        "PG_TestPropertyTypes",
        CIMKeyBinding::STRING));
    CIMObjectPath returnReference(
        String::EMPTY,
        CIMNamespaceName(),
        instanceReference.getClassName(),
        keys);

    // ensure the property values are valid
    _testPropertyTypesValue(instanceObject);

    // Determine if a property exists in the class
    if (instanceObject.findProperty("PropertyUint8") == PEG_NOT_FOUND)
    {
        throw CIMException(CIM_ERR_INVALID_PARAMETER);
    }

    // ensure the requested object do not exist
    if (findObjectPath(references, instanceReference) != PEG_NOT_FOUND)
    {
        throw CIMException(CIM_ERR_ALREADY_EXISTS);
    }

    // begin processing the request
    handler.processing();

    handler.deliver(returnReference);

    // complete processing request
    handler.complete();
}
Пример #20
0
void NamespaceProvider::createInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    const CIMInstance& myInstance,
    ObjectPathResponseHandler & handler)
{
    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "NamespaceProvider::createInstance()");

    CIMNamespaceName childNamespaceName;
    CIMNamespaceName newNamespaceName;
    Boolean isRelativeName;

    // Verify that the className = __namespace
    if (!myInstance.getClassName().equal(NAMESPACE_CLASSNAME))
    {
        PEG_METHOD_EXIT();
        //l10n
        //throw CIMNotSupportedException(myInstance.getClassName().getString()
        //+ " not supported by Namespace Provider");
        throw CIMNotSupportedException(MessageLoaderParms(
                                           "ControlProviders.NamespaceProvider.NamespaceProvider.NOT_SUPPORTED_BY_NAMESPACEPROVIDER",
                                           "$0 not supported by Namespace Provider",
                                           myInstance.getClassName().getString()));

    }

    //ATTN-DME-P3-20020522: ADD AUTHORIZATION CHECK TO __NAMESPACE PROVIDER
    String userName;
    try
    {
        IdentityContainer container = context.get(IdentityContainer::NAME);
        userName = container.getUserName();
    }
    catch (...)
    {
        userName = String::EMPTY;
    }

    _getKeyValue(myInstance, childNamespaceName, isRelativeName);
    CIMNamespaceName parentNamespaceName = instanceReference.getNameSpace();

    PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
                     "childNamespaceName = " + childNamespaceName.getString() +
                     ", isRelativeName = " +
                     (isRelativeName?String("true"):String("false")) +
                     ", parentNamespaceName = " + parentNamespaceName.getString());

    // begin processing the request
    handler.processing();

    try
    {
        Array<CIMNamespaceName> namespaceNames;
        namespaceNames = _repository->enumerateNameSpaces();

        _generateFullNamespaceName(namespaceNames, parentNamespaceName,
                                   childNamespaceName, isRelativeName,
                                   newNamespaceName);

        _repository->createNameSpace(newNamespaceName);

        PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
                         "Namespace = " + newNamespaceName.getString() +
                         " successfully created.");

    }
    catch(const CIMException&)
    {
        PEG_METHOD_EXIT();
        throw;
    }
    catch(const Exception&)
    {
        PEG_METHOD_EXIT();
        throw;
    }

    // return key (i.e., CIMObjectPath) for newly created namespace

    Array<CIMKeyBinding> keyBindings;
    keyBindings.append(CIMKeyBinding(NAMESPACE_PROPERTYNAME,
                                     isRelativeName?childNamespaceName.getString():
                                     parentNamespaceName.getString(),
                                     CIMKeyBinding::STRING));
    CIMObjectPath newInstanceReference (String::EMPTY, parentNamespaceName,
                                        NAMESPACE_CLASSNAME, keyBindings);
    handler.deliver(newInstanceReference);

    // complete processing the request
    handler.complete();

    PEG_METHOD_EXIT();
    return;
}
Пример #21
0
void NamespaceProvider::enumerateInstanceNames(
    const OperationContext & context,
    const CIMObjectPath & classReference,
    ObjectPathResponseHandler & handler)
{

    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
                     "NamespaceProvider::enumerateInstanceNames()");


    // Verify that ClassName == __Namespace
    if (!classReference.getClassName().equal(NAMESPACE_CLASSNAME))
    {
        PEG_METHOD_EXIT();
        //l10n
        //throw CIMNotSupportedException
        //(classReference.getClassName().getString() +
        //" not supported by Namespace Provider");
        throw CIMNotSupportedException(MessageLoaderParms(
                                           "ControlProviders.NamespaceProvider.NamespaceProvider.NOT_SUPPORTED_BY_NAMESPACEPROVIDER",
                                           "$0 not supported by Namespace Provider",
                                           classReference.getClassName().getString()));
    }

    //ATTN-DME-P3-20020522: ADD AUTHORIZATION CHECK TO __NAMESPACE PROVIDER
    String userName;
    try
    {
        IdentityContainer container = context.get(IdentityContainer::NAME);
        userName = container.getUserName();
    }
    catch (...)
    {
        userName = String::EMPTY;
    }

    CIMNamespaceName parentNamespaceName = classReference.getNameSpace();
    PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
                     "parentNamespaceName = " + parentNamespaceName.getString());

    Array<CIMObjectPath> instanceRefs;

    try
    {
        Array<CIMNamespaceName> namespaceNames =
            _repository->enumerateNameSpaces();
        Array<CIMKeyBinding> keyBindings;

        // Build the instances. For now simply build the __Namespace instances
        // Note that for the moment, the only property is name.
        for (Uint32 i = 0; i < namespaceNames.size(); i++)
        {
            if (_isChild(parentNamespaceName, namespaceNames[i]))
            {
                keyBindings.clear();
                keyBindings.append(CIMKeyBinding(NAMESPACE_PROPERTYNAME,
                                                 namespaceNames[i].getString().subString
                                                 (parentNamespaceName.getString().size()+1,
                                                  namespaceNames[i].getString().size()-
                                                  parentNamespaceName.getString().size()-1),
                                                 CIMKeyBinding::STRING));
                CIMObjectPath ref(String::EMPTY, parentNamespaceName,
                                  NAMESPACE_CLASSNAME, keyBindings);
                instanceRefs.append(ref);
                PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
                                 "childNamespace = " + namespaceNames[i].getString());
            }
        }
    }
    catch(const CIMException&)
    {
        PEG_METHOD_EXIT();
        throw;
    }
    catch(const Exception&)
    {
        PEG_METHOD_EXIT();
        throw;
    }

    handler.deliver(instanceRefs);

    handler.complete();

    PEG_METHOD_EXIT();
}
Пример #22
0
//
// 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();
}
Пример #24
0
//
// 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;
}