summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-27 05:49:31 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-27 05:49:31 +0000
commit6c8beb5f61062a2926301d53f721dd81aa6dfda7 (patch)
tree046a10a30db42cf75605bfd0bf9834fd1b1c5694
parente648166a931897dc068fb7b84725200e70911731 (diff)
downloadchromium_src-6c8beb5f61062a2926301d53f721dd81aa6dfda7.zip
chromium_src-6c8beb5f61062a2926301d53f721dd81aa6dfda7.tar.gz
chromium_src-6c8beb5f61062a2926301d53f721dd81aa6dfda7.tar.bz2
Recombined buzz::PreXmppAuth and buzz::SaslHandler to be compatible
with upstream libjingle again. Changed GaiaOnlySaslHandler to GaiaTokenPreXmppAuth to match libjingle changes. BUG=none TEST=made sure sync worked with an @google.com account. Review URL: http://codereview.chromium.org/2221004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48364 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/sync/tools/sync_listen_notifications.cc2
-rw-r--r--chrome/common/net/notifier/communicator/single_login_attempt.cc43
-rw-r--r--chrome/common/net/notifier/communicator/single_login_attempt.h4
-rw-r--r--third_party/libjingle/files/talk/xmpp/plainsaslhandler.h6
-rw-r--r--third_party/libjingle/files/talk/xmpp/prexmppauth.h3
-rw-r--r--third_party/libjingle/files/talk/xmpp/saslhandler.h10
-rw-r--r--third_party/libjingle/files/talk/xmpp/xmppclient.cc38
-rw-r--r--third_party/libjingle/files/talk/xmpp/xmppclient.h4
8 files changed, 60 insertions, 50 deletions
diff --git a/chrome/browser/sync/tools/sync_listen_notifications.cc b/chrome/browser/sync/tools/sync_listen_notifications.cc
index 91610f2..d57f466 100644
--- a/chrome/browser/sync/tools/sync_listen_notifications.cc
+++ b/chrome/browser/sync/tools/sync_listen_notifications.cc
@@ -92,7 +92,7 @@ class XmppNotificationClient : public sigslot::has_slots<> {
// Transfers ownership of xmpp_socket_adapter.
buzz::XmppReturnStatus connect_status =
xmpp_client_->Connect(xmpp_client_settings_, "",
- xmpp_socket_adapter, NULL, NULL);
+ xmpp_socket_adapter, NULL);
CHECK_EQ(connect_status, buzz::XMPP_RETURN_OK);
xmpp_client_->Start();
talk_base::Thread* current_thread =
diff --git a/chrome/common/net/notifier/communicator/single_login_attempt.cc b/chrome/common/net/notifier/communicator/single_login_attempt.cc
index 217e13f..965a024 100644
--- a/chrome/common/net/notifier/communicator/single_login_attempt.cc
+++ b/chrome/common/net/notifier/communicator/single_login_attempt.cc
@@ -23,8 +23,8 @@
#include "talk/base/taskrunner.h"
#include "talk/base/winsock_initializer.h"
#include "talk/xmllite/xmlelement.h"
+#include "talk/xmpp/prexmppauth.h"
#include "talk/xmpp/saslcookiemechanism.h"
-#include "talk/xmpp/saslhandler.h"
#include "talk/xmpp/xmppclient.h"
#include "talk/xmpp/xmppclientsettings.h"
#include "talk/xmpp/xmppconstants.h"
@@ -58,9 +58,9 @@ 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 GaiaOnlySaslHandler : public buzz::SaslHandler {
+class GaiaTokenPreXmppAuth : public buzz::PreXmppAuth {
public:
- GaiaOnlySaslHandler(
+ GaiaTokenPreXmppAuth(
const std::string& username,
const std::string& token,
const std::string& token_service)
@@ -68,6 +68,36 @@ class GaiaOnlySaslHandler : public buzz::SaslHandler {
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() { return true; }
+
+ virtual bool IsAuthorized() { return true; }
+
+ virtual bool HadError() { return false; }
+
+ virtual int GetError() { return 0; }
+
+ virtual buzz::CaptchaChallenge GetCaptchaChallenge() {
+ return buzz::CaptchaChallenge();
+ }
+
+ virtual std::string GetAuthCookie() { return std::string(); }
+
+ // buzz::SaslHandler implementation.
+
virtual std::string ChooseBestSaslMechanism(
const std::vector<std::string> & mechanisms, bool encrypted) {
return (std::find(mechanisms.begin(),
@@ -249,8 +279,7 @@ void SingleLoginAttempt::DoLogin(
// Start connecting.
client_->Connect(client_settings, login_settings_->lang(),
CreateSocket(client_settings),
- NULL,
- CreateSaslHandler(client_settings));
+ CreatePreXmppAuth(client_settings));
client_->Start();
}
@@ -279,10 +308,10 @@ buzz::AsyncSocket* SingleLoginAttempt::CreateSocket(
return adapter;
}
-buzz::SaslHandler* SingleLoginAttempt::CreateSaslHandler(
+buzz::PreXmppAuth* SingleLoginAttempt::CreatePreXmppAuth(
const buzz::XmppClientSettings& xcs) {
buzz::Jid jid(xcs.user(), xcs.host(), buzz::STR_EMPTY);
- return new GaiaOnlySaslHandler(
+ return new GaiaTokenPreXmppAuth(
jid.Str(), xcs.auth_cookie(), xcs.token_service());
}
diff --git a/chrome/common/net/notifier/communicator/single_login_attempt.h b/chrome/common/net/notifier/communicator/single_login_attempt.h
index 0f4ac91..4d63cf0 100644
--- a/chrome/common/net/notifier/communicator/single_login_attempt.h
+++ b/chrome/common/net/notifier/communicator/single_login_attempt.h
@@ -15,7 +15,7 @@
namespace buzz {
class AsyncSocket;
-class SaslHandler;
+class PreXmppAuth;
class XmppClient;
class XmppClientSettings;
class XmppClientSettings;
@@ -94,7 +94,7 @@ class SingleLoginAttempt : public talk_base::Task, public sigslot::has_slots<> {
private:
void DoLogin(const ConnectionSettings& connection_settings);
buzz::AsyncSocket* CreateSocket(const buzz::XmppClientSettings& xcs);
- static buzz::SaslHandler* CreateSaslHandler(
+ static buzz::PreXmppAuth* CreatePreXmppAuth(
const buzz::XmppClientSettings& xcs);
// Cleans up any xmpp client state to get ready for a new one.
diff --git a/third_party/libjingle/files/talk/xmpp/plainsaslhandler.h b/third_party/libjingle/files/talk/xmpp/plainsaslhandler.h
index 39e4fb0..8cf1ed8 100644
--- a/third_party/libjingle/files/talk/xmpp/plainsaslhandler.h
+++ b/third_party/libjingle/files/talk/xmpp/plainsaslhandler.h
@@ -68,12 +68,6 @@ public:
}
return NULL;
}
-
- virtual bool GetTlsServerInfo(const talk_base::SocketAddress& server,
- std::string* tls_server_hostname,
- std::string* tls_server_domain) {
- return false;
- }
private:
Jid jid_;
diff --git a/third_party/libjingle/files/talk/xmpp/prexmppauth.h b/third_party/libjingle/files/talk/xmpp/prexmppauth.h
index d8fdbc6..f94bd3d 100644
--- a/third_party/libjingle/files/talk/xmpp/prexmppauth.h
+++ b/third_party/libjingle/files/talk/xmpp/prexmppauth.h
@@ -30,6 +30,7 @@
#include "talk/base/cryptstring.h"
#include "talk/base/sigslot.h"
+#include "talk/xmpp/saslhandler.h"
namespace talk_base {
class SocketAddress;
@@ -60,7 +61,7 @@ class CaptchaChallenge {
std::string captcha_image_url_;
};
-class PreXmppAuth {
+class PreXmppAuth : public SaslHandler {
public:
virtual ~PreXmppAuth() {}
diff --git a/third_party/libjingle/files/talk/xmpp/saslhandler.h b/third_party/libjingle/files/talk/xmpp/saslhandler.h
index 739f6cc..acccd76 100644
--- a/third_party/libjingle/files/talk/xmpp/saslhandler.h
+++ b/third_party/libjingle/files/talk/xmpp/saslhandler.h
@@ -31,11 +31,8 @@
#include <string>
#include <vector>
-#include "talk/base/socketaddress.h"
-
namespace buzz {
-class XmlElement;
class SaslMechanism;
// Creates mechanisms to deal with a given mechanism
@@ -54,13 +51,6 @@ public:
// once you get it).
// If not handled, return NULL.
virtual SaslMechanism * CreateSaslMechanism(const std::string & mechanism) = 0;
-
- // Fills in the tls server hostname/domain to use for the given
- // server (and returns true). Return false if you want the defaults
- // to be used.
- virtual bool GetTlsServerInfo(const talk_base::SocketAddress& server,
- std::string* tls_server_hostname,
- std::string* tls_server_domain) = 0;
};
}
diff --git a/third_party/libjingle/files/talk/xmpp/xmppclient.cc b/third_party/libjingle/files/talk/xmpp/xmppclient.cc
index 985f51e..5f63b67 100644
--- a/third_party/libjingle/files/talk/xmpp/xmppclient.cc
+++ b/third_party/libjingle/files/talk/xmpp/xmppclient.cc
@@ -30,7 +30,6 @@
#include "talk/xmpp/xmppconstants.h"
#include "talk/base/sigslot.h"
#include "talk/xmpp/saslplainmechanism.h"
-#include "talk/xmpp/saslhandler.h"
#include "talk/xmpp/prexmppauth.h"
#include "talk/base/scoped_ptr.h"
#include "talk/xmpp/plainsaslhandler.h"
@@ -67,7 +66,6 @@ public:
scoped_ptr<AsyncSocket> socket_;
scoped_ptr<XmppEngine> engine_;
scoped_ptr<PreXmppAuth> pre_auth_;
- scoped_ptr<SaslHandler> sasl_handler_;
talk_base::CryptString pass_;
std::string auth_cookie_;
talk_base::SocketAddress server_;
@@ -95,8 +93,7 @@ XmppReturnStatus
XmppClient::Connect(const XmppClientSettings & settings,
const std::string & lang,
AsyncSocket * socket,
- PreXmppAuth * pre_auth,
- SaslHandler * sasl_handler) {
+ PreXmppAuth * pre_auth) {
if (socket == NULL)
return XMPP_RETURN_BADARGUMENT;
if (d_->socket_.get() != NULL)
@@ -116,13 +113,19 @@ XmppClient::Connect(const XmppClientSettings & settings,
}
d_->engine_->SetUseTls(settings.use_tls());
- if (sasl_handler) {
- std::string tls_server_hostname, tls_server_domain;
- if (sasl_handler->GetTlsServerInfo(settings.server(),
- &tls_server_hostname,
- &tls_server_domain)) {
- d_->engine_->SetTlsServer(tls_server_hostname, tls_server_domain);
- }
+ //
+ // 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.
+ // For all other servers, we leave the strings empty, which causes
+ // the jid's domain to be used. "foo@example.com" -> stream to="example.com"
+ // tls certificate for "example.com"
+ //
+ // This is only true when using Gaia auth, so let's say if there's
+ // no sasl_handler, we should use the actual server name
+ if ((settings.server().IPAsString() == buzz::STR_TALK_GOOGLE_COM ||
+ settings.server().IPAsString() == buzz::STR_TALKX_L_GOOGLE_COM) &&
+ pre_auth != NULL) {
+ d_->engine_->SetTlsServer(buzz::STR_GMAIL_COM, buzz::STR_GMAIL_COM);
}
// Set language
@@ -137,7 +140,6 @@ XmppClient::Connect(const XmppClientSettings & settings,
d_->proxy_port_ = settings.proxy_port();
d_->allow_plain_ = settings.allow_plain();
d_->pre_auth_.reset(pre_auth);
- d_->sasl_handler_.reset(sasl_handler);
return XMPP_RETURN_OK;
}
@@ -199,14 +201,6 @@ ForgetPassword(std::string & to_erase) {
int
XmppClient::ProcessStart() {
- if (d_->sasl_handler_.get()) {
- d_->engine_->SetSaslHandler(d_->sasl_handler_.release());
- }
- else {
- d_->engine_->SetSaslHandler(new PlainSaslHandler(
- d_->engine_->GetUser(), d_->pass_, d_->allow_plain_));
- }
-
if (d_->pre_auth_.get()) {
d_->pre_auth_->SignalAuthDone.connect(this, &XmppClient::OnAuthDone);
d_->pre_auth_->StartPreXmppAuth(
@@ -215,6 +209,8 @@ XmppClient::ProcessStart() {
return STATE_PRE_XMPP_LOGIN;
}
else {
+ d_->engine_->SetSaslHandler(new PlainSaslHandler(
+ d_->engine_->GetUser(), d_->pass_, d_->allow_plain_));
d_->pass_.Clear(); // done with this;
return STATE_START_XMPP_LOGIN;
}
@@ -257,6 +253,8 @@ XmppClient::ProcessCookieLogin() {
// Save auth cookie as a result
d_->auth_cookie_ = d_->pre_auth_->GetAuthCookie();
+ // transfer ownership of pre_auth_ to engine
+ d_->engine_->SetSaslHandler(d_->pre_auth_.release());
return STATE_START_XMPP_LOGIN;
}
diff --git a/third_party/libjingle/files/talk/xmpp/xmppclient.h b/third_party/libjingle/files/talk/xmpp/xmppclient.h
index 013d468c..1ca6fec 100644
--- a/third_party/libjingle/files/talk/xmpp/xmppclient.h
+++ b/third_party/libjingle/files/talk/xmpp/xmppclient.h
@@ -40,7 +40,6 @@ namespace buzz {
class XmppTask;
class PreXmppAuth;
-class SaslHandler;
class CaptchaChallenge;
// Just some non-colliding number. Could have picked "1".
@@ -78,8 +77,7 @@ public:
XmppReturnStatus Connect(const XmppClientSettings & settings,
const std::string & lang,
AsyncSocket * socket,
- PreXmppAuth * preauth,
- SaslHandler * sasl_handler);
+ PreXmppAuth * preauth);
virtual talk_base::Task* GetParent(int code);
virtual int ProcessStart();