| 1 | // |
| 2 | // PrivateKeyFactoryMgr.h |
| 3 | // |
| 4 | // Library: NetSSL_OpenSSL |
| 5 | // Package: SSLCore |
| 6 | // Module: PrivateKeyFactoryMgr |
| 7 | // |
| 8 | // Definition of the PrivateKeyFactoryMgr class. |
| 9 | // |
| 10 | // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. |
| 11 | // and Contributors. |
| 12 | // |
| 13 | // SPDX-License-Identifier: BSL-1.0 |
| 14 | // |
| 15 | |
| 16 | |
| 17 | #ifndef NetSSL_PrivateKeyFactoryMgr_INCLUDED |
| 18 | #define NetSSL_PrivateKeyFactoryMgr_INCLUDED |
| 19 | |
| 20 | |
| 21 | #include "Poco/Net/NetSSL.h" |
| 22 | #include "Poco/Net/PrivateKeyFactory.h" |
| 23 | #include "Poco/SharedPtr.h" |
| 24 | #include <map> |
| 25 | |
| 26 | |
| 27 | namespace Poco { |
| 28 | namespace Net { |
| 29 | |
| 30 | |
| 31 | class NetSSL_API PrivateKeyFactoryMgr |
| 32 | /// A PrivateKeyFactoryMgr manages all existing PrivateKeyFactories. |
| 33 | { |
| 34 | public: |
| 35 | typedef std::map<std::string, Poco::SharedPtr<PrivateKeyFactory> > FactoriesMap; |
| 36 | |
| 37 | PrivateKeyFactoryMgr(); |
| 38 | /// Creates the PrivateKeyFactoryMgr. |
| 39 | |
| 40 | ~PrivateKeyFactoryMgr(); |
| 41 | /// Destroys the PrivateKeyFactoryMgr. |
| 42 | |
| 43 | void setFactory(const std::string& name, PrivateKeyFactory* pFactory); |
| 44 | /// Registers the factory. Class takes ownership of the pointer. |
| 45 | /// If a factory with the same name already exists, an exception is thrown. |
| 46 | |
| 47 | bool hasFactory(const std::string& name) const; |
| 48 | /// Returns true if for the given name a factory is already registered |
| 49 | |
| 50 | const PrivateKeyFactory* getFactory(const std::string& name) const; |
| 51 | /// Returns NULL if for the given name a factory does not exist, otherwise the factory is returned |
| 52 | |
| 53 | void removeFactory(const std::string& name); |
| 54 | /// Removes the factory from the manager. |
| 55 | |
| 56 | private: |
| 57 | FactoriesMap _factories; |
| 58 | }; |
| 59 | |
| 60 | |
| 61 | } } // namespace Poco::Net |
| 62 | |
| 63 | |
| 64 | #endif // NetSSL_PrivateKeyFactoryMgr_INCLUDED |
| 65 | |