Files
lib3mf/Source/Common/NMR_SecureContext.cpp
SaraP f8c998f6ff lib3mf :
- primo commit.
2021-09-07 16:50:23 +02:00

35 lines
1.2 KiB
C++

#include "Common/NMR_SecureContext.h"
#include "Common/NMR_Exception.h"
namespace NMR {
bool CSecureContext::hasDekCtx() const {
return m_bHasDek;
}
ContentEncryptionDescriptor CSecureContext::getDekCtx() const {
return m_sDekDescriptor;
}
void CSecureContext::setDekCtx(ContentEncryptionDescriptor const & descriptor) {
m_sDekDescriptor = descriptor;
m_bHasDek = true;
}
ClientConsumerMap::const_iterator CSecureContext::kekCtxBegin() const {
return m_ConsumerMap.cbegin();
}
ClientConsumerMap::const_iterator CSecureContext::kekCtxEnd() const {
return m_ConsumerMap.cend();
}
void CSecureContext::addKekCtx(std::string const & consumerId, KeyWrappingDescriptor const & descriptor) {
if (m_ConsumerMap.find(consumerId) != m_ConsumerMap.end())
throw CNMRException(NMR_ERROR_KEYSTOREDUPLICATECONSUMERID);
m_ConsumerMap[consumerId] = descriptor;
}
KeyWrappingDescriptor CSecureContext::getKekCtx(std::string const & consumerId) const {
auto it = m_ConsumerMap.find(consumerId);
if (it != m_ConsumerMap.end())
return (*it).second;
throw CNMRException(NMR_ERROR_KEKDESCRIPTORNOTFOUND);
}
bool CSecureContext::emptyKekCtx() const {
return m_ConsumerMap.empty();
}
}