Attempt at a metadata generation handler.
[shibboleth/cpp-sp.git] / shibsp / handler / impl / SAML2Logout.cpp
1 /*
2  *  Copyright 2001-2007 Internet2
3  * 
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /**
18  * SAML2Logout.cpp
19  * 
20  * Handles SAML 2.0 single logout protocol messages.
21  */
22
23 #include "internal.h"
24 #include "exceptions.h"
25 #include "Application.h"
26 #include "ServiceProvider.h"
27 #include "handler/AbstractHandler.h"
28 #include "handler/LogoutHandler.h"
29 #include "util/SPConstants.h"
30
31 #ifndef SHIBSP_LITE
32 # include "SessionCache.h"
33 # include "security/SecurityPolicy.h"
34 # include "util/TemplateParameters.h"
35 # include <fstream>
36 # include <saml/SAMLConfig.h>
37 # include <saml/saml2/core/Protocols.h>
38 # include <saml/saml2/metadata/EndpointManager.h>
39 # include <saml/saml2/metadata/MetadataCredentialCriteria.h>
40 # include <xmltooling/util/URLEncoder.h>
41 using namespace opensaml::saml2;
42 using namespace opensaml::saml2p;
43 using namespace opensaml::saml2md;
44 using namespace opensaml;
45 #endif
46
47 using namespace shibsp;
48 using namespace xmltooling;
49 using namespace std;
50
51 namespace shibsp {
52
53 #if defined (_MSC_VER)
54     #pragma warning( push )
55     #pragma warning( disable : 4250 )
56 #endif
57     
58     class SHIBSP_DLLLOCAL SAML2Logout : public AbstractHandler, public LogoutHandler
59     {
60     public:
61         SAML2Logout(const DOMElement* e, const char* appId);
62         virtual ~SAML2Logout() {
63 #ifndef SHIBSP_LITE
64             if (SPConfig::getConfig().isEnabled(SPConfig::OutOfProcess)) {
65                 delete m_decoder;
66                 XMLString::release(&m_outgoing);
67                 for_each(m_encoders.begin(), m_encoders.end(), cleanup_pair<const XMLCh*,MessageEncoder>());
68             }
69 #endif
70         }
71         
72         void receive(DDF& in, ostream& out);
73         pair<bool,long> run(SPRequest& request, bool isHandler=true) const;
74
75 #ifndef SHIBSP_LITE
76         void generateMetadata(SPSSODescriptor& role, const char* handlerURL) const {
77             const char* loc = getString("Location").second;
78             string hurl(handlerURL);
79             if (*loc != '/')
80                 hurl += '/';
81             hurl += loc;
82             auto_ptr_XMLCh widen(hurl.c_str());
83             SingleLogoutService* ep = SingleLogoutServiceBuilder::buildSingleLogoutService();
84             ep->setLocation(widen.get());
85             ep->setBinding(getXMLString("Binding").second);
86             role.getSingleLogoutServices().push_back(ep);
87             role.addSupport(samlconstants::SAML20P_NS);
88         }
89 #endif
90
91     private:
92         pair<bool,long> doRequest(
93             const Application& application, const char* session_id, const HTTPRequest& httpRequest, HTTPResponse& httpResponse
94             ) const;
95
96 #ifndef SHIBSP_LITE
97         bool stronglyMatches(const XMLCh* idp, const XMLCh* sp, const saml2::NameID& n1, const saml2::NameID& n2) const;
98
99         pair<bool,long> sendResponse(
100             const XMLCh* requestID,
101             const XMLCh* code,
102             const XMLCh* subcode,
103             const char* msg,
104             const char* relayState,
105             const RoleDescriptor* role,
106             const Application& application,
107             HTTPResponse& httpResponse,
108             bool front
109             ) const;
110
111         QName m_role;
112         MessageDecoder* m_decoder;
113         XMLCh* m_outgoing;
114         vector<const XMLCh*> m_bindings;
115         map<const XMLCh*,MessageEncoder*> m_encoders;
116 #endif
117     };
118
119 #if defined (_MSC_VER)
120     #pragma warning( pop )
121 #endif
122
123     Handler* SHIBSP_DLLLOCAL SAML2LogoutFactory(const pair<const DOMElement*,const char*>& p)
124     {
125         return new SAML2Logout(p.first, p.second);
126     }
127 };
128
129 SAML2Logout::SAML2Logout(const DOMElement* e, const char* appId)
130     : AbstractHandler(e, Category::getInstance(SHIBSP_LOGCAT".Logout.SAML2"))
131 #ifndef SHIBSP_LITE
132         ,m_role(samlconstants::SAML20MD_NS, IDPSSODescriptor::LOCAL_NAME), m_decoder(NULL), m_outgoing(NULL)
133 #endif
134 {
135 #ifndef SHIBSP_LITE
136     m_initiator = false;
137     m_preserve.push_back("ID");
138     m_preserve.push_back("entityID");
139     m_preserve.push_back("RelayState");
140
141     if (SPConfig::getConfig().isEnabled(SPConfig::OutOfProcess)) {
142         SAMLConfig& conf = SAMLConfig::getConfig();
143
144         // Handle incoming binding.
145         m_decoder = conf.MessageDecoderManager.newPlugin(getString("Binding").second,make_pair(e,shibspconstants::SHIB2SPCONFIG_NS));
146         m_decoder->setArtifactResolver(SPConfig::getConfig().getArtifactResolver());
147
148         if (m_decoder->isUserAgentPresent()) {
149             // Handle front-channel binding setup.
150             pair<bool,const XMLCh*> outgoing = getXMLString("outgoingBindings", m_configNS.get());
151             if (outgoing.first) {
152                 m_outgoing = XMLString::replicate(outgoing.second);
153                 XMLString::trim(m_outgoing);
154             }
155             else {
156                 // No override, so we'll install a default binding precedence.
157                 string prec = string(samlconstants::SAML20_BINDING_HTTP_REDIRECT) + ' ' + samlconstants::SAML20_BINDING_HTTP_POST + ' ' +
158                     samlconstants::SAML20_BINDING_HTTP_POST_SIMPLESIGN + ' ' + samlconstants::SAML20_BINDING_HTTP_ARTIFACT;
159                 m_outgoing = XMLString::transcode(prec.c_str());
160             }
161
162             int pos;
163             XMLCh* start = m_outgoing;
164             while (start && *start) {
165                 pos = XMLString::indexOf(start,chSpace);
166                 if (pos != -1)
167                     *(start + pos)=chNull;
168                 m_bindings.push_back(start);
169                 try {
170                     auto_ptr_char b(start);
171                     MessageEncoder * encoder = conf.MessageEncoderManager.newPlugin(b.get(),make_pair(e,shibspconstants::SHIB2SPCONFIG_NS));
172                     m_encoders[start] = encoder;
173                     m_log.debug("supporting outgoing front-channel binding (%s)", b.get());
174                 }
175                 catch (exception& ex) {
176                     m_log.error("error building MessageEncoder: %s", ex.what());
177                 }
178                 if (pos != -1)
179                     start = start + pos + 1;
180                 else
181                     break;
182             }
183         }
184         else {
185             MessageEncoder* encoder = conf.MessageEncoderManager.newPlugin(
186                 getString("Binding").second,make_pair(e,shibspconstants::SHIB2SPCONFIG_NS)
187                 );
188             m_encoders.insert(pair<const XMLCh*,MessageEncoder*>(NULL, encoder));
189         }
190     }
191 #endif
192
193     string address(appId);
194     address += getString("Location").second;
195     setAddress(address.c_str());
196 }
197
198 pair<bool,long> SAML2Logout::run(SPRequest& request, bool isHandler) const
199 {
200     // Defer to base class for front-channel loop first.
201     // This won't initiate the loop, only continue/end it.
202     pair<bool,long> ret = LogoutHandler::run(request, isHandler);
203     if (ret.first)
204         return ret;
205
206     // Get the session_id in case this is a front-channel LogoutRequest.
207     pair<string,const char*> shib_cookie = request.getApplication().getCookieNameProps("_shibsession_");
208     const char* session_id = request.getCookie(shib_cookie.first.c_str());
209
210     SPConfig& conf = SPConfig::getConfig();
211     if (conf.isEnabled(SPConfig::OutOfProcess)) {
212         // When out of process, we run natively and directly process the message.
213         return doRequest(request.getApplication(), session_id, request, request);
214     }
215     else {
216         // When not out of process, we remote all the message processing.
217         DDF out,in = wrap(request, NULL, true);
218         DDFJanitor jin(in), jout(out);
219         if (session_id)
220             in.addmember("session_id").string(session_id);
221         out=request.getServiceProvider().getListenerService()->send(in);
222         return unwrap(request, out);
223     }
224 }
225
226 void SAML2Logout::receive(DDF& in, ostream& out)
227 {
228     // Find application.
229     const char* aid=in["application_id"].string();
230     const Application* app=aid ? SPConfig::getConfig().getServiceProvider()->getApplication(aid) : NULL;
231     if (!app) {
232         // Something's horribly wrong.
233         m_log.error("couldn't find application (%s) for logout", aid ? aid : "(missing)");
234         throw ConfigurationException("Unable to locate application for logout, deleted?");
235     }
236     
237     // Unpack the request.
238     DDF ret(NULL);
239     DDFJanitor jout(ret);
240     auto_ptr<HTTPRequest> req(getRequest(in));
241     auto_ptr<HTTPResponse> resp(getResponse(ret));
242     
243     // Since we're remoted, the result should either be a throw, which we pass on,
244     // a false/0 return, which we just return as an empty structure, or a response/redirect,
245     // which we capture in the facade and send back.
246     doRequest(*app, in["session_id"].string(), *req.get(), *resp.get());
247     out << ret;
248 }
249
250 pair<bool,long> SAML2Logout::doRequest(
251     const Application& application, const char* session_id, const HTTPRequest& request, HTTPResponse& response
252     ) const
253 {
254 #ifndef SHIBSP_LITE
255     SessionCache* cache = application.getServiceProvider().getSessionCache();
256     if (!strcmp(request.getMethod(),"GET") && request.getParameter("notifying")) {
257
258         // This is returning from a front-channel notification, so we have to do the back-channel and then
259         // respond. To do that, we need state from the original request.
260         if (!request.getParameter("entityID")) {
261             if (session_id) {
262                 cache->remove(session_id, application);
263                 // Clear the cookie.
264                 pair<string,const char*> shib_cookie=application.getCookieNameProps("_shibsession_");
265                 response.setCookie(shib_cookie.first.c_str(), shib_cookie.second);
266             }
267             throw FatalProfileException("Application notification loop did not return entityID for LogoutResponse.");
268         }
269
270         // Best effort on back channel and to remove the user agent's session.
271         bool worked1 = false,worked2 = false;
272         if (session_id) {
273             vector<string> sessions(1,session_id);
274             worked1 = notifyBackChannel(application, request.getRequestURL(), sessions, false);
275             try {
276                 cache->remove(session_id, application);
277                 worked2 = true;
278             }
279             catch (exception& ex) {
280                 m_log.error("error removing session (%s): %s", session_id, ex.what());
281             }
282
283             // Clear the cookie.
284             pair<string,const char*> shib_cookie=application.getCookieNameProps("_shibsession_");
285             response.setCookie(shib_cookie.first.c_str(), shib_cookie.second);
286         }
287         else {
288             worked1 = worked2 = true;
289         }
290
291         // We need metadata to issue a response.
292         Locker metadataLocker(application.getMetadataProvider());
293         const EntityDescriptor* entity = application.getMetadataProvider()->getEntityDescriptor(request.getParameter("entityID"));
294         if (!entity) {
295             throw MetadataException(
296                 "Unable to locate metadata for identity provider ($entityID)", namedparams(1, "entityID", request.getParameter("entityID"))
297                 );
298         }
299         const IDPSSODescriptor* idp = entity->getIDPSSODescriptor(samlconstants::SAML20P_NS);
300         if (!idp) {
301             throw MetadataException(
302                 "Unable to locate SAML 2.0 IdP role for identity provider ($entityID).",
303                 namedparams(1, "entityID", request.getParameter("entityID"))
304                 );
305         }
306
307         auto_ptr_XMLCh reqid(request.getParameter("ID"));
308         if (worked1 && worked2) {
309             // Successful LogoutResponse. Has to be front-channel or we couldn't be here.
310             return sendResponse(
311                 reqid.get(), StatusCode::SUCCESS, NULL, NULL, request.getParameter("RelayState"), idp, application, response, true
312                 );
313         }
314
315         return sendResponse(
316             reqid.get(),
317             StatusCode::RESPONDER, NULL, "Unable to fully destroy principal's session.",
318             request.getParameter("RelayState"),
319             idp,
320             application,
321             response,
322             true
323             );
324     }
325
326     // If we get here, it's an external protocol message to decode.
327
328     // Locate policy key.
329     pair<bool,const char*> policyId = getString("policyId", m_configNS.get());  // namespace-qualified if inside handler element
330     if (!policyId.first)
331         policyId = application.getString("policyId");   // unqualified in Application(s) element
332         
333     // Access policy properties.
334     const PropertySet* settings = application.getServiceProvider().getPolicySettings(policyId.second);
335     pair<bool,bool> validate = settings->getBool("validate");
336
337     // Lock metadata for use by policy.
338     Locker metadataLocker(application.getMetadataProvider());
339
340     // Create the policy.
341     shibsp::SecurityPolicy policy(application, &m_role, validate.first && validate.second);
342     
343     // Decode the message.
344     string relayState;
345     auto_ptr<XMLObject> msg(m_decoder->decode(relayState, request, policy));
346     const LogoutRequest* logoutRequest = dynamic_cast<LogoutRequest*>(msg.get());
347     if (logoutRequest) {
348         if (!policy.isAuthenticated())
349             throw SecurityPolicyException("Security of LogoutRequest not established.");
350
351         // Message from IdP to logout one or more sessions.
352         
353         // If this is front-channel, we have to have a session_id to use already.
354         if (m_decoder->isUserAgentPresent() && !session_id) {
355             m_log.error("no active session");
356             return sendResponse(
357                 logoutRequest->getID(),
358                 StatusCode::REQUESTER, StatusCode::UNKNOWN_PRINCIPAL, "No active session found in request.",
359                 relayState.c_str(),
360                 policy.getIssuerMetadata(),
361                 application,
362                 response,
363                 true
364                 );
365         }
366
367         bool ownedName = false;
368         NameID* nameid = logoutRequest->getNameID();
369         if (!nameid) {
370             // Check for EncryptedID.
371             EncryptedID* encname = logoutRequest->getEncryptedID();
372             if (encname) {
373                 CredentialResolver* cr=application.getCredentialResolver();
374                 if (!cr)
375                     m_log.warn("found encrypted NameID, but no decryption credential was available");
376                 else {
377                     Locker credlocker(cr);
378                     auto_ptr<MetadataCredentialCriteria> mcc(
379                         policy.getIssuerMetadata() ? new MetadataCredentialCriteria(*policy.getIssuerMetadata()) : NULL
380                         );
381                     try {
382                         auto_ptr<XMLObject> decryptedID(encname->decrypt(*cr,application.getXMLString("entityID").second,mcc.get()));
383                         nameid = dynamic_cast<NameID*>(decryptedID.get());
384                         if (nameid) {
385                             ownedName = true;
386                             decryptedID.release();
387                         }
388                     }
389                     catch (exception& ex) {
390                         m_log.error(ex.what());
391                     }
392                 }
393             }
394         }
395         if (!nameid) {
396             // No NameID, so must respond with an error.
397             m_log.error("NameID not found in request");
398             return sendResponse(
399                 logoutRequest->getID(),
400                 StatusCode::REQUESTER, StatusCode::UNKNOWN_PRINCIPAL, "NameID not found in request.",
401                 relayState.c_str(),
402                 policy.getIssuerMetadata(),
403                 application,
404                 response,
405                 m_decoder->isUserAgentPresent()
406                 );
407         }
408
409         // Suck indexes out of the request for next steps.
410         set<string> indexes;
411         EntityDescriptor* entity = policy.getIssuerMetadata() ? dynamic_cast<EntityDescriptor*>(policy.getIssuerMetadata()->getParent()) : NULL;
412         const vector<SessionIndex*> sindexes = logoutRequest->getSessionIndexs();
413         for (vector<SessionIndex*>::const_iterator i = sindexes.begin(); i != sindexes.end(); ++i) {
414             auto_ptr_char sindex((*i)->getSessionIndex());
415             indexes.insert(sindex.get());
416         }
417
418         // For a front-channel LogoutRequest, we have to match the information in the request
419         // against the current session.
420         if (session_id) {
421             if (!cache->matches(session_id, entity, *nameid, &indexes, application)) {
422                 return sendResponse(
423                     logoutRequest->getID(),
424                     StatusCode::REQUESTER, StatusCode::REQUEST_DENIED, "Active sessions did not match logout request.",
425                     relayState.c_str(),
426                     policy.getIssuerMetadata(),
427                     application,
428                     response,
429                     true
430                     );
431             }
432
433         }
434
435         // Now we perform "logout" by finding the matching sessions.
436         vector<string> sessions;
437         try {
438             time_t expires = logoutRequest->getNotOnOrAfter() ? logoutRequest->getNotOnOrAfterEpoch() : 0;
439             cache->logout(entity, *nameid, &indexes, expires, application, sessions);
440
441             // Now we actually terminate everything except for the active session,
442             // if this is front-channel, for notification purposes.
443             for (vector<string>::const_iterator sit = sessions.begin(); sit != sessions.end(); ++sit)
444                 if (session_id && strcmp(sit->c_str(), session_id))
445                     cache->remove(sit->c_str(), application);
446         }
447         catch (exception& ex) {
448             m_log.error("error while logging out matching sessions: %s", ex.what());
449             return sendResponse(
450                 logoutRequest->getID(),
451                 StatusCode::RESPONDER, NULL, ex.what(),
452                 relayState.c_str(),
453                 policy.getIssuerMetadata(),
454                 application,
455                 response,
456                 m_decoder->isUserAgentPresent()
457                 );
458         }
459
460         if (m_decoder->isUserAgentPresent()) {
461             // Pass control to the first front channel notification point, if any.
462             map<string,string> parammap;
463             if (!relayState.empty())
464                 parammap["RelayState"] = relayState;
465             auto_ptr_char entityID(entity ? entity->getEntityID() : NULL);
466             if (entityID.get())
467                 parammap["entityID"] = entityID.get();
468             auto_ptr_char reqID(logoutRequest->getID());
469             if (reqID.get())
470                 parammap["ID"] = reqID.get();
471             pair<bool,long> result = notifyFrontChannel(application, request, response, &parammap);
472             if (result.first)
473                 return result;
474         }
475         
476         // For back-channel requests, or if no front-channel notification is needed...
477         bool worked1 = false,worked2 = false;
478         worked1 = notifyBackChannel(application, request.getRequestURL(), sessions, false);
479         if (session_id) {
480             // One last session to yoink...
481             try {
482                 cache->remove(session_id, application);
483                 worked2 = true;
484             }
485             catch (exception& ex) {
486                 m_log.error("error removing active session (%s): %s", session_id, ex.what());
487             }
488
489             // Clear the cookie.
490             pair<string,const char*> shib_cookie=application.getCookieNameProps("_shibsession_");
491             response.setCookie(shib_cookie.first.c_str(), shib_cookie.second);
492         }
493
494         return sendResponse(
495             logoutRequest->getID(),
496             (worked1 && worked2) ? StatusCode::SUCCESS : StatusCode::RESPONDER,
497             (worked1 && worked2) ? NULL : StatusCode::PARTIAL_LOGOUT,
498             NULL,
499             relayState.c_str(),
500             policy.getIssuerMetadata(),
501             application,
502             response,
503             m_decoder->isUserAgentPresent()
504             );
505     }
506
507     // A LogoutResponse completes an SP-initiated logout sequence.
508     const LogoutResponse* logoutResponse = dynamic_cast<LogoutResponse*>(msg.get());
509     if (logoutResponse) {
510         if (!policy.isAuthenticated()) {
511             SecurityPolicyException ex("Security of LogoutResponse not established.");
512             if (policy.getIssuerMetadata())
513                 annotateException(&ex, policy.getIssuerMetadata()); // throws it
514             ex.raise();
515         }
516         checkError(logoutResponse, policy.getIssuerMetadata()); // throws if Status doesn't look good...
517
518         // Return template for completion of global logout, or redirect to homeURL.
519         return sendLogoutPage(application, response, false, "Global logout completed.");
520     }
521
522     FatalProfileException ex("Incoming message was not a samlp:LogoutRequest or samlp:LogoutResponse.");
523     if (policy.getIssuerMetadata())
524         annotateException(&ex, policy.getIssuerMetadata()); // throws it
525     ex.raise();
526     return make_pair(false,0);  // never happen, satisfies compiler
527 #else
528     throw ConfigurationException("Cannot process logout message using lite version of shibsp library.");
529 #endif
530 }
531
532 #ifndef SHIBSP_LITE
533
534 bool SAML2Logout::stronglyMatches(const XMLCh* idp, const XMLCh* sp, const saml2::NameID& n1, const saml2::NameID& n2) const
535 {
536     if (!XMLString::equals(n1.getName(), n2.getName()))
537         return false;
538     
539     const XMLCh* s1 = n1.getFormat();
540     const XMLCh* s2 = n2.getFormat();
541     if (!s1 || !*s1)
542         s1 = saml2::NameID::UNSPECIFIED;
543     if (!s2 || !*s2)
544         s2 = saml2::NameID::UNSPECIFIED;
545     if (!XMLString::equals(s1,s2))
546         return false;
547     
548     s1 = n1.getNameQualifier();
549     s2 = n2.getNameQualifier();
550     if (!s1 || !*s1)
551         s1 = idp;
552     if (!s2 || !*s2)
553         s2 = idp;
554     if (!XMLString::equals(s1,s2))
555         return false;
556
557     s1 = n1.getSPNameQualifier();
558     s2 = n2.getSPNameQualifier();
559     if (!s1 || !*s1)
560         s1 = sp;
561     if (!s2 || !*s2)
562         s2 = sp;
563     if (!XMLString::equals(s1,s2))
564         return false;
565
566     return true;
567 }
568
569 pair<bool,long> SAML2Logout::sendResponse(
570     const XMLCh* requestID,
571     const XMLCh* code,
572     const XMLCh* subcode,
573     const char* msg,
574     const char* relayState,
575     const RoleDescriptor* role,
576     const Application& application,
577     HTTPResponse& httpResponse,
578     bool front
579     ) const
580 {
581     // Get endpoint and encoder to use.
582     const EndpointType* ep = NULL;
583     const MessageEncoder* encoder = NULL;
584     if (front) {
585         const IDPSSODescriptor* idp = dynamic_cast<const IDPSSODescriptor*>(role);
586         for (vector<const XMLCh*>::const_iterator b = m_bindings.begin(); idp && b!=m_bindings.end(); ++b) {
587             if (ep=EndpointManager<SingleLogoutService>(idp->getSingleLogoutServices()).getByBinding(*b)) {
588                 map<const XMLCh*,MessageEncoder*>::const_iterator enc = m_encoders.find(*b);
589                 if (enc!=m_encoders.end())
590                     encoder = enc->second;
591                 break;
592             }
593         }
594         if (!ep || !encoder) {
595             auto_ptr_char id(dynamic_cast<EntityDescriptor*>(role->getParent())->getEntityID());
596             m_log.error("unable to locate compatible SLO service for provider (%s)", id.get());
597             MetadataException ex("Unable to locate endpoint at IdP ($entityID) to send LogoutResponse.");
598             annotateException(&ex, role);   // throws it
599         }
600     }
601     else {
602         encoder = m_encoders.begin()->second;
603     }
604
605     // Prepare response.
606     auto_ptr<LogoutResponse> logout(LogoutResponseBuilder::buildLogoutResponse());
607     logout->setInResponseTo(requestID);
608     if (ep) {
609         const XMLCh* loc = ep->getResponseLocation();
610         if (!loc || !*loc)
611             loc = ep->getLocation();
612         logout->setDestination(loc);
613     }
614     Issuer* issuer = IssuerBuilder::buildIssuer();
615     logout->setIssuer(issuer);
616     issuer->setName(application.getXMLString("entityID").second);
617     fillStatus(*logout.get(), code, subcode, msg);
618
619     auto_ptr_char dest(logout->getDestination());
620
621     long ret = sendMessage(*encoder, logout.get(), relayState, dest.get(), role, application, httpResponse);
622     logout.release();  // freed by encoder
623     return make_pair(true,ret);
624 }
625
626 #endif