OLD | NEW |
(Empty) | |
| 1 // Copyright 2004 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WEBRTC_LIBJINGLE_XMPP_SASLCOOKIEMECHANISM_H_ |
| 6 #define WEBRTC_LIBJINGLE_XMPP_SASLCOOKIEMECHANISM_H_ |
| 7 |
| 8 #include "third_party/libjingle_xmpp/xmllite/qname.h" |
| 9 #include "third_party/libjingle_xmpp/xmllite/xmlelement.h" |
| 10 #include "third_party/libjingle_xmpp/xmpp/constants.h" |
| 11 #include "third_party/libjingle_xmpp/xmpp/saslmechanism.h" |
| 12 |
| 13 namespace buzz { |
| 14 |
| 15 class SaslCookieMechanism : public SaslMechanism { |
| 16 |
| 17 public: |
| 18 SaslCookieMechanism(const std::string & mechanism, |
| 19 const std::string & username, |
| 20 const std::string & cookie, |
| 21 const std::string & token_service) |
| 22 : mechanism_(mechanism), |
| 23 username_(username), |
| 24 cookie_(cookie), |
| 25 token_service_(token_service) {} |
| 26 |
| 27 SaslCookieMechanism(const std::string & mechanism, |
| 28 const std::string & username, |
| 29 const std::string & cookie) |
| 30 : mechanism_(mechanism), |
| 31 username_(username), |
| 32 cookie_(cookie), |
| 33 token_service_("") {} |
| 34 |
| 35 virtual std::string GetMechanismName() { return mechanism_; } |
| 36 |
| 37 virtual XmlElement * StartSaslAuth() { |
| 38 // send initial request |
| 39 XmlElement * el = new XmlElement(QN_SASL_AUTH, true); |
| 40 el->AddAttr(QN_MECHANISM, mechanism_); |
| 41 if (!token_service_.empty()) { |
| 42 el->AddAttr(QN_GOOGLE_AUTH_SERVICE, token_service_); |
| 43 } |
| 44 |
| 45 std::string credential; |
| 46 credential.append("\0", 1); |
| 47 credential.append(username_); |
| 48 credential.append("\0", 1); |
| 49 credential.append(cookie_); |
| 50 el->AddText(Base64Encode(credential)); |
| 51 return el; |
| 52 } |
| 53 |
| 54 private: |
| 55 std::string mechanism_; |
| 56 std::string username_; |
| 57 std::string cookie_; |
| 58 std::string token_service_; |
| 59 }; |
| 60 |
| 61 } |
| 62 |
| 63 #endif // WEBRTC_LIBJINGLE_XMPP_SASLCOOKIEMECHANISM_H_ |
OLD | NEW |