tlsbase.h
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 "mutex.h"
00020 #include "tlshandler.h"
00021
00022 namespace gloox
00023 {
00024
00031 class GLOOX_API TLSBase
00032 {
00033 public:
00039 TLSBase( TLSHandler* th, const std::string server )
00040 : m_handler( th ), m_server( server ), m_secure( false ), m_valid( false ), m_initLib( true )
00041 {}
00042
00046 virtual ~TLSBase() {}
00047
00057 virtual bool init( const std::string& clientKey = EmptyString,
00058 const std::string& clientCerts = EmptyString,
00059 const StringList& cacerts = StringList() ) = 0;
00060
00068 void setInitLib( bool init ) { m_initLib = init; }
00069
00076 virtual bool encrypt( const std::string& data ) = 0;
00077
00085 virtual int decrypt( const std::string& data ) = 0;
00086
00090 virtual void cleanup() = 0;
00091
00099 virtual bool handshake() = 0;
00100
00105 virtual bool isSecure() const { return m_secure; }
00106
00112 virtual void setCACerts( const StringList& cacerts ) = 0;
00113
00118 virtual const CertInfo& fetchTLSInfo() const { return m_certInfo; }
00119
00131 virtual void setClientCert( const std::string& clientKey, const std::string& clientCerts ) = 0;
00132
00133 protected:
00134 TLSHandler* m_handler;
00135 StringList m_cacerts;
00136 std::string m_clientKey;
00137 std::string m_clientCerts;
00138 std::string m_server;
00139 CertInfo m_certInfo;
00140 util::Mutex m_mutex;
00141 bool m_secure;
00142 bool m_valid;
00143 bool m_initLib;
00144
00145 };
00146
00147 }
00148
00149 #endif // TLSBASE_H__