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


C++ IdentityContainer::getUserName方法代码示例

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


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

示例1: invokeMethod

//
// Invoke Method, used to modify user's password
//
void UserAuthProvider::invokeMethod(
    const OperationContext & context,
    const CIMObjectPath & ref,
    const CIMName & methodName,
    const Array<CIMParamValue> & inParams,
    MethodResultResponseHandler & handler)
{
    PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::invokeMethod");

    //
    // get userName
    //
    String user;
    try
    {
        IdentityContainer container = context.get(IdentityContainer::NAME);
        user= container.getUserName();
    }
    catch (...)
    {
        user= String::EMPTY;
    }
    //
    // verify user authorizations
    //
    if ( user != String::EMPTY || user != "" )
    {
        _verifyAuthorization(user);
    }

#ifndef PEGASUS_NO_PASSWORDFILE
    String            userName;
    String            password;
    String            newPassword;
    Array<CIMKeyBinding>     kbArray;

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

    // Check if the class name is PG_USER
    if (!ref.getClassName().equal (CLASS_NAME_PG_USER))
    {
        handler.complete();
        throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED,
                                     ref.getClassName().getString());
    }

    // Check if the method name is correct
    if (!methodName.equal (METHOD_NAME_MODIFY_PASSWORD))
    {
        handler.complete();
        PEG_METHOD_EXIT();
        //l10n
        //throw PEGASUS_CIM_EXCEPTION (
        //CIM_ERR_FAILED,
        //"Unsupported method name, " + methodName.getString());
        MessageLoaderParms parms("ControlProviders.UserAuthProvider.UNSUPPORTED_METHOD_NAME",
                                 "Unsupported method name, $0",
                                 methodName.getString());
        throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,parms);
    }

    // Check if all the input parameters are passed.
    if ( inParams.size() < 2 )
    {
        handler.complete();
        PEG_METHOD_EXIT();
        //l10n
        //     throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER,
        //                           "Input parameters are not valid.");
        MessageLoaderParms parms("ControlProviders.UserAuthProvider.INPUT_PARAMETERS_NOT_VALID",
                                 "Input parameters are not valid.");
        throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_INVALID_PARAMETER, parms);
    }

    try
    {
        kbArray = ref.getKeyBindings();

        if ( !kbArray.size() )
        {
            PEG_METHOD_EXIT();
            //l10n
            //throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER,
            //       "Unable to find Key Property Username");
            MessageLoaderParms parms("ControlProviders.UserAuthProvider.UNABLE_TO_FIND_KEY_PROPERTY_USERNAME",
                                     "Unable to find Key Property Username");
            throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_INVALID_PARAMETER,parms);
        }

        //
        // Get the user name
        //
        if ( kbArray[0].getName() == PROPERTY_NAME_USERNAME )
        {
            userName = kbArray[0].getValue();
        }
//.........这里部分代码省略.........
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:101,代码来源:UserAuthProvider.cpp

示例2: 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 || user != "" )
    {
        _verifyAuthorization(user);
    }

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

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

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

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

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

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

    PEG_METHOD_EXIT();
    return;
}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:77,代码来源:UserAuthProvider.cpp

示例3: enumerateInstanceNames

//
// 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);
//.........这里部分代码省略.........
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:101,代码来源:UserAuthProvider.cpp

示例4: 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 || user != "" )
    {
        _verifyAuthorization(user);
    }

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

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

            //
            // Remove the user from User Manager
            //
            _userManager->removeUser(userNameStr);
        }
        catch ( const CIMException & )
        {
            handler.complete();
            PEG_METHOD_EXIT();
            throw;
        }
        catch ( const Exception &e )
        {
            handler.complete();
            PEG_METHOD_EXIT();
            throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
        }
    }
    //
    // check if the class name requested is PG_Authorization
    //
    else if (myInstance.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION))
#else
    if (myInstance.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION))
#endif
//.........这里部分代码省略.........
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:101,代码来源:UserAuthProvider.cpp

示例5: 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 || user != "" )
    {
        _verifyAuthorization(user);
    }

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

    CIMInstance newInstance = modifiedIns;

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

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

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

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

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

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

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

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

        //
        // set authorization in the UserManager
        //
        _userManager->setAuthorization(
            userNameStr, namespaceStr, authorizationStr );
//.........这里部分代码省略.........
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:101,代码来源:UserAuthProvider.cpp

示例6: enumerateInstanceNames

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();
}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:86,代码来源:NamespaceProvider.cpp

示例7: 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;

    //
    // 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
        {
            //
//.........这里部分代码省略.........
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:101,代码来源:UserAuthProvider.cpp

示例8: enumerateInstances

void NamespaceProvider::enumerateInstances(
    const OperationContext & context,
    const CIMObjectPath & ref,
    const Boolean includeQualifiers,
    const Boolean includeClassOrigin,
    const CIMPropertyList& propertyList,
    InstanceResponseHandler & handler)
{
    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "NamespaceProvider::enumerateInstances()");

    // Verify that ClassName == __Namespace
    if (!ref.getClassName().equal(NAMESPACE_CLASSNAME))
    {
        PEG_METHOD_EXIT();
        //l10n
        //throw CIMNotSupportedException(ref.getClassName().getString() +
        // " not supported by Namespace Provider");
        throw CIMNotSupportedException(MessageLoaderParms(
                                           "ControlProviders.NamespaceProvider.NamespaceProvider.NOT_SUPPORTED_BY_NAMESPACEPROVIDER",
                                           "$0 not supported by Namespace Provider",
                                           ref.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 = ref.getNameSpace();

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

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

    Array<CIMInstance> instanceArray;

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

        // 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]))
            {
                CIMInstance instance(NAMESPACE_CLASSNAME);
                instance.addProperty(
                    (CIMProperty(NAMESPACE_PROPERTYNAME,
                                 namespaceNames[i].getString().subString
                                 (parentNamespaceName.getString().size()+1,
                                  namespaceNames[i].getString().size()-
                                  parentNamespaceName.getString().size()-1))));
                instanceArray.append(instance);
                //instance.setPath(instanceName);
                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(instanceArray);

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

    PEG_METHOD_EXIT();
}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:88,代码来源:NamespaceProvider.cpp

示例9: getInstance

void NamespaceProvider::getInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceName,
    const Boolean includeQualifiers,
    const Boolean includeClassOrigin,
    const CIMPropertyList & properatyList,
    InstanceResponseHandler & handler)
{
    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "NamespaceProvider::getInstance");

    CIMNamespaceName childNamespaceName;
    CIMNamespaceName getNamespaceName;
    Boolean isRelativeName;

    // Verify that the className = __namespace
    if (!instanceName.getClassName().equal(NAMESPACE_CLASSNAME))
    {
        PEG_METHOD_EXIT();
        //l10n
        //throw CIMNotSupportedException(instanceName.getClassName().getString()
        //+ " not supported by Namespace Provider");
        throw CIMNotSupportedException(MessageLoaderParms(
                                           "ControlProviders.NamespaceProvider.NamespaceProvider.NOT_SUPPORTED_BY_NAMESPACEPROVIDER",
                                           "$0 not supported by Namespace Provider",
                                           instanceName.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(instanceName, childNamespaceName, isRelativeName);
    CIMNamespaceName parentNamespaceName = instanceName.getNameSpace();

    PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
                     "childNamespaceName = " + childNamespaceName.getString() +
                     (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,
                                   getNamespaceName);

        if (!Contains(namespaceNames, getNamespaceName))
        {
            //l10n
            //throw CIMObjectNotFoundException("Namespace deos not exist: "
            //+ getNamespaceName.getString());
            throw CIMObjectNotFoundException(MessageLoaderParms(
                                                 "ControlProviders.NamespaceProvider.NamespaceProvider.NAMESPACE_DOES_NOT_EXIST",
                                                 "Namespace does not exist: $0",
                                                 getNamespaceName.getString()));
        }

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

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

    //Set name of class
    CIMInstance instance(NAMESPACE_CLASSNAME);

    //
    // construct the instance
    //
    instance.addProperty(CIMProperty(NAMESPACE_PROPERTYNAME,
                                     isRelativeName?childNamespaceName.getString():
                                     parentNamespaceName.getString()));
    //instance.setPath(instanceName);

    handler.deliver(instance);

    // complete processing the request
//.........这里部分代码省略.........
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:101,代码来源:NamespaceProvider.cpp

示例10: deleteInstance

void NamespaceProvider::deleteInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceName,
    ResponseHandler & handler)
{
    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "NamespaceProvider::deleteInstance");

    CIMNamespaceName childNamespaceName;
    CIMNamespaceName deleteNamespaceName;
    Boolean isRelativeName;

    // Verify that the className = __namespace
    if (!instanceName.getClassName().equal(NAMESPACE_CLASSNAME))
    {
        PEG_METHOD_EXIT();
        //l10n
        //throw CIMNotSupportedException(instanceName.getClassName().getString()
        //+ " not supported by Namespace Provider");
        throw CIMNotSupportedException(MessageLoaderParms(
                                           "ControlProviders.NamespaceProvider.NamespaceProvider.NOT_SUPPORTED_BY_NAMESPACEPROVIDER",
                                           "$0 not supported by Namespace Provider",
                                           instanceName.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(instanceName, childNamespaceName, isRelativeName);
    CIMNamespaceName parentNamespaceName = instanceName.getNameSpace();

    PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
                     "childNamespaceName = " + childNamespaceName.getString() +
                     (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,
                                   deleteNamespaceName);

        if (deleteNamespaceName.equal (ROOTNS))
        {
            //l10n
            //throw CIMNotSupportedException("root namespace may be deleted.");
            throw CIMNotSupportedException(MessageLoaderParms(
                                               "ControlProviders.NamespaceProvider.NamespaceProvider.ROOT_NAMESPACE_CANNOT_BE_DELETED",
                                               "root namespace may be deleted."));
        }

        _repository->deleteNameSpace(deleteNamespaceName);

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

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

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

    PEG_METHOD_EXIT();
    return ;
}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:89,代码来源:NamespaceProvider.cpp

示例11: createInstance

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;
}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:94,代码来源:NamespaceProvider.cpp

示例12: _modifyInstance

void ConfigSettingProvider::_modifyInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    const CIMInstance& modifiedIns,
    const CIMPropertyList& propertyList,
    Uint32 timeoutSeconds)
    {
        PEG_METHOD_ENTER(TRC_CONFIG,
            "ConfigSettingProvider::_modifyInstance()");

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

        //
        // verify user authorizations
        // z/OS: authorization check is done in CIMOpReqAuth already
        //
#ifndef PEGASUS_OS_ZOS
        if (userName != String::EMPTY)
        {
            _verifyAuthorization(userName);
        }
#endif
        // NOTE: Qualifiers are not processed by this provider, so the
        // IncludeQualifiers flag is ignored.

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

        //
        // validate key bindings
        //
        Array<CIMKeyBinding> kbArray = instanceReference.getKeyBindings();
        if ( (kbArray.size() != 1) ||
             (!kbArray[0].getName().equal (PROPERTY_NAME)))
        {
            PEG_METHOD_EXIT();
            throw PEGASUS_CIM_EXCEPTION_L(
                CIM_ERR_INVALID_PARAMETER,
                MessageLoaderParms(
                    "ControlProviders.ConfigSettingProvider."
                        "ConfigSettingProvider."
                        "INVALID_INSTANCE_NAME",
                    "Invalid instance name"));

        }

        String configPropertyName = kbArray[0].getValue();

        // Modification of the entire instance is not supported by this provider
        if (propertyList.isNull())
        {
            PEG_METHOD_EXIT();
            //l10n
            //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
            //"Modification of entire instance");
            throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,
                  MessageLoaderParms(
                      "ControlProviders.ConfigSettingProvider."
                          "ConfigSettingProvider."
                          "MODIFICATION_OF_ENTIRE_INSTANCE",
                     "Modification of entire instance"));
        }

        Boolean currentValueModified = false;
        Boolean plannedValueModified = false;

        for (Uint32 i = 0; i < propertyList.size(); ++i)
        {
            CIMName propertyName = propertyList[i];
            if (propertyName.equal (CURRENT_VALUE))
            {
                currentValueModified = true;
            }
            else if (propertyName.equal (PLANNED_VALUE))
            {
                plannedValueModified = true;
            }
            else
            {
                PEG_METHOD_EXIT();

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


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