Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / jingle / notifier / base / gaia_token_pre_xmpp_auth.h
blob7b86bd556e40dfd53539af8964bf2fd350da994a
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef JINGLE_NOTIFIER_BASE_GAIA_TOKEN_PRE_XMPP_AUTH_H_
6 #define JINGLE_NOTIFIER_BASE_GAIA_TOKEN_PRE_XMPP_AUTH_H_
8 #include <string>
9 #include <vector>
11 #include "base/compiler_specific.h"
12 #include "webrtc/libjingle/xmpp/prexmppauth.h"
14 namespace notifier {
16 // This class implements buzz::PreXmppAuth interface for token-based
17 // authentication in GTalk. It looks for the X-GOOGLE-TOKEN auth mechanism
18 // and uses that instead of the default auth mechanism (PLAIN).
19 class GaiaTokenPreXmppAuth : public buzz::PreXmppAuth {
20 public:
21 GaiaTokenPreXmppAuth(const std::string& username, const std::string& token,
22 const std::string& token_service,
23 const std::string& auth_mechanism);
25 ~GaiaTokenPreXmppAuth() override;
27 // buzz::PreXmppAuth (-buzz::SaslHandler) implementation. We stub
28 // all the methods out as we don't actually do any authentication at
29 // this point.
30 void StartPreXmppAuth(const buzz::Jid& jid,
31 const rtc::SocketAddress& server,
32 const rtc::CryptString& pass,
33 const std::string& auth_mechanism,
34 const std::string& auth_token) override;
36 bool IsAuthDone() const override;
38 bool IsAuthorized() const override;
40 bool HadError() const override;
42 int GetError() const override;
44 buzz::CaptchaChallenge GetCaptchaChallenge() const override;
46 std::string GetAuthToken() const override;
48 std::string GetAuthMechanism() const override;
50 // buzz::SaslHandler implementation.
52 std::string ChooseBestSaslMechanism(
53 const std::vector<std::string>& mechanisms,
54 bool encrypted) override;
56 buzz::SaslMechanism* CreateSaslMechanism(
57 const std::string& mechanism) override;
59 private:
60 std::string username_;
61 std::string token_;
62 std::string token_service_;
63 std::string auth_mechanism_;
66 } // namespace notifier
68 #endif // JINGLE_NOTIFIER_BASE_GAIA_TOKEN_PRE_XMPP_AUTH_H_