PrivateKeyFactoryMgr.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #include "Poco/Net/PrivateKeyFactoryMgr.h"
  14. #include "Poco/Net/KeyFileHandler.h"
  15. #include "Poco/Net/KeyConsoleHandler.h"
  16. namespace Poco {
  17. namespace Net {
  18. PrivateKeyFactoryMgr::PrivateKeyFactoryMgr()
  19. {
  20. setFactory("KeyFileHandler", new PrivateKeyFactoryImpl<KeyFileHandler>());
  21. setFactory("KeyConsoleHandler", new PrivateKeyFactoryImpl<KeyConsoleHandler>());
  22. }
  23. PrivateKeyFactoryMgr::~PrivateKeyFactoryMgr()
  24. {
  25. }
  26. void PrivateKeyFactoryMgr::setFactory(const std::string& name, PrivateKeyFactory* pFactory)
  27. {
  28. bool success = _factories.insert(make_pair(name, Poco::SharedPtr<PrivateKeyFactory>(pFactory))).second;
  29. if (!success)
  30. delete pFactory;
  31. poco_assert(success);
  32. }
  33. bool PrivateKeyFactoryMgr::hasFactory(const std::string& name) const
  34. {
  35. return _factories.find(name) != _factories.end();
  36. }
  37. const PrivateKeyFactory* PrivateKeyFactoryMgr::getFactory(const std::string& name) const
  38. {
  39. FactoriesMap::const_iterator it = _factories.find(name);
  40. if (it != _factories.end())
  41. return it->second;
  42. else
  43. return 0;
  44. }
  45. void PrivateKeyFactoryMgr::removeFactory(const std::string& name)
  46. {
  47. _factories.erase(name);
  48. }
  49. } } // namespace Poco::Net