Home | History | Annotate | Download | only in base
      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.
      4 
      5 #ifndef JINGLE_NOTIFIER_BASE_GAIA_TOKEN_PRE_XMPP_AUTH_H_
      6 #define JINGLE_NOTIFIER_BASE_GAIA_TOKEN_PRE_XMPP_AUTH_H_
      7 
      8 #include <string>
      9 #include <vector>
     10 
     11 #include "base/compiler_specific.h"
     12 #include "talk/xmpp/prexmppauth.h"
     13 
     14 namespace notifier {
     15 
     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);
     24 
     25   virtual ~GaiaTokenPreXmppAuth();
     26 
     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   virtual void StartPreXmppAuth(const buzz::Jid& jid,
     31                                 const talk_base::SocketAddress& server,
     32                                 const talk_base::CryptString& pass,
     33                                 const std::string& auth_mechanism,
     34                                 const std::string& auth_token) OVERRIDE;
     35 
     36   virtual bool IsAuthDone() const OVERRIDE;
     37 
     38   virtual bool IsAuthorized() const OVERRIDE;
     39 
     40   virtual bool HadError() const OVERRIDE;
     41 
     42   virtual int GetError() const OVERRIDE;
     43 
     44   virtual buzz::CaptchaChallenge GetCaptchaChallenge() const OVERRIDE;
     45 
     46   virtual std::string GetAuthToken() const OVERRIDE;
     47 
     48   virtual std::string GetAuthMechanism() const OVERRIDE;
     49 
     50   // buzz::SaslHandler implementation.
     51 
     52   virtual std::string ChooseBestSaslMechanism(
     53       const std::vector<std::string>& mechanisms, bool encrypted) OVERRIDE;
     54 
     55   virtual buzz::SaslMechanism* CreateSaslMechanism(
     56       const std::string& mechanism) OVERRIDE;
     57 
     58  private:
     59   std::string username_;
     60   std::string token_;
     61   std::string token_service_;
     62   std::string auth_mechanism_;
     63 };
     64 
     65 }  // namespace notifier
     66 
     67 #endif  // JINGLE_NOTIFIER_BASE_GAIA_TOKEN_PRE_XMPP_AUTH_H_
     68