aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/poco/NetSSL_OpenSSL/include/Poco/Net/CertificateHandlerFactory.h
blob: 5e3699c3cab0d8da8b04ea6e3732ec524c4f2f19 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// 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"


namespace Poco {
namespace Net {


class InvalidCertificateHandler;


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.

	virtual ~CertificateHandlerFactory();
		/// Destroys the CertificateHandlerFactory.

	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.
};


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.

	virtual ~CertificateHandlerFactoryRegistrar();
		/// Destroys the CertificateHandlerFactoryRegistrar.
};


template <typename T>
class CertificateHandlerFactoryImpl: public Poco::Net::CertificateHandlerFactory
{
public:
	CertificateHandlerFactoryImpl()
	{
	}

	~CertificateHandlerFactoryImpl()
	{
	}

	InvalidCertificateHandler* create(bool server) const
	{
		return new T(server);
	}
};


} } // namespace Poco::Net


// DEPRECATED: register the factory directly at the FactoryMgr:
// Poco::Net::SSLManager::instance().certificateHandlerFactoryMgr().setFactory(name, new Poco::Net::CertificateHandlerFactoryImpl<MyConsoleHandler>());
#define POCO_REGISTER_CHFACTORY(API, PKCLS)		\
	static Poco::Net::CertificateHandlerFactoryRegistrar aRegistrar(std::string(#PKCLS), new Poco::Net::CertificateHandlerFactoryImpl<PKCLS>());


#endif // NetSSL_CertificateHandlerFactory_INCLUDED