当前位置: 首页>>代码示例>>C++>>正文


C++ OperationContext::get方法代码示例

本文整理汇总了C++中OperationContext::get方法的典型用法代码示例。如果您正苦于以下问题:C++ OperationContext::get方法的具体用法?C++ OperationContext::get怎么用?C++ OperationContext::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OperationContext的用法示例。


在下文中一共展示了OperationContext::get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: enumerateInstances

//
// Enumerates instances.
//
void UserAuthProvider::enumerateInstances(
    const OperationContext & context,
    const CIMObjectPath & ref,
    const Boolean includeQualifiers,
    const Boolean includeClassOrigin,
    const CIMPropertyList& propertyList,
    InstanceResponseHandler & handler)
{
    PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::enumerateInstances");

    Array<CIMInstance> instanceArray;
    Array<CIMInstance> namedInstances;

    //
    // get userName
    //
    String user;
    try
    {
        IdentityContainer container = context.get(IdentityContainer::NAME);
        user= container.getUserName();
    }
    catch (...)
    {
        user= String::EMPTY;
    }

    //
    // verify user authorizations
    //
    if (user != String::EMPTY)
    {
        _verifyAuthorization(user);
    }

    //
    // check if the class name requested is PG_Authorization
    //
    if (!ref.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION))
    {
        PEG_METHOD_EXIT();
        throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED,
            ref.getClassName().getString());
    }

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

    //
    // call enumerateInstancesForClass of the repository
    //
    namedInstances = _repository->enumerateInstancesForClass(
        ref.getNameSpace(), ref.getClassName());

    for(Uint32 i = 0, n = namedInstances.size(); i < n; i++)
    {
        handler.deliver(namedInstances[i]);
    }

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

    PEG_METHOD_EXIT();
    return;
}
开发者ID:deleisha,项目名称:neopegasus,代码行数:68,代码来源:UserAuthProvider.cpp

示例2: modifyInstance

//
// Modify instance based on modifiedInstance.
//
void UserAuthProvider::modifyInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    const CIMInstance& modifiedIns,
    const Boolean includeQualifiers,
    const CIMPropertyList & propertyList,
    ResponseHandler & handler)
{
    PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::modifyInstance");

    //
    // get userName
    //
    String user;
    try
    {
        IdentityContainer container = context.get(IdentityContainer::NAME);
        user= container.getUserName();
    }
    catch (...)
    {
        user= String::EMPTY;
    }

    //
    // verify user authorizations
    //
    if (user != String::EMPTY)
    {
        _verifyAuthorization(user);
    }

    //
    // check if the class name requested is PG_Authorization
    //
    if (!instanceReference.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION))
    {
        PEG_METHOD_EXIT();
        throw PEGASUS_CIM_EXCEPTION (
            CIM_ERR_NOT_SUPPORTED,
            instanceReference.getClassName().getString());
    }

    CIMInstance newInstance = modifiedIns;

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

    //
    // Get the user name from the instance
    //
    String userNameStr;
    String namespaceStr;
    String authorizationStr;

    Uint32 pos = modifiedIns.findProperty ( PROPERTY_NAME_USERNAME );
    CIMProperty prop = (CIMProperty)newInstance.getProperty(pos);
    prop.getValue().get(userNameStr);

    //
    // Get the namespace from the instance
    //
    pos = modifiedIns.findProperty ( PROPERTY_NAME_NAMESPACE );
    prop = (CIMProperty)newInstance.getProperty(pos);
    prop.getValue().get(namespaceStr);

    //
    // Get the authorization from the instance
    //
    pos = modifiedIns.findProperty ( PROPERTY_NAME_AUTHORIZATION );
    prop = (CIMProperty)newInstance.getProperty(pos);
    prop.getValue().get(authorizationStr);

    //
    // ATTN: Note that the following is a hack, because
    // modifyInstance() in repository does not like
    // the hostname and namespace included in the CIMObjectPath
    // passed to it as a parameter.
    //
    CIMObjectPath ref("", CIMNamespaceName (),
        modifiedIns.getClassName(), instanceReference.getKeyBindings());

    CIMInstance newModifiedIns = modifiedIns.clone ();
    newModifiedIns.setPath (ref);

    //
    // call modifyInstances of the repository
    //
    _repository->modifyInstance(
        instanceReference.getNameSpace(), newModifiedIns);

    //
    // set authorization in the UserManager
    //
    _userManager->setAuthorization(
        userNameStr, namespaceStr, authorizationStr);

//.........这里部分代码省略.........
开发者ID:deleisha,项目名称:neopegasus,代码行数:101,代码来源:UserAuthProvider.cpp

示例3: deleteInstance

//
// Deletes the specified instance.
//
void UserAuthProvider::deleteInstance(
    const OperationContext & context,
    const CIMObjectPath& myInstance,
    ResponseHandler & handler)
{
    CIMValue                userName ;
    String                  userNameStr;
    String                  namespaceStr;
    Array<CIMKeyBinding>       kbArray;

    PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::deleteInstance");

    //
    // get userName
    //
    String user;
    try
    {
        IdentityContainer container = context.get(IdentityContainer::NAME);
        user= container.getUserName();
    }
    catch (...)
    {
        user= String::EMPTY;
    }

    //
    // verify user authorizations
    //
    if (user != String::EMPTY)
    {
        _verifyAuthorization(user);
    }

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

#ifndef PEGASUS_NO_PASSWORDFILE
    //
    // check if the class name requested is PG_User
    //
    if (myInstance.getClassName().equal (CLASS_NAME_PG_USER))
    {
        //
        // Get the user name from the instance
        //
        kbArray = myInstance.getKeyBindings();
        if (!kbArray.size())
        {
            MessageLoaderParms parms(
                "ControlProviders.UserAuthProvider."
                    "UNABLE_TO_FIND_KEY_PROPERTY_USERNAME",
                "Unable to find Key Property Username");
            throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_INVALID_PARAMETER,parms);
        }
        if (kbArray[0].getName() == PROPERTY_NAME_USERNAME)
        {
            userNameStr = kbArray[0].getValue();
        }
        else
        {
            MessageLoaderParms parms(
                "ControlProviders.UserAuthProvider.UNEXPECTED_KEY_PROPERTY",
                "Unexpected Key property");
            throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER, parms);
        }

        //
        // Remove the user from User Manager
        //
        _userManager->removeUser(userNameStr);
    }
    //
    // check if the class name requested is PG_Authorization
    //
    else if (myInstance.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION))
#else
    if (myInstance.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION))
#endif
    {
        //
        // Get the user name and namespace from the instance
        //
        kbArray = myInstance.getKeyBindings();
        for (Uint32 i = 0; i < kbArray.size(); i++)
        {
            if ( kbArray[i].getName() == PROPERTY_NAME_USERNAME )
            {
                userNameStr = kbArray[i].getValue();
            }
            else if ( kbArray[i].getName() == PROPERTY_NAME_NAMESPACE )
            {
                namespaceStr = kbArray[i].getValue();
            }
        }

        if ( !userNameStr.size() )
//.........这里部分代码省略.........
开发者ID:deleisha,项目名称:neopegasus,代码行数:101,代码来源:UserAuthProvider.cpp

示例4: createInstance

//
// 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;
    Boolean     authAlreadyExists = false;
    //
    // 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)
    {
        _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()))
    {
        //
        // 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);
    }
    //
    // 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
//.........这里部分代码省略.........
开发者ID:deleisha,项目名称:neopegasus,代码行数:101,代码来源:UserAuthProvider.cpp

示例5: container

//------------------------------------------------------------------------------
// Constructor to set context
//------------------------------------------------------------------------------
NTPProviderSecurity::NTPProviderSecurity(const OperationContext & context)
{
    IdentityContainer container(context.get(IdentityContainer::NAME));
    secUsername.assign(container.getUserName());
}
开发者ID:deleisha,项目名称:neopegasus,代码行数:8,代码来源:NTPProviderSecurity_HPUX.cpp

示例6: deliver

void EnableIndicationsResponseHandler::deliver(const OperationContext & context, const CIMIndication & cimIndication)
{
    if(cimIndication.isUninitialized())
    {
        MessageLoaderParms message(
            "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
            "The object is not initialized.");

        throw CIMException(CIM_ERR_FAILED, message);
    }

    // ATTN: temporarily convert indication to instance
    CIMInstance cimInstance(cimIndication);

    //  Get list of subscription instance names from context
    Array<CIMObjectPath> subscriptionInstanceNames;

    try
    {
        SubscriptionInstanceNamesContainer container =
            context.get(SubscriptionInstanceNamesContainer::NAME);

        subscriptionInstanceNames = container.getInstanceNames();
    }
    catch(Exception &)
    {
        subscriptionInstanceNames.clear();
    }

    // l10n
    ContentLanguages contentLangs;

    try
    {
        // Get the Content-Language for this indication.  The provider
        // does not have to add specify a language for the indication.
        ContentLanguageListContainer langContainer =
            context.get(ContentLanguageListContainer::NAME);

        contentLangs = langContainer.getLanguages();
    }
    catch(Exception &)
    {
        // The provider did not explicitly set a Content-Language for
        // the indication.  Fall back to the lang set in this object.
        contentLangs = getLanguages();
    }
    // l10n -end

    // create message
    // l10n
    CIMProcessIndicationRequestMessage * request =
        new CIMProcessIndicationRequestMessage(
        XmlWriter::getNextMessageId(),
        cimInstance.getPath().getNameSpace(),
        cimInstance,
        subscriptionInstanceNames,
        _provider,
        QueueIdStack());  // Must be filled in by the callback function

    request->operationContext = context;

    try
    {
        request->operationContext.set(ContentLanguageListContainer(contentLangs));
    }
    catch(Exception &)
    {
        request->operationContext.insert(ContentLanguageListContainer(contentLangs));
    }

    _indicationCallback(request);
}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:73,代码来源:OperationResponseHandler.cpp


注:本文中的OperationContext::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。