prexmppauth.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright 2004 The WebRTC Project Authors. All rights reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef THIRD_PARTY_LIBJINGLE_XMPP_XMPP_PREXMPPAUTH_H_
  11. #define THIRD_PARTY_LIBJINGLE_XMPP_XMPP_PREXMPPAUTH_H_
  12. #include "third_party/libjingle_xmpp/xmpp/saslhandler.h"
  13. #include "third_party/webrtc/rtc_base/third_party/sigslot/sigslot.h"
  14. namespace jingle_xmpp {
  15. class Jid;
  16. class SaslMechanism;
  17. class CaptchaChallenge {
  18. public:
  19. CaptchaChallenge() : captcha_needed_(false) {}
  20. CaptchaChallenge(const std::string& token, const std::string& url)
  21. : captcha_needed_(true), captcha_token_(token), captcha_image_url_(url) {
  22. }
  23. bool captcha_needed() const { return captcha_needed_; }
  24. const std::string& captcha_token() const { return captcha_token_; }
  25. // This url is relative to the gaia server. Once we have better tools
  26. // for cracking URLs, we should probably make this a full URL
  27. const std::string& captcha_image_url() const { return captcha_image_url_; }
  28. private:
  29. bool captcha_needed_;
  30. std::string captcha_token_;
  31. std::string captcha_image_url_;
  32. };
  33. class PreXmppAuth : public SaslHandler {
  34. public:
  35. virtual ~PreXmppAuth() {}
  36. virtual void StartPreXmppAuth(
  37. const Jid& jid,
  38. const std::string& pass,
  39. const std::string& auth_mechanism,
  40. const std::string& auth_token) = 0;
  41. sigslot::signal0<> SignalAuthDone;
  42. virtual bool IsAuthDone() const = 0;
  43. virtual bool IsAuthorized() const = 0;
  44. virtual bool HadError() const = 0;
  45. virtual int GetError() const = 0;
  46. virtual CaptchaChallenge GetCaptchaChallenge() const = 0;
  47. virtual std::string GetAuthMechanism() const = 0;
  48. virtual std::string GetAuthToken() const = 0;
  49. };
  50. }
  51. #endif // THIRD_PARTY_LIBJINGLE_XMPP_XMPP_PREXMPPAUTH_H_