14#include "keyple/card/calypso/crypto/legacysam/SecuritySettingAdapter.hpp"
20#include "keyple/core/util/KeypleAssert.hpp"
21#include "keyple/core/util/cpp/exception/IllegalArgumentException.hpp"
29using keyple::core::util::Assert;
30using keyple::core::util::cpp::exception::IllegalArgumentException;
33SecuritySettingAdapter::setControlSamResource(
34 std::shared_ptr<CardReader> samReader,
35 std::shared_ptr<LegacySam> controlSam)
38 .notNull(samReader,
"samReader")
39 .notNull(controlSam,
"controlSam")
41 controlSam->getProductType() != ProductType::UNKNOWN,
44 auto proxyReader = std::dynamic_pointer_cast<ProxyReaderApi>(samReader);
46 const CardReader& samReaderRef = *samReader;
47 throw IllegalArgumentException(
48 "Cannot cast 'samReader' to ProxyReaderApi. Actual type: "
49 + std::string(
typeid(samReaderRef).name()));
53 = std::dynamic_pointer_cast<LegacySamAdapter>(controlSam);
54 if (!legacySamAdapter) {
55 const LegacySam& controlSamRef = *controlSam;
56 throw IllegalArgumentException(
57 "Cannot cast 'controlSam' to LegacySamAdapter. Actual type: "
58 + std::string(
typeid(controlSamRef).name()));
61 mControlSamReader = proxyReader;
62 mControlSam = legacySamAdapter;
67std::shared_ptr<ProxyReaderApi>
68SecuritySettingAdapter::getControlSamReader()
const
70 return mControlSamReader;
73std::shared_ptr<LegacySamAdapter>
74SecuritySettingAdapter::getControlSam()
const