Memory leak of decrypted NameID.
[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         auto_ptr<NameID> namewrapper(ownedName ? nameid : NULL);
410
411         // Suck indexes out of the request for next steps.
412         set<string> indexes;
413         EntityDescriptor* entity = policy.getIssuerMetadata() ? dynamic_cast<EntityDescriptor*>(policy.getIssuerMetadata()->getParent()) : NULL;
414         const vector<SessionIndex*> sindexes = logoutRequest->getSessionIndexs();
415         for (vector<SessionIndex*>::const_iterator i = sindexes.begin(); i != sindexes.end(); ++i) {
416             auto_ptr_char sindex((*i)->getSessionIndex());
417             indexes.insert(sindex.get());
418         }
419
420         // For a front-channel LogoutRequest, we have to match the information in the request
421         // against the current session.
422         if (session_id) {
423             if (!cache->matches(session_id, entity, *nameid, &indexes, application)) {
424                 return sendResponse(
425                     logoutRequest->getID(),
426                     StatusCode::REQUESTER, StatusCode::REQUEST_DENIED, "Active sessions did not match logout request.",
427                     relayState.c_str(),
428                     policy.getIssuerMetadata(),
429                     application,
430                     response,
431                     true
432                     );
433             }
434
435         }
436
437         // Now we perform "logout" by finding the matching sessions.
438         vector<string> sessions;
439         try {
440             time_t expires = logoutRequest->getNotOnOrAfter() ? logoutRequest->getNotOnOrAfterEpoch() : 0;
441             cache->logout(entity, *nameid, &indexes, expires, application, sessions);
442
443             // Now we actually terminate everything except for the active session,
444             // if this is front-channel, for notification purposes.
445             for (vector<string>::const_iterator sit = sessions.begin(); sit != sessions.end(); ++sit)
446                 if (session_id && strcmp(sit->c_str(), session_id))
447                     cache->remove(sit->c_str(), application);
448         }
449         catch (exception& ex) {
450             m_log.error("error while logging out matching sessions: %s", ex.what());
451             return sendResponse(
452                 logoutRequest->getID(),
453                 StatusCode::RESPONDER, NULL, ex.what(),
454                 relayState.c_str(),
455                 policy.getIssuerMetadata(),
456                 application,
457                 response,
458                 m_decoder->isUserAgentPresent()
459                 );
460         }
461
462         if (m_decoder->isUserAgentPresent()) {
463             // Pass control to the first front channel notification point, if any.
464             map<string,string> parammap;
465             if (!relayState.empty())
466                 parammap["RelayState"] = relayState;
467             auto_ptr_char entityID(entity ? entity->getEntityID() : NULL);
468             if (entityID.get())
469                 parammap["entityID"] = entityID.get();
470             auto_ptr_char reqID(logoutRequest->getID());
471             if (reqID.get())
472                 parammap["ID"] = reqID.get();
473             pair<bool,long> result = notifyFrontChannel(application, request, response, &parammap);
474             if (result.first)
475                 return result;
476         }
477         
478         // For back-channel requests, or if no front-channel notification is needed...
479         bool worked1 = false,worked2 = false;
480         worked1 = notifyBackChannel(application, request.getRequestURL(), sessions, false);
481         if (session_id) {
482             // One last session to yoink...
483             try {
484                 cache->remove(session_id, application);
485                 worked2 = true;
486             }
487             catch (exception& ex) {
488                 m_log.error("error removing active session (%s): %s", session_id, ex.what());
489             }
490
491             // Clear the cookie.
492             pair<string,const char*> shib_cookie=application.getCookieNameProps("_shibsession_");
493             response.setCookie(shib_cookie.first.c_str(), shib_cookie.second);
494         }
495
496         return sendResponse(
497             logoutRequest->getID(),
498             (worked1 && worked2) ? StatusCode::SUCCESS : StatusCode::RESPONDER,
499             (worked1 && worked2) ? NULL : StatusCode::PARTIAL_LOGOUT,
500             NULL,
501             relayState.c_str(),
502             policy.getIssuerMetadata(),
503             application,
504             response,
505             m_decoder->isUserAgentPresent()
506             );
507     }
508
509     // A LogoutResponse completes an SP-initiated logout sequence.
510     const LogoutResponse* logoutResponse = dynamic_cast<LogoutResponse*>(msg.get());
511     if (logoutResponse) {
512         if (!policy.isAuthenticated()) {
513             SecurityPolicyException ex("Security of LogoutResponse not established.");
514             if (policy.getIssuerMetadata())
515                 annotateException(&ex, policy.getIssuerMetadata()); // throws it
516             ex.raise();
517         }
518         checkError(logoutResponse, policy.getIssuerMetadata()); // throws if Status doesn't look good...
519
520         // Return template for completion of global logout, or redirect to homeURL.
521         return sendLogoutPage(application, response, false, "Global logout completed.");
522     }
523
524     FatalProfileException ex("Incoming message was not a samlp:LogoutRequest or samlp:LogoutResponse.");
525     if (policy.getIssuerMetadata())
526         annotateException(&ex, policy.getIssuerMetadata()); // throws it
527     ex.raise();
528     return make_pair(false,0);  // never happen, satisfies compiler
529 #else
530     throw ConfigurationException("Cannot process logout message using lite version of shibsp library.");
531 #endif
532 }
533
534 #ifndef SHIBSP_LITE
535
536 bool SAML2Logout::stronglyMatches(const XMLCh* idp, const XMLCh* sp, const saml2::NameID& n1, const saml2::NameID& n2) const
537 {
538     if (!XMLString::equals(n1.getName(), n2.getName()))
539         return false;
540     
541     const XMLCh* s1 = n1.getFormat();
542     const XMLCh* s2 = n2.getFormat();
543     if (!s1 || !*s1)
544         s1 = saml2::NameID::UNSPECIFIED;
545     if (!s2 || !*s2)
546         s2 = saml2::NameID::UNSPECIFIED;
547     if (!XMLString::equals(s1,s2))
548         return false;
549     
550     s1 = n1.getNameQualifier();
551     s2 = n2.getNameQualifier();
552     if (!s1 || !*s1)
553         s1 = idp;
554     if (!s2 || !*s2)
555         s2 = idp;
556     if (!XMLString::equals(s1,s2))
557         return false;
558
559     s1 = n1.getSPNameQualifier();
560     s2 = n2.getSPNameQualifier();
561     if (!s1 || !*s1)
562         s1 = sp;
563     if (!s2 || !*s2)
564         s2 = sp;
565     if (!XMLString::equals(s1,s2))
566         return false;
567
568     return true;
569 }
570
571 pair<bool,long> SAML2Logout::sendResponse(
572     const XMLCh* requestID,
573     const XMLCh* code,
574     const XMLCh* subcode,
575     const char* msg,
576     const char* relayState,
577     const RoleDescriptor* role,
578     const Application& application,
579     HTTPResponse& httpResponse,
580     bool front
581     ) const
582 {
583     // Get endpoint and encoder to use.
584     const EndpointType* ep = NULL;
585     const MessageEncoder* encoder = NULL;
586     if (front) {
587         const IDPSSODescriptor* idp = dynamic_cast<const IDPSSODescriptor*>(role);
588         for (vector<const XMLCh*>::const_iterator b = m_bindings.begin(); idp && b!=m_bindings.end(); ++b) {
589             if (ep=EndpointManager<SingleLogoutService>(idp->getSingleLogoutServices()).getByBinding(*b)) {
590                 map<const XMLCh*,MessageEncoder*>::const_iterator enc = m_encoders.find(*b);
591                 if (enc!=m_encoders.end())
592                     encoder = enc->second;
593                 break;
594             }
595         }
596         if (!ep || !encoder) {
597             auto_ptr_char id(dynamic_cast<EntityDescriptor*>(role->getParent())->getEntityID());
598             m_log.error("unable to locate compatible SLO service for provider (%s)", id.get());
599             MetadataException ex("Unable to locate endpoint at IdP ($entityID) to send LogoutResponse.");
600             annotateException(&ex, role);   // throws it
601         }
602     }
603     else {
604         encoder = m_encoders.begin()->second;
605     }
606
607     // Prepare response.
608     auto_ptr<LogoutResponse> logout(LogoutResponseBuilder::buildLogoutResponse());
609     logout->setInResponseTo(requestID);
610     if (ep) {
611         const XMLCh* loc = ep->getResponseLocation();
612         if (!loc || !*loc)
613             loc = ep->getLocation();
614         logout->setDestination(loc);
615     }
616     Issuer* issuer = IssuerBuilder::buildIssuer();
617     logout->setIssuer(issuer);
618     issuer->setName(application.getXMLString("entityID").second);
619     fillStatus(*logout.get(), code, subcode, msg);
620
621     auto_ptr_char dest(logout->getDestination());
622
623     long ret = sendMessage(*encoder, logout.get(), relayState, dest.get(), role, application, httpResponse);
624     logout.release();  // freed by encoder
625     return make_pair(true,ret);
626 }
627
628 #endif