henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 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 | |
| 11 | #ifndef WEBRTC_LIBJINGLE_XMPP_PREXMPPAUTH_H_ |
| 12 | #define WEBRTC_LIBJINGLE_XMPP_PREXMPPAUTH_H_ |
| 13 | |
| 14 | #include "webrtc/libjingle/xmpp/saslhandler.h" |
| 15 | #include "webrtc/base/cryptstring.h" |
| 16 | #include "webrtc/base/sigslot.h" |
| 17 | |
| 18 | namespace rtc { |
| 19 | class SocketAddress; |
| 20 | } |
| 21 | |
| 22 | namespace buzz { |
| 23 | |
| 24 | class Jid; |
| 25 | class SaslMechanism; |
| 26 | |
| 27 | class CaptchaChallenge { |
| 28 | public: |
| 29 | CaptchaChallenge() : captcha_needed_(false) {} |
| 30 | CaptchaChallenge(const std::string& token, const std::string& url) |
| 31 | : captcha_needed_(true), captcha_token_(token), captcha_image_url_(url) { |
| 32 | } |
| 33 | |
| 34 | bool captcha_needed() const { return captcha_needed_; } |
| 35 | const std::string& captcha_token() const { return captcha_token_; } |
| 36 | |
| 37 | // This url is relative to the gaia server. Once we have better tools |
| 38 | // for cracking URLs, we should probably make this a full URL |
| 39 | const std::string& captcha_image_url() const { return captcha_image_url_; } |
| 40 | |
| 41 | private: |
| 42 | bool captcha_needed_; |
| 43 | std::string captcha_token_; |
| 44 | std::string captcha_image_url_; |
| 45 | }; |
| 46 | |
| 47 | class PreXmppAuth : public SaslHandler { |
| 48 | public: |
| 49 | virtual ~PreXmppAuth() {} |
| 50 | |
| 51 | virtual void StartPreXmppAuth( |
| 52 | const Jid& jid, |
| 53 | const rtc::SocketAddress& server, |
| 54 | const rtc::CryptString& pass, |
| 55 | const std::string& auth_mechanism, |
| 56 | const std::string& auth_token) = 0; |
| 57 | |
| 58 | sigslot::signal0<> SignalAuthDone; |
| 59 | |
| 60 | virtual bool IsAuthDone() const = 0; |
| 61 | virtual bool IsAuthorized() const = 0; |
| 62 | virtual bool HadError() const = 0; |
| 63 | virtual int GetError() const = 0; |
| 64 | virtual CaptchaChallenge GetCaptchaChallenge() const = 0; |
| 65 | virtual std::string GetAuthMechanism() const = 0; |
| 66 | virtual std::string GetAuthToken() const = 0; |
| 67 | }; |
| 68 | |
| 69 | } |
| 70 | |
| 71 | #endif // WEBRTC_LIBJINGLE_XMPP_PREXMPPAUTH_H_ |