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

📄 cimtrustcommand.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 4 页
字号:
        pos = certificateInstance.findProperty(PROPERTY_NAME_SUBJECTNAME);        prop = certificateInstance.getProperty(pos);        prop.getValue().get(subjectName);        if ( _issuerSet )        {            if (String::equal(_issuer, issuer))            {                if (_serialNumberSet &&                    !String::equal(_serialNumber, serialNumber))                {                    continue;                }                else if (_subjectSet &&                    !String::equal(_subject, subjectName))                {                    continue;                }                else                {                    issuerFound = true;                }            }            else            {                continue;            }        }        //        // Get the remaining properties and display them.        //        pos = certificateInstance.findProperty(                        PROPERTY_NAME_REGISTERED_USER_NAME);        prop = certificateInstance.getProperty(pos);        prop.getValue().get(registeredUserName);        pos = certificateInstance.findProperty(PROPERTY_NAME_NOTBEFORE);        prop = certificateInstance.getProperty(pos);        prop.getValue().get(notBefore);        String notBeforeStr = _formatCIMDateTime(notBefore.toString());        pos = certificateInstance.findProperty(PROPERTY_NAME_NOTAFTER);        prop = certificateInstance.getProperty(pos);        prop.getValue().get(notAfter);        String notAfterStr = _formatCIMDateTime(notAfter.toString());        pos = certificateInstance.findProperty(PROPERTY_NAME_TYPE);        prop = certificateInstance.getProperty(pos);        prop.getValue().get(type);        if (type == _CERTIFICATE_TYPE_AUTHORITY)        {            typeStr = TYPE_AUTHORITY_STR;        }        else if ( type == _CERTIFICATE_TYPE_AUTHORITY_END_ENTITY )        {            typeStr = TYPE_AUTHORITY_END_ENTITY_STR;        }        else if ( type == _CERTIFICATE_TYPE_SELF_SIGNED_IDENTITY )        {            typeStr = TYPE_SELF_SIGNED_IDENTITY_STR;        }        else if ( type == _CERTIFICATE_TYPE_UNKNOWN )        {            typeStr = TYPE_UNKNOWN;        }        //        // Display the certificate content        //        outPrintWriter << "Issuer: " << issuer << endl;        outPrintWriter << "Serial Number: " << serialNumber << endl;        outPrintWriter << "Subject: " << subjectName << endl;        outPrintWriter << "Registered User Name: "                        << registeredUserName << endl;        outPrintWriter << "Type: "                        << typeStr << endl;        outPrintWriter << "Validity:" << endl;        outPrintWriter << "    NotBefore: " << notBeforeStr << endl;        outPrintWriter << "    NotAfter : " << notAfterStr << endl ;        outPrintWriter <<            "---------------------------------------------"<< endl;    }    if ( _issuerSet && !issuerFound)    {         CIMException ce(CIM_ERR_NOT_FOUND);         throw ce;    }}/**    Parses the command line, validates the options, and sets instance    variables based on the option arguments.    @param   argc  the number of command line arguments    @param   argv  the string vector of command line arguments    @exception  CommandFormatException  if an error is encountered in parsing                                        the command line */void CIMTrustCommand::setCommand (Uint32 argc, char* argv []){    Uint32         i               = 0;    Uint32         c               = 0;    String         timeoutStr;    String         serialNumberStr;    String         optString;    getoopt        getOpts;    //    //  Construct optString    //    optString.append (_OPTION_ADD);    optString.append (getoopt::NOARG);    optString.append (_OPTION_CERTFILE);    optString.append (getoopt::GETOPT_ARGUMENT_DESIGNATOR);    optString.append (_OPTION_CERTUSER);    optString.append (getoopt::GETOPT_ARGUMENT_DESIGNATOR);    optString.append (_OPTION_TYPE);    optString.append (getoopt::GETOPT_ARGUMENT_DESIGNATOR);    optString.append (_OPTION_REMOVE);    optString.append (getoopt::NOARG);    optString.append (_OPTION_ISSUER);    optString.append (getoopt::GETOPT_ARGUMENT_DESIGNATOR);    optString.append (_OPTION_SERIALNUMBER);    optString.append (getoopt::GETOPT_ARGUMENT_DESIGNATOR);    optString.append (_OPTION_SUBJECT);    optString.append (getoopt::GETOPT_ARGUMENT_DESIGNATOR);    optString.append (_OPTION_LIST);    optString.append (getoopt::NOARG);    optString.append (_OPTION_ISSUER);    optString.append (getoopt::GETOPT_ARGUMENT_DESIGNATOR);    optString.append (_OPTION_SERIALNUMBER);    optString.append (getoopt::GETOPT_ARGUMENT_DESIGNATOR);    optString.append (_OPTION_SUBJECT);    optString.append (getoopt::GETOPT_ARGUMENT_DESIGNATOR);    //    //  Initialize and parse getOpts    //    getOpts = getoopt ();    getOpts.addFlagspec (optString);    //    // Add long flag options for 'help' and 'version'    //    getOpts.addLongFlagspec (LONG_HELP, getoopt::NOARG);    getOpts.addLongFlagspec (LONG_VERSION, getoopt::NOARG);    getOpts.parse (argc, argv);    if (getOpts.hasErrors ())    {        CommandFormatException e (getOpts.getErrorStrings () [0]);        throw e;    }    _operationType = _OPERATION_TYPE_UNINITIALIZED;    //    //  Get options and arguments from the command line    //    for (i =  getOpts.first (); i <  getOpts.last (); i++)    {        if (getOpts [i].getType () == Optarg::LONGFLAG)        {            if (getOpts [i].getopt () == LONG_HELP)            {                if (_operationType != _OPERATION_TYPE_UNINITIALIZED)                {                    String param = String (LONG_HELP);                    //                    // More than one operation option was found                    //                    UnexpectedOptionException e (param);                    throw e;                }                _operationType = _OPERATION_TYPE_HELP;            }            else if (getOpts [i].getopt () == LONG_VERSION)            {                if (_operationType != _OPERATION_TYPE_UNINITIALIZED)                {                    String param = String (LONG_VERSION);                    //                    // More than one operation option was found                    //                    UnexpectedOptionException e (param);                    throw e;                }               _operationType = _OPERATION_TYPE_VERSION;            }        }        else if (getOpts [i].getType () == Optarg::REGULAR)        {            //            //  The cimtrust command has no non-option argument options            //            UnexpectedArgumentException e (getOpts [i].Value ());            throw e;        }        else /* getOpts [i].getType () == FLAG */        {            c = getOpts [i].getopt () [0];            switch (c)            {                case _OPTION_ADD:                {                    if (_operationType != _OPERATION_TYPE_UNINITIALIZED)                    {                        //                        // More than one operation option was found                        //                        UnexpectedOptionException e (_OPTION_ADD);                        throw e;                    }                    if (getOpts.isSet (_OPTION_ADD) > 1)                    {                        //                        // More than one add option was found                        //                        DuplicateOptionException e (_OPTION_ADD);                        throw e;                    }                    _operationType = _OPERATION_TYPE_ADD;                    break;                }                case _OPTION_REMOVE:                {                    if (_operationType != _OPERATION_TYPE_UNINITIALIZED)                    {                        //                        // More than one operation option was found                        //                        UnexpectedOptionException e (_OPTION_REMOVE);                        throw e;                    }                    if (getOpts.isSet (_OPTION_REMOVE) > 1)                    {                        //                        // More than one remove option was found                        //                        DuplicateOptionException e (_OPTION_REMOVE);                        throw e;                    }                    _operationType = _OPERATION_TYPE_REMOVE;                    break;                }                case _OPTION_LIST:                {                    if (_operationType != _OPERATION_TYPE_UNINITIALIZED)                    {                        //                        // More than one operation option was found                        //                        UnexpectedOptionException e (_OPTION_LIST);                        throw e;                    }                    if (getOpts.isSet (_OPTION_LIST) > 1)                    {                        //                        // More than one list option was found                        //                        DuplicateOptionException e (_OPTION_LIST);                        throw e;                    }                    _operationType = _OPERATION_TYPE_LIST;                    break;                }                case _OPTION_CERTUSER:                {                    if (getOpts.isSet (_OPTION_CERTUSER) > 1)                    {                        //                        // More than one certificate user option was found                        //                        DuplicateOptionException e (_OPTION_CERTUSER);                        throw e;                    }                    _certUser = getOpts [i].Value ();                    _certUserSet = true;                    break;                }                case _OPTION_CERTFILE:                {                    if (getOpts.isSet (_OPTION_CERTFILE) > 1)                    {                        //                        // More than one cert file option was found                        //                        DuplicateOptionException e (_OPTION_CERTFILE);                        throw e;                    }                    _certFile = getOpts [i].Value ();                    _certFileSet = true;                    break;                }                case _OPTION_ISSUER:                {                    if (getOpts.isSet (_OPTION_ISSUER) > 1)                    {                        //                        // More than one issuer name option was found                        //                        DuplicateOptionException e (_OPTION_ISSUER);                        throw e;                    }                    _issuer = getOpts [i].Value ();                    _issuerSet = true;                    break;                }                case _OPTION_TYPE:                {                    if (getOpts.isSet (_OPTION_TYPE) > 1)                    {                        //                        // More than one type option was found                        //                        DuplicateOptionException e (_OPTION_TYPE);                        throw e;                    }                    _type = getOpts [i].Value ();                    _typeSet = true;                    break;                }                case _OPTION_SERIALNUMBER:                {                    if (getOpts.isSet (_OPTION_SERIALNUMBER) > 1)                    {                        //                        // More than one serial number option was found                        //                        DuplicateOptionException e (_OPTION_SERIALNUMBER);                        throw e;                    }                    if (_subjectSet)                    {                        //                        // Both the subject and serial number may not be specified.                        //                         UnexpectedOptionException e (_OPTION_SERIALNUMBER);                        throw e;                    }                    _serialNumber = getOpts [i].Value ();                    _serialNumberSet = true;                    break;                }                case _OPTION_SUBJECT:                {                    if (getOpts.isSet (_OPTION_SUBJECT) > 1)                    {                        //                        // More than one subject option was found                        //                        DuplicateOptionException e (_OPTION_SUBJECT);                        throw e;                    }                    if (_serialNumberSet)                    {                        // Both the subject and serial number may not be specified.                        UnexpectedOptionException e (_OPTION_SUBJECT);                        throw e;                    }                    _subject = getOpts [i].Value ();                    _subjectSet = true;                    break;                }                default:                {                    //                    //  This path should not be hit                    //                    break;                }            }        }    }    if ( _operationType == _OPERATION_TYPE_UNINITIALIZED )    {        //        // No operation type was specified        // Show the usage        //        CommandFormatException e ( localizeMessage ( MSG_PATH,            REQUIRED_ARGS_MISSING_KEY, REQUIRED_ARGS_MISSING ) );        throw e;

⌨️ 快捷键说明

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