diff options
-rw-r--r-- | jingle/jingle.gyp | 1 | ||||
-rw-r--r-- | jingle/notifier/base/notifier_options.cc | 19 | ||||
-rw-r--r-- | jingle/notifier/base/notifier_options.h | 11 | ||||
-rw-r--r-- | jingle/notifier/communicator/gaia_token_pre_xmpp_auth.cc | 26 | ||||
-rw-r--r-- | jingle/notifier/communicator/gaia_token_pre_xmpp_auth.h | 6 | ||||
-rw-r--r-- | jingle/notifier/communicator/login.cc | 6 | ||||
-rw-r--r-- | jingle/notifier/communicator/login.h | 3 | ||||
-rw-r--r-- | jingle/notifier/communicator/login_settings.cc | 6 | ||||
-rw-r--r-- | jingle/notifier/communicator/login_settings.h | 9 | ||||
-rw-r--r-- | jingle/notifier/communicator/single_login_attempt.cc | 3 | ||||
-rw-r--r-- | jingle/notifier/listener/mediator_thread_impl.cc | 3 | ||||
-rw-r--r-- | remoting/jingle_glue/jingle_client.cc | 7 |
12 files changed, 74 insertions, 26 deletions
diff --git a/jingle/jingle.gyp b/jingle/jingle.gyp index 9af72b4..fbc1b72 100644 --- a/jingle/jingle.gyp +++ b/jingle/jingle.gyp @@ -21,6 +21,7 @@ 'notifier/base/fake_ssl_client_socket.h', 'notifier/base/notification_method.h', 'notifier/base/notification_method.cc', + 'notifier/base/notifier_options.cc', 'notifier/base/notifier_options.h', 'notifier/base/task_pump.cc', 'notifier/base/task_pump.h', diff --git a/jingle/notifier/base/notifier_options.cc b/jingle/notifier/base/notifier_options.cc new file mode 100644 index 0000000..6191af1 --- /dev/null +++ b/jingle/notifier/base/notifier_options.cc @@ -0,0 +1,19 @@ +// Copyright (c) 2011 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 "jingle/notifier/base/notifier_options.h" + +// TODO(akalin): Fix the cross-directory dependency. +#include "jingle/notifier/communicator/gaia_token_pre_xmpp_auth.h" + +namespace notifier { + +NotifierOptions::NotifierOptions() + : try_ssltcp_first(false), + allow_insecure_connection(false), + invalidate_xmpp_login(false), + notification_method(kDefaultNotificationMethod), + auth_mechanism(GaiaTokenPreXmppAuth::kDefaultAuthMechanism) {} + +} // namespace notifier diff --git a/jingle/notifier/base/notifier_options.h b/jingle/notifier/base/notifier_options.h index ec63cdb..5cd4243 100644 --- a/jingle/notifier/base/notifier_options.h +++ b/jingle/notifier/base/notifier_options.h @@ -5,17 +5,15 @@ #ifndef JINGLE_NOTIFIER_BASE_NOTIFIER_OPTIONS_H_ #define JINGLE_NOTIFIER_BASE_NOTIFIER_OPTIONS_H_ +#include <string> + #include "jingle/notifier/base/notification_method.h" #include "net/base/host_port_pair.h" namespace notifier { struct NotifierOptions { - NotifierOptions() - : try_ssltcp_first(false), - allow_insecure_connection(false), - invalidate_xmpp_login(false), - notification_method(kDefaultNotificationMethod) {} + NotifierOptions(); // Indicates that the SSLTCP port (443) is to be tried before the the XMPP // port (5222) during login. @@ -36,6 +34,9 @@ struct NotifierOptions { // Indicates the method used by sync clients while sending and listening to // notifications. NotificationMethod notification_method; + + // Specifies the auth mechanism to use ("X-GOOGLE-TOKEN", "X-OAUTH2", etc), + std::string auth_mechanism; }; } // namespace notifier diff --git a/jingle/notifier/communicator/gaia_token_pre_xmpp_auth.cc b/jingle/notifier/communicator/gaia_token_pre_xmpp_auth.cc index a10900d..eb42e6a 100644 --- a/jingle/notifier/communicator/gaia_token_pre_xmpp_auth.cc +++ b/jingle/notifier/communicator/gaia_token_pre_xmpp_auth.cc @@ -7,6 +7,7 @@ #include <algorithm> #include "base/basictypes.h" +#include "base/logging.h" #include "talk/base/socketaddress.h" #include "talk/xmpp/constants.h" #include "talk/xmpp/saslcookiemechanism.h" @@ -15,8 +16,6 @@ namespace notifier { namespace { -const char kGaiaAuthMechanism[] = "X-GOOGLE-TOKEN"; - class GaiaCookieMechanism : public buzz::SaslCookieMechanism { public: GaiaCookieMechanism(const std::string & mechanism, @@ -49,13 +48,20 @@ class GaiaCookieMechanism : public buzz::SaslCookieMechanism { } // namespace +// By default use a Google cookie auth mechanism. +const char GaiaTokenPreXmppAuth::kDefaultAuthMechanism[] = "X-GOOGLE-TOKEN"; + GaiaTokenPreXmppAuth::GaiaTokenPreXmppAuth( const std::string& username, const std::string& token, - const std::string& token_service) + const std::string& token_service, + const std::string& auth_mechanism) : username_(username), token_(token), - token_service_(token_service) { } + token_service_(token_service), + auth_mechanism_(auth_mechanism) { + DCHECK(!auth_mechanism_.empty()); +} GaiaTokenPreXmppAuth::~GaiaTokenPreXmppAuth() { } @@ -94,16 +100,16 @@ std::string GaiaTokenPreXmppAuth::GetAuthCookie() const { std::string GaiaTokenPreXmppAuth::ChooseBestSaslMechanism( const std::vector<std::string> & mechanisms, bool encrypted) { return (std::find(mechanisms.begin(), - mechanisms.end(), kGaiaAuthMechanism) != - mechanisms.end()) ? kGaiaAuthMechanism : ""; + mechanisms.end(), auth_mechanism_) != + mechanisms.end()) ? auth_mechanism_ : ""; } buzz::SaslMechanism* GaiaTokenPreXmppAuth::CreateSaslMechanism( const std::string& mechanism) { - if (mechanism != kGaiaAuthMechanism) - return NULL; - return new GaiaCookieMechanism( - kGaiaAuthMechanism, username_, token_, token_service_); + if (mechanism == auth_mechanism_) + return new GaiaCookieMechanism( + mechanism, username_, token_, token_service_); + return NULL; } } // namespace notifier diff --git a/jingle/notifier/communicator/gaia_token_pre_xmpp_auth.h b/jingle/notifier/communicator/gaia_token_pre_xmpp_auth.h index a18c77a..9f7f035 100644 --- a/jingle/notifier/communicator/gaia_token_pre_xmpp_auth.h +++ b/jingle/notifier/communicator/gaia_token_pre_xmpp_auth.h @@ -18,7 +18,8 @@ namespace notifier { class GaiaTokenPreXmppAuth : public buzz::PreXmppAuth { public: GaiaTokenPreXmppAuth(const std::string& username, const std::string& token, - const std::string& token_service); + const std::string& token_service, + const std::string& auth_mechanism); virtual ~GaiaTokenPreXmppAuth(); @@ -50,10 +51,13 @@ class GaiaTokenPreXmppAuth : public buzz::PreXmppAuth { virtual buzz::SaslMechanism* CreateSaslMechanism( const std::string& mechanism); + static const char kDefaultAuthMechanism[]; + private: std::string username_; std::string token_; std::string token_service_; + std::string auth_mechanism_; }; } // namespace notifier diff --git a/jingle/notifier/communicator/login.cc b/jingle/notifier/communicator/login.cc index b19169c..6b1119b 100644 --- a/jingle/notifier/communicator/login.cc +++ b/jingle/notifier/communicator/login.cc @@ -37,7 +37,8 @@ Login::Login(Delegate* delegate, net::CertVerifier* cert_verifier, ServerInformation* server_list, int server_count, - bool try_ssltcp_first) + bool try_ssltcp_first, + const std::string& auth_mechanism) : delegate_(delegate), login_settings_(new LoginSettings(user_settings, options, @@ -45,7 +46,8 @@ Login::Login(Delegate* delegate, cert_verifier, server_list, server_count, - try_ssltcp_first)), + try_ssltcp_first, + auth_mechanism)), redirect_port_(0) { net::NetworkChangeNotifier::AddIPAddressObserver(this); ResetReconnectState(); diff --git a/jingle/notifier/communicator/login.h b/jingle/notifier/communicator/login.h index d7ecbdf..0d3e430 100644 --- a/jingle/notifier/communicator/login.h +++ b/jingle/notifier/communicator/login.h @@ -64,7 +64,8 @@ class Login : public net::NetworkChangeNotifier::IPAddressObserver, net::CertVerifier* cert_verifier, ServerInformation* server_list, int server_count, - bool try_ssltcp_first); + bool try_ssltcp_first, + const std::string& auth_mechanism); virtual ~Login(); void StartConnection(); diff --git a/jingle/notifier/communicator/login_settings.cc b/jingle/notifier/communicator/login_settings.cc index fd70400..6345810 100644 --- a/jingle/notifier/communicator/login_settings.cc +++ b/jingle/notifier/communicator/login_settings.cc @@ -22,14 +22,16 @@ LoginSettings::LoginSettings(const buzz::XmppClientSettings& user_settings, net::CertVerifier* cert_verifier, ServerInformation* server_list, int server_count, - bool try_ssltcp_first) + bool try_ssltcp_first, + const std::string& auth_mechanism) : try_ssltcp_first_(try_ssltcp_first), host_resolver_(host_resolver), cert_verifier_(cert_verifier), server_list_(new ServerInformation[server_count]), server_count_(server_count), user_settings_(new buzz::XmppClientSettings(user_settings)), - connection_options_(new ConnectionOptions(options)) { + connection_options_(new ConnectionOptions(options)), + auth_mechanism_(auth_mechanism) { // Note: firewall may be NULL. DCHECK(server_list); DCHECK(host_resolver); diff --git a/jingle/notifier/communicator/login_settings.h b/jingle/notifier/communicator/login_settings.h index d0f4bc6..812022b 100644 --- a/jingle/notifier/communicator/login_settings.h +++ b/jingle/notifier/communicator/login_settings.h @@ -35,7 +35,8 @@ class LoginSettings { net::CertVerifier* cert_verifier, ServerInformation* server_list, int server_count, - bool try_ssltcp_first); + bool try_ssltcp_first, + const std::string& auth_mechanism); ~LoginSettings(); @@ -74,6 +75,10 @@ class LoginSettings { void set_server_override(const net::HostPortPair& server); void clear_server_override(); + std::string auth_mechanism() const { + return auth_mechanism_; + } + private: bool try_ssltcp_first_; @@ -86,6 +91,8 @@ class LoginSettings { scoped_ptr<buzz::XmppClientSettings> user_settings_; scoped_ptr<ConnectionOptions> connection_options_; + std::string auth_mechanism_; + DISALLOW_COPY_AND_ASSIGN(LoginSettings); }; } // namespace notifier diff --git a/jingle/notifier/communicator/single_login_attempt.cc b/jingle/notifier/communicator/single_login_attempt.cc index fdd8ad5..5bfe6e3 100644 --- a/jingle/notifier/communicator/single_login_attempt.cc +++ b/jingle/notifier/communicator/single_login_attempt.cc @@ -113,7 +113,8 @@ void SingleLoginAttempt::OnNewSettings( buzz::PreXmppAuth* pre_xmpp_auth = new GaiaTokenPreXmppAuth( jid.Str(), client_settings.auth_cookie(), - client_settings.token_service()); + client_settings.token_service(), + login_settings_->auth_mechanism()); xmpp_connection_.reset( new XmppConnection(client_settings, login_settings_->cert_verifier(), this, pre_xmpp_auth)); diff --git a/jingle/notifier/listener/mediator_thread_impl.cc b/jingle/notifier/listener/mediator_thread_impl.cc index 032c08e..c7b5e5c 100644 --- a/jingle/notifier/listener/mediator_thread_impl.cc +++ b/jingle/notifier/listener/mediator_thread_impl.cc @@ -156,7 +156,8 @@ void MediatorThreadImpl::DoLogin( cert_verifier_.get(), server_list, server_list_count, - notifier_options_.try_ssltcp_first)); + notifier_options_.try_ssltcp_first, + notifier_options_.auth_mechanism)); login_->StartConnection(); } diff --git a/remoting/jingle_glue/jingle_client.cc b/remoting/jingle_glue/jingle_client.cc index 6ef8815..dd72de6 100644 --- a/remoting/jingle_glue/jingle_client.cc +++ b/remoting/jingle_glue/jingle_client.cc @@ -114,8 +114,11 @@ void XmppSignalStrategy::OnConnectionStateChanged( buzz::PreXmppAuth* XmppSignalStrategy::CreatePreXmppAuth( const buzz::XmppClientSettings& settings) { buzz::Jid jid(settings.user(), settings.host(), buzz::STR_EMPTY); - return new notifier::GaiaTokenPreXmppAuth(jid.Str(), settings.auth_cookie(), - settings.token_service()); + return new notifier::GaiaTokenPreXmppAuth( + jid.Str(), + settings.auth_cookie(), + settings.token_service(), + notifier::GaiaTokenPreXmppAuth::kDefaultAuthMechanism); } |