1//
2// PrivateKeyFactoryMgr.cpp
3//
4// Library: NetSSL_OpenSSL
5// Package: SSLCore
6// Module: PrivateKeyFactoryMgr
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/PrivateKeyFactoryMgr.h"
16#include "Poco/Net/KeyFileHandler.h"
17#include "Poco/Net/KeyConsoleHandler.h"
18
19
20namespace Poco {
21namespace Net {
22
23
24PrivateKeyFactoryMgr::PrivateKeyFactoryMgr()
25{
26 setFactory("KeyFileHandler", new PrivateKeyFactoryImpl<KeyFileHandler>());
27 setFactory("KeyConsoleHandler", new PrivateKeyFactoryImpl<KeyConsoleHandler>());
28}
29
30
31PrivateKeyFactoryMgr::~PrivateKeyFactoryMgr()
32{
33}
34
35
36void PrivateKeyFactoryMgr::setFactory(const std::string& name, PrivateKeyFactory* pFactory)
37{
38 bool success = _factories.insert(make_pair(name, Poco::SharedPtr<PrivateKeyFactory>(pFactory))).second;
39 if (!success)
40 delete pFactory;
41 poco_assert(success);
42}
43
44
45bool PrivateKeyFactoryMgr::hasFactory(const std::string& name) const
46{
47 return _factories.find(name) != _factories.end();
48}
49
50
51const PrivateKeyFactory* PrivateKeyFactoryMgr::getFactory(const std::string& name) const
52{
53 FactoriesMap::const_iterator it = _factories.find(name);
54 if (it != _factories.end())
55 return it->second;
56 else
57 return 0;
58}
59
60
61void PrivateKeyFactoryMgr::removeFactory(const std::string& name)
62{
63 _factories.erase(name);
64}
65
66
67} } // namespace Poco::Net
68