Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: third_party/libjingle_xmpp/xmpp/plainsaslhandler.h

Issue 2443903004: Add xmllite and xmpp sources to third_party/ (Closed)
Patch Set: Fix GN and sort includes Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_PLAINSASLHANDLER_H_
6 #define WEBRTC_LIBJINGLE_XMPP_PLAINSASLHANDLER_H_
7
8 #include <algorithm>
9 #include "third_party/libjingle_xmpp/xmpp/saslhandler.h"
10 #include "third_party/libjingle_xmpp/xmpp/saslplainmechanism.h"
11 #include "webrtc/base/cryptstring.h"
12
13 namespace buzz {
14
15 class PlainSaslHandler : public SaslHandler {
16 public:
17 PlainSaslHandler(const Jid & jid, const rtc::CryptString & password,
18 bool allow_plain) : jid_(jid), password_(password),
19 allow_plain_(allow_plain) {}
20
21 virtual ~PlainSaslHandler() {}
22
23 // Should pick the best method according to this handler
24 // returns the empty string if none are suitable
25 virtual std::string ChooseBestSaslMechanism(const std::vector<std::string> & m echanisms, bool encrypted) {
26
27 if (!encrypted && !allow_plain_) {
28 return "";
29 }
30
31 std::vector<std::string>::const_iterator it = std::find(mechanisms.begin(), mechanisms.end(), "PLAIN");
32 if (it == mechanisms.end()) {
33 return "";
34 }
35 else {
36 return "PLAIN";
37 }
38 }
39
40 // Creates a SaslMechanism for the given mechanism name (you own it
41 // once you get it). If not handled, return NULL.
42 virtual SaslMechanism * CreateSaslMechanism(const std::string & mechanism) {
43 if (mechanism == "PLAIN") {
44 return new SaslPlainMechanism(jid_, password_);
45 }
46 return NULL;
47 }
48
49 private:
50 Jid jid_;
51 rtc::CryptString password_;
52 bool allow_plain_;
53 };
54
55
56 }
57
58 #endif // WEBRTC_LIBJINGLE_XMPP_PLAINSASLHANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698