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

📄 cimcrlcommand.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 3 页
字号:
//%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.////==============================================================================////%/////////////////////////////////////////////////////////////////////////////// define asprintf used to implement ultostr on Linux#if defined(PEGASUS_LINUX_GENERIC_GNU)#define _GNU_SOURCE#include <features.h>#include <stdio.h>#endif#include <iostream>#include <Pegasus/Common/Config.h>#include <Pegasus/Common/Constants.h>#include <Pegasus/Common/System.h>#include <Pegasus/Common/FileSystem.h>#include <Pegasus/Common/String.h>#include <Pegasus/Common/InternalException.h>#include <Pegasus/Common/PegasusVersion.h>#include <Pegasus/getoopt/getoopt.h>#include "CIMCRLCommand.h"PEGASUS_NAMESPACE_BEGIN/** * The CLI message resource name */static const char MSG_PATH []                  = "pegasus/pegasusCLI";/**    The command name. */const char   CIMCRLCommand::COMMAND_NAME []      = "cimcrl";/**    Label for the usage string for this command. */const char   CIMCRLCommand::_USAGE []            = "Usage: ";/**    The option character used to specify add CRL.*/const char   CIMCRLCommand::_OPTION_ADD          = 'a';/**    The option character used to specify remove CRL.*/const char   CIMCRLCommand::_OPTION_REMOVE       = 'r';/**    The option character used to specify list CRLs.*/const char   CIMCRLCommand::_OPTION_LIST         = 'l';/**    The option character used to specify a CRL file path. */const char   CIMCRLCommand::_OPTION_CRLFILE     = 'f';/**    The option character used to specify the issuer name. */const char   CIMCRLCommand::_OPTION_ISSUERNAME   = 'i';static const char   LONG_HELP []  = "help";static const char   LONG_VERSION []  = "version";/**    This constant signifies that an operation option has not    been recorded*/const Uint32 CIMCRLCommand::_OPERATION_TYPE_UNINITIALIZED = 0;/**    The constant representing an add operation*/const Uint32 CIMCRLCommand::_OPERATION_TYPE_ADD = 1;/**    The constant representing a remove operation*/const Uint32 CIMCRLCommand::_OPERATION_TYPE_REMOVE = 2;/**    The constant representing a list operation*/const Uint32 CIMCRLCommand::_OPERATION_TYPE_LIST = 3;/**    The constant representing a help operation*/const Uint32 CIMCRLCommand::_OPERATION_TYPE_HELP = 4;/**    The constant representing a version display operation*/const Uint32 CIMCRLCommand::_OPERATION_TYPE_VERSION = 5;/**    This constant represents the name of the Issuer name    property in the schema*/static const CIMName PROPERTY_NAME_ISSUERNAME = CIMName ("IssuerName");/**    This constant represents the name of the lastUpdate     property in the schema*/static const CIMName PROPERTY_NAME_LASTUPDATE   = CIMName ("LastUpdate");/**    This constant represents the name of the nextUpdate     property in the schema*/static const CIMName PROPERTY_NAME_NEXTUPDATE   = CIMName ("NextUpdate");/**    This constant represents the name of the revokedSerialNumbers     property in the schema*/static const CIMName PROPERTY_NAME_REVOKED_SERIAL_NUMBERS =                                      CIMName ("RevokedSerialNumbers");/**    This constant represents the name of the revocationDates     property in the schema*/static const CIMName PROPERTY_NAME_REVOCATION_DATES =                                      CIMName ("RevocationDates");/**    The name of the Method that implements add revoked certificate to    the CRL store.*/static const CIMName ADD_CRL_METHOD = CIMName ("addCertificateRevocationList");/**    The input parameter name for CRL content.*/static const char   CRL_CONTENTS []     = "CRLContents";/**    The constants representing the display messages.*/static const char REQUIRED_ARGS_MISSING [] =                "Required arguments missing.";static const char REQUIRED_ARGS_MISSING_KEY [] =                "Clients.cimcrl.CIMCRLCommand.REQUIRED_ARGS_MISSING";static const char CANNOT_CONNECT_CIMSERVER_NOT_RUNNING [] =                "Cannot connect to CIM Server, CIM Server may not be running.";static const char CANNOT_CONNECT_CIMSERVER_NOT_RUNNING_KEY [] =            "Clients.cimcrl.CIMCRLCommand.CANNOT_CONNECT_CIMSERVER_NOT_RUNNING";static const char CONNECTION_TIMEOUT [] =                "Connection timed out.";static const char CONNECTION_TIMEOUT_KEY [] =                "Clients.cimcrl.CIMCRLCommand._CONNECTION_TIMEOUT";static const char ADD_CRL_SUCCESS [] =                "CRL added successfully.";static const char ADD_CRL_SUCCESS_KEY [] =                "Clients.cimcrl.CIMCRLCommand.ADD_CRL_SUCCESS";static const char REMOVE_CRL_SUCCESS [] =                "CRL removed successfully.";static const char REMOVE_CRL_SUCCESS_KEY [] =                "Clients.cimcrl.CIMCRLCommand.REMOVE_CRL_SUCCESS";static const char CRL_NOT_FOUND [] =                "Specified CRL does not exist.";static const char CRL_NOT_FOUND_KEY [] =                "Clients.cimcrl.CIMCRLCommand.CRL_NOT_FOUND";static const char CERT_SCHEMA_NOT_LOADED []  =                "Please restore the internal repository on the CIM Server.";static const char CERT_SCHEMA_NOT_LOADED_KEY []  =                "Clients.cimcrl.CIMCRLCommand.CERT_SCHEMA_NOT_LOADED";// Return codesstatic const Uint32 RC_CONNECTION_FAILED = 2;static const Uint32 RC_CONNECTION_TIMEOUT = 3;static const Uint32 RC_CRL_DOES_NOT_EXIST = 4;/**    Constructs a CIMCRLCommand and initializes instance variables. */CIMCRLCommand::CIMCRLCommand (){    //    // Initialize the instance variables.    //    _operationType       = _OPERATION_TYPE_UNINITIALIZED;    _crlFileSet          = false;    _issuerSet           = false;;    _timeout             = DEFAULT_TIMEOUT_MILLISECONDS;    //    // build Usage string.    //    _usage = String (_USAGE);    _usage.append (COMMAND_NAME);    //    // Add option     //    _usage.append (" -").append (_OPTION_ADD);    _usage.append (" -").append (_OPTION_CRLFILE).append (" crlfile");    _usage.append ("\n");    //    // Remove option     //    //_usage.append ("                   -").append (_OPTION_REMOVE);    _usage.append("       ").append (COMMAND_NAME);    _usage.append (" -").append (_OPTION_REMOVE);    _usage.append (" -").append (_OPTION_ISSUERNAME).append (" issuername");    _usage.append ("\n");    //    // List option    //    //_usage.append ("                   -").append (_OPTION_LIST);    _usage.append("       ").append (COMMAND_NAME);    _usage.append (" -").append (_OPTION_LIST);    _usage.append (" [ -").append (_OPTION_ISSUERNAME);    _usage.append (" issuername").append (" ]");    _usage.append ("\n");    //    // Version options    //    _usage.append("       ").append (COMMAND_NAME);    _usage.append (" --").append (LONG_VERSION)         .append("\n");    //    // Help option    //    _usage.append("       ").append (COMMAND_NAME);    _usage.append (" --").append (LONG_HELP)         .append("\n");    //    // Options description    //    _usage.append("Options : \n");    _usage.append("    -a              ");    _usage.append("- Adds the specified crl to the CRL store\n");    _usage.append("    -r              ");    _usage.append("- Removes the specified crl from the CRL store\n");    _usage.append("    -l              ");    _usage.append("- Displays the crls in the CRL store\n");    _usage.append("    -f crlfile      ");    _usage.append("- Specifies the PEM format file containing ");    _usage.append("an X509 CRL\n");    _usage.append("    -i issuername   ");    _usage.append("- Specifies the CRL issuer name\n");    _usage.append("    --help          - Displays this help message\n");    _usage.append("    --version       - Displays CIM Server version number\n");    _usage.append("\nUsage note: The cimcrl command requires that ");    _usage.append("the CIM Server is running.\n");#ifdef PEGASUS_HAS_ICU    MessageLoaderParms menuparms(        "Clients.cimcrl.CIMCRLCommand.MENU.STANDARD", _usage);    menuparms.msg_src_path = MSG_PATH;    _usage = MessageLoader::getMessage(menuparms);#endif    setUsage (_usage);}/**    Convert CIMDateTime to user-readable string of the format    month day-of-month, year  hour:minute:second (value-hrs-GMT-offset)    @param  cimDateTimeStr  CIM formated DateTime String    @return  String user-readable date time string. */String CIMCRLCommand::_formatCIMDateTime(const String& cimDateTimeStr){    Uint32 year = 0;    Uint32 month = 0;    Uint32 day = 0;    Uint32 hour = 0;    Uint32 minute = 0;    Uint32 second = 0;    Uint32 microsecond = 0;    Uint32 timezone = 0;    sscanf(cimDateTimeStr.getCString(), "%04d%02d%02d%02d%02d%02d.%06d%04d",           &year, &month, &day, &hour, &minute, &second,           &microsecond, &timezone);     char monthString[5];    switch (month)    {       case 1 :           sprintf(monthString, "Jan");           break;       case 2 :           sprintf(monthString, "Feb");           break;       case 3 :           sprintf(monthString, "Mar");           break;      case 4 :          sprintf(monthString, "Apr");          break;      case 5 :          sprintf(monthString, "May");          break;      case 6 :          sprintf(monthString, "Jun");          break;      case 7 :          sprintf(monthString, "Jul");          break;      case 8 :          sprintf(monthString, "Aug");          break;      case 9 :          sprintf(monthString, "Sep");          break;

⌨️ 快捷键说明

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