⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cimauthcommand.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 4 页
字号:
                        // More than one operation option was found                        //                        throw UnexpectedOptionException(OPTION_HELP);                    }                    if (options.isSet (OPTION_HELP) > 1)                    {                        //                        // More than one list option was found                        //                        throw DuplicateOptionException(OPTION_HELP);                    }                    _operationType = OPERATION_TYPE_HELP;                    break;                }                case OPTION_VERSION:                {                    if (_operationType != OPERATION_TYPE_UNINITIALIZED)                    {                        //                        // More than one operation option was found                        //                        throw UnexpectedOptionException(OPTION_VERSION);                    }                    if (options.isSet (OPTION_VERSION) > 1)                    {                        //                        // More than one list option was found                        //                        throw DuplicateOptionException(OPTION_VERSION);                    }                    _operationType = OPERATION_TYPE_VERSION;                    break;                }                default:                {                    //                    // Should never get here                    //                    break;                }            }        }    }    if ( _operationType == OPERATION_TYPE_UNINITIALIZED )    {        //        // No operation type was specified        // Show the usage        //        throw CommandFormatException(localizeMessage(            MSG_PATH, REQUIRED_ARGS_MISSING_KEY, REQUIRED_ARGS_MISSING));    }    if ( _operationType == OPERATION_TYPE_ADD ||         _operationType == OPERATION_TYPE_MODIFY )    {        if ( !_userNameSet )        {            //            // A required option is missing            //            throw MissingOptionException(OPTION_USER_NAME);        }        if ( !_namespaceSet )        {            //            // A required option is missing            //            throw MissingOptionException(OPTION_NAMESPACE);        }        if ( !_readFlagSet && !_writeFlagSet )        {            //            // Authorization flags were not specified,            // set default to read only            //            _authorizations.append("r");            _readFlagSet = true;        }    }    else if ( _operationType == OPERATION_TYPE_REMOVE )    {        if ( !_userNameSet )        {            //            // A required option is missing            //            throw MissingOptionException(OPTION_USER_NAME);        }    }    else if (_operationType != OPERATION_TYPE_ADD &&        _operationType != OPERATION_TYPE_MODIFY)    {        //        // Unexpected option was specified        //        if ( _readFlagSet )        {            throw UnexpectedOptionException(OPTION_READ);        }        else if ( _writeFlagSet )        {            throw UnexpectedOptionException(OPTION_WRITE);        }    }}/**    Executes the command and writes the results to the PrintWriters.*/Uint32 CIMAuthCommand::execute (    ostream& outPrintWriter,    ostream& errPrintWriter){    if ( _operationType == OPERATION_TYPE_UNINITIALIZED )    {        //        // The command was not initialized        //        return ( RC_ERROR );    }    //PEP#167 - Added Options HELP and VERSION    //PEP#167 - CIMServer need not be running for these to work    else if (_operationType == OPERATION_TYPE_HELP)    {        cerr << usage << endl;        return (RC_SUCCESS);    }    else if(_operationType == OPERATION_TYPE_VERSION)    {        cerr << "Version " << PEGASUS_PRODUCT_VERSION << endl;        return (RC_SUCCESS);    }    //    // Get local host name    //    _hostName.assign(System::getHostName());    try    {        // Construct the CIMClient and set to request server messages        // in the default language of this client process.        _client.reset(new CIMClient);        _client->setRequestDefaultLanguages(); //l10n    }    catch (Exception & e)    {        errPrintWriter << e.getMessage() << endl;        return ( RC_ERROR );    }    try    {        //        // Open connection with CIMSever        //        _client->connectLocal();    }    catch(Exception&)    {        //l10n        //outPrintWriter << CIMOM_NOT_RUNNING << endl;        outPrintWriter << localizeMessage(MSG_PATH,            CIMOM_NOT_RUNNING_KEY,            CIMOM_NOT_RUNNING)            << endl;        return 1;    }    //    // Perform the requested operation    //    switch ( _operationType )    {        case OPERATION_TYPE_ADD:            try            {                _AddAuthorization( outPrintWriter, errPrintWriter );            }            catch (CIMException& e)            {                CIMStatusCode code = e.getCode();                if (code == CIM_ERR_FAILED)                {                    //l10n                    //outPrintWriter << ADD_AUTH_FAILURE << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        ADD_AUTH_FAILURE_KEY,                        ADD_AUTH_FAILURE)                        << endl;                    errPrintWriter << e.getMessage() << endl;                }                else if (code == CIM_ERR_NOT_SUPPORTED)                {                    //l10n                    //outPrintWriter << ADD_AUTH_FAILURE << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        ADD_AUTH_FAILURE_KEY,                        ADD_AUTH_FAILURE)                        << endl;                    errPrintWriter << e.getMessage()  << endl;                }                else if (code == CIM_ERR_ALREADY_EXISTS)                {                    //l10n                    //outPrintWriter << ADD_AUTH_FAILURE << endl;                    //outPrintWriter << AUTH_ALREADY_EXISTS << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        ADD_AUTH_FAILURE_KEY,                        ADD_AUTH_FAILURE)                        << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        AUTH_ALREADY_EXISTS_KEY,                        AUTH_ALREADY_EXISTS)                        << endl;                    errPrintWriter << e.getMessage()  << endl;                }                else if (code == CIM_ERR_INVALID_CLASS)                {                    //l10n                    //outPrintWriter << ADD_AUTH_FAILURE << endl;                    //outPrintWriter << AUTH_SCHEMA_NOT_LOADED << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        ADD_AUTH_FAILURE_KEY,                        ADD_AUTH_FAILURE)                        << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        AUTH_SCHEMA_NOT_LOADED_KEY,                        AUTH_SCHEMA_NOT_LOADED)                        << endl;                }                else                {                    errPrintWriter << e.getMessage() << endl;                }                return ( RC_ERROR );            }            catch (Exception& e)            {                //l10n                //outPrintWriter << ADD_AUTH_FAILURE << endl <<                    //e.getMessage() << endl;                outPrintWriter << localizeMessage(MSG_PATH,                    ADD_AUTH_FAILURE_KEY,                    ADD_AUTH_FAILURE)                    << endl << e.getMessage() << endl;                return ( RC_ERROR );            }            break;        case OPERATION_TYPE_MODIFY:            try            {                _ModifyAuthorization( outPrintWriter, errPrintWriter );            }            catch (CIMException& e)            {                CIMStatusCode code = e.getCode();                if (code == CIM_ERR_FAILED)                {                    //l10n                    //outPrintWriter << MODIFY_AUTH_FAILURE << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        MODIFY_AUTH_FAILURE_KEY,                        MODIFY_AUTH_FAILURE)                        << endl;                    errPrintWriter << e.getMessage() << endl;                }                else if (code == CIM_ERR_NOT_SUPPORTED)                {                    //l10n                    //outPrintWriter << MODIFY_AUTH_FAILURE << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        MODIFY_AUTH_FAILURE_KEY,                        MODIFY_AUTH_FAILURE)                        << endl;                    errPrintWriter << e.getMessage()  << endl;                }                else if (code == CIM_ERR_NOT_FOUND)                {                    //l10n                    //outPrintWriter << MODIFY_AUTH_FAILURE << endl;                    //outPrintWriter << AUTH_NOT_FOUND          << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        MODIFY_AUTH_FAILURE_KEY,                        MODIFY_AUTH_FAILURE)                        << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        AUTH_NOT_FOUND_KEY,                        AUTH_NOT_FOUND)                        << endl;                    errPrintWriter << e.getMessage()  << endl;                }                else if (code == CIM_ERR_INVALID_CLASS)                {                    //l10n                    //outPrintWriter << MODIFY_AUTH_FAILURE << endl;                    //outPrintWriter << AUTH_SCHEMA_NOT_LOADED << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        MODIFY_AUTH_FAILURE_KEY,                        MODIFY_AUTH_FAILURE)                        << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        AUTH_SCHEMA_NOT_LOADED_KEY,                        AUTH_SCHEMA_NOT_LOADED)                        << endl;                }                else                {                    errPrintWriter << e.getMessage() << endl;                }                return ( RC_ERROR );            }            catch (Exception& e)            {                //l10n                //outPrintWriter << MODIFY_AUTH_FAILURE << endl <<                    //e.getMessage() << endl;                outPrintWriter << localizeMessage(MSG_PATH,                    MODIFY_AUTH_FAILURE_KEY,                    MODIFY_AUTH_FAILURE)                    << endl << e.getMessage() << endl;                return ( RC_ERROR );            }            break;        case OPERATION_TYPE_REMOVE:            try            {                _RemoveAuthorization( outPrintWriter, errPrintWriter );            }            catch (CIMException& e)            {                CIMStatusCode code = e.getCode();                if (code == CIM_ERR_FAILED)                {                    //l10n                    //outPrintWriter << REMOVE_AUTH_FAILURE << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        REMOVE_AUTH_FAILURE_KEY,                        REMOVE_AUTH_FAILURE)                        << endl;                    errPrintWriter << e.getMessage() << endl;                }                else if (code == CIM_ERR_NOT_SUPPORTED)                {                    //l10n                    //outPrintWriter << REMOVE_AUTH_FAILURE << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        REMOVE_AUTH_FAILURE_KEY,                        REMOVE_AUTH_FAILURE)                        << endl;                    errPrintWriter << e.getMessage()  << endl;                }                else if (code == CIM_ERR_NOT_FOUND)                {                    //l10n                    //outPrintWriter << REMOVE_AUTH_FAILURE << endl;                    //outPrintWriter << AUTH_NOT_FOUND          << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        REMOVE_AUTH_FAILURE_KEY,                        REMOVE_AUTH_FAILURE)                        << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        AUTH_NOT_FOUND_KEY,                        AUTH_NOT_FOUND)                        << endl;                    errPrintWriter << e.getMessage()  << endl;                }                else if (code == CIM_ERR_INVALID_CLASS)                {                    //l10n                    //outPrintWriter << REMOVE_AUTH_FAILURE << endl;                    //outPrintWriter << AUTH_SCHEMA_NOT_LOADED << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        REMOVE_AUTH_FAILURE_KEY,                        REMOVE_AUTH_FAILURE)                        << endl;                    outPrintWriter << localizeMessage(MSG_PATH,                        AUTH_SCHEMA_NOT_LOADED_KEY,                        AUTH_SCHEMA_NOT_LOADED)                        << endl;                }                else                {                    errPrintWriter << e.getMessage() << endl;                }                return ( RC_ERROR );            }            catch (Exception& e)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -