glooxd  0.3-svn
featuresasl.h
1 /*
2  Copyright (c) 2009 by Jakob Schroeter <js@camaya.net>
3  This file is part of the glooxd library. http://camaya.net/glooxd
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 #ifndef FEATURESASL_H__
15 #define FEATURESASL_H__
16 
17 #include "glooxd.h"
18 #include "streamfeature.h"
19 
20 #include <gloox/jid.h>
21 
22 namespace gloox
23 {
24  class DataForm;
25 }
26 
27 namespace glooxd
28 {
29 
30  class AuthenticationHandler;
31 
38  class GLOOXD_API FeatureSASL : public StreamFeature
39  {
40  public:
45  FeatureSASL( AuthenticationHandler* authHandler );
46 
50  virtual ~FeatureSASL() {}
51 
52  // reimplemented from StreamFeature
53  virtual const std::string& filterString() const;
54 
55  // reimplemented from StreamFeature
56  virtual gloox::Tag* tag( int state, const std::string& domain );
57 
58  // reimplemented from StreamFeature
59  virtual StreamFeature* newInstance() const
60  {
61  return new FeatureSASL( m_authHandler );
62  }
63 
64  // reimplemented from StreamFeature
65  virtual void handleTag( gloox::Tag* tag );
66 
67  private:
68  void decodeSASLPLAIN( const std::string& cdata );
69 
70  enum State
71  {
72  SASLOffered,
73  SASLChecking,
74  SASLEnabled,
75  SASLCanceled
76  };
77 
78  State m_state;
79  AuthenticationHandler* m_authHandler;
80 
81  };
82 
83 }
84 
85 #endif // FEATURESASL_H__