Move SecureString class to ipmid/types.hpp
SecureString class doesn't have access in user_library to use in
other files
Tested:
Added class to ipmid/types.hpp from user_channel/user_mgmt.hpp
Build got successful.
Signed-off-by: Snehalatha Venkatesh <snehalathax.v@intel.com>
Change-Id: I5e0c4bb0744113e70540b272f16a5116421048fb
diff --git a/user_channel/user_mgmt.cpp b/user_channel/user_mgmt.cpp
index 036f73d..6b31eb9 100644
--- a/user_channel/user_mgmt.cpp
+++ b/user_channel/user_mgmt.cpp
@@ -27,6 +27,7 @@
#include <boost/interprocess/sync/scoped_lock.hpp>
#include <cerrno>
#include <fstream>
+#include <ipmid/types.hpp>
#include <nlohmann/json.hpp>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
diff --git a/user_channel/user_mgmt.hpp b/user_channel/user_mgmt.hpp
index d41a387..6dbda25 100644
--- a/user_channel/user_mgmt.hpp
+++ b/user_channel/user_mgmt.hpp
@@ -402,44 +402,4 @@
void cacheUserDataFile();
};
-template <typename T>
-class SecureAllocator : public std::allocator<T>
-{
- public:
- typedef size_t size_type;
- typedef T* pointer;
- typedef const T* const_pointer;
-
- template <typename _Tp1>
- struct rebind
- {
- typedef SecureAllocator<_Tp1> other;
- };
- pointer allocate(size_type n, const void* hint = 0)
- {
- return std::allocator<T>::allocate(n, hint);
- }
-
- void deallocate(pointer p, size_type n)
- {
- OPENSSL_cleanse(p, n);
- return std::allocator<T>::deallocate(p, n);
- }
-
- SecureAllocator() throw() : std::allocator<T>()
- {
- }
- SecureAllocator(const SecureAllocator& a) throw() : std::allocator<T>(a)
- {
- }
- template <class U>
- SecureAllocator(const SecureAllocator<U>& a) throw() : std::allocator<T>(a)
- {
- }
- ~SecureAllocator() throw()
- {
- }
-};
-using SecureString = std::basic_string<char, std::char_traits<char>,
- ipmi::SecureAllocator<char>>;
} // namespace ipmi