2 * Copyright 2001-2006 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <saml/SAMLConfig.h>
20 #include <saml/binding/MessageDecoder.h>
21 #include <saml/binding/MessageEncoder.h>
22 #include <saml/saml2/metadata/MetadataProvider.h>
23 #include <saml/security/X509TrustEngine.h>
25 using namespace saml2md;
26 using namespace xmlsignature;
28 class SAMLBindingBaseTestCase : public MessageDecoder::HTTPRequest
31 CredentialResolver* m_creds;
32 MetadataProvider* m_metadata;
33 opensaml::X509TrustEngine* m_trust;
34 map<string,string> m_fields;
44 string config = data_path + "binding/ExampleMetadataProvider.xml";
45 ifstream in(config.c_str());
46 DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in);
47 XercesJanitor<DOMDocument> janitor(doc);
49 auto_ptr_XMLCh path("path");
50 string s = data_path + "binding/example-metadata.xml";
51 auto_ptr_XMLCh file(s.c_str());
52 doc->getDocumentElement()->setAttributeNS(NULL,path.get(),file.get());
54 m_metadata = SAMLConfig::getConfig().MetadataProviderManager.newPlugin(
55 FILESYSTEM_METADATA_PROVIDER,doc->getDocumentElement()
59 config = data_path + "FilesystemCredentialResolver.xml";
60 ifstream in2(config.c_str());
61 DOMDocument* doc2=XMLToolingConfig::getConfig().getParser().parse(in2);
62 XercesJanitor<DOMDocument> janitor2(doc2);
63 m_creds = XMLToolingConfig::getConfig().CredentialResolverManager.newPlugin(
64 FILESYSTEM_CREDENTIAL_RESOLVER,doc2->getDocumentElement()
67 m_trust = dynamic_cast<X509TrustEngine*>(
68 SAMLConfig::getConfig().TrustEngineManager.newPlugin(EXPLICIT_KEY_SAMLTRUSTENGINE, NULL)
71 catch (XMLToolingException& ex) {
89 const char* getParameter(const char* name) const {
90 map<string,string>::const_iterator i=m_fields.find(name);
91 return i==m_fields.end() ? NULL : i->second.c_str();
94 vector<const char*>::size_type getParameters(const char* name, vector<const char*>& values) const {
96 map<string,string>::const_iterator i=m_fields.find(name);
97 if (i!=m_fields.end())
98 values.push_back(i->second.c_str());