in xsec/tools/xklient/xklient.cpp [4500:4620]
int doMsgDump(int argc, char ** argv, int paramCount) {
char * inputFile = NULL;
bool doValidate = false;
if (paramCount >= argc ||
(_stricmp(argv[paramCount], "--help") == 0) ||
(_stricmp(argv[paramCount], "-h") == 0)) {
printMsgDumpUsage();
return -1;
}
while (paramCount < argc-1) {
if ((_stricmp(argv[paramCount], "--validate") == 0) ||
(_stricmp(argv[paramCount], "-v") == 0)) {
doValidate = true;
paramCount++;
}
else if ((_stricmp(argv[paramCount], "--auth-phrase") == 0) ||
(_stricmp(argv[paramCount], "-a") == 0)) {
paramCount++;
g_authPassPhrase = argv[paramCount];
paramCount++;
}
#if defined (XSEC_HAVE_OPENSSL)
else if (_stricmp(argv[paramCount], "--output-private-key") == 0 || _stricmp(argv[paramCount], "-p") == 0) {
if (paramCount >= argc + 2) {
printMsgDumpUsage();
return -1;
}
++paramCount;
g_privateKeyFile = argv[paramCount++];
g_privateKeyPassPhrase = argv[paramCount++];
}
#endif
else {
printMsgDumpUsage();
return -1;
}
}
if (paramCount >= argc) {
printMsgDumpUsage();
return -1;
}
inputFile = argv[paramCount];
// Dump the details of an XKMS message to the console
cout << "Decoding XKMS Message contained in " << inputFile << endl;
// Create and set up the parser
XercesDOMParser * parser = new XercesDOMParser;
Janitor<XercesDOMParser> j_parser(parser);
parser->setDoNamespaces(true);
parser->setCreateEntityReferenceNodes(true);
// Error handling
xkmsErrorHandler xeh;
parser->setErrorHandler(&xeh);
#if 0
// Local load of XMLSchema.dtd
XMLSchemaDTDResolver sdr;
parser->setEntityResolver(&sdr);
#endif
// Schema handling
if (doValidate) {
parser->setDoSchema(true);
parser->setExternalSchemaLocation("http://www.w3.org/2002/03/xkms# http://www.w3.org/TR/xkms2/Schemas/xkms.xsd");
}
bool errorsOccured = false;
XMLSize_t errorCount = 0;
try
{
parser->parse(inputFile);
errorCount = parser->getErrorCount();
}
catch (const XMLException& e)
{
char * msg = XMLString::transcode(e.getMessage());
cerr << "An error occurred during parsing\n Message: "
<< msg << endl;
XSEC_RELEASE_XMLCH(msg);
errorsOccured = true;
}
catch (const DOMException& e)
{
cerr << "A DOM error occurred during parsing\n DOMException code: "
<< e.code << endl;
errorsOccured = true;
}
if (errorCount > 0 || errorsOccured) {
cout << "Errors during parse" << endl;
return (2);
}
/*
Now that we have the parsed file, get the DOM document and start looking at it
*/
DOMDocument *doc = parser->getDocument();
return doParsedMsgDump(doc);
}