14#include "keyple/card/calypso/FreeTransactionManagerAdapter.hpp"
21#include "keyple/card/calypso/CalypsoCardAdapter.hpp"
22#include "keyple/card/calypso/CalypsoCardConstant.hpp"
23#include "keyple/card/calypso/CommandChangePin.hpp"
24#include "keyple/card/calypso/CommandVerifyPin.hpp"
25#include "keyple/core/plugin/CardIOException.hpp"
26#include "keyple/core/util/KeypleAssert.hpp"
27#include "keyple/core/util/cpp/exception/RuntimeException.hpp"
28#include "keyple/core/util/cpp/exception/UnsupportedOperationException.hpp"
29#include "keypop/calypso/card/transaction/UnexpectedCommandStatusException.hpp"
30#include "keypop/calypso/crypto/legacysam/transaction/ReaderIOException.hpp"
31#include "keypop/reader/CardCommunicationException.hpp"
32#include "keypop/reader/ReaderCommunicationException.hpp"
33#include "keypop/reader/selection/InvalidCardResponseException.hpp"
39using keyple::core::plugin::CardIOException;
40using keyple::core::util::Assert;
41using keyple::core::util::cpp::exception::RuntimeException;
42using keyple::core::util::cpp::exception::UnsupportedOperationException;
43using keypop::calypso::card::transaction::UnexpectedCommandStatusException;
44using keypop::calypso::crypto::legacysam::transaction::ReaderIOException;
45using keypop::reader::CardCommunicationException;
46using keypop::reader::ReaderCommunicationException;
47using keypop::reader::selection::InvalidCardResponseException;
49const std::string FreeTransactionManagerAdapter::MSG_PIN_NOT_AVAILABLE
50 =
"PIN is not available for this card";
52FreeTransactionManagerAdapter::FreeTransactionManagerAdapter(
53 std::shared_ptr<ProxyReaderApi> cardReader,
54 std::shared_ptr<CalypsoCardAdapter> card)
55: TransactionManagerAdapter<FreeTransactionManager>(cardReader, card)
57 std::make_shared<DtoAdapters::TransactionContextDto>(card))
59 std::make_shared<DtoAdapters::CommandContextDto>(false, false))
63std::shared_ptr<DtoAdapters::TransactionContextDto>
64FreeTransactionManagerAdapter::getTransactionContext()
const
66 return mTransactionContext;
69std::shared_ptr<DtoAdapters::CommandContextDto>
70FreeTransactionManagerAdapter::getCommandContext()
const
72 return mCommandContext;
76FreeTransactionManagerAdapter::getPayloadCapacity()
const
78 return mCard->getPayloadCapacity();
82FreeTransactionManagerAdapter::resetTransaction()
88FreeTransactionManagerAdapter::prepareNewSecureSessionIfNeeded(
89 const std::shared_ptr<Command>& )
95FreeTransactionManagerAdapter::canConfigureReadOnOpenSecureSession()
const
119FreeTransactionManager&
120FreeTransactionManagerAdapter::processCommands(ChannelControl channelControl)
122 if (mCommands.empty()) {
127 std::vector<std::shared_ptr<Command>> cardRequestCommands;
128 for (
auto& command : mCommands) {
129 command->finalizeRequest();
130 cardRequestCommands.push_back(command);
133 executeCardCommands(cardRequestCommands, channelControl);
150FreeTransactionManager&
151FreeTransactionManagerAdapter::prepareVerifyPin(
152 const std::vector<std::uint8_t>& pin)
155 Assert::getInstance().isEqual(
156 pin.size(), CalypsoCardConstant::PIN_LENGTH,
"PIN length");
158 if (!mCard->isPinFeatureAvailable()) {
159 throw UnsupportedOperationException(MSG_PIN_NOT_AVAILABLE);
163 std::make_shared<CommandVerifyPin>(
164 getTransactionContext(), getCommandContext(), pin));
174FreeTransactionManager&
175FreeTransactionManagerAdapter::prepareChangePin(
176 const std::vector<std::uint8_t>& newPin)
179 Assert::getInstance().isEqual(
180 newPin.size(), CalypsoCardConstant::PIN_LENGTH,
"PIN length");
181 if (!mCard->isPinFeatureAvailable()) {
182 throw UnsupportedOperationException(MSG_PIN_NOT_AVAILABLE);
187 std::make_shared<CommandChangePin>(
188 getTransactionContext(), getCommandContext(), newPin));