version 1.37, 2005/03/11 12:48:41
|
version 1.38, 2005/04/22 15:51:38
|
|
|
static const char NOT_PRIVILEGED_USER [] = | static const char NOT_PRIVILEGED_USER [] = |
"You must have superuser privilege to run this command."; | "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 NOT_PRIVILEGED_USER_KEY [] = |
|
"Clients.cimuser.CIMUserCommand.NOT_PRIVILEGED_USER"; |
| |
static const char CIMOM_NOT_RUNNING [] = | static const char CIMOM_NOT_RUNNING [] = |
"CIM Server may not be running."; | "CIM Server may not be running."; |
| |
static const char CIMOM_NOT_RUNNING_KEY [] = "Clients.cimuser.CIMUserCommand.CIMOM_NOT_RUNNING"; |
static const char CIMOM_NOT_RUNNING_KEY [] = |
|
"Clients.cimuser.CIMUserCommand.CIMOM_NOT_RUNNING"; |
| |
static const char ADD_USER_FAILURE [] = | static const char ADD_USER_FAILURE [] = |
"Failed to add user."; | "Failed to add user."; |
| |
static const char ADD_USER_FAILURE_KEY [] = "Clients.cimuser.CIMUserCommand.ADD_USER_FAILURE"; |
static const char ADD_USER_FAILURE_KEY [] = |
|
"Clients.cimuser.CIMUserCommand.ADD_USER_FAILURE"; |
| |
static const char REMOVE_USER_FAILURE [] = | static const char REMOVE_USER_FAILURE [] = |
"Failed to remove user."; | "Failed to remove user."; |
| |
static const char REMOVE_USER_FAILURE_KEY [] = "Clients.cimuser.CIMUserCommand.REMOVE_USER_FAILURE"; |
static const char REMOVE_USER_FAILURE_KEY [] = |
|
"Clients.cimuser.CIMUserCommand.REMOVE_USER_FAILURE"; |
| |
static const char CHANGE_PASSWORD_FAILURE [] = | static const char CHANGE_PASSWORD_FAILURE [] = |
"Failed to change password."; | "Failed to change password."; |
| |
static const char CHANGE_PASSWORD_FAILURE_KEY [] = "Clients.cimuser.CIMUserCommand.CHANGE_PASSWORD_FAILURE"; |
static const char CHANGE_PASSWORD_FAILURE_KEY [] = |
|
"Clients.cimuser.CIMUserCommand.CHANGE_PASSWORD_FAILURE"; |
| |
static const char LIST_USERS_FAILURE [] = | static const char LIST_USERS_FAILURE [] = |
"Failed to list the users. "; | "Failed to list the users. "; |
| |
static const char LIST_USERS_FAILURE_KEY [] = "Clients.cimuser.CIMUserCommand.LIST_USERS_FAILURE"; |
static const char LIST_USERS_FAILURE_KEY [] = |
|
"Clients.cimuser.CIMUserCommand.LIST_USERS_FAILURE"; |
| |
static const char ADD_USER_SUCCESS [] = | static const char ADD_USER_SUCCESS [] = |
"User added successfully."; | "User added successfully."; |
| |
static const char ADD_USER_SUCCESS_KEY [] = "Clients.cimuser.CIMUserCommand.ADD_USER_SUCCESS"; |
static const char ADD_USER_SUCCESS_KEY [] = |
|
"Clients.cimuser.CIMUserCommand.ADD_USER_SUCCESS"; |
| |
static const char REMOVE_USER_SUCCESS[] = | static const char REMOVE_USER_SUCCESS[] = |
"User removed successfully."; | "User removed successfully."; |
| |
static const char REMOVE_USER_SUCCESS_KEY[] = "Clients.cimuser.CIMUserCommand.REMOVE_USER_SUCCESS"; |
static const char REMOVE_USER_SUCCESS_KEY[] = |
|
"Clients.cimuser.CIMUserCommand.REMOVE_USER_SUCCESS"; |
| |
static const char CHANGE_PASSWORD_SUCCESS [] = | static const char CHANGE_PASSWORD_SUCCESS [] = |
"Password changed successfully."; | "Password changed successfully."; |
| |
static const char CHANGE_PASSWORD_SUCCESS_KEY [] = "Clients.cimuser.CIMUserCommand.CHANGE_PASSWORD_SUCCESS"; |
static const char CHANGE_PASSWORD_SUCCESS_KEY [] = |
|
"Clients.cimuser.CIMUserCommand.CHANGE_PASSWORD_SUCCESS"; |
| |
static const char PASSWORD_BLANK [] = | static const char PASSWORD_BLANK [] = |
"Password cannot be blank. Please re-enter your password."; | "Password cannot be blank. Please re-enter your password."; |
| |
static const char PASSWORD_BLANK_KEY [] = "Clients.cimuser.CIMUserCommand.PASSWORD_BLANK"; |
static const char PASSWORD_BLANK_KEY [] = |
|
"Clients.cimuser.CIMUserCommand.PASSWORD_BLANK"; |
| |
static const char NO_USERS_FOUND[] = | static const char NO_USERS_FOUND[] = |
"No users found for listing."; | "No users found for listing."; |
| |
static const char NO_USERS_FOUND_KEY[] = "Clients.cimuser.CIMUserCommand.NO_USERS_FOUND"; |
static const char NO_USERS_FOUND_KEY[] = |
|
"Clients.cimuser.CIMUserCommand.NO_USERS_FOUND"; |
| |
static const char AUTH_SCHEMA_NOT_LOADED [] = | static const char AUTH_SCHEMA_NOT_LOADED [] = |
"Please restore the internal repository on the CIM Server."; | "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 AUTH_SCHEMA_NOT_LOADED_KEY [] = |
|
"Clients.cimuser.CIMUserCommand.AUTH_SCHEMA_NOT_LOADED"; |
| |
static const char REQUIRED_ARGS_MISSING [] = | static const char REQUIRED_ARGS_MISSING [] = |
"Required arguments missing."; | "Required arguments missing."; |
| |
static const char REQUIRED_ARGS_MISSING_KEY [] = "Clients.cimuser.CIMUserCommand.REQUIRED_ARGS_MISSING"; |
static const char REQUIRED_ARGS_MISSING_KEY [] = |
|
"Clients.cimuser.CIMUserCommand.REQUIRED_ARGS_MISSING"; |
| |
static const char INVALID_ARGS [] = | static const char INVALID_ARGS [] = |
"Invalid arguments."; | "Invalid arguments."; |
| |
static const char INVALID_ARGS_KEY [] = "Clients.cimuser.CIMUserCommand.INVALID_ARGS"; |
static const char INVALID_ARGS_KEY [] = |
|
"Clients.cimuser.CIMUserCommand.INVALID_ARGS"; |
| |
static const char USER_ALREADY_EXISTS [] = | static const char USER_ALREADY_EXISTS [] = |
"Specified user name already exist."; | "Specified user name already exist."; |
| |
static const char USER_ALREADY_EXISTS_KEY [] = "Clients.cimuser.CIMUserCommand.USER_ALREADY_EXISTS"; |
static const char USER_ALREADY_EXISTS_KEY [] = |
|
"Clients.cimuser.CIMUserCommand.USER_ALREADY_EXISTS"; |
| |
static const char USER_NOT_FOUND [] = | static const char USER_NOT_FOUND [] = |
"Specified user name was not found."; | "Specified user name was not found."; |
| |
static const char USER_NOT_FOUND_KEY [] = "Clients.cimuser.CIMUserCommand.USER_NOT_FOUND"; |
static const char USER_NOT_FOUND_KEY [] = |
|
"Clients.cimuser.CIMUserCommand.USER_NOT_FOUND"; |
| |
static const char USERNAME_REQUIRED [] = | static const char USERNAME_REQUIRED [] = |
"User name is required."; | "User name is required."; |
| |
static const char USERNAME_REQUIRED_KEY [] = "Clients.cimuser.CIMUserCommand.USERNAME_REQUIRED"; |
static const char USERNAME_REQUIRED_KEY [] = |
|
"Clients.cimuser.CIMUserCommand.USERNAME_REQUIRED"; |
| |
/** | /** |
The option character used to specify add user. | The option character used to specify add user. |
|
|
options.parse (argc, argv); | options.parse (argc, argv); |
if (options.hasErrors ()) | if (options.hasErrors ()) |
{ | { |
CommandFormatException e (options.getErrorStrings () [0]); |
throw CommandFormatException(options.getErrorStrings()[0]); |
throw e; |
|
} | } |
_operationType = OPERATION_TYPE_UNINITIALIZED; | _operationType = OPERATION_TYPE_UNINITIALIZED; |
| |
|
|
// | // |
// More than one operation option was found | // More than one operation option was found |
// | // |
UnexpectedOptionException e (param); |
throw UnexpectedOptionException(param); |
throw e; |
|
} | } |
| |
_operationType = OPERATION_TYPE_HELP; | _operationType = OPERATION_TYPE_HELP; |
|
|
// | // |
// More than one operation option was found | // More than one operation option was found |
// | // |
UnexpectedOptionException e (param); |
throw UnexpectedOptionException(param); |
throw e; |
|
} | } |
| |
_operationType = OPERATION_TYPE_VERSION; | _operationType = OPERATION_TYPE_VERSION; |
|
|
// | // |
// The cimuser command has no non-option argument options | // The cimuser command has no non-option argument options |
// | // |
UnexpectedArgumentException e (options [i].Value ()); |
throw UnexpectedArgumentException(options[i].Value()); |
throw e; |
|
} | } |
else /* if (options [i].getType () == Optarg::FLAG) */ | else /* if (options [i].getType () == Optarg::FLAG) */ |
{ | { |
|
|
// | // |
// More than one operation option was found | // More than one operation option was found |
// | // |
UnexpectedOptionException e (OPTION_ADD); |
throw UnexpectedOptionException(OPTION_ADD); |
throw e; |
|
} | } |
| |
if (options.isSet (OPTION_ADD) > 1) | if (options.isSet (OPTION_ADD) > 1) |
|
|
// | // |
// More than one add user option was found | // More than one add user option was found |
// | // |
DuplicateOptionException e (OPTION_ADD); |
throw DuplicateOptionException(OPTION_ADD); |
throw e; |
|
} | } |
| |
_operationType = OPERATION_TYPE_ADD; | _operationType = OPERATION_TYPE_ADD; |
|
|
// | // |
// More than one operation option was found | // More than one operation option was found |
// | // |
UnexpectedOptionException e (OPTION_MODIFY); |
throw UnexpectedOptionException(OPTION_MODIFY); |
throw e; |
|
} | } |
| |
if (options.isSet (OPTION_MODIFY) > 1) | if (options.isSet (OPTION_MODIFY) > 1) |
|
|
// | // |
// More than one modify user option was found | // More than one modify user option was found |
// | // |
DuplicateOptionException e (OPTION_MODIFY); |
throw DuplicateOptionException(OPTION_MODIFY); |
throw e; |
|
} | } |
| |
_operationType = OPERATION_TYPE_MODIFY; | _operationType = OPERATION_TYPE_MODIFY; |
|
|
// | // |
// More than one username option was found | // More than one username option was found |
// | // |
DuplicateOptionException e (OPTION_USER_NAME); |
throw DuplicateOptionException(OPTION_USER_NAME); |
throw e; |
|
} | } |
| |
_userName = options [i].Value (); | _userName = options [i].Value (); |
|
|
// | // |
// More than one password option was found | // More than one password option was found |
// | // |
DuplicateOptionException e (OPTION_PASSWORD); |
throw DuplicateOptionException(OPTION_PASSWORD); |
throw e; |
|
} | } |
| |
String password = options [i].Value (); | String password = options [i].Value (); |
|
|
// | // |
// More than one new password option was found | // More than one new password option was found |
// | // |
DuplicateOptionException e (OPTION_NEW_PASSWORD); |
throw DuplicateOptionException(OPTION_NEW_PASSWORD); |
throw e; |
|
} | } |
| |
String newpassword = options [i].Value (); | String newpassword = options [i].Value (); |
|
|
// | // |
// More than one operation option was found | // More than one operation option was found |
// | // |
UnexpectedOptionException e (OPTION_REMOVE); |
throw UnexpectedOptionException(OPTION_REMOVE); |
throw e; |
|
} | } |
| |
if (options.isSet (OPTION_REMOVE) > 1) | if (options.isSet (OPTION_REMOVE) > 1) |
|
|
// | // |
// More than one remove user option was found | // More than one remove user option was found |
// | // |
DuplicateOptionException e (OPTION_REMOVE); |
throw DuplicateOptionException(OPTION_REMOVE); |
throw e; |
|
} | } |
| |
_operationType = OPERATION_TYPE_REMOVE; | _operationType = OPERATION_TYPE_REMOVE; |
|
|
// | // |
// More than one operation option was found | // More than one operation option was found |
// | // |
UnexpectedOptionException e (OPTION_LIST); |
throw UnexpectedOptionException(OPTION_LIST); |
throw e; |
|
} | } |
| |
if (options.isSet (OPTION_LIST) > 1) | if (options.isSet (OPTION_LIST) > 1) |
|
|
// | // |
// More than one list option was found | // More than one list option was found |
// | // |
DuplicateOptionException e (OPTION_LIST); |
throw DuplicateOptionException(OPTION_LIST); |
throw e; |
|
} | } |
_operationType = OPERATION_TYPE_LIST; | _operationType = OPERATION_TYPE_LIST; |
break; | break; |
|
|
// | // |
// More than one operation option was found | // More than one operation option was found |
// | // |
UnexpectedOptionException e (OPTION_HELP); |
throw UnexpectedOptionException(OPTION_HELP); |
throw e; |
|
} | } |
| |
if (options.isSet (OPTION_HELP) > 1) | if (options.isSet (OPTION_HELP) > 1) |
|
|
// | // |
// More than one list option was found | // More than one list option was found |
// | // |
DuplicateOptionException e (OPTION_HELP); |
throw DuplicateOptionException(OPTION_HELP); |
throw e; |
|
} | } |
_operationType = OPERATION_TYPE_HELP; | _operationType = OPERATION_TYPE_HELP; |
break; | break; |
|
|
// | // |
// More than one operation option was found | // More than one operation option was found |
// | // |
UnexpectedOptionException e (OPTION_VERSION); |
throw UnexpectedOptionException(OPTION_VERSION); |
throw e; |
|
} | } |
| |
if (options.isSet (OPTION_VERSION) > 1) | if (options.isSet (OPTION_VERSION) > 1) |
|
|
// | // |
// More than one list option was found | // More than one list option was found |
// | // |
DuplicateOptionException e (OPTION_VERSION); |
throw DuplicateOptionException(OPTION_VERSION); |
throw e; |
|
} | } |
_operationType = OPERATION_TYPE_VERSION; | _operationType = OPERATION_TYPE_VERSION; |
break; | break; |
|
|
// | // |
//l10n | //l10n |
//CommandFormatException e (REQUIRED_ARGS_MISSING); | //CommandFormatException e (REQUIRED_ARGS_MISSING); |
CommandFormatException e (localizeMessage(MSG_PATH,REQUIRED_ARGS_MISSING_KEY, REQUIRED_ARGS_MISSING)); |
throw CommandFormatException(localizeMessage( |
throw e; |
MSG_PATH, REQUIRED_ARGS_MISSING_KEY, REQUIRED_ARGS_MISSING)); |
} | } |
| |
if ( _operationType == OPERATION_TYPE_LIST && | if ( _operationType == OPERATION_TYPE_LIST && |
|
|
//l10n | //l10n |
MessageLoaderParms parms("Clients.cimuser.CIMUserCommand.UNEXPECTED_OPTION", | MessageLoaderParms parms("Clients.cimuser.CIMUserCommand.UNEXPECTED_OPTION", |
"Unexpected Option."); | "Unexpected Option."); |
CommandFormatException e(parms); |
|
//CommandFormatException e("Unexpected Option."); | //CommandFormatException e("Unexpected Option."); |
throw e; |
throw CommandFormatException(parms); |
} | } |
| |
if (_operationType == OPERATION_TYPE_ADD) | if (_operationType == OPERATION_TYPE_ADD) |
|
|
// | // |
// An invalid option was encountered | // An invalid option was encountered |
// | // |
UnexpectedOptionException e( OPTION_NEW_PASSWORD ); |
throw UnexpectedOptionException(OPTION_NEW_PASSWORD); |
throw e; |
|
} | } |
if ( !_userNameSet ) | if ( !_userNameSet ) |
{ | { |
// | // |
// An invalid option was encountered | // An invalid option was encountered |
// | // |
MissingOptionException e (OPTION_USER_NAME); |
throw MissingOptionException(OPTION_USER_NAME); |
throw e; |
|
} | } |
if ( !_passwordSet ) | if ( !_passwordSet ) |
{ | { |
|
|
// | // |
// An invalid option was encountered | // An invalid option was encountered |
// | // |
MissingOptionException e (OPTION_USER_NAME); |
throw MissingOptionException(OPTION_USER_NAME); |
throw e; |
|
} | } |
if ( _passwordSet && _newpasswordSet ) | if ( _passwordSet && _newpasswordSet ) |
{ | { |
|
|
// | // |
// An invalid option was encountered | // An invalid option was encountered |
// | // |
MissingOptionException e (OPTION_USER_NAME); |
throw MissingOptionException(OPTION_USER_NAME); |
throw e; |
|
} | } |
if ( _passwordSet ) | if ( _passwordSet ) |
{ | { |
// | // |
// An invalid option was encountered | // An invalid option was encountered |
// | // |
UnexpectedOptionException e ( OPTION_PASSWORD ); |
throw UnexpectedOptionException(OPTION_PASSWORD); |
throw e; |
|
} | } |
if ( _newpasswordSet ) | if ( _newpasswordSet ) |
{ | { |
// | // |
// An invalid option was encountered | // An invalid option was encountered |
// | // |
UnexpectedOptionException e ( OPTION_NEW_PASSWORD ); |
throw UnexpectedOptionException(OPTION_NEW_PASSWORD); |
throw e; |
|
} | } |
} | } |
} | } |
|
|
{ | { |
CIMProperty prop; | CIMProperty prop; |
| |
try |
|
{ |
|
CIMInstance newInstance( PEGASUS_CLASSNAME_USER ); | CIMInstance newInstance( PEGASUS_CLASSNAME_USER ); |
newInstance.addProperty ( | newInstance.addProperty ( |
CIMProperty( PROPERTY_NAME_USER_NAME, _userName ) ); | CIMProperty( PROPERTY_NAME_USER_NAME, _userName ) ); |
|
|
_client->createInstance( PEGASUS_NAMESPACENAME_USER, newInstance ); | _client->createInstance( PEGASUS_NAMESPACENAME_USER, newInstance ); |
//l10n | //l10n |
//outPrintWriter << ADD_USER_SUCCESS << endl; | //outPrintWriter << ADD_USER_SUCCESS << endl; |
outPrintWriter << localizeMessage(MSG_PATH,ADD_USER_SUCCESS_KEY,ADD_USER_SUCCESS) << endl; |
outPrintWriter << |
|
localizeMessage(MSG_PATH,ADD_USER_SUCCESS_KEY,ADD_USER_SUCCESS) << endl; |
} |
|
catch (Exception& e) |
|
{ |
|
throw e; |
|
} |
|
} | } |
| |
// | // |
|
|
ostream& errPrintWriter | ostream& errPrintWriter |
) | ) |
{ | { |
try |
|
{ |
|
Array<CIMKeyBinding> kbArray; | Array<CIMKeyBinding> kbArray; |
CIMKeyBinding kb; | CIMKeyBinding kb; |
Array<CIMParamValue> inParams; | Array<CIMParamValue> inParams; |
|
|
//outPrintWriter << CHANGE_PASSWORD_SUCCESS << endl; | //outPrintWriter << CHANGE_PASSWORD_SUCCESS << endl; |
outPrintWriter << localizeMessage(MSG_PATH,CHANGE_PASSWORD_SUCCESS_KEY,CHANGE_PASSWORD_SUCCESS) << endl; | outPrintWriter << localizeMessage(MSG_PATH,CHANGE_PASSWORD_SUCCESS_KEY,CHANGE_PASSWORD_SUCCESS) << endl; |
} | } |
catch (Exception& e) |
|
{ |
|
throw e; |
|
} |
|
} |
|
| |
// | // |
// Remove a user | // Remove a user |
|
|
ostream& errPrintWriter | ostream& errPrintWriter |
) | ) |
{ | { |
try |
|
{ |
|
Array<CIMKeyBinding> kbArray; | Array<CIMKeyBinding> kbArray; |
CIMKeyBinding kb; | CIMKeyBinding kb; |
| |
|
|
//outPrintWriter << REMOVE_USER_SUCCESS << endl; | //outPrintWriter << REMOVE_USER_SUCCESS << endl; |
outPrintWriter << localizeMessage(MSG_PATH,REMOVE_USER_SUCCESS_KEY,REMOVE_USER_SUCCESS) << endl; | outPrintWriter << localizeMessage(MSG_PATH,REMOVE_USER_SUCCESS_KEY,REMOVE_USER_SUCCESS) << endl; |
} | } |
catch (Exception& e) |
|
{ |
|
throw e; |
|
} |
|
} |
|
| |
| |
/** | /** |
|
|
ostream& errPrintWriter | ostream& errPrintWriter |
) | ) |
{ | { |
try |
|
{ |
|
// | // |
// get all the instances of class PG_User | // get all the instances of class PG_User |
// | // |
|
|
{ | { |
//l10n | //l10n |
//outPrintWriter << NO_USERS_FOUND << endl; | //outPrintWriter << NO_USERS_FOUND << endl; |
outPrintWriter << localizeMessage(MSG_PATH,NO_USERS_FOUND_KEY,NO_USERS_FOUND) << endl; |
outPrintWriter << |
|
localizeMessage(MSG_PATH,NO_USERS_FOUND_KEY,NO_USERS_FOUND) << |
|
endl; |
} | } |
else | else |
{ | { |
|
|
} | } |
} | } |
} | } |
catch (Exception& e) |
|
{ |
|
throw e; |
|
} |
|
} |
|
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |