2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #ifndef WEBRTC_LIBJINGLE_XMPP_PLAINSASLHANDLER_H_
12 #define WEBRTC_LIBJINGLE_XMPP_PLAINSASLHANDLER_H_
15 #include "webrtc/libjingle/xmpp/saslhandler.h"
16 #include "webrtc/libjingle/xmpp/saslplainmechanism.h"
17 #include "webrtc/base/cryptstring.h"
21 class PlainSaslHandler : public SaslHandler {
23 PlainSaslHandler(const Jid & jid, const rtc::CryptString & password,
24 bool allow_plain) : jid_(jid), password_(password),
25 allow_plain_(allow_plain) {}
27 virtual ~PlainSaslHandler() {}
29 // Should pick the best method according to this handler
30 // returns the empty string if none are suitable
31 virtual std::string ChooseBestSaslMechanism(const std::vector<std::string> & mechanisms, bool encrypted) {
33 if (!encrypted && !allow_plain_) {
37 std::vector<std::string>::const_iterator it = std::find(mechanisms.begin(), mechanisms.end(), "PLAIN");
38 if (it == mechanisms.end()) {
46 // Creates a SaslMechanism for the given mechanism name (you own it
47 // once you get it). If not handled, return NULL.
48 virtual SaslMechanism * CreateSaslMechanism(const std::string & mechanism) {
49 if (mechanism == "PLAIN") {
50 return new SaslPlainMechanism(jid_, password_);
57 rtc::CryptString password_;
64 #endif // WEBRTC_LIBJINGLE_XMPP_PLAINSASLHANDLER_H_