00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef TLSBASE_H__
00016 #define TLSBASE_H__
00017
00018 #include "gloox.h"
00019 #include "tlshandler.h"
00020
00021 namespace gloox
00022 {
00023
00030 class GLOOX_API TLSBase
00031 {
00032 public:
00038 TLSBase( TLSHandler* th, const std::string server )
00039 : m_handler( th ), m_server( server ), m_secure( false ), m_valid( false ), m_initLib( true )
00040 {}
00041
00045 virtual ~TLSBase() {}
00046
00053 virtual bool init() = 0;
00054
00062 void setInitLib( bool init ) { m_initLib = init; }
00063
00070 virtual bool encrypt( const std::string& data ) = 0;
00071
00079 virtual int decrypt( const std::string& data ) = 0;
00080
00084 virtual void cleanup() = 0;
00085
00093 virtual bool handshake() = 0;
00094
00099 virtual bool isSecure() const { return m_secure; }
00100
00106 virtual void setCACerts( const StringList& cacerts ) = 0;
00107
00112 virtual const CertInfo& fetchTLSInfo() const { return m_certInfo; }
00113
00125 virtual void setClientCert( const std::string& clientKey, const std::string& clientCerts ) = 0;
00126
00127 protected:
00128 TLSHandler* m_handler;
00129 StringList m_cacerts;
00130 std::string m_clientKey;
00131 std::string m_clientCerts;
00132 std::string m_server;
00133 CertInfo m_certInfo;
00134 bool m_secure;
00135 bool m_valid;
00136 bool m_initLib;
00137
00138 };
00139
00140 }
00141
00142 #endif // TLSBASE_H__