tlsbase.h
/*
Copyright (c) 2007-2023 by Jakob Schröter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#ifndef TLSBASE_H__
#define TLSBASE_H__
#include "gloox.h"
#include "mutex.h"
#include "tlshandler.h"
namespace gloox
{
class GLOOX_API TLSBase
{
public:
TLSBase( TLSHandler* th, const std::string server )
: m_handler( th ), m_server( server ), m_secure( false ), m_valid( false ), m_initLib( true )
{}
virtual ~TLSBase() {}
virtual bool init( const std::string& clientKey = EmptyString,
const std::string& clientCerts = EmptyString,
const StringList& cacerts = StringList() ) = 0;
void setInitLib( bool init ) { m_initLib = init; }
virtual bool encrypt( const std::string& data ) = 0;
virtual int decrypt( const std::string& data ) = 0;
virtual void cleanup() = 0;
virtual bool handshake() = 0;
virtual bool isSecure() const { return m_secure; }
virtual bool hasChannelBinding() const { return false; }
virtual const std::string channelBinding() const { return EmptyString; }
virtual const std::string channelBindingType() const { return "tls-unique"; }
virtual void setCACerts( const StringList& cacerts ) = 0;
virtual const CertInfo& fetchTLSInfo() const { return m_certInfo; }
virtual void setClientCert( const std::string& clientKey, const std::string& clientCerts ) = 0;
protected:
TLSHandler* m_handler;
StringList m_cacerts;
std::string m_clientKey;
std::string m_clientCerts;
std::string m_server;
CertInfo m_certInfo;
util::Mutex m_mutex;
bool m_secure;
bool m_valid;
bool m_initLib;
};
}
#endif // TLSBASE_H__
gloox::TLSBase::encrypt
virtual bool encrypt(const std::string &data)=0
gloox::TLSBase::~TLSBase
virtual ~TLSBase()
Definition tlsbase.h:46
gloox::TLSBase::decrypt
virtual int decrypt(const std::string &data)=0
gloox::TLSBase::channelBinding
virtual const std::string channelBinding() const
Definition tlsbase.h:117
gloox::TLSBase::setClientCert
virtual void setClientCert(const std::string &clientKey, const std::string &clientCerts)=0
gloox::TLSBase::hasChannelBinding
virtual bool hasChannelBinding() const
Definition tlsbase.h:111
gloox::TLSBase::init
virtual bool init(const std::string &clientKey=EmptyString, const std::string &clientCerts=EmptyString, const StringList &cacerts=StringList())=0
gloox::TLSBase::handshake
virtual bool handshake()=0
gloox::TLSBase::cleanup
virtual void cleanup()=0
gloox::TLSBase::isSecure
virtual bool isSecure() const
Definition tlsbase.h:105
gloox::TLSBase::setCACerts
virtual void setCACerts(const StringList &cacerts)=0
gloox::TLSBase::channelBindingType
virtual const std::string channelBindingType() const
Definition tlsbase.h:123
gloox::TLSBase::setInitLib
void setInitLib(bool init)
Definition tlsbase.h:68
gloox::TLSBase::fetchTLSInfo
virtual const CertInfo & fetchTLSInfo() const
Definition tlsbase.h:136
gloox::TLSBase::TLSBase
TLSBase(TLSHandler *th, const std::string server)
Definition tlsbase.h:39
gloox::TLSHandler
An interface that allows for interacting with TLS implementations derived from TLSBase.
Definition tlshandler.h:35
gloox::util::Mutex
A simple implementation of mutex as a wrapper around a pthread mutex or a win32 critical section.
Definition mutex.h:34
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::StringList
std::list< std::string > StringList
Definition gloox.h:1251
gloox::EmptyString
const std::string EmptyString
Definition gloox.cpp:124
gloox::CertInfo
Definition gloox.h:990