diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-09 19:09:11 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-09 19:09:11 +0000 |
commit | 6f5ec4a51a4cfc6023c094801f2f180c6739a89b (patch) | |
tree | 256f64b843183e4c1c0b525ac84b84797e038848 /chrome | |
parent | c78559eabd562359ef23585df9268eeb5119b718 (diff) | |
download | chromium_src-6f5ec4a51a4cfc6023c094801f2f180c6739a89b.zip chromium_src-6f5ec4a51a4cfc6023c094801f2f180c6739a89b.tar.gz chromium_src-6f5ec4a51a4cfc6023c094801f2f180c6739a89b.tar.bz2 |
Revert 49298 - Broke compile - Token-based authentication for chromoting.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/2749004
TBR=sergeyu@chromium.org
Review URL: http://codereview.chromium.org/2724010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49300 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
4 files changed, 87 insertions, 138 deletions
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 4c8d24e..b2ac50a 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -726,8 +726,6 @@ 'common/net/notifier/communicator/connection_settings.cc', 'common/net/notifier/communicator/connection_settings.h', 'common/net/notifier/communicator/const_communicator.h', - 'common/net/notifier/communicator/gaia_token_pre_xmpp_auth.cc', - 'common/net/notifier/communicator/gaia_token_pre_xmpp_auth.h', 'common/net/notifier/communicator/login.cc', 'common/net/notifier/communicator/login.h', 'common/net/notifier/communicator/login_connection_state.h', diff --git a/chrome/common/net/notifier/communicator/gaia_token_pre_xmpp_auth.cc b/chrome/common/net/notifier/communicator/gaia_token_pre_xmpp_auth.cc deleted file mode 100644 index 8763809..0000000 --- a/chrome/common/net/notifier/communicator/gaia_token_pre_xmpp_auth.cc +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/common/net/notifier/communicator/gaia_token_pre_xmpp_auth.h" - -#include "talk/base/socketaddress.h" -#include "talk/xmpp/constants.h" -#include "talk/xmpp/saslcookiemechanism.h" - -namespace notifier { - -namespace { -const char kGaiaAuthMechanism[] = "X-GOOGLE-TOKEN"; -} // namespace - -GaiaTokenPreXmppAuth::GaiaTokenPreXmppAuth( - const std::string& username, - const std::string& token, - const std::string& token_service) - : username_(username), - token_(token), - token_service_(token_service) { } - -GaiaTokenPreXmppAuth::~GaiaTokenPreXmppAuth() { } - -void GaiaTokenPreXmppAuth::StartPreXmppAuth( - const buzz::Jid& jid, - const talk_base::SocketAddress& server, - const talk_base::CryptString& pass, - const std::string& auth_cookie) { - SignalAuthDone(); -} - -bool GaiaTokenPreXmppAuth::IsAuthDone() const { - return true; -} - -bool GaiaTokenPreXmppAuth::IsAuthorized() const { - return true; -} - -bool GaiaTokenPreXmppAuth::HadError() const { - return false; -} - -int GaiaTokenPreXmppAuth::GetError() const { - return 0; -} - -buzz::CaptchaChallenge GaiaTokenPreXmppAuth::GetCaptchaChallenge() const { - return buzz::CaptchaChallenge(); -} - -std::string GaiaTokenPreXmppAuth::GetAuthCookie() const { - return std::string(); -} - -std::string GaiaTokenPreXmppAuth::ChooseBestSaslMechanism( - const std::vector<std::string> & mechanisms, bool encrypted) { - return (std::find(mechanisms.begin(), - mechanisms.end(), kGaiaAuthMechanism) != - mechanisms.end()) ? kGaiaAuthMechanism : ""; -} - -buzz::SaslMechanism* GaiaTokenPreXmppAuth::CreateSaslMechanism( - const std::string& mechanism) { - if (mechanism != kGaiaAuthMechanism) - return NULL; - return new buzz::SaslCookieMechanism( - kGaiaAuthMechanism, username_, token_, token_service_); -} - -} // namespace notifier diff --git a/chrome/common/net/notifier/communicator/gaia_token_pre_xmpp_auth.h b/chrome/common/net/notifier/communicator/gaia_token_pre_xmpp_auth.h deleted file mode 100644 index 0eb6aa0..0000000 --- a/chrome/common/net/notifier/communicator/gaia_token_pre_xmpp_auth.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_COMMON_NET_NOTIFIER_COMMUNICATOR_GAIA_TOKEN_PRE_XMPP_AUTH_H_ -#define CHROME_COMMON_NET_NOTIFIER_COMMUNICATOR_GAIA_TOKEN_PRE_XMPP_AUTH_H_ - -#include <string> -#include <vector> - -#include "talk/xmpp/prexmppauth.h" - -namespace notifier { - -// This class implements buzz::PreXmppAuth interface for token-based -// authentication in GTalk. It looks for the X-GOOGLE-TOKEN auth mechanism -// and uses that instead of the default auth mechanism (PLAIN). -class GaiaTokenPreXmppAuth : public buzz::PreXmppAuth { - public: - GaiaTokenPreXmppAuth(const std::string& username, const std::string& token, - const std::string& token_service); - - virtual ~GaiaTokenPreXmppAuth(); - - // buzz::PreXmppAuth (-buzz::SaslHandler) implementation. We stub - // all the methods out as we don't actually do any authentication at - // this point. - virtual void StartPreXmppAuth(const buzz::Jid& jid, - const talk_base::SocketAddress& server, - const talk_base::CryptString& pass, - const std::string& auth_cookie); - - virtual bool IsAuthDone() const; - - virtual bool IsAuthorized() const; - - virtual bool HadError() const; - - virtual int GetError() const; - - virtual buzz::CaptchaChallenge GetCaptchaChallenge() const; - - virtual std::string GetAuthCookie() const; - - // buzz::SaslHandler implementation. - - virtual std::string ChooseBestSaslMechanism( - const std::vector<std::string>& mechanisms, bool encrypted); - - virtual buzz::SaslMechanism* CreateSaslMechanism( - const std::string& mechanism); - - private: - std::string username_; - std::string token_; - std::string token_service_; -}; - -} // namespace notifier - -#endif // CHROME_COMMON_NET_NOTIFIER_COMMUNICATOR_GAIA_TOKEN_PRE_XMPP_AUTH_H_ diff --git a/chrome/common/net/notifier/communicator/single_login_attempt.cc b/chrome/common/net/notifier/communicator/single_login_attempt.cc index 7781c38..706c8f2 100644 --- a/chrome/common/net/notifier/communicator/single_login_attempt.cc +++ b/chrome/common/net/notifier/communicator/single_login_attempt.cc @@ -12,7 +12,6 @@ #include "chrome/common/net/notifier/communicator/connection_options.h" #include "chrome/common/net/notifier/communicator/connection_settings.h" #include "chrome/common/net/notifier/communicator/const_communicator.h" -#include "chrome/common/net/notifier/communicator/gaia_token_pre_xmpp_auth.h" #include "chrome/common/net/notifier/communicator/login_failure.h" #include "chrome/common/net/notifier/communicator/login_settings.h" #include "chrome/common/net/notifier/communicator/product_info.h" @@ -24,6 +23,8 @@ #include "talk/base/taskrunner.h" #include "talk/base/win32socketinit.h" #include "talk/xmllite/xmlelement.h" +#include "talk/xmpp/prexmppauth.h" +#include "talk/xmpp/saslcookiemechanism.h" #include "talk/xmpp/xmppclient.h" #include "talk/xmpp/xmppclientsettings.h" #include "talk/xmpp/constants.h" @@ -51,6 +52,91 @@ static void GetClientErrorInformation( } } +namespace { + +const char kGaiaAuthMechanism[] = "X-GOOGLE-TOKEN"; + +// This class looks for the X-GOOGLE-TOKEN auth mechanism and uses +// that instead of the default auth mechanism (PLAIN). +class GaiaTokenPreXmppAuth : public buzz::PreXmppAuth { + public: + GaiaTokenPreXmppAuth( + const std::string& username, + const std::string& token, + const std::string& token_service) + : username_(username), + token_(token), + token_service_(token_service) {} + + virtual ~GaiaTokenPreXmppAuth() {} + + // buzz::PreXmppAuth (-buzz::SaslHandler) implementation. We stub + // all the methods out as we don't actually do any authentication at + // this point. + + virtual void StartPreXmppAuth( + const buzz::Jid& jid, + const talk_base::SocketAddress& server, + const talk_base::CryptString& pass, + const std::string& auth_cookie) { + SignalAuthDone(); + } + + virtual bool IsAuthDone() const { return true; } + + virtual bool IsAuthorized() const { return true; } + + virtual bool HadError() const { return false; } + + virtual int GetError() const { return 0; } + + virtual buzz::CaptchaChallenge GetCaptchaChallenge() const { + return buzz::CaptchaChallenge(); + } + + virtual std::string GetAuthCookie() const { return std::string(); } + + // buzz::SaslHandler implementation. + + virtual std::string ChooseBestSaslMechanism( + const std::vector<std::string> & mechanisms, bool encrypted) { + return (std::find(mechanisms.begin(), + mechanisms.end(), kGaiaAuthMechanism) != + mechanisms.end()) ? kGaiaAuthMechanism : ""; + } + + virtual buzz::SaslMechanism* CreateSaslMechanism( + const std::string& mechanism) { + return + (mechanism == kGaiaAuthMechanism) ? + new buzz::SaslCookieMechanism( + kGaiaAuthMechanism, username_, token_, token_service_) + : NULL; + } + + // TODO(akalin): remove this code. + virtual bool GetTlsServerInfo(const talk_base::SocketAddress& server, + std::string* tls_server_hostname, + std::string* tls_server_domain) const { + std::string server_ip = server.IPAsString(); + if ((server_ip == buzz::STR_TALK_GOOGLE_COM) || + (server_ip == buzz::STR_TALKX_L_GOOGLE_COM)) { + // For Gaia auth, the talk.google.com server expects you to use + // "gmail.com" in the stream, and expects the domain certificate + // to be "gmail.com" as well. + *tls_server_hostname = buzz::STR_GMAIL_COM; + *tls_server_domain = buzz::STR_GMAIL_COM; + return true; + } + return false; + } + + private: + std::string username_, token_, token_service_; +}; + +} // namespace + SingleLoginAttempt::SingleLoginAttempt(talk_base::TaskParent* parent, LoginSettings* login_settings, bool successful_connection) |