2 * Copyright 2001-2007 Internet2
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
20 * SAML Metadata Query tool layered on SP configuration
\r
23 #if defined (_MSC_VER) || defined(__BORLANDC__)
\r
24 # include "config_win32.h"
\r
26 # include "config.h"
\r
30 # define _CRT_NONSTDC_NO_DEPRECATE 1
\r
31 # define _CRT_SECURE_NO_DEPRECATE 1
\r
34 #include <shibsp/Application.h>
\r
35 #include <shibsp/exceptions.h>
\r
36 #include <shibsp/SPConfig.h>
\r
37 #include <shibsp/ServiceProvider.h>
\r
38 #include <shibsp/util/SPConstants.h>
\r
39 #include <saml/saml2/metadata/Metadata.h>
\r
41 using namespace shibsp;
\r
42 using namespace opensaml::saml2md;
\r
43 using namespace opensaml;
\r
44 using namespace xmltooling;
\r
45 using namespace std;
\r
47 int main(int argc,char* argv[])
\r
55 for (int i=1; i<argc; i++) {
\r
56 if (!strcmp(argv[i],"-n") && i+1<argc)
\r
58 else if (!strcmp(argv[i],"-q") && i+1<argc)
\r
60 else if (!strcmp(argv[i],"-f") && i+1<argc)
\r
62 else if (!strcmp(argv[i],"-a") && i+1<argc)
\r
66 if (!n_param || !q_param) {
\r
67 cerr << "usage: samlquery -n <name> -q <IdP> [-f <format URI> -a <application id>]" << endl;
\r
74 char* path=getenv("SHIBSP_SCHEMAS");
\r
76 path=SHIBSP_SCHEMAS;
\r
77 char* config=getenv("SHIBSP_CONFIG");
\r
79 config=SHIBSP_CONFIG;
\r
81 XMLToolingConfig::getConfig().log_config(getenv("SHIBSP_LOGGING") ? getenv("SHIBSP_LOGGING") : SHIBSP_LOGGING);
\r
83 SPConfig& conf=SPConfig::getConfig();
\r
84 conf.setFeatures(SPConfig::Metadata | SPConfig::OutOfProcess);
\r
85 if (!conf.init(path))
\r
89 static const XMLCh _path[] = UNICODE_LITERAL_4(p,a,t,h);
\r
90 static const XMLCh validate[] = UNICODE_LITERAL_8(v,a,l,i,d,a,t,e);
\r
91 xercesc::DOMDocument* dummydoc=XMLToolingConfig::getConfig().getParser().newDocument();
\r
92 XercesJanitor<xercesc::DOMDocument> docjanitor(dummydoc);
\r
93 xercesc::DOMElement* dummy = dummydoc->createElementNS(NULL,_path);
\r
94 auto_ptr_XMLCh src(config);
\r
95 dummy->setAttributeNS(NULL,_path,src.get());
\r
96 dummy->setAttributeNS(NULL,validate,xmlconstants::XML_ONE);
\r
97 conf.setServiceProvider(conf.ServiceProviderManager.newPlugin(XML_SERVICE_PROVIDER,dummy));
\r
98 conf.getServiceProvider()->init();
\r
100 catch (exception&) {
\r
105 ServiceProvider* sp=conf.getServiceProvider();
\r