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

📄 cimusercommand.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 4 页
字号:
//%2006//////////////////////////////////////////////////////////////////////////// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation, The Open Group.// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; Symantec Corporation; The Open Group.//// Permission is hereby granted, free of charge, to any person obtaining a copy// of this software and associated documentation files (the "Software"), to// deal in the Software without restriction, including without limitation the// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or// sell copies of the Software, and to permit persons to whom the Software is// furnished to do so, subject to the following conditions:// // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.////==============================================================================//// Author: Sushma Fernandes, Hewlett Packard Company (sushma_fernandes@hp.com)//// Modified By: Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com)//              Carol Ann Krug Graves, Hewlett-Packard Company//                  (carolann_graves@hp.com)//              Amit K Arora, IBM (amita@in.ibm.com) for PEP-101//              Alagaraja Ramasubramanian, IBM (alags_raj@in.ibm.com) - PEP-167//              Amit K Arora, IBM (amita@in.ibm.com) - Bug#2311,#2333,#2351//              Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) - Bug#2756//              David Dillard, VERITAS Software Corp.//                  (david.dillard@veritas.com)//              Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) for Bug#3032////%/////////////////////////////////////////////////////////////////////////////#include <Pegasus/Common/Config.h>#include <Pegasus/Common/Constants.h>#include <iostream>#include <Clients/cliutils/Command.h>#include <Clients/cliutils/CommandException.h>#include <Pegasus/getoopt/getoopt.h>#include <Pegasus/Client/CIMClient.h>#include <Pegasus/Common/CIMProperty.h>#include <Pegasus/Common/CIMObjectPath.h>#include <Pegasus/Common/CIMStatusCode.h>#include <Pegasus/Common/String.h>#include <Pegasus/Common/System.h>#include <Pegasus/Common/PegasusVersion.h>#include <Pegasus/Common/AutoPtr.h>PEGASUS_USING_STD;PEGASUS_NAMESPACE_BEGIN//l10n/** * The CLI message resource name */static const char MSG_PATH [] = "pegasus/pegasusCLI";/**    The command name.*/static const char COMMAND_NAME []              = "cimuser";/**    This constant represents the name of the User name property in the schema*/static const CIMName PROPERTY_NAME_USER_NAME            = CIMName ("Username");/**    This constant represents the name of the Password property in the schema*/static const CIMName PROPERTY_NAME_PASSWORD             = CIMName ("Password");/**    The usage string for this command.  This string is displayed    when an error occurs in parsing or validating the command line.*/static const char USAGE []                     = "Usage: ";/**    This constant represents the getoopt argument designator*/static const char GETOPT_ARGUMENT_DESIGNATOR   = ':';/*    These constants represent the operation modes supported by the CLI.    Any new operation should be added here.*//**    This constant signifies that an operation option has not been recorded*/static const Uint32 OPERATION_TYPE_UNINITIALIZED  = 0;/**    This constant represents a add user operation*/static const Uint32 OPERATION_TYPE_ADD            = 1;/**    This constant represents a add user operation*/static const Uint32 OPERATION_TYPE_MODIFY         = 2;/**    This constant represents a remove user operation*/static const Uint32 OPERATION_TYPE_REMOVE         = 3;/**    This constant represents a list operation*/static const Uint32 OPERATION_TYPE_LIST           = 4;/**    This constant represents a help operation*/static const Uint32 OPERATION_TYPE_HELP           = 5;/**    This constant represents a version display operation*/static const Uint32 OPERATION_TYPE_VERSION        = 6;/**    The constants representing the messages.*///l10nstatic const char NOT_PRIVILEGED_USER [] =    "You must have superuser privilege to run this command.";static const char NOT_PRIVILEGED_USER_KEY [] =    "Clients.cimuser.CIMUserCommand.NOT_PRIVILEGED_USER";static const char CIMOM_NOT_RUNNING [] =    "CIM Server may not be running.";static const char CIMOM_NOT_RUNNING_KEY [] =    "Clients.cimuser.CIMUserCommand.CIMOM_NOT_RUNNING";static const char ADD_USER_FAILURE [] =    "Failed to add user.";static const char ADD_USER_FAILURE_KEY [] =    "Clients.cimuser.CIMUserCommand.ADD_USER_FAILURE";static const char REMOVE_USER_FAILURE [] =    "Failed to remove user.";static const char REMOVE_USER_FAILURE_KEY [] =    "Clients.cimuser.CIMUserCommand.REMOVE_USER_FAILURE";static const char CHANGE_PASSWORD_FAILURE [] =    "Failed to change password.";static const char CHANGE_PASSWORD_FAILURE_KEY [] =    "Clients.cimuser.CIMUserCommand.CHANGE_PASSWORD_FAILURE";static const char LIST_USERS_FAILURE [] =    "Failed to list the users. ";static const char LIST_USERS_FAILURE_KEY [] =    "Clients.cimuser.CIMUserCommand.LIST_USERS_FAILURE";static const char ADD_USER_SUCCESS [] =    "User added successfully.";static const char ADD_USER_SUCCESS_KEY [] =    "Clients.cimuser.CIMUserCommand.ADD_USER_SUCCESS";static const char REMOVE_USER_SUCCESS[] =    "User removed successfully.";static const char REMOVE_USER_SUCCESS_KEY[] =    "Clients.cimuser.CIMUserCommand.REMOVE_USER_SUCCESS";static const char CHANGE_PASSWORD_SUCCESS [] =    "Password changed successfully.";static const char CHANGE_PASSWORD_SUCCESS_KEY [] =    "Clients.cimuser.CIMUserCommand.CHANGE_PASSWORD_SUCCESS";static const char PASSWORD_BLANK [] =    "Password cannot be blank. Please re-enter your password.";static const char PASSWORD_BLANK_KEY [] =    "Clients.cimuser.CIMUserCommand.PASSWORD_BLANK";static const char NO_USERS_FOUND[] =    "No users found for listing.";static const char NO_USERS_FOUND_KEY[] =    "Clients.cimuser.CIMUserCommand.NO_USERS_FOUND";static const char AUTH_SCHEMA_NOT_LOADED [] =    "Please restore the internal repository on the CIM Server.";static const char AUTH_SCHEMA_NOT_LOADED_KEY [] =    "Clients.cimuser.CIMUserCommand.AUTH_SCHEMA_NOT_LOADED";static const char REQUIRED_ARGS_MISSING [] =    "Required arguments missing.";static const char REQUIRED_ARGS_MISSING_KEY [] =    "Clients.cimuser.CIMUserCommand.REQUIRED_ARGS_MISSING";static const char INVALID_ARGS [] =    "Invalid arguments.";static const char INVALID_ARGS_KEY [] =    "Clients.cimuser.CIMUserCommand.INVALID_ARGS";static const char USER_ALREADY_EXISTS [] =    "Specified user name already exist.";static const char USER_ALREADY_EXISTS_KEY [] =    "Clients.cimuser.CIMUserCommand.USER_ALREADY_EXISTS";static const char USER_NOT_FOUND [] =    "Specified user name was not found.";static const char USER_NOT_FOUND_KEY [] =    "Clients.cimuser.CIMUserCommand.USER_NOT_FOUND";static const char USERNAME_REQUIRED [] =    "User name is required.";static const char USERNAME_REQUIRED_KEY [] =    "Clients.cimuser.CIMUserCommand.USERNAME_REQUIRED";/**    The option character used to specify add user.*/static const char   OPTION_ADD                 = 'a';/**    The option character used to specify modify user.*/static const char   OPTION_MODIFY              = 'm';/**    The option character used to specify user name.*/static const char   OPTION_USER_NAME           = 'u';/**    The option character used to specify password.*/static const char   OPTION_PASSWORD            = 'w';/**    The option character used to specify new password.*/static const char   OPTION_NEW_PASSWORD        = 'n';/**    The option character used to specify remove user.*/static const char   OPTION_REMOVE              = 'r';/**    The option character used to specify listing of users.*/static const char   OPTION_LIST                = 'l';/**    The option character used to display help info.*/static const char   OPTION_HELP                = 'h';/**    The option character used to display version info.*/static const char   OPTION_VERSION             = 'v';/**    The name of the Method that implements modify password*/static const CIMName   MODIFY_METHOD            = CIMName ("modifyPassword");/**    The input parameter name for old password*/static const char   OLD_PASS_PARAM[]             = "OldPassword";/**    The input parameter name for new password*/static const char   NEW_PASS_PARAM[]             = "NewPassword";static const char   PASSWORD_PROMPT []  =                        "Please enter your password: ";static const char   PASSWORD_PROMPT_KEY [] = "Clients.cimuser.CIMUserCommand.PASSWORD_PROMPT";static const char   OLD_PASSWORD_PROMPT []  =                        "Please enter your old password: ";static const char   OLD_PASSWORD_PROMPT_KEY []  ="Clients.cimuser.CIMUserCommand.OLD_PASSWORD_PROMPT";static const char   RE_ENTER_PROMPT []  =                        "Please re-enter your password: ";static const char   RE_ENTER_PROMPT_KEY []  ="Clients.cimuser.CIMUserCommand.RE_ENTER_PROMPT";static const char   NEW_PASSWORD_PROMPT []  =                        "Please enter your new password: ";static const char   NEW_PASSWORD_PROMPT_KEY []  ="Clients.cimuser.CIMUserCommand.NEW_PASSWORD_PROMPT";static const char   PASSWORD_DOES_NOT_MATCH []  =                        "Passwords do not match. Please Re-enter.";static const char   PASSWORD_DOES_NOT_MATCH_KEY []  = "Clients.cimuser.CIMUserCommand.PASSWORD_DOES_NOT_MATCH";static const char   PASSWORD_SAME_ERROR []  =                        "Error, new and old passwords cannot be same.";static const char   PASSWORD_SAME_ERROR_KEY []  = "Clients.cimuser.CIMUserCommand.PASSWORD_SAME_ERROR";static const char ERR_OPTION_NOT_SUPPORTED [] = "Invalid option. Use '--help' to obtain command syntax.";static const char ERR_OPTION_NOT_SUPPORTED_KEY [] = "Clients.cimuser.CIMUserCommand.ERR_OPTION_NOT_SUPPORTED";static const char ERR_USAGE [] = "Incorrect usage. Use '--help' to obtain command syntax.";static const char ERR_USAGE_KEY [] = "Clients.cimuser.CIMUserCommand.ERR_USAGE";static const char   LONG_HELP []  = "help";static const char   LONG_VERSION []  = "version";/**This is a CLI used to manage users of the CIM Server.  This command supportsoperations to add, modify, list and remove users.@author Sushma Fernandes, Hewlett-Packard Company*/class CIMUserCommand : public Command{public:    /**        Constructs a CIMUserCommand and initializes instance variables.    */    CIMUserCommand ();    //    // Overrides the virtual function setCommand from Command class    // This is defined as an empty function.    //    void setCommand (        Uint32 argc,        char* argv[])    {        // Empty function    }    /**    Parses the command line, validates the options, and sets instance    variables based on the option arguments. This implementation of    setCommand includes the parameters for output and error stream.    @param  ostream    The stream to which command output is written.    @param  ostream    The stream to which command errors are written.    @param  args       The string array containing the command line arguments    @param  argc       The int containing the arguments count    @throws  CommandFormatException  if an error is encountered in parsing                                     the command line

⌨️ 快捷键说明

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