/*\r
* Copyright 2001-2007 Internet2\r
- * \r
+ *\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
* You may obtain a copy of the License at\r
virtual void clearHeader(const char* rawname, const char* cginame) {\r
throw runtime_error("clearHeader not implemented by FastCGI responder.");\r
}\r
- \r
+\r
virtual void setHeader(const char* name, const char* value) {\r
throw runtime_error("setHeader not implemented by FastCGI responder.");\r
}\r
exit(1);\r
}\r
\r
- const char* config=getenv("SHIBSP_CONFIG");\r
- if (!config)\r
- config=SHIBSP_CONFIG;\r
-\r
try {\r
- DOMDocument* dummydoc=XMLToolingConfig::getConfig().getParser().newDocument();\r
- XercesJanitor<DOMDocument> docjanitor(dummydoc);\r
- DOMElement* dummy = dummydoc->createElementNS(NULL,path);\r
- auto_ptr_XMLCh src(config);\r
- dummy->setAttributeNS(NULL,path,src.get());\r
- dummy->setAttributeNS(NULL,validate,xmlconstants::XML_ONE);\r
-\r
- g_Config->setServiceProvider(g_Config->ServiceProviderManager.newPlugin(XML_SERVICE_PROVIDER,dummy));\r
- g_Config->getServiceProvider()->init();\r
+ if (!g_Config->instantiate(NULL, true))\r
+ throw exception("unknown error");\r
}\r
catch (exception& ex) {\r
g_Config->term();\r
\r
FCGX_Init();\r
FCGX_InitRequest(&request, 0, 0);\r
- \r
+\r
cout << "Shibboleth initialization complete. Starting request loop." << endl;\r
while (FCGX_Accept_r(&request) == 0) {\r
// Note that the default bufsize (0) will cause the use of iostream\r
try {\r
xmltooling::NDC ndc("FastCGI shibresponder");\r
ShibTargetFCGI stf(&request, content, g_ServerScheme.c_str(), g_ServerName.c_str(), g_ServerPort);\r
- \r
+\r
pair<bool,long> res = stf.getServiceProvider().doHandler(stf);\r
if (res.first) {\r
-#ifdef _DEBUG\r
- cerr << "shib: doHandler handled the request" << endl;\r
-#endif\r
+ stf.log(SPRequest::SPDebug, "shib: doHandler handled the request");\r
switch(res.second) {\r
case SHIB_RETURN_OK:\r
print_ok();\r
break;\r
- \r
+\r
case SHIB_RETURN_KO:\r
cerr << "shib: doHandler failed to handle the request" << endl;\r
print_error("<html><body>FastCGI Shibboleth responder should only be used for Shibboleth protocol requests.</body></html>");\r
case SHIB_RETURN_DONE:\r
// response already handled\r
break;\r
- \r
+\r
default:\r
cerr << "shib: doHandler returned an unexpected result: " << res.second << endl;\r
print_error("<html><body>FastCGI Shibboleth responder returned an unexpected result.</body></html>");\r
else {\r
cerr << "shib: doHandler failed to handle request." << endl;\r
print_error("<html><body>FastCGI Shibboleth responder failed to process request.</body></html>");\r
- } \r
- \r
+ }\r
+\r
}\r
catch (exception& e) {\r
cerr << "shib: FastCGI responder caught an exception: " << e.what() << endl;\r
\r
if (g_Config)\r
g_Config->term();\r
- \r
+\r
return 0;\r
}\r