123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- /*
- * Copyright 2004 The WebRTC Project Authors. All rights reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
- #ifndef THIRD_PARTY_LIBJINGLE_XMPP_XMPP_SASLCOOKIEMECHANISM_H_
- #define THIRD_PARTY_LIBJINGLE_XMPP_XMPP_SASLCOOKIEMECHANISM_H_
- #include "third_party/libjingle_xmpp/xmllite/qname.h"
- #include "third_party/libjingle_xmpp/xmllite/xmlelement.h"
- #include "third_party/libjingle_xmpp/xmpp/constants.h"
- #include "third_party/libjingle_xmpp/xmpp/saslmechanism.h"
- namespace jingle_xmpp {
- class SaslCookieMechanism : public SaslMechanism {
- public:
- SaslCookieMechanism(const std::string & mechanism,
- const std::string & username,
- const std::string & cookie,
- const std::string & token_service)
- : mechanism_(mechanism),
- username_(username),
- cookie_(cookie),
- token_service_(token_service) {}
- SaslCookieMechanism(const std::string & mechanism,
- const std::string & username,
- const std::string & cookie)
- : mechanism_(mechanism),
- username_(username),
- cookie_(cookie),
- token_service_("") {}
- virtual std::string GetMechanismName() { return mechanism_; }
- virtual XmlElement * StartSaslAuth() {
- // send initial request
- XmlElement * el = new XmlElement(QN_SASL_AUTH, true);
- el->AddAttr(QN_MECHANISM, mechanism_);
- if (!token_service_.empty()) {
- el->AddAttr(QN_GOOGLE_AUTH_SERVICE, token_service_);
- }
- std::string credential;
- credential.append("\0", 1);
- credential.append(username_);
- credential.append("\0", 1);
- credential.append(cookie_);
- el->AddText(Base64Encode(credential));
- return el;
- }
- private:
- std::string mechanism_;
- std::string username_;
- std::string cookie_;
- std::string token_service_;
- };
- }
- #endif // THIRD_PARTY_LIBJINGLE_XMPP_XMPP_SASLCOOKIEMECHANISM_H_
|