[cpp-sp COMMIT] in /branches/REL_2/shibsp: ServiceProvider.cpp util/TemplateParameters.cpp util/TemplateParameters.h
noreply at shibboleth.net
noreply at shibboleth.net
Thu Nov 10 19:54:36 GMT 2011
Author: scantor
Date: Thu Nov 10 19:54:36 2011
New Revision: 3544
URL: http://svn.shibboleth.net/view/cpp-sp?rev=3544&view=rev
Log:
Give template engine access to user session.
Modified:
branches/REL_2/shibsp/ServiceProvider.cpp
branches/REL_2/shibsp/util/TemplateParameters.cpp
branches/REL_2/shibsp/util/TemplateParameters.h
Modified: branches/REL_2/shibsp/ServiceProvider.cpp
URL: http://svn.shibboleth.net/view/cpp-sp/branches/REL_2/shibsp/ServiceProvider.cpp?rev=3544&r1=3543&r2=3544&view=diff
==============================================================================
--- branches/REL_2/shibsp/ServiceProvider.cpp (original)
+++ branches/REL_2/shibsp/ServiceProvider.cpp Thu Nov 10 19:54:36 2011
@@ -345,6 +345,7 @@
Category& log = Category::getInstance(SHIBSP_LOGCAT".ServiceProvider");
const Application* app=nullptr;
+ const Session* session = nullptr;
string targetURL = request.getRequestURL();
try {
@@ -371,7 +372,6 @@
// Do we have an access control plugin?
if (settings.second) {
- const Session* session = nullptr;
try {
session = request.getSession(false);
}
@@ -388,7 +388,7 @@
case AccessControl::shib_acl_false:
{
log.warn("access control provider denied access");
- TemplateParameters tp;
+ TemplateParameters tp(nullptr, nullptr, session);
tp.m_map["requestURL"] = targetURL;
return make_pair(true,sendError(log, request, app, "access", tp, false));
}
@@ -404,7 +404,7 @@
}
catch (exception& e) {
request.log(SPRequest::SPError, e.what());
- TemplateParameters tp(&e);
+ TemplateParameters tp(&e, nullptr, session);
tp.m_map["requestURL"] = targetURL.substr(0,targetURL.find('?'));
return make_pair(true,sendError(log, request, app, "access", tp));
}
@@ -418,13 +418,13 @@
Category& log = Category::getInstance(SHIBSP_LOGCAT".ServiceProvider");
const Application* app=nullptr;
+ const Session* session = nullptr;
string targetURL = request.getRequestURL();
try {
RequestMapper::Settings settings = request.getRequestSettings();
app = &(request.getApplication());
- const Session* session = nullptr;
try {
session = request.getSession(false);
}
@@ -559,7 +559,7 @@
}
catch (exception& e) {
request.log(SPRequest::SPError, e.what());
- TemplateParameters tp(&e);
+ TemplateParameters tp(&e, nullptr, session);
tp.m_map["requestURL"] = targetURL.substr(0,targetURL.find('?'));
return make_pair(true,sendError(log, request, app, "session", tp));
}
@@ -639,7 +639,13 @@
}
catch (exception& e) {
request.log(SPRequest::SPError, e.what());
- TemplateParameters tp(&e);
+ const Session* session = nullptr;
+ try {
+ session = request.getSession(false, true);
+ }
+ catch (exception& e2) {
+ }
+ TemplateParameters tp(&e, nullptr, session);
tp.m_map["requestURL"] = targetURL.substr(0,targetURL.find('?'));
tp.m_request = &request;
return make_pair(true,sendError(log, request, app, "session", tp));
Modified: branches/REL_2/shibsp/util/TemplateParameters.cpp
URL: http://svn.shibboleth.net/view/cpp-sp/branches/REL_2/shibsp/util/TemplateParameters.cpp?rev=3544&r1=3543&r2=3544&view=diff
==============================================================================
--- branches/REL_2/shibsp/util/TemplateParameters.cpp (original)
+++ branches/REL_2/shibsp/util/TemplateParameters.cpp Thu Nov 10 19:54:36 2011
@@ -25,6 +25,8 @@
*/
#include "internal.h"
+#include "SessionCache.h"
+#include "attribute/Attribute.h"
#include "util/PropertySet.h"
#include "util/TemplateParameters.h"
@@ -36,8 +38,8 @@
using namespace xmltooling;
using namespace std;
-TemplateParameters::TemplateParameters(const exception* e, const PropertySet* props)
- : m_exception(e), m_toolingException(dynamic_cast<const XMLToolingException*>(e))
+TemplateParameters::TemplateParameters(const exception* e, const PropertySet* props, const Session* session)
+ : m_exception(e), m_toolingException(dynamic_cast<const XMLToolingException*>(e)), m_session(session)
{
setPropertySet(props);
}
@@ -78,10 +80,25 @@
}
const char* pch = TemplateEngine::TemplateParameters::getParameter(name);
- if (pch || !m_props)
+ if (pch)
return pch;
- pair<bool,const char*> p = m_props->getString(name);
- return p.first ? p.second : nullptr;
+
+ if (m_session) {
+ const multimap<string,const Attribute*>& attrs = m_session->getIndexedAttributes();
+ pair<multimap<string,const Attribute*>::const_iterator, multimap<string,const Attribute*>::const_iterator> walker;
+ for (walker = attrs.equal_range(name); walker.first != walker.second; ++walker.first) {
[... 69 lines stripped ...]
More information about the commits
mailing list