+ if (session) {
+ // Check for logout interception.
+ if (requireLogoutWith.first) {
+ // Check for a completion parameter on the query string.
+ const char* qstr = request.getQueryString();
+ if (!qstr || !strstr(qstr, "shiblogoutdone=1")) {
+ // First leg of circuit, so we redirect to the logout endpoint specified with this URL as a return location.
+ string selfurl = request.getRequestURL();
+ if (!qstr)
+ selfurl += '?';
+ selfurl += "shiblogoutdone=1";
+ string loc = requireLogoutWith.second;
+ request.absolutize(loc);
+ if (loc.find('?') != string::npos)
+ loc += '&';
+ else
+ loc += '?';
+ loc += "return=" + XMLToolingConfig::getConfig().getURLEncoder()->encode(selfurl.c_str());
+ return make_pair(true, request.sendRedirect(loc.c_str()));
+ }
+ }
+ }
+ else {