Esempio n. 1
0
void _generateFullNamespaceName(
    Array<CIMNamespaceName>& namespaceNames,
    CIMNamespaceName& parentNamespaceName,
    CIMNamespaceName& childNamespaceName,
    Boolean isRelativeName,
    CIMNamespaceName& fullNamespaceName)

{
    // If isRelativeName is true, then the parentNamespace
    // MUST exist
    //
    if (isRelativeName)
    {
        if (!Contains(namespaceNames, parentNamespaceName))
        {
            //l10n
            //throw CIMObjectNotFoundException("Parent namespace does not exist: "
            //+ parentNamespaceName.getString());
            throw CIMObjectNotFoundException(MessageLoaderParms(
                                                 "ControlProviders.NamespaceProvider.NamespaceProvider.PARENT_NAMESPACE_DOES_NOT_EXIST",
                                                 "Parent namespace does not exist: $0",
                                                 parentNamespaceName.getString()));
        }
        // Create full namespace name by prepending parentNamespaceName
        fullNamespaceName = CIMNamespaceName (parentNamespaceName.getString()
                                              + "/" + childNamespaceName.getString());
    }
    else
    {
        fullNamespaceName = parentNamespaceName;
    }

}
Esempio n. 2
0
Boolean _isChild(
    CIMNamespaceName& parentNamespaceName,
    CIMNamespaceName& namespaceName)

{
    String parent = parentNamespaceName.getString();
    String child = namespaceName.getString();
    //
    //  If length of namespace name is shorter than or equal to the
    //  length of parent namespace name, cannot be a child
    //
    if (child.size () <= parent.size ())
    {
        return false;
    }

    //
    //  Compare prefix substring of namespace name with parent namespace name
    //
    else if (String::equalNoCase (child.subString (0, parent.size ()), parent))
    {
        return true;
    }
    return false;
}
Esempio n. 3
0
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();
}
Esempio n. 4
0
SCMOClass ProviderAgent::_scmoClassCache_GetClass(
    const CIMNamespaceName& nameSpace,
    const CIMName& className)
{

    PEG_METHOD_ENTER(TRC_PROVIDERAGENT,
        "ProviderAgent::_scmoClassCache_GetClass");

    // create message
    ProvAgtGetScmoClassRequestMessage* message =
        new ProvAgtGetScmoClassRequestMessage(
        XmlWriter::getNextMessageId(),
        nameSpace,
        className,
        QueueIdStack());

    // Send the request for the SCMOClass to the server
    _providerAgent->_writeResponse(message);

    delete message;

    // Wait for semaphore signaled by _readAndProcessRequest()
    if (!_scmoClassDelivered.time_wait(
            PEGASUS_DEFAULT_CLIENT_TIMEOUT_MILLISECONDS))
    {
        PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1,
            "Timed-out waiting for SCMOClass for "
                    "Name Space Name '%s' Class Name '%s'",
                (const char*)nameSpace.getString().getCString(),
                (const char*)className.getString().getCString()));
        PEG_METHOD_EXIT();
        return SCMOClass("","");
    }

    if ( 0 == _transferSCMOClass)
    {
        PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1,
            "No SCMOClass received for Name Space Name '%s' Class Name '%s'",
                (const char*)nameSpace.getString().getCString(),
                (const char*)className.getString().getCString()));
        PEG_METHOD_EXIT();
        return SCMOClass("","");
    }

    // Create a local copy.
    SCMOClass ret = SCMOClass(*_transferSCMOClass);

    // Delete the transferred instance.
    delete _transferSCMOClass;
    _transferSCMOClass = 0;

    PEG_METHOD_EXIT();
    return ret;

}
Esempio n. 5
0
void CompareClasses(
    CIMRepository& r1,
    CIMRepository& r2,
    const CIMNamespaceName& namespaceName)
{
    Array<CIMName> classNames1 = r1.enumerateClassNames(namespaceName);
    Array<CIMName> classNames2 = r2.enumerateClassNames(namespaceName);
    BubbleSort(classNames1);
    BubbleSort(classNames2);


    PEGASUS_TEST_ASSERT(classNames1 == classNames2);

    for (Uint32 i = 0; i < classNames1.size(); i++)
    {
    CIMClass class1 = r1.getClass(namespaceName, classNames1[i]);
    CIMClass class2 = r2.getClass(namespaceName, classNames2[i]);

    if (verbose)
    {
        cout << "testing class " << namespaceName.getString() << "/";
        cout << classNames1[i].getString() << "..." << endl;
    }

    if (!class1.identical(class2))
    {
        PutClass("file1", class1);
        PutClass("file2", class2);

        cout << "=========================================================";
        cout << "=========================================================";
        cout << endl;
        cout << "ERROR: not identical! - ";


        cout << "ERROR FOUND testing class: " << namespaceName.getString();
        cout << "/";
        cout << classNames1[i].getString();

        cout << " .... differences follow:" << endl << endl;

        if (system("diff file1 file2") == -1)
        {
            cout << "Error:  system(\"diff file1 file2\") failed." << endl;
        }

        if (verbose)
        {
            XmlWriter::printClassElement(class1, cout);
            XmlWriter::printClassElement(class2, cout);
        }
        failures++;
    }
    }
}
Esempio n. 6
0
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();
}
Esempio n. 7
0
void DefaultInstanceProvider::deleteInstance(
	const OperationContext & context,
	const CIMObjectPath & instanceReference,
	ResponseHandler & 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()); 
        }

	// convert a potential fully qualified reference into a local reference
	// (class name and keys only).
	CIMObjectPath localReference = CIMObjectPath(
		String(),
		String(),
		instanceReference.getClassName(),
		instanceReference.getKeyBindings());
	
	// begin processing the request
	handler.processing();

        try
        {
           _repository->deleteInstance(nameSpace, localReference);
        }
        catch (Exception & ex)
        {
            const String msg = "delete Instance failed. " + ex.getMessage();
            throw CIMOperationFailedException( msg );
        }

	// complete processing the request
	handler.complete();
}
Esempio n. 8
0
void AuditLogger::logUpdateInstanceOperation(
    const char* cimMethodName,
    AuditEvent eventType,
    const String& userName,
    const String& ipAddr,
    const CIMNamespaceName& nameSpace,
    const CIMObjectPath& instanceName,
    const String& moduleName,
    const String& providerName,
    CIMStatusCode statusCode)
{
    // check if SMF is gathering this type of records.
    if (_smf.isRecording(CIM_OPERATION) ||
        (! _isInternalWriterUsed) )
    {
        String cimInstanceName =
            CIMObjectPath("", CIMNamespaceName(), instanceName.getClassName(),
            instanceName.getKeyBindings()).toString();

        _writeCIMOperationRecord(
            INSTANCE_OPERATION, userName, statusCode,
            ipAddr, cimMethodName, cimInstanceName,
            nameSpace.getString(), providerName, moduleName );
    }
}
//
//  Create subscription to receive indications of the RT_TestIndication
//  class and have them sent to the SimpleDisplayConsumer
//  The SimpleDisplayConsumer logs received indications to the 
//  indicationLog file
//
void _subscribe
    (CIMClient & client)
{
    //
    //  Create filter
    //
    CIMObjectPath filterPath = _createFilter 
       (client, 
        "TestFilter",
        "SELECT MethodName FROM RT_TestIndication",
        "WQL",
         SOURCENAMESPACE.getString ());

    //
    //  Create handler
    //
    CIMObjectPath handlerPath = _createHandler 
       (client,
        "TestHandler",
        "localhost/CIMListener/Pegasus_SimpleDisplayConsumer");

    //
    //  Create subscription to receive indications of the RT_TestIndication
    //  class and have them sent to the SimpleDisplayConsumer
    //  The SimpleDisplayConsumer logs received indications to the 
    //  indicationLog file
    //
    CIMObjectPath subscriptionPath = _createSubscription 
       (client,
        filterPath, 
        handlerPath);
}
Esempio n. 10
0
PEGASUS_NAMESPACE_END

void CompareQualifiers(
    CIMRepository& r1,
    CIMRepository& r2,
    const CIMNamespaceName& namespaceName)
{
    Array<CIMQualifierDecl> quals1 = r1.enumerateQualifiers(namespaceName);
    Array<CIMQualifierDecl> quals2 = r2.enumerateQualifiers(namespaceName);
    PEGASUS_TEST_ASSERT(quals1.size() == quals2.size());

    BubbleSort(quals1);
    BubbleSort(quals2);

    for (Uint32 i = 0; i < quals2.size(); i++)
    {
        if (verbose)
        {
            cout << "testing qualifier " << namespaceName.getString() << "/";
            cout << quals1[i].getName().getString() << "/ against /";
            cout << quals2[i].getName().getString() << "/" << endl;
        }

        PEGASUS_TEST_ASSERT(quals1[i].identical(quals2[i]));
    }
}
Esempio n. 11
0
void _getKeyValue (
    const CIMObjectPath&  instanceName,
    CIMNamespaceName& childNamespaceName,
    Boolean& isRelativeName)

{

    Array<CIMKeyBinding> kbArray = instanceName.getKeyBindings();
    if ((kbArray.size() == 1) &&
            (kbArray[0].getName() == NAMESPACE_PROPERTYNAME))
    {
        String childNamespaceString = kbArray[0].getValue();

        if (childNamespaceString != String::EMPTY)
        {
            childNamespaceName = childNamespaceString;
        }

        isRelativeName = !(childNamespaceName.isNull());
    }
    else
    {
        //l10n
        //throw CIMInvalidParameterException("Invalid key property:  ");
        throw CIMInvalidParameterException(MessageLoaderParms(
                                               "ControlProviders.NamespaceProvider.NamespaceProvider.INVALID_KEY_PROPERTY",
                                               "Invalid key property:  "));
    }
}
Esempio n. 12
0
void tests::_displayTimes(Uint32 objCount,
    Uint32 objSize,
    Uint64 elapsed,
    Uint64 providerTime,
    ClientOpPerformanceData& perfData)
{
    if (first)
    {
        printf("Request : %s:%s\n",
               (const char *)testNamespaceName.getString().getCString(),
               (const char *)testClass.getString().getCString());
        if (!perfData.serverTimeKnown)
        {
            cout << "WARNING: Server data may not be valid" << endl;
        }
        printf(
"Op ClientTime   ProvTime RndTrpTime SvrTime ReqSize   RespSize ObjSize  ObjCnt"
"\n"
"           us         us         us      us   bytes      bytes   bytes\n");
        first = false;
    }

    printf("%2u%11lu%11lu%11lu%8lu%8lu%11lu%8u%8u\n",
           perfData.operationType,
           (long unsigned int) elapsed,
           (long unsigned int) providerTime,
           (long unsigned int)perfData.roundTripTime,
           (long unsigned int)perfData.serverTime,
           (long unsigned int) perfData.requestSize,
           (long unsigned int) perfData.responseSize,
           objSize,
           objCount);
}
Esempio n. 13
0
void AuthorizationHandler::removeAuthorization(
    const String& userName,
    const CIMNamespaceName& nameSpace)
{
    PEG_METHOD_ENTER(
        TRC_AUTHORIZATION, "AuthorizationHandler::removeAuthorization()");

    //
    // Remove the specified authorization
    //
    if (!_authTable.remove(userName + nameSpace.getString()))
    {
        PEG_METHOD_EXIT();
        throw AuthorizationEntryNotFound(userName, nameSpace.getString());
    }
    PEG_METHOD_EXIT();
}
Esempio n. 14
0
Array<CIMObject> WMIClientRep::associators(
    const CIMNamespaceName& nameSpace,
    const CIMObjectPath& objectName,
    const CIMName& assocClass,
    const CIMName& resultClass,
    const String& role,
    const String& resultRole,
    Boolean includeQualifiers,
    Boolean includeClassOrigin,
    const CIMPropertyList& propertyList)
{
	Array<CIMObject> cimObjects;
	CIMPropertyList myPropertyList(propertyList);
	CIMException cimException;
	
	try
	{
		//Initializes the WMI Provider Interface
    	WMIAssociatorProvider provider;
		provider.initialize(TRUE);

		//Performs the WMI call
		cimObjects = provider.associators(
			nameSpace.getString(),
			String::EMPTY,
			String::EMPTY,
			objectName,
			assocClass.getString(),
			resultClass.getString(),
			role,
			resultRole,
			includeQualifiers,
			includeClassOrigin,
			myPropertyList);

		//terminate the provider
		provider.terminate();
	}
	catch(CIMException&)
	{
		throw;
	}
	catch(Exception& exception)
	{
	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());
	   throw cimException;
	}
	catch(...)
	{
		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "associators() failed!");
		throw cimException;
	}

	return(cimObjects);
}
Esempio n. 15
0
SCMOClass CIMServer::_scmoClassCache_GetClass(
    const CIMNamespaceName& nameSpace,
    const CIMName& className)
{
    CIMClass cc;

    PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::_scmoClassCache_GetClass()");
    try
    {
        cc = _cimserver->_repository->getClass(
            nameSpace,
            className,
            false, // localOnly
            true, // includeQualifiers
            true, // includeClassOrigin
            CIMPropertyList());
    }
    catch (Exception& e)
    {
        PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL2,
                   "The class '%s' in the name space '%s' was not found. "
                       "The repository throws the following exception: %s",
                   (const char*)className.getString().getCString(),
                   (const char*)nameSpace.getString().getCString(),
                   (const char*)e.getMessage().getCString()));
        // Return a empty class.
        PEG_METHOD_EXIT();
        return SCMOClass("","");
    }

    if (cc.isUninitialized())
    {
        // The requested class was not found !
        // Return a empty class.
        PEG_METHOD_EXIT();
        return SCMOClass("","");
    }
    PEG_METHOD_EXIT();
    return SCMOClass(cc,(const char*)nameSpace.getString().getCString());

}
Esempio n. 16
0
inline String DynamicRoutingTable::_getRoutingKey(
    const CIMName& className,
    const CIMNamespaceName& namespaceName) const
{
    //ATTN: We don't support wild class names.
    PEGASUS_ASSERT(!className.isNull());
    String key(namespaceName.getString());
    key.append(Char16(':'));
    key.append(className.getString());

    return key;
}
Esempio n. 17
0
//
// Check if a given namespace exists
//
Boolean AuthorizationHandler::verifyNamespace(
    const CIMNamespaceName& nameSpace)
{
    PEG_METHOD_ENTER(
        TRC_AUTHORIZATION, "AuthorizationHandler::verifyNamespace()");

    try
    {
        //
        // call enumerateNameSpaces to get all the namespaces
        // in the repository
        //
        Array<CIMNamespaceName> namespaceNames =
            _repository->enumerateNameSpaces();

        //
        // check for the given namespace
        //
        Uint32 size = namespaceNames.size();

        for (Uint32 i = 0; i < size; i++)
        {
             if (nameSpace.equal (namespaceNames[i]))
             {
                 PEG_METHOD_EXIT();
                 return true;
             }
        }
    }
    catch (Exception& e)
    {
        PEG_METHOD_EXIT();
        throw InvalidNamespace(nameSpace.getString() + e.getMessage());
    }

    PEG_METHOD_EXIT();

    return false;
}
Esempio n. 18
0
String AuthorizationHandler::getAuthorization(
    const String& userName,
    const CIMNamespaceName& nameSpace)
{
    PEG_METHOD_ENTER(
        TRC_AUTHORIZATION, "AuthorizationHandler::getAuthorization()");

    String auth;

    //
    // Get authorization for the specified userName and nameSpace
    //
    if (!_authTable.lookup(userName + nameSpace.getString(), auth))
    {
        PEG_METHOD_EXIT();
        throw AuthorizationEntryNotFound(userName, nameSpace.getString());
    }

    PEG_METHOD_EXIT();

    return auth;
}
Esempio n. 19
0
//
//  Valid test cases: create, get, enumerate, modify, delete operations
//
void
_addFilter (CIMClient & client, String & filter, String & query,
	    String & qlang)
{
  CIMObjectPath path;
  CIMInstance retrievedInstance;

  //
  // IBMKR:
  //
  CIMInstance filter01 (PEGASUS_CLASSNAME_INDFILTER);
  _addStringProperty (filter01, "SystemCreationClassName",
		      System::getSystemCreationClassName ());
  _addStringProperty (filter01, "SystemName",
		      System::getFullyQualifiedHostName ());
  _addStringProperty (filter01, "CreationClassName",
		      PEGASUS_CLASSNAME_INDFILTER.getString ());
  _addStringProperty (filter01, "Name", filter);
  _addStringProperty (filter01, "SourceNamespace",
		      SOURCENAMESPACE.getString ());
  _addStringProperty (filter01, "Query", query);
  _addStringProperty (filter01, "QueryLanguage", qlang);
  path = client.createInstance (NAMESPACE, filter01);

  _checkFilterOrHandlerPath (path, PEGASUS_CLASSNAME_INDFILTER, filter);
  retrievedInstance = client.getInstance (NAMESPACE, path);
  _checkStringProperty (retrievedInstance, "SystemCreationClassName",
			System::getSystemCreationClassName ());
  _checkStringProperty (retrievedInstance, "SystemName",
			System::getFullyQualifiedHostName ());
  _checkStringProperty (retrievedInstance, "CreationClassName",
			PEGASUS_CLASSNAME_INDFILTER.getString ());
  _checkStringProperty (retrievedInstance, "Name", filter);
  _checkStringProperty (retrievedInstance, "SourceNamespace",
			SOURCENAMESPACE.getString ());
  _checkStringProperty (retrievedInstance, "Query", query);
  _checkStringProperty (retrievedInstance, "QueryLanguage", qlang);

}
Esempio n. 20
0
Array<CIMInstance> WMIClientRep::enumerateInstances(
    const CIMNamespaceName& nameSpace,
    const CIMName& className,
    Boolean deepInheritance,
    Boolean localOnly,
    Boolean includeQualifiers,
    Boolean includeClassOrigin,
    const CIMPropertyList& propertyList)
{
    Array<CIMInstance> cimInstances;
	CIMPropertyList myPropertyList(propertyList);
	CIMException cimException;

	try
	{
		//Initializes the WMI Provider Interface
    	WMIInstanceProvider provider;
		provider.initialize(TRUE);

		//Performs the WMI call
		cimInstances = provider.enumerateInstances(
			nameSpace.getString(),
			String::EMPTY,
			String::EMPTY,
			className.getString(),
			deepInheritance,
			localOnly,
			includeQualifiers,
			includeClassOrigin,
			myPropertyList);

		//terminate the provider
		provider.terminate();
	}
	catch(CIMException&)
	{
		throw;
	}
	catch(Exception& exception)
	{
	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());
	   throw cimException;
	}
	catch(...)
	{
		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "enumerateInstances() failed!");
		throw cimException;
	}

	return(cimInstances);
}
Esempio n. 21
0
void _getKeyValue (
    const CIMInstance& namespaceInstance,
    CIMNamespaceName& childNamespaceName,
    Boolean& isRelativeName)

{
    //Validate key property

    Uint32 pos;
    CIMValue propertyValue;

    // [Key, MaxLen (256), Description (
    //       "A string that uniquely identifies the Namespace "
    //       "within the ObjectManager.") ]
    // string Name;

    pos = namespaceInstance.findProperty(NAMESPACE_PROPERTYNAME);
    if (pos == PEG_NOT_FOUND)
    {
        throw CIMPropertyNotFoundException
        (NAMESPACE_PROPERTYNAME.getString());
    }

    propertyValue = namespaceInstance.getProperty(pos).getValue();
    if (propertyValue.getType() != CIMTYPE_STRING)
    {
        //l10n
        //throw CIMInvalidParameterException("Invalid type for property: "
        //+ NAMESPACE_PROPERTYNAME.getString());
        throw CIMInvalidParameterException(MessageLoaderParms(
                                               "ControlProviders.NamespaceProvider.NamespaceProvider.INVALID_TYPE_FOR_PROPERTY",
                                               "Invalid type for property: $0",
                                               NAMESPACE_PROPERTYNAME.getString()));
    }

    String cnsName;
    propertyValue.get(cnsName);
    if (cnsName == String::EMPTY)
    {
        childNamespaceName = CIMNamespaceName();
    }
    else
    {
        childNamespaceName = CIMNamespaceName(cnsName);
    }

    isRelativeName = !(childNamespaceName.isNull());

}
Esempio n. 22
0
CIMClass WMIClientRep::getClass(
    const CIMNamespaceName& nameSpace,
    const CIMName& className,
    Boolean localOnly,
    Boolean includeQualifiers,
    Boolean includeClassOrigin,
    const CIMPropertyList& propertyList)
{
    CIMClass cimClass;
	CIMException cimException;
	
	try
	{
		//Initializes the WMI Provider Interface
   		WMIClassProvider provider;
		provider.initialize(TRUE);
		
		//Performs the WMI call
		cimClass = provider.getClass(
			nameSpace.getString(),
			String::EMPTY,
			String::EMPTY,
			className.getString(),
			localOnly,
			includeQualifiers,
			includeClassOrigin,
			propertyList);

		//terminate the provider
		provider.terminate();

	}
	catch(CIMException&)
	{
		throw;
	}
	catch(Exception& exception)
	{
	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());
	   throw cimException;
	}
	catch(...)
	{
		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "getClass() failed!");
		throw cimException;
	}

	return(cimClass);
}
Esempio n. 23
0
void AuthorizationHandler::setAuthorization(
    const String& userName,
    const CIMNamespaceName& nameSpace,
    const String& auth)
{
    PEG_METHOD_ENTER(
        TRC_AUTHORIZATION, "AuthorizationHandler::setAuthorization()");

    //
    // Remove auth if it already exists
    //
    _authTable.remove(userName + nameSpace.getString());

    //
    // Insert the specified authorization
    //
    if (!_authTable.insert(userName + nameSpace.getString(), auth))
    {
        PEG_METHOD_EXIT();
        throw AuthorizationCacheError();
    }

    PEG_METHOD_EXIT();
}
Esempio n. 24
0
Array<CIMObjectPath> WMIClientRep::associatorNames(
    const CIMNamespaceName& nameSpace,
    const CIMObjectPath& objectName,
    const CIMName& assocClass,
    const CIMName& resultClass,
    const String& role,
    const String& resultRole)
{
	Array<CIMObjectPath> objectNames;
	CIMException cimException;
	
	try
	{
		//Initializes the WMI Provider Interface
    	WMIAssociatorProvider provider;
		provider.initialize(TRUE);

		//Performs the WMI call
		objectNames = provider.associatorNames(
			nameSpace.getString(),
			String::EMPTY,
			String::EMPTY,
			objectName,
			assocClass.getString(),
			resultClass.getString(),
			role,
			resultRole);

		//terminate the provider
		provider.terminate();
	}
	catch(CIMException&)
	{
		throw;
	}
	catch(Exception& exception)
	{
	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());
	   throw cimException;
	}
	catch(...)
	{
		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "associatorNames() failed!");
		throw cimException;
	}

	return(objectNames);
}
Esempio n. 25
0
CIMValue WMIClientRep::invokeMethod(
    const CIMNamespaceName& nameSpace,
    const CIMObjectPath& instanceName,
    const CIMName& methodName,
    const Array<CIMParamValue>& inParameters,
    Array<CIMParamValue>& outParameters)
{
    CIMValue retValue;
	CIMException cimException;

	try
	{
		//Initializes the WMI Provider Interface
    	WMIMethodProvider provider;
		provider.initialize(TRUE);

		//Performs the WMI call
		retValue = provider.invokeMethod(
			nameSpace.getString(),
			String::EMPTY,
			String::EMPTY,
			instanceName,
			methodName.getString(),
			inParameters,
			outParameters);

		//terminate the provider
		provider.terminate();
	}
	catch(CIMException&)
	{
		throw;
	}
	catch(Exception& exception)
	{
	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());
	   throw cimException;
	}
	catch(...)
	{
		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "invokeMethod() failed!");
		throw cimException;
	}

	return(retValue);
}
Esempio n. 26
0
void AuditLogger::logUpdateQualifierOperation(
    const char* cimMethodName,
    AuditEvent eventType,
    const String& userName,
    const String& ipAddr,
    const CIMNamespaceName& nameSpace,
    const CIMName& className,
    CIMStatusCode statusCode)
{
    // check if SMF is gathering this type of records.
    if (_smf.isRecording(CIM_OPERATION) ||
        (! _isInternalWriterUsed) )
    {
        _writeCIMOperationRecord(
            QUALIFER_OPERATION, userName, statusCode,
            ipAddr, cimMethodName, className.getString(),
            nameSpace.getString(), String::EMPTY, String::EMPTY );
    }
}
Esempio n. 27
0
Array<CIMName> WMIClientRep::enumerateClassNames(
    const CIMNamespaceName& nameSpace,
    const CIMName& className,
    Boolean deepInheritance)
{
    Array<CIMName> classNames;
	CIMException cimException;

	try
	{
		//Initializes the WMI Provider Interface
    	WMIClassProvider provider;
		provider.initialize(TRUE);

		//Performs the WMI call
		classNames = provider.enumerateClassNames(
			nameSpace.getString(),
			String::EMPTY,
			String::EMPTY,
			className.getString(),
			deepInheritance);

		//terminate the provider
		provider.terminate();
	}
	catch(CIMException&)
	{
		throw;
	}
	catch(Exception& exception)
	{
	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());
	   throw cimException;
	}
	catch(...)
	{
		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "enumerateClassNames() failed!");
		throw cimException;
	}

	return(classNames);
}
Esempio n. 28
0
Array<CIMObject> WMIClientRep::execQuery(
    const CIMNamespaceName& nameSpace,
    const String& queryLanguage,
    const String& query)
{
    Array<CIMObject> cimObjects;
	CIMException cimException;
	
	try
	{
		//Initializes the WMI Provider Interface
    	WMIQueryProvider provider;
		provider.initialize(TRUE);

		//Performs the WMI call
		cimObjects = provider.execQuery(
			nameSpace.getString(),
			String::EMPTY,
			String::EMPTY,
			queryLanguage,
			query);

		//terminate the provider
		provider.terminate();
	}
	catch(CIMException&)
	{
		throw;
	}
	catch(Exception& exception)
	{
	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());
	   throw cimException;
	}
	catch(...)
	{
		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "execQuery() failed!");
		throw cimException;
	}

	return(cimObjects);
}
Esempio n. 29
0
void WMIClientRep::setProperty(
    const CIMNamespaceName& nameSpace,
    const CIMObjectPath& instanceName,
    const CIMName& propertyName,
    const CIMValue& newValue
)
{
    CIMException cimException;

	try
	{
		//Initializes the WMI Provider Interface
    	WMIInstanceProvider provider;
		provider.initialize(TRUE);

		//Performs the WMI call
		provider.setProperty(
			nameSpace.getString(),
			String::EMPTY,
			String::EMPTY,
			instanceName,
			propertyName.getString(),
			newValue);

		//terminate the provider
		provider.terminate();
	}
	catch(CIMException&)
	{
		throw;
	}
	catch(Exception& exception)
	{
	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());
	   throw cimException;
	}
	catch(...)
	{
		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "setProperty() failed!");
		throw cimException;
	}
}
Esempio n. 30
0
void CompareQualifiers(
    CIMRepository& r1,
    CIMRepository& r2,
    const CIMNamespaceName& namespaceName)
{
    Array<CIMQualifierDecl> quals1 = r1.enumerateQualifiers(namespaceName);
    Array<CIMQualifierDecl> quals2 = r2.enumerateQualifiers(namespaceName);
    assert(quals1.size() == quals2.size());

    for (size_t i = 0; i < quals2.size(); i++)
    {
	if (verbose)
	{
	    cout << "testing qualifier " << namespaceName.getString() << "/";
	    cout << quals2[i].getName().getString() << "..." << endl;
	}

	assert(quals1[i].identical(quals2[i]));
    }
}