OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 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. | |
4 | |
5 #include "remoting/jingle_glue/gaia_token_pre_xmpp_auth.h" | |
6 | |
7 #include <algorithm> | |
8 | |
9 #include "talk/base/socketaddress.h" | |
10 #include "talk/xmpp/constants.h" | |
11 #include "talk/xmpp/saslcookiemechanism.h" | |
12 | |
13 namespace remoting { | |
14 | |
15 namespace { | |
16 const char kGaiaAuthMechanism[] = "X-GOOGLE-TOKEN"; | |
17 } // namespace | |
18 | |
19 GaiaTokenPreXmppAuth::GaiaTokenPreXmppAuth( | |
20 const std::string& username, | |
21 const std::string& token, | |
22 const std::string& token_service) | |
23 : username_(username), | |
24 token_(token), | |
25 token_service_(token_service) { } | |
26 | |
27 GaiaTokenPreXmppAuth::~GaiaTokenPreXmppAuth() { } | |
28 | |
29 void GaiaTokenPreXmppAuth::StartPreXmppAuth( | |
30 const buzz::Jid& jid, | |
31 const talk_base::SocketAddress& server, | |
32 const talk_base::CryptString& pass, | |
33 const std::string& auth_cookie) { | |
34 SignalAuthDone(); | |
35 } | |
36 | |
37 bool GaiaTokenPreXmppAuth::IsAuthDone() const { | |
38 return true; | |
39 } | |
40 | |
41 bool GaiaTokenPreXmppAuth::IsAuthorized() const { | |
42 return true; | |
43 } | |
44 | |
45 bool GaiaTokenPreXmppAuth::HadError() const { | |
46 return false; | |
47 } | |
48 | |
49 int GaiaTokenPreXmppAuth::GetError() const { | |
50 return 0; | |
51 } | |
52 | |
53 buzz::CaptchaChallenge GaiaTokenPreXmppAuth::GetCaptchaChallenge() const { | |
54 return buzz::CaptchaChallenge(); | |
55 } | |
56 | |
57 std::string GaiaTokenPreXmppAuth::GetAuthCookie() const { | |
58 return std::string(); | |
59 } | |
60 | |
61 std::string GaiaTokenPreXmppAuth::ChooseBestSaslMechanism( | |
62 const std::vector<std::string> & mechanisms, bool encrypted) { | |
63 return (std::find(mechanisms.begin(), | |
64 mechanisms.end(), kGaiaAuthMechanism) != | |
65 mechanisms.end()) ? kGaiaAuthMechanism : ""; | |
66 } | |
67 | |
68 buzz::SaslMechanism* GaiaTokenPreXmppAuth::CreateSaslMechanism( | |
69 const std::string& mechanism) { | |
70 if (mechanism != kGaiaAuthMechanism) | |
71 return NULL; | |
72 return new buzz::SaslCookieMechanism( | |
73 kGaiaAuthMechanism, username_, token_, token_service_); | |
74 } | |
75 | |
76 } // namespace remoting | |
OLD | NEW |