From 243fee8117a05e1088833e49f6dfe3a17f7f9061 Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Tue, 11 Sep 2007 18:39:57 +0000 Subject: [PATCH] Init logging. --- samlsign/samlsign.cpp | 57 ++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/samlsign/samlsign.cpp b/samlsign/samlsign.cpp index d20f256..04ceb52 100644 --- a/samlsign/samlsign.cpp +++ b/samlsign/samlsign.cpp @@ -181,11 +181,12 @@ int main(int argc,char* argv[]) cerr << "either -k or -R option required when signing, see documentation for usage" << endl; return -1; } - + + XMLToolingConfig& xmlconf = XMLToolingConfig::getConfig(); + xmlconf.log_config(); SAMLConfig& conf=SAMLConfig::getConfig(); if (!conf.init()) return -2; - XMLToolingConfig& xmlconf = XMLToolingConfig::getConfig(); Category& log = Category::getInstance("OpenSAML.Utility.SAMLSign"); int ret = 0; @@ -279,34 +280,34 @@ int main(int argc,char* argv[]) auto_ptr trust(buildPlugin(t_param, xmlconf.TrustEngineManager)); SignatureTrustEngine* sigtrust = dynamic_cast(trust.get()); if (m_param && rname && issuer) { - if (!protocol) { - if (prot) - protocol = XMLString::transcode(prot); - } - if (!protocol) { - conf.term(); - cerr << "use of metadata option requires a protocol option" << endl; - return -1; - } + if (!protocol) { + if (prot) + protocol = XMLString::transcode(prot); + } + if (!protocol) { + conf.term(); + cerr << "use of metadata option requires a protocol option" << endl; + return -1; + } auto_ptr metadata(buildPlugin(m_param, conf.MetadataProviderManager)); metadata->init(); Locker locker(metadata.get()); - const EntityDescriptor* entity = metadata->getEntityDescriptor(issuer); - if (!entity) - throw MetadataException("no metadata found for ($1)", params(1, issuer)); - const XMLCh* ns = rns ? XMLString::transcode(rns) : samlconstants::SAML20MD_NS; - auto_ptr_XMLCh n(rname); - QName q(ns, n.get()); - const RoleDescriptor* role = entity->getRoleDescriptor(q, protocol); - if (!role) - throw MetadataException("compatible role $1 not found for ($2)", params(2, q.toString().c_str(), issuer)); - - MetadataCredentialCriteria mcc(*role); - if (sigtrust->validate(*signable->getSignature(), *metadata.get(), &mcc)) + const EntityDescriptor* entity = metadata->getEntityDescriptor(issuer); + if (!entity) + throw MetadataException("no metadata found for ($1)", params(1, issuer)); + const XMLCh* ns = rns ? XMLString::transcode(rns) : samlconstants::SAML20MD_NS; + auto_ptr_XMLCh n(rname); + QName q(ns, n.get()); + const RoleDescriptor* role = entity->getRoleDescriptor(q, protocol); + if (!role) + throw MetadataException("compatible role $1 not found for ($2)", params(2, q.toString().c_str(), issuer)); + + MetadataCredentialCriteria mcc(*role); + if (sigtrust->validate(*signable->getSignature(), *metadata.get(), &mcc)) log.info("successful signature verification"); - else - throw SignatureException("Unable to verify signature with TrustEngine and supplied metadata."); + else + throw SignatureException("Unable to verify signature with TrustEngine and supplied metadata."); } else { // Set up criteria. @@ -316,10 +317,10 @@ int main(int argc,char* argv[]) if (issuer) cc.setPeerName(issuer); DummyCredentialResolver dummy; - if (sigtrust->validate(*signable->getSignature(), dummy, &cc)) + if (sigtrust->validate(*signable->getSignature(), dummy, &cc)) log.info("successful signature verification"); - else - throw SignatureException("Unable to verify signature with TrustEngine (no metadata supplied)."); + else + throw SignatureException("Unable to verify signature with TrustEngine (no metadata supplied)."); } } } -- 2.1.4