1//
2// CertificateHandlerFactoryMgr.cpp
3//
4// Library: NetSSL_OpenSSL
5// Package: SSLCore
6// Module: CertificateHandlerFactoryMgr
7//
8// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
9// and Contributors.
10//
11// SPDX-License-Identifier: BSL-1.0
12//
13
14
15#include "Poco/Net/CertificateHandlerFactoryMgr.h"
16#include "Poco/Net/ConsoleCertificateHandler.h"
17#include "Poco/Net/AcceptCertificateHandler.h"
18#include "Poco/Net/RejectCertificateHandler.h"
19
20
21namespace Poco {
22namespace Net {
23
24
25CertificateHandlerFactoryMgr::CertificateHandlerFactoryMgr()
26{
27 setFactory("ConsoleCertificateHandler", new CertificateHandlerFactoryImpl<ConsoleCertificateHandler>());
28 setFactory("AcceptCertificateHandler", new CertificateHandlerFactoryImpl<AcceptCertificateHandler>());
29 setFactory("RejectCertificateHandler", new CertificateHandlerFactoryImpl<RejectCertificateHandler>());
30}
31
32
33CertificateHandlerFactoryMgr::~CertificateHandlerFactoryMgr()
34{
35}
36
37
38void CertificateHandlerFactoryMgr::setFactory(const std::string& name, CertificateHandlerFactory* pFactory)
39{
40 bool success = _factories.insert(make_pair(name, Poco::SharedPtr<CertificateHandlerFactory>(pFactory))).second;
41 if (!success)
42 delete pFactory;
43 poco_assert(success);
44}
45
46
47bool CertificateHandlerFactoryMgr::hasFactory(const std::string& name) const
48{
49 return _factories.find(name) != _factories.end();
50}
51
52
53const CertificateHandlerFactory* CertificateHandlerFactoryMgr::getFactory(const std::string& name) const
54{
55 FactoriesMap::const_iterator it = _factories.find(name);
56 if (it != _factories.end())
57 return it->second;
58 else
59 return 0;
60}
61
62
63void CertificateHandlerFactoryMgr::removeFactory(const std::string& name)
64{
65 _factories.erase(name);
66}
67
68
69} } // namespace Poco::Net
70