2023-02-08 11:04:11 +00:00
//
// CertificateHandlerFactory.h
//
// Library: NetSSL_OpenSSL
// Package: SSLCore
// Module: CertificateHandlerFactory
//
// Definition of the CertificateHandlerFactory class.
//
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
# ifndef NetSSL_CertificateHandlerFactory_INCLUDED
# define NetSSL_CertificateHandlerFactory_INCLUDED
# include "Poco/Net/NetSSL.h"
2023-02-13 09:22:33 +00:00
namespace Poco
{
namespace Net
{
2023-02-08 11:04:11 +00:00
2023-02-13 09:22:33 +00:00
class InvalidCertificateHandler ;
2023-02-08 11:04:11 +00:00
2023-02-13 09:22:33 +00:00
class NetSSL_API CertificateHandlerFactory
/// A CertificateHandlerFactory is responsible for creating InvalidCertificateHandlers.
///
/// You don't need to access this class directly. Use the macro
/// POCO_REGISTER_CHFACTORY(namespace, InvalidCertificateHandlerName)
/// instead (see the documentation of InvalidCertificateHandler for an example).
{
public :
CertificateHandlerFactory ( ) ;
/// Creates the CertificateHandlerFactory.
2023-02-08 11:04:11 +00:00
2023-02-13 09:22:33 +00:00
virtual ~ CertificateHandlerFactory ( ) ;
/// Destroys the CertificateHandlerFactory.
2023-02-08 11:04:11 +00:00
2023-02-13 09:22:33 +00:00
virtual InvalidCertificateHandler * create ( bool server ) const = 0 ;
/// Creates a new InvalidCertificateHandler. Set server to true if the certificate handler is used on the server side.
} ;
2023-02-08 11:04:11 +00:00
2023-02-13 09:22:33 +00:00
class NetSSL_API CertificateHandlerFactoryRegistrar
/// Registrar class which automatically registers CertificateHandlerFactory at the CertificateHandlerFactoryMgr.
/// You don't need to access this class directly. Use the macro
/// POCO_REGISTER_CHFACTORY(namespace, InvalidCertificateHandlerName)
/// instead (see the documentation of InvalidCertificateHandler for an example).
{
public :
CertificateHandlerFactoryRegistrar ( const std : : string & name , CertificateHandlerFactory * pFactory ) ;
/// Registers the CertificateHandlerFactory with the given name at the factory manager.
2023-02-08 11:04:11 +00:00
2023-02-13 09:22:33 +00:00
virtual ~ CertificateHandlerFactoryRegistrar ( ) ;
/// Destroys the CertificateHandlerFactoryRegistrar.
} ;
2023-02-08 11:04:11 +00:00
2023-02-13 09:22:33 +00:00
template < typename T >
class CertificateHandlerFactoryImpl : public Poco : : Net : : CertificateHandlerFactory
{
public :
CertificateHandlerFactoryImpl ( ) { }
2023-02-08 11:04:11 +00:00
2023-02-13 09:22:33 +00:00
~ CertificateHandlerFactoryImpl ( ) { }
2023-02-08 11:04:11 +00:00
2023-02-13 09:22:33 +00:00
InvalidCertificateHandler * create ( bool server ) const { return new T ( server ) ; }
} ;
2023-02-08 11:04:11 +00:00
2023-02-13 09:22:33 +00:00
}
} // namespace Poco::Net
2023-02-08 11:04:11 +00:00
// DEPRECATED: register the factory directly at the FactoryMgr:
// Poco::Net::SSLManager::instance().certificateHandlerFactoryMgr().setFactory(name, new Poco::Net::CertificateHandlerFactoryImpl<MyConsoleHandler>());
2023-02-13 09:22:33 +00:00
# define POCO_REGISTER_CHFACTORY(API, PKCLS) \
static Poco : : Net : : CertificateHandlerFactoryRegistrar aRegistrar ( \
std : : string ( # PKCLS ) , new Poco : : Net : : CertificateHandlerFactoryImpl < PKCLS > ( ) ) ;
2023-02-08 11:04:11 +00:00
# endif // NetSSL_CertificateHandlerFactory_INCLUDED