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

Side by Side Diff: jingle/notifier/communicator/gaia_token_pre_xmpp_auth.cc

Issue 6649006: Added support for other authentication mechanisms in jingle. This will allow ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Review comments addressed Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "jingle/notifier/communicator/gaia_token_pre_xmpp_auth.h" 5 #include "jingle/notifier/communicator/gaia_token_pre_xmpp_auth.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h"
10 #include "talk/base/socketaddress.h" 11 #include "talk/base/socketaddress.h"
11 #include "talk/xmpp/constants.h" 12 #include "talk/xmpp/constants.h"
12 #include "talk/xmpp/saslcookiemechanism.h" 13 #include "talk/xmpp/saslcookiemechanism.h"
13 14
14 namespace notifier { 15 namespace notifier {
15 16
16 namespace { 17 namespace {
17 18
18 const char kGaiaAuthMechanism[] = "X-GOOGLE-TOKEN";
19
20 class GaiaCookieMechanism : public buzz::SaslCookieMechanism { 19 class GaiaCookieMechanism : public buzz::SaslCookieMechanism {
21 public: 20 public:
22 GaiaCookieMechanism(const std::string & mechanism, 21 GaiaCookieMechanism(const std::string & mechanism,
23 const std::string & username, 22 const std::string & username,
24 const std::string & cookie, 23 const std::string & cookie,
25 const std::string & token_service) 24 const std::string & token_service)
26 : buzz::SaslCookieMechanism( 25 : buzz::SaslCookieMechanism(
27 mechanism, username, cookie, token_service) {} 26 mechanism, username, cookie, token_service) {}
28 27
29 virtual ~GaiaCookieMechanism() {} 28 virtual ~GaiaCookieMechanism() {}
(...skipping 12 matching lines...) Expand all
42 auth->SetAttr(QN_GOOGLE_AUTH_CLIENT_USES_FULL_BIND_RESULT, "true"); 41 auth->SetAttr(QN_GOOGLE_AUTH_CLIENT_USES_FULL_BIND_RESULT, "true");
43 return auth; 42 return auth;
44 } 43 }
45 44
46 private: 45 private:
47 DISALLOW_COPY_AND_ASSIGN(GaiaCookieMechanism); 46 DISALLOW_COPY_AND_ASSIGN(GaiaCookieMechanism);
48 }; 47 };
49 48
50 } // namespace 49 } // namespace
51 50
51 // By default use a Google cookie auth mechanism.
52 const char GaiaTokenPreXmppAuth::kDefaultAuthMechanism[] = "X-GOOGLE-TOKEN";
53
52 GaiaTokenPreXmppAuth::GaiaTokenPreXmppAuth( 54 GaiaTokenPreXmppAuth::GaiaTokenPreXmppAuth(
53 const std::string& username, 55 const std::string& username,
54 const std::string& token, 56 const std::string& token,
55 const std::string& token_service) 57 const std::string& token_service,
58 const std::string& auth_mechanism)
56 : username_(username), 59 : username_(username),
57 token_(token), 60 token_(token),
58 token_service_(token_service) { } 61 token_service_(token_service),
62 auth_mechanism_(auth_mechanism) {
63 DCHECK(!auth_mechanism_.empty());
64 }
59 65
60 GaiaTokenPreXmppAuth::~GaiaTokenPreXmppAuth() { } 66 GaiaTokenPreXmppAuth::~GaiaTokenPreXmppAuth() { }
61 67
62 void GaiaTokenPreXmppAuth::StartPreXmppAuth( 68 void GaiaTokenPreXmppAuth::StartPreXmppAuth(
63 const buzz::Jid& jid, 69 const buzz::Jid& jid,
64 const talk_base::SocketAddress& server, 70 const talk_base::SocketAddress& server,
65 const talk_base::CryptString& pass, 71 const talk_base::CryptString& pass,
66 const std::string& auth_cookie) { 72 const std::string& auth_cookie) {
67 SignalAuthDone(); 73 SignalAuthDone();
68 } 74 }
(...skipping 18 matching lines...) Expand all
87 return buzz::CaptchaChallenge(); 93 return buzz::CaptchaChallenge();
88 } 94 }
89 95
90 std::string GaiaTokenPreXmppAuth::GetAuthCookie() const { 96 std::string GaiaTokenPreXmppAuth::GetAuthCookie() const {
91 return std::string(); 97 return std::string();
92 } 98 }
93 99
94 std::string GaiaTokenPreXmppAuth::ChooseBestSaslMechanism( 100 std::string GaiaTokenPreXmppAuth::ChooseBestSaslMechanism(
95 const std::vector<std::string> & mechanisms, bool encrypted) { 101 const std::vector<std::string> & mechanisms, bool encrypted) {
96 return (std::find(mechanisms.begin(), 102 return (std::find(mechanisms.begin(),
97 mechanisms.end(), kGaiaAuthMechanism) != 103 mechanisms.end(), auth_mechanism_) !=
98 mechanisms.end()) ? kGaiaAuthMechanism : ""; 104 mechanisms.end()) ? auth_mechanism_ : "";
99 } 105 }
100 106
101 buzz::SaslMechanism* GaiaTokenPreXmppAuth::CreateSaslMechanism( 107 buzz::SaslMechanism* GaiaTokenPreXmppAuth::CreateSaslMechanism(
102 const std::string& mechanism) { 108 const std::string& mechanism) {
103 if (mechanism != kGaiaAuthMechanism) 109 if (mechanism == auth_mechanism_)
104 return NULL; 110 return new GaiaCookieMechanism(
105 return new GaiaCookieMechanism( 111 mechanism, username_, token_, token_service_);
106 kGaiaAuthMechanism, username_, token_, token_service_); 112 return NULL;
107 } 113 }
108 114
109 } // namespace notifier 115 } // namespace notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698