2 * Copyright 2001-2005 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.
17 #include "../shib/shib.h"
20 #include <openssl/bio.h>
21 #include <openssl/err.h>
22 #include <openssl/rsa.h>
23 #include <openssl/evp.h>
24 #include <openssl/pem.h>
28 using namespace shibboleth;
30 int main(int argc,char* argv[])
32 SAMLConfig& conf1=SAMLConfig::getConfig();
33 ShibConfig& conf2=ShibConfig::getConfig();
37 for (int i=1; i<argc; i++)
39 if (!strcmp(argv[i],"-d") && i+1<argc)
41 else if (!strcmp(argv[i],"-k") && i+1<argc)
45 conf1.schema_dir=path;
47 cerr << "unable to initialize SAML runtime" << endl;
50 cerr << "unable to initialize Shibboleth runtime" << endl;
55 DOMImplementation* impl=DOMImplementationRegistry::getDOMImplementation(NULL);
56 DOMDocument* dummydoc=impl->createDocument();
57 DOMElement* dummy = dummydoc->createElementNS(NULL,L(Request));
58 static const XMLCh url[] = { chLatin_u, chLatin_r, chLatin_l, chNull };
59 auto_ptr_XMLCh src("/opt/shibboleth/etc/shibboleth/sites.xml");
60 dummy->setAttributeNS(NULL,url,src.get());
62 IMetadata* metadatas[1];
63 metadatas[0]=dynamic_cast<IMetadata*>(conf1.getPlugMgr().newPlugin("edu.internet2.middleware.shibboleth.provider.XMLMetadata",dummy));
65 ArrayIterator<IMetadata*> sites(metadatas,1);
69 auto_ptr<XMLCh> recip(XMLString::transcode("https://shib2.internet2.edu/shib/SHIRE"));
70 ShibBrowserProfile p (sites,EMPTY(ITrust*));
81 SAMLBrowserProfile::BrowserProfileResponse bpr=p.receive(buf.c_str(),recip.get(),SAMLBrowserProfile::Post);
82 cout << "Consumed Response: " << endl << *bpr.response << endl;
85 catch(SAMLException& e)
87 cerr << "caught a SAML exception: " << e << endl;
89 catch(XMLException& e)
91 cerr << "caught an XML exception: "; xmlout(cerr,e.getMessage()); cerr << endl;
95 cerr << "caught an unknown exception" << endl;