if (p.first) {
ifstream infile(p.second);
if (!infile.fail()) {
- const char* res = mlp.run(infile);
+ const char* res = mlp.run(infile,props);
if (res) {
r->content_type = ap_psprintf(r->pool, "text/html");
ap_send_http_header(r);
// Make sure this session is still valid.
RPCError* status = NULL;
- ShibMLP markupProcessor(application);
+ ShibMLP markupProcessor;
markupProcessor.insert("requestURL", targeturl);
try {
return SERVER_ERROR;
}
- ShibMLP markupProcessor(application);
+ ShibMLP markupProcessor;
markupProcessor.insert("requestURL", targeturl);
// Process SHIRE request
return HTTP_FORBIDDEN;
}
- ShibMLP markupProcessor(application);
+ ShibMLP markupProcessor;
markupProcessor.insert("requestURL", ap_construct_url(r->pool,r->unparsed_uri,r));
return shib_error_page(r, application, "access", markupProcessor);
}
if (p.first) {
ifstream infile(p.second);
if (!infile.fail()) {
- const char* res = mlp.run(infile);
+ const char* res = mlp.run(infile,props);
if (res) {
static const char* ctype="Content-Type: text/html\r\n";
pfc->AddResponseHeaders(pfc,const_cast<char*>(ctype),0);
// Make sure this session is still valid.
RPCError* status = NULL;
- ShibMLP markupProcessor(application);
+ ShibMLP markupProcessor;
markupProcessor.insert("requestURL", targeturl);
dynabuf abuf(16);
if (p.first) {
ifstream infile(p.second);
if (!infile.fail()) {
- const char* res = mlp.run(infile);
+ const char* res = mlp.run(infile,props);
if (res) {
static const char* ctype="Content-Type: text/html\r\n";
lpECB->ServerSupportFunction(lpECB->ConnID,HSE_REQ_SEND_RESPONSE_HEADER,"200 OK",0,(LPDWORD)ctype);
// Process the post.
string cookie;
RPCError* status=NULL;
- ShibMLP markupProcessor(application);
+ ShibMLP markupProcessor;
markupProcessor.insert("requestURL", targeturl.c_str());
try {
status = shire.sessionCreate(elements.first,buf,cookie);
}
catch (ShibTargetException &e) {
if (application) {
- ShibMLP markupProcessor(application);
+ ShibMLP markupProcessor;
markupProcessor.insert("requestURL", targeturl.c_str());
markupProcessor.insert("errorType", "Session Creation Service Error");
markupProcessor.insert("errorText", e.what());
#ifndef _DEBUG
catch (...) {
if (application) {
- ShibMLP markupProcessor(application);
+ ShibMLP markupProcessor;
markupProcessor.insert("requestURL", targeturl.c_str());
markupProcessor.insert("errorType", "Session Creation Service Error");
markupProcessor.insert("errorText", "Unexpected Exception");
s = s.substr(start, end - start + 1);
}
-ShibMLP::ShibMLP (const IApplication* app)
+ShibMLP::ShibMLP()
{
m_priv = new ShibMLPPriv ();
// Create a timestamp
time_t now = time(NULL);
insert("now", ctime(&now));
-
- // Insert any available information.
- if (app) {
- const IPropertySet* props=app->getPropertySet("Errors");
- if (props) {
- pair<bool,const char*> p=props->getString("supportContact");
- if (p.first)
- insert("supportContact",p.second);
- p=props->getString("logoLocation");
- if (p.first)
- insert("logoLocation",p.second);
- }
- }
}
ShibMLP::~ShibMLP ()
delete m_priv;
}
-const char* ShibMLP::run (const string& is)
+const char* ShibMLP::run(const string& is, const IPropertySet* props)
{
const char* line = is.c_str();
const char* lastpos = line;
m_priv->log->debug("found key: \"%s\"", key.c_str());
map<string,string>::const_iterator i=m_map.find(key);
- if (i == m_map.end()) {
- static string s1 = "<!-- Unknown SHIBMLP key: ";
- static string s2 = "/>";
- m_generated += s1 + key + s2;
- m_priv->log->debug("key unknown");
- }
- else {
+ if (i != m_map.end()) {
m_generated += i->second;
m_priv->log->debug("key maps to \"%s\"", i->second.c_str());
}
+ else {
+ pair<bool,const char*> p=props ? props->getString(key.c_str()) : pair<bool,const char*>(false,NULL);
+ if (p.first) {
+ m_generated += p.second;
+ m_priv->log->debug("property maps to \"%s\"", p.second);
+ }
+ else {
+ static string s1 = "<!-- Unknown SHIBMLP key: ";
+ static string s2 = "/>";
+ m_generated += s1 + key + s2;
+ m_priv->log->debug("key unknown");
+ }
+ }
lastpos = thispos + 2; // strlen("/>")
}
return m_generated.c_str();
}
-const char* ShibMLP::run (istream& is)
+const char* ShibMLP::run(istream& is, const IPropertySet* props)
{
static string eol = "\r\n";
string str, line;
while (getline(is, line))
str += line + eol;
- return run(str);
+ return run(str,props);
}
void ShibMLP::insert (RPCError& e)
class ShibMLPPriv;
class SHIBTARGET_EXPORTS ShibMLP {
public:
- ShibMLP(const IApplication* app=NULL);
+ ShibMLP();
~ShibMLP();
void insert (const std::string& key, const std::string& value);
void clear () { m_map.clear(); }
- const char* run (std::istream& s);
- const char* run (const std::string& input);
- const char* run (const char* input) {
+ const char* run (std::istream& s, const IPropertySet* props=NULL);
+ const char* run (const std::string& input, const IPropertySet* props=NULL);
+ const char* run (const char* input, const IPropertySet* props=NULL) {
std::string i = input;
- return run(i);
+ return run(i,props);
}
private: