gloox  1.0
tlsdefault.h
1 /*
2  * Copyright (c) 2007-2009 by Jakob Schroeter <js@camaya.net>
3  * This file is part of the gloox library. http://camaya.net/gloox
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 TLSDEFAULT_H__
15 #define TLSDEFAULT_H__
16 
17 #include "tlsbase.h"
18 
19 namespace gloox
20 {
21 
22  class TLSHandler;
23 
33  class GLOOX_API TLSDefault : public TLSBase
34  {
35  public:
36 
40  enum Type
41  {
42  VerifyingClient = 1,
44  AnonymousClient = 2,
46  VerifyingServer = 4,
47  AnonymousServer = 8
49  };
50 
57  TLSDefault( TLSHandler* th, const std::string server, Type type = VerifyingClient );
58 
62  virtual ~TLSDefault();
63 
64  // reimplemented from TLSBase
65  virtual bool init( const std::string& clientKey = EmptyString,
66  const std::string& clientCerts = EmptyString,
67  const StringList& cacerts = StringList() );
68 
69  // reimplemented from TLSBase
70  virtual bool encrypt( const std::string& data );
71 
72  // reimplemented from TLSBase
73  virtual int decrypt( const std::string& data );
74 
75  // reimplemented from TLSBase
76  virtual void cleanup();
77 
78  // reimplemented from TLSBase
79  virtual bool handshake();
80 
81  // reimplemented from TLSBase
82  virtual bool isSecure() const;
83 
84  // reimplemented from TLSBase
85  virtual void setCACerts( const StringList& cacerts );
86 
87  // reimplemented from TLSBase
88  virtual const CertInfo& fetchTLSInfo() const;
89 
90  // reimplemented from TLSBase
91  virtual void setClientCert( const std::string& clientKey, const std::string& clientCerts );
92 
97  static int types();
98 
99  private:
100  TLSBase* m_impl;
101 
102  };
103 }
104 
105 #endif // TLSDEFAULT_H__