From: Scott Cantor Date: Thu, 13 Sep 2007 18:58:53 +0000 (+0000) Subject: Update version resources. X-Git-Tag: 2.0-beta1~13 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-sp.git;a=commitdiff_plain;h=54b9f408e2bb43ecc6e5f1c157b1ddc4f5745a76 Update version resources. --- diff --git a/adfs/adfs-lite.vcproj b/adfs/adfs-lite.vcproj index e2e4f18..175e433 100644 --- a/adfs/adfs-lite.vcproj +++ b/adfs/adfs-lite.vcproj @@ -56,6 +56,7 @@ /> -#include -#include -#include +/* + * Copyright 2001-2007 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * resolvertest.cpp + * + * Tool to exercise SP attribute subsystems. + */ + +#if defined (_MSC_VER) || defined(__BORLANDC__) +# include "config_win32.h" +#else +# include "config.h" +#endif + +#ifdef WIN32 +# define _CRT_NONSTDC_NO_DEPRECATE 1 +# define _CRT_SECURE_NO_DEPRECATE 1 +#endif + +#include +#include +#include +#include #include #include #include -#include - -#include -#include -#include -#include -#include -#include - -using namespace shibsp; -using namespace opensaml::saml2md; -using namespace opensaml; -using namespace xmltooling::logging; -using namespace xmltooling; -using namespace xercesc; -using namespace std; - +#include + +#include +#include +#include +#include +#include +#include + +using namespace shibsp; +using namespace opensaml::saml2md; +using namespace opensaml; +using namespace xmltooling::logging; +using namespace xmltooling; +using namespace xercesc; +using namespace std; + #if defined (_MSC_VER) #pragma warning( push ) #pragma warning( disable : 4250 ) #endif - + class ResolverTest : public shibsp::AssertionConsumerService { public: @@ -94,233 +94,233 @@ private: throw FatalProfileException("Should never be called."); } }; - + #if defined (_MSC_VER) #pragma warning( pop ) #endif - -void usage() -{ - cerr << "usage: resolvertest -n -i -p [-f -a ]" << endl; - cerr << " resolvertest [-a ] < assertion.xml" << endl; -} - -int main(int argc,char* argv[]) -{ - char* a_param=NULL; - char* n_param=NULL; - char* f_param=NULL; - char* i_param=NULL; - char* prot = NULL; - const XMLCh* protocol = NULL; - char* path=NULL; - char* config=NULL; - - for (int i=1; i docjanitor(dummydoc); - xercesc::DOMElement* dummy = dummydoc->createElementNS(NULL,path); - auto_ptr_XMLCh src(config); - dummy->setAttributeNS(NULL,path,src.get()); - dummy->setAttributeNS(NULL,validate,xmlconstants::XML_ONE); - - conf.setServiceProvider(conf.ServiceProviderManager.newPlugin(XML_SERVICE_PROVIDER,dummy)); - conf.getServiceProvider()->init(); - } - catch (exception&) { - conf.term(); - return -2; - } - - ServiceProvider* sp=conf.getServiceProvider(); - sp->lock(); - - Category& log = Category::getInstance(SHIBSP_LOGCAT".Utility.ResolverTest"); - - const Application* app = sp->getApplication(a_param); - if (!app) { - log.error("unknown application ID (%s)", a_param); - sp->unlock(); - conf.term(); - return -3; - } - - try { - ResolutionContext* ctx; - - if (n_param) { - auto_ptr_XMLCh issuer(i_param); - auto_ptr_XMLCh name(n_param); - auto_ptr_XMLCh format(f_param); - - MetadataProvider* m=app->getMetadataProvider(); - xmltooling::Locker mlocker(m); - const EntityDescriptor* site=m->getEntityDescriptor(issuer.get()); - if (!site) - throw MetadataException("Unable to locate metadata for IdP ($1).", params(1,i_param)); - - // Build NameID(s). - auto_ptr v2name(saml2::NameIDBuilder::buildNameID()); + +void usage() +{ + cerr << "usage: resolvertest -n -i -p [-f -a ]" << endl; + cerr << " resolvertest [-a ] < assertion.xml" << endl; +} + +int main(int argc,char* argv[]) +{ + char* a_param=NULL; + char* n_param=NULL; + char* f_param=NULL; + char* i_param=NULL; + char* prot = NULL; + const XMLCh* protocol = NULL; + char* path=NULL; + char* config=NULL; + + for (int i=1; i docjanitor(dummydoc); + xercesc::DOMElement* dummy = dummydoc->createElementNS(NULL,path); + auto_ptr_XMLCh src(config); + dummy->setAttributeNS(NULL,path,src.get()); + dummy->setAttributeNS(NULL,validate,xmlconstants::XML_ONE); + + conf.setServiceProvider(conf.ServiceProviderManager.newPlugin(XML_SERVICE_PROVIDER,dummy)); + conf.getServiceProvider()->init(); + } + catch (exception&) { + conf.term(); + return -2; + } + + ServiceProvider* sp=conf.getServiceProvider(); + sp->lock(); + + Category& log = Category::getInstance(SHIBSP_LOGCAT".Utility.ResolverTest"); + + const Application* app = sp->getApplication(a_param); + if (!app) { + log.error("unknown application ID (%s)", a_param); + sp->unlock(); + conf.term(); + return -3; + } + + try { + ResolutionContext* ctx; + + if (n_param) { + auto_ptr_XMLCh issuer(i_param); + auto_ptr_XMLCh name(n_param); + auto_ptr_XMLCh format(f_param); + + MetadataProvider* m=app->getMetadataProvider(); + xmltooling::Locker mlocker(m); + const EntityDescriptor* site=m->getEntityDescriptor(issuer.get()); + if (!site) + throw MetadataException("Unable to locate metadata for IdP ($1).", params(1,i_param)); + + // Build NameID(s). + auto_ptr v2name(saml2::NameIDBuilder::buildNameID()); v2name->setName(name.get()); v2name->setFormat(format.get()); - saml1::NameIdentifier* v1name = NULL; + saml1::NameIdentifier* v1name = NULL; if (!XMLString::equals(protocol, samlconstants::SAML20P_NS)) { v1name = saml1::NameIdentifierBuilder::buildNameIdentifier(); v1name->setName(name.get()); v1name->setFormat(format.get()); v1name->setNameQualifier(issuer.get()); } - - ResolverTest rt(NULL, a_param); - try { - ctx = rt.resolveAttributes(*app, site->getIDPSSODescriptor(protocol), protocol, v1name, v2name.get(), NULL, NULL, NULL); - } - catch (...) { - delete v1name; - throw; - } - } - else { - // Try and load assertion from stdin. - DOMDocument* doc = XMLToolingConfig::getConfig().getParser().parse(cin); - XercesJanitor docjan(doc); - auto_ptr token(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(), true)); - docjan.release(); - - // Get the issuer and protocol and NameIDs. - const XMLCh* issuer = NULL; - const saml1::NameIdentifier* v1name = NULL; - saml2::NameID* v2name = NULL; - saml2::Assertion* a2 = dynamic_cast(token.get()); - saml1::Assertion* a1 = dynamic_cast(token.get()); - if (a2) { - const saml2::Issuer* iss = a2->getIssuer(); - issuer = iss ? iss->getName() : NULL; - protocol = samlconstants::SAML20P_NS; - v2name = a2->getSubject() ? a2->getSubject()->getNameID() : NULL; - } - else if (a1) { - issuer = a1->getIssuer(); - if (a1->getMinorVersion().first && a1->getMinorVersion().second == 0) - protocol = samlconstants::SAML10_PROTOCOL_ENUM; - else - protocol = samlconstants::SAML11_PROTOCOL_ENUM; - v1name = a1->getAuthenticationStatements().size() ? - a1->getAuthenticationStatements().front()->getSubject()->getNameIdentifier() : NULL; + + ResolverTest rt(NULL, a_param); + try { + ctx = rt.resolveAttributes(*app, site->getIDPSSODescriptor(protocol), protocol, v1name, v2name.get(), NULL, NULL, NULL); + } + catch (...) { + delete v1name; + throw; + } + } + else { + // Try and load assertion from stdin. + DOMDocument* doc = XMLToolingConfig::getConfig().getParser().parse(cin); + XercesJanitor docjan(doc); + auto_ptr token(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(), true)); + docjan.release(); + + // Get the issuer and protocol and NameIDs. + const XMLCh* issuer = NULL; + const saml1::NameIdentifier* v1name = NULL; + saml2::NameID* v2name = NULL; + saml2::Assertion* a2 = dynamic_cast(token.get()); + saml1::Assertion* a1 = dynamic_cast(token.get()); + if (a2) { + const saml2::Issuer* iss = a2->getIssuer(); + issuer = iss ? iss->getName() : NULL; + protocol = samlconstants::SAML20P_NS; + v2name = a2->getSubject() ? a2->getSubject()->getNameID() : NULL; + } + else if (a1) { + issuer = a1->getIssuer(); + if (a1->getMinorVersion().first && a1->getMinorVersion().second == 0) + protocol = samlconstants::SAML10_PROTOCOL_ENUM; + else + protocol = samlconstants::SAML11_PROTOCOL_ENUM; + v1name = a1->getAuthenticationStatements().size() ? + a1->getAuthenticationStatements().front()->getSubject()->getNameIdentifier() : NULL; // Normalize the SAML 1.x NameIdentifier... v2name = saml2::NameIDBuilder::buildNameID(); v2name->setName(v1name->getName()); v2name->setFormat(v1name->getFormat()); v2name->setNameQualifier(v1name->getNameQualifier()); - } - else { - throw FatalProfileException("Unknown assertion type."); - } - - if (!issuer) { - if (v1name) - delete v2name; - throw FatalProfileException("Unable to determine issuer."); - } - - MetadataProvider* m=app->getMetadataProvider(); - xmltooling::Locker mlocker(m); - const EntityDescriptor* site=m->getEntityDescriptor(issuer); - if (!site) { - auto_ptr_char temp(issuer); - throw MetadataException("Unable to locate metadata for IdP ($1).", params(1,temp.get())); - } - - vector tokens(1, dynamic_cast(token.get())); - ResolverTest rt(NULL, a_param); - try { - ctx = rt.resolveAttributes(*app, site->getIDPSSODescriptor(protocol), protocol, v1name, v2name, NULL, NULL, &tokens); - } - catch (...) { - if (v1name) - delete v2name; - throw; - } - } - - auto_ptr wrapper(ctx); - for (vector::const_iterator a = ctx->getResolvedAttributes().begin(); a != ctx->getResolvedAttributes().end(); ++a) { - cout << endl; - for (vector::const_iterator s = (*a)->getAliases().begin(); s != (*a)->getAliases().end(); ++s) - cout << "ID: " << *s << endl; - for (vector::const_iterator s = (*a)->getSerializedValues().begin(); s != (*a)->getSerializedValues().end(); ++s) - cout << "Value: " << *s << endl; - } - cout << endl; - } - catch(exception& ex) { - log.error(ex.what()); - sp->unlock(); - conf.term(); - return -10; - } - - sp->unlock(); - conf.term(); - return 0; -} + } + else { + throw FatalProfileException("Unknown assertion type."); + } + + if (!issuer) { + if (v1name) + delete v2name; + throw FatalProfileException("Unable to determine issuer."); + } + + MetadataProvider* m=app->getMetadataProvider(); + xmltooling::Locker mlocker(m); + const EntityDescriptor* site=m->getEntityDescriptor(issuer); + if (!site) { + auto_ptr_char temp(issuer); + throw MetadataException("Unable to locate metadata for IdP ($1).", params(1,temp.get())); + } + + vector tokens(1, dynamic_cast(token.get())); + ResolverTest rt(NULL, a_param); + try { + ctx = rt.resolveAttributes(*app, site->getIDPSSODescriptor(protocol), protocol, v1name, v2name, NULL, NULL, &tokens); + } + catch (...) { + if (v1name) + delete v2name; + throw; + } + } + + auto_ptr wrapper(ctx); + for (vector::const_iterator a = ctx->getResolvedAttributes().begin(); a != ctx->getResolvedAttributes().end(); ++a) { + cout << endl; + for (vector::const_iterator s = (*a)->getAliases().begin(); s != (*a)->getAliases().end(); ++s) + cout << "ID: " << *s << endl; + for (vector::const_iterator s = (*a)->getSerializedValues().begin(); s != (*a)->getSerializedValues().end(); ++s) + cout << "Value: " << *s << endl; + } + cout << endl; + } + catch(exception& ex) { + log.error(ex.what()); + sp->unlock(); + conf.term(); + return -10; + } + + sp->unlock(); + conf.term(); + return 0; +}