gloox  0.9.9.12
tlsbase.h
1 /*
2  Copyright (c) 2007-2008 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 
15 #ifndef TLSBASE_H__
16 #define TLSBASE_H__
17 
18 #include "gloox.h"
19 #include "tlshandler.h"
20 
21 namespace gloox
22 {
23 
30  class GLOOX_API TLSBase
31  {
32  public:
38  TLSBase( TLSHandler *th, const std::string server )
39  : m_handler( th ), m_server( server ), m_secure( false ), m_valid( false ) {}
40 
44  virtual ~TLSBase() {}
45 
52  virtual bool encrypt( const std::string& data ) = 0;
53 
61  virtual int decrypt( const std::string& data ) = 0;
62 
66  virtual void cleanup() = 0;
67 
75  virtual bool handshake() = 0;
76 
81  virtual bool isSecure() const { return m_secure; }
82 
88  virtual void setCACerts( const StringList& cacerts ) = 0;
89 
94  virtual const CertInfo& fetchTLSInfo() const { return m_certInfo; }
95 
107  virtual void setClientCert( const std::string& clientKey, const std::string& clientCerts ) = 0;
108 
109  protected:
110  TLSHandler *m_handler;
111  StringList m_cacerts;
112  std::string m_clientKey;
113  std::string m_clientCerts;
114  std::string m_server;
115  CertInfo m_certInfo;
116  bool m_secure;
117  bool m_valid;
118 
119  };
120 
121 }
122 
123 #endif // TLSBASE_H__