OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef JINGLE_NOTIFIER_BASE_GAIA_TOKEN_PRE_XMPP_AUTH_H_ | 5 #ifndef JINGLE_NOTIFIER_BASE_GAIA_TOKEN_PRE_XMPP_AUTH_H_ |
6 #define JINGLE_NOTIFIER_BASE_GAIA_TOKEN_PRE_XMPP_AUTH_H_ | 6 #define JINGLE_NOTIFIER_BASE_GAIA_TOKEN_PRE_XMPP_AUTH_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
| 11 #include "base/compiler_specific.h" |
11 #include "talk/xmpp/prexmppauth.h" | 12 #include "talk/xmpp/prexmppauth.h" |
12 | 13 |
13 namespace notifier { | 14 namespace notifier { |
14 | 15 |
15 // This class implements buzz::PreXmppAuth interface for token-based | 16 // This class implements buzz::PreXmppAuth interface for token-based |
16 // authentication in GTalk. It looks for the X-GOOGLE-TOKEN auth mechanism | 17 // authentication in GTalk. It looks for the X-GOOGLE-TOKEN auth mechanism |
17 // and uses that instead of the default auth mechanism (PLAIN). | 18 // and uses that instead of the default auth mechanism (PLAIN). |
18 class GaiaTokenPreXmppAuth : public buzz::PreXmppAuth { | 19 class GaiaTokenPreXmppAuth : public buzz::PreXmppAuth { |
19 public: | 20 public: |
20 GaiaTokenPreXmppAuth(const std::string& username, const std::string& token, | 21 GaiaTokenPreXmppAuth(const std::string& username, const std::string& token, |
21 const std::string& token_service, | 22 const std::string& token_service, |
22 const std::string& auth_mechanism); | 23 const std::string& auth_mechanism); |
23 | 24 |
24 virtual ~GaiaTokenPreXmppAuth(); | 25 virtual ~GaiaTokenPreXmppAuth(); |
25 | 26 |
26 // buzz::PreXmppAuth (-buzz::SaslHandler) implementation. We stub | 27 // buzz::PreXmppAuth (-buzz::SaslHandler) implementation. We stub |
27 // all the methods out as we don't actually do any authentication at | 28 // all the methods out as we don't actually do any authentication at |
28 // this point. | 29 // this point. |
29 virtual void StartPreXmppAuth(const buzz::Jid& jid, | 30 virtual void StartPreXmppAuth(const buzz::Jid& jid, |
30 const talk_base::SocketAddress& server, | 31 const talk_base::SocketAddress& server, |
31 const talk_base::CryptString& pass, | 32 const talk_base::CryptString& pass, |
32 const std::string& auth_cookie); | 33 const std::string& auth_cookie) OVERRIDE; |
33 | 34 |
34 virtual bool IsAuthDone() const; | 35 virtual bool IsAuthDone() const OVERRIDE; |
35 | 36 |
36 virtual bool IsAuthorized() const; | 37 virtual bool IsAuthorized() const OVERRIDE; |
37 | 38 |
38 virtual bool HadError() const; | 39 virtual bool HadError() const OVERRIDE; |
39 | 40 |
40 virtual int GetError() const; | 41 virtual int GetError() const OVERRIDE; |
41 | 42 |
42 virtual buzz::CaptchaChallenge GetCaptchaChallenge() const; | 43 virtual buzz::CaptchaChallenge GetCaptchaChallenge() const OVERRIDE; |
43 | 44 |
44 virtual std::string GetAuthCookie() const; | 45 virtual std::string GetAuthCookie() const OVERRIDE; |
45 | 46 |
46 // buzz::SaslHandler implementation. | 47 // buzz::SaslHandler implementation. |
47 | 48 |
48 virtual std::string ChooseBestSaslMechanism( | 49 virtual std::string ChooseBestSaslMechanism( |
49 const std::vector<std::string>& mechanisms, bool encrypted); | 50 const std::vector<std::string>& mechanisms, bool encrypted) OVERRIDE; |
50 | 51 |
51 virtual buzz::SaslMechanism* CreateSaslMechanism( | 52 virtual buzz::SaslMechanism* CreateSaslMechanism( |
52 const std::string& mechanism); | 53 const std::string& mechanism) OVERRIDE; |
53 | 54 |
54 static const char kDefaultAuthMechanism[]; | 55 static const char kDefaultAuthMechanism[]; |
55 | 56 |
56 private: | 57 private: |
57 std::string username_; | 58 std::string username_; |
58 std::string token_; | 59 std::string token_; |
59 std::string token_service_; | 60 std::string token_service_; |
60 std::string auth_mechanism_; | 61 std::string auth_mechanism_; |
61 }; | 62 }; |
62 | 63 |
63 } // namespace notifier | 64 } // namespace notifier |
64 | 65 |
65 #endif // JINGLE_NOTIFIER_BASE_GAIA_TOKEN_PRE_XMPP_AUTH_H_ | 66 #endif // JINGLE_NOTIFIER_BASE_GAIA_TOKEN_PRE_XMPP_AUTH_H_ |
OLD | NEW |