xmppauth.h revision 269fb4bc90b79bebbb8311da0110ccd6803fd0a8
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_XMPPAUTH_H_
12#define WEBRTC_LIBJINGLE_XMPP_XMPPAUTH_H_
13
14#include <vector>
15
16#include "webrtc/libjingle/xmpp/jid.h"
17#include "webrtc/libjingle/xmpp/prexmppauth.h"
18#include "webrtc/libjingle/xmpp/saslhandler.h"
19#include "webrtc/base/cryptstring.h"
20#include "webrtc/base/sigslot.h"
21
22class XmppAuth: public buzz::PreXmppAuth {
23public:
24  XmppAuth();
25  virtual ~XmppAuth();
26
27  // TODO: Just have one "secret" that is either pass or
28  // token?
29  virtual void StartPreXmppAuth(const buzz::Jid& jid,
30                                const rtc::SocketAddress& server,
31                                const rtc::CryptString& pass,
32                                const std::string& auth_mechanism,
33                                const std::string& auth_token);
34
35  virtual bool IsAuthDone() const { return done_; }
36  virtual bool IsAuthorized() const { return true; }
37  virtual bool HadError() const { return false; }
38  virtual int  GetError() const { return 0; }
39  virtual buzz::CaptchaChallenge GetCaptchaChallenge() const {
40      return buzz::CaptchaChallenge();
41  }
42  virtual std::string GetAuthMechanism() const { return auth_mechanism_; }
43  virtual std::string GetAuthToken() const { return auth_token_; }
44
45  virtual std::string ChooseBestSaslMechanism(
46      const std::vector<std::string>& mechanisms,
47      bool encrypted);
48
49  virtual buzz::SaslMechanism * CreateSaslMechanism(
50      const std::string& mechanism);
51
52private:
53  buzz::Jid jid_;
54  rtc::CryptString passwd_;
55  std::string auth_mechanism_;
56  std::string auth_token_;
57  bool done_;
58};
59
60#endif  // WEBRTC_LIBJINGLE_XMPP_XMPPAUTH_H_
61
62