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 | |
20 | namespace Poco { |
21 | namespace Net { |
22 | |
23 | |
24 | PrivateKeyFactoryMgr::PrivateKeyFactoryMgr() |
25 | { |
26 | setFactory("KeyFileHandler", new PrivateKeyFactoryImpl<KeyFileHandler>()); |
27 | setFactory("KeyConsoleHandler", new PrivateKeyFactoryImpl<KeyConsoleHandler>()); |
28 | } |
29 | |
30 | |
31 | PrivateKeyFactoryMgr::~PrivateKeyFactoryMgr() |
32 | { |
33 | } |
34 | |
35 | |
36 | void 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 | |
45 | bool PrivateKeyFactoryMgr::hasFactory(const std::string& name) const |
46 | { |
47 | return _factories.find(name) != _factories.end(); |
48 | } |
49 | |
50 | |
51 | const 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 | |
61 | void PrivateKeyFactoryMgr::removeFactory(const std::string& name) |
62 | { |
63 | _factories.erase(name); |
64 | } |
65 | |
66 | |
67 | } } // namespace Poco::Net |
68 |