| Index: jingle/notifier/communicator/gaia_token_pre_xmpp_auth.cc
|
| ===================================================================
|
| --- jingle/notifier/communicator/gaia_token_pre_xmpp_auth.cc (revision 77421)
|
| +++ jingle/notifier/communicator/gaia_token_pre_xmpp_auth.cc (working copy)
|
| @@ -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 {
|
|
|
| -const char kGaiaAuthMechanism[] = "X-GOOGLE-TOKEN";
|
| -
|
| class GaiaCookieMechanism : public buzz::SaslCookieMechanism {
|
| public:
|
| GaiaCookieMechanism(const std::string & mechanism,
|
| @@ -49,13 +48,20 @@
|
|
|
| } // 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::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
|
|
|